file_version = defined('WP_DEBUG') && WP_DEBUG ? time() : BETTER_PAYMENT_VERSION; add_action('admin_enqueue_scripts', array($this, 'setup_wizard_scripts')); add_action('admin_menu', array($this, 'admin_menu')); add_action('wp_ajax_save_setup_wizard_data', [$this, 'save_setup_wizard_data']); add_action( 'wp_ajax_bp_quick_setup_save_tracking', [ $this, 'bp_quick_setup_save_tracking' ] ); add_action('in_admin_header', [$this, 'remove_notice'], 1000); } /** * Remove all notice in setup wizard page * * @since 0.0.2 */ public function remove_notice() { if (isset($_GET['page']) && $_GET['page'] == 'better-payment-setup-wizard') { remove_all_actions('admin_notices'); remove_all_actions('all_admin_notices'); } } /** * setup_wizard_scripts * @param $hook * @return array * * @since 0.0.2 */ public function setup_wizard_scripts($hook) { if (isset($hook) && $hook == 'admin_page_better-payment-setup-wizard') { // Determine the correct file extension based on debug mode $js_ext = file_exists(BETTER_PAYMENT_PATH . '/assets/admin/quick-setup/quick-setup.min.js') ? '.min.js' : '.js'; $css_ext = file_exists(BETTER_PAYMENT_PATH . '/assets/admin/quick-setup/quick-setup.min.css') ? '.min.css' : '.css'; // Enqueue React Quick Setup CSS wp_enqueue_style( 'bp-quick-setup-css', BETTER_PAYMENT_ASSETS . '/admin/quick-setup/quick-setup' . $css_ext, array(), $this->file_version ); // Enqueue React Quick Setup JS with WordPress dependencies wp_enqueue_script( 'bp-quick-setup-js', BETTER_PAYMENT_ASSETS . '/admin/quick-setup/quick-setup' . $js_ext, array('wp-element', 'wp-i18n'), $this->file_version, true ); // Localize script with necessary data wp_localize_script('bp-quick-setup-js', 'betterPaymentObjWizard', array( 'admin_nonce' => wp_create_nonce('better_payment_admin_nonce'), 'ajaxUrl' => admin_url('admin-ajax.php'), 'assetsUrl' => BETTER_PAYMENT_ASSETS . '/admin/quick-setup', 'success_image' => BETTER_PAYMENT_ASSETS . '/img/success.gif', 'settings' => DB::get_settings(), 'is_tracking' => get_option('better_payment_settings_opt_in') === 'yes' ? 1 : 0, 'currencies' => $this->get_currency_list(), 'is_pro' => defined('BETTER_PAYMENT_PRO_VERSION') && BETTER_PAYMENT_PRO_VERSION ? true : false, 'alerts' => [ 'confirm' => esc_html__('Are you sure?', 'better-payment'), 'confirm_description' => esc_html__("You won't be able to revert this!", 'better-payment'), 'yes' => esc_html__('Yes, delete it!', 'better-payment'), 'no' => esc_html__('No, cancel!', 'better-payment'), ], 'messages' => [ 'success' => esc_html__('Changes saved successfully!', 'better-payment'), 'error' => esc_html__('Opps! something went wrong!', 'better-payment'), 'no_action_taken' => esc_html__('No action taken!', 'better-payment'), ] )); } return []; } /** * Create admin menu for setup wizard * * @since 0.0.2 */ public function admin_menu() { add_submenu_page( "admin.php?page=better-payment-setup-wizard", esc_html__('Better Payment ', 'better-payment'), esc_html__('Better Payment ', 'better-payment'), 'manage_options', 'better-payment-setup-wizard', [$this, 'render_wizard'] ); } /** * Render tab step * * @since 0.0.2 */ public function tab_step() { $wizard_column = 'four'; ?>