rules = $rules; add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 5 ); add_filter( 'script_loader_tag', array( $this, 'script_tag' ), 10, 2 ); } /** * Ask performance plugins not to defer, delay, combine or minify the tiny runner, * otherwise hidden text could flash or never be hidden. * * @param string $tag Script tag(s), including inline scripts attached to the handle. * @param string $handle Script handle. * @return string */ public function script_tag( $tag, $handle ) { if ( 'hidexo-lite-core' !== $handle ) { return $tag; } return str_replace( 'rules->active_for_path( Hidexo_Lite_Rules::current_path() ); if ( ! $applicable ) { return; } $payload = array(); foreach ( $applicable as $rule ) { $payload[] = array( 'id' => $rule['id'], 'type' => $rule['type'], 'targets' => $rule['targets'], ); } wp_register_style( 'hidexo-lite-frontend', false, array(), HIDEXO_LITE_VERSION ); wp_enqueue_style( 'hidexo-lite-frontend' ); wp_add_inline_style( 'hidexo-lite-frontend', '[data-hidexo-hidden]{display:none!important}' ); wp_enqueue_script( 'hidexo-lite-core', HIDEXO_LITE_URL . 'assets/js/core.js', array(), HIDEXO_LITE_VERSION, true ); wp_add_inline_script( 'hidexo-lite-core', 'window.HidexoData = ' . wp_json_encode( array( 'rules' => $payload, 'check' => ( 'check' === $mode ), 'adminOrigin' => Hidexo_Lite_Picker::origin( admin_url() ), ), JSON_HEX_TAG | JSON_HEX_AMP ) . ';', 'before' ); } }