log_debug( '[Gating Manager] __construct started.' ); // Front-end Hooks add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) ); // Register always add_action( 'wp_enqueue_scripts', array( $this, 'maybe_enqueue_gate_assets' ), 20 ); // Conditionally enqueue later add_filter( 'body_class', array( $this, 'add_body_classes' ) ); // Add initial hiding class conditionally // Strict Mode Interception (New in 1.1.0) // Runs just before the template is included. Priority 99 ensures we override theme logic. // Filter added to allow priority adjustment (Dev Hook) $priority = apply_filters( 'agewallet_template_include_priority', 99 ); add_filter( 'template_include', array( $this, 'intercept_template_loading' ), $priority ); // Shortcode Hooks add_shortcode( 'agewallet_button', array( $this, 'button_shortcode_handler' ) ); add_shortcode( 'agewallet_protected', array( $this, 'protected_content_shortcode_handler' ) ); // Meta Box Hooks (Admin-side) add_action( 'add_meta_boxes', array( $this, 'add_restriction_meta_box' ) ); add_action( 'save_post', array( $this, 'save_restriction_meta_box' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_post_restriction_script' ) ); $this->log_debug( '[Gating Manager] __construct finished, hooks added.' ); } /** * Registers front-end CSS and JS assets. Hooked to 'wp_enqueue_scripts'. * @since 0.1.0 */ public function register_assets() { // Register Stylesheet $style_path = 'assets/css/gate.css'; $style_ver = AGEWALLET_VERSION; if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $file_path = AGEWALLET_PLUGIN_DIR . $style_path; if ( file_exists( $file_path ) ) { $style_ver = filemtime( $file_path ) ?: $style_ver; } } wp_register_style( self::STYLE_HANDLE, AGEWALLET_PLUGIN_URL . $style_path, array(), $style_ver, 'all' ); // Register JavaScript $script_path = 'assets/js/gate.js'; $script_ver = AGEWALLET_VERSION; if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $file_path = AGEWALLET_PLUGIN_DIR . $script_path; if ( file_exists( $file_path ) ) { $script_ver = filemtime( $file_path ) ?: $script_ver; } } wp_register_script( self::SCRIPT_HANDLE, AGEWALLET_PLUGIN_URL . $script_path, array( 'jquery' ), $script_ver, true ); // Skeleton-only CSS used by the strict-mode gatekeeper page (spinner, background). $skeleton_path = 'assets/css/gate-skeleton.css'; $skeleton_ver = AGEWALLET_VERSION; if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { $file_path = AGEWALLET_PLUGIN_DIR . $skeleton_path; if ( file_exists( $file_path ) ) { $skeleton_ver = filemtime( $file_path ) ?: $skeleton_ver; } } wp_register_style( 'agewallet-gate-skeleton', AGEWALLET_PLUGIN_URL . $skeleton_path, array( self::STYLE_HANDLE ), $skeleton_ver, 'all' ); $this->log_debug( '[Gating Manager] Assets registered.' ); } /** * Enqueue + configure every asset needed by the strict-mode gatekeeper skeleton * (templates/gatekeeper.php). Called from the template right before it emits the * `
` and body scripts via wp_print_styles() / wp_print_scripts(). All admin- * chosen values (CSS vars, Customizer CSS, analytics IDs, gate config) reach the * browser via wp_add_inline_style / wp_add_inline_script / wp_localize_script so * the template itself contains no raw `