options = $this->get_service('configuration')->get_options(); // $this->options = PayplugWoocommerceHelper::get_payplug_options(); //add_action( 'admin_notices', [ $this, 'admin_notices' ] ); //add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] ); } /** * Enqueue PayPlug notice style. * * @return void */ public function admin_enqueue_scripts(): void { $api_key = json_decode($this->options, true); $test_key = !empty($api_key['test']) ? $api_key['test'] : ''; $live_key = !empty($api_key['live']) ? $api_key['live'] : ''; if (empty($test_key) && empty($live_key)) { wp_enqueue_style( 'payplug-notice', PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/css/notice.css', [], PAYPLUG_GATEWAY_VERSION ); } } /** * Display admin notices. * * @return void */ public function admin_notices(): void { if (!current_user_can('manage_woocommerce')) { return; } /* * Before Woocommerce 3.2.x, settings were saved just before displaying the page * which cause the admin_notice to display old data. * * This condition check if we are on the PayPlug gateway settings page and if we * have new settings to save. If true we hook the notice to a hook which will run after the new * settings have been saved. */ $screen = get_current_screen(); $wc = function_exists('WC') ? WC() : $GLOBALS['woocommerce']; if ( version_compare($wc->version, '3.2.0', '<') && !empty($_POST) && 'woocommerce_page_wc-settings' === $screen->id && isset($_GET['section']) && 'payplug' === $_GET['section'] ) { add_action('woocommerce_settings_saved', [$this, 'display_notice']); return; } $this->display_notice(); } public function display_notice(): void { $testmode = isset($this->options['mode']) && !(bool) $this->options['mode']; $api_key = json_decode($this->options, true); $test_key = !empty($api_key['test']) ? $api_key['test'] : ''; $live_key = !empty($api_key['live']) ? $api_key['live'] : ''; if (empty($test_key) && empty($live_key)) { ?>


PayPlug logo