false, 'all_no_av' => false, ); $script_choice = \Oneacc\AgeCheck::script_choice( $tags, $this->client_id, $this->tobacco_client_id, $this->client_secret, $this->tobacco_client_secret ); wp_enqueue_script( 'one-account-push-api', $this->push_api_script_url, [], false, true ); wp_script_add_data( 'one-account-push-api', 'attributes', array( 'data-ecommerce' => '1' ) ); wp_enqueue_script( 'oneacc-script', "{$this->plugin_url}assets/one-account.js", [ 'jquery', 'one-account-push-api' ], filemtime( "{$this->plugin_path}assets/one-account.js" ), true ); wp_localize_script( 'oneacc-script', 'oneacc_woo_params', [ 'ajax_url' => admin_url( 'admin-ajax.php' ), 'thankyou_status_nonce' => wp_create_nonce( 'oneacc_thankyou_status_update_' . $order_id ), 'check_pending_nonce' => wp_create_nonce( 'oneacc_check_pending_status_' . $order_id ), 'check_update_nonce' => wp_create_nonce( 'oneacc_check_update_status_' . $order_id ), 'is_user_logged_in' => is_user_logged_in() ? 'true' : 'false', 'current_page' => 'order_received', 'client_id' => $script_choice['client_id'], 'client_secret' => $script_choice['client_secret'], 'skip_av' => $script_choice['skip_av'], ] ); } } /** * Settings styles and the orders-list badges. The script only drives the settings tab. * * @param string $hook Current admin screen hook. */ function admin_enqueue( $hook ) { $hook = (string) $hook; $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; $post_type = ( $screen && isset( $screen->post_type ) ) ? (string) $screen->post_type : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only settings tab. Every WooCommerce settings screen shares this hook, and the tab URL has no nonce. $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : ''; $is_settings = ( 'woocommerce_page_wc-settings' === $hook && 'oneacc_settings' === $tab ); $is_orders = ( 'woocommerce_page_wc-orders' === $hook ) || ( 'edit.php' === $hook && 'shop_order' === $post_type ); if ( ! $is_settings && ! $is_orders ) { return; } wp_enqueue_style( 'oneacc-scriptss', "{$this->plugin_url}assets/one-account.css", array(), filemtime( "{$this->plugin_path}assets/one-account.css" ) ); if ( ! $is_settings ) { return; } wp_enqueue_script('oneacc-admins', "{$this->plugin_url}assets/one-admin-account.js", ['jquery'], filemtime("{$this->plugin_path}assets/one-admin-account.js"), true); } // Replace ID oneacc-script-js removed -js text function custom_script_loader_tag($tag, $handle) { return str_replace("oneacc-script-js", "oneacc-script", $tag); } }