get_aircash_payment_gateway(), 'admin_init' ) ); add_action( 'admin_init', array( $this->get_aircash_payment_gateway(), 'check_configuration' ) ); add_action( 'in_admin_footer', array( $this->get_aircash_payment_gateway(), 'add_html_to_admin' ) ); } } public function admin_init() { add_action( 'admin_notices', array( $this, 'admin_notices' ) ); add_action( 'wp_ajax_aircash_dismiss_notice', array( $this, 'ajax_dismiss_notice' ) ); wp_enqueue_script( 'jquery-ui-tabs' ); } private function get_aircash_payment_gateway() { if ( ! isset( $this->gateway ) ) { $this->gateway = new Aircash_Payment_Gateway(); } return $this->gateway; } private function get_admin_notices(): array { add_thickbox(); $gateway = $this->get_aircash_payment_gateway(); $notices = []; $fatal_error = false; if ( ! extension_loaded( 'openssl' ) && $gateway->get_option( 'enabled' ) != 'no' ) { $fatal_error = true; $notice = array( 'class' => 'notice-error', 'text' => __( '"Aircash for WooCommerce" gateway is disabled because OpenSSL extension is not installed.', 'aircash-for-woocommerce' ) . '
' . __( 'Please install OpenSSL PHP extension in order to use "Aircash for WooCommerce".', 'aircash-for-woocommerce' ) . '
' . __( 'Contact your web server administrator or your web hosting provider if not sure how to install PHP extensions.', 'aircash-for-woocommerce' ), 'is_dismissable' => false, 'dismiss_action' => 'dismiss_notice_openssl_extension_missing', ); if ( ! $notice['is_dismissable'] ) { $notices[] = $notice; } else { if ( get_option( $notice['dismiss_action'] ) !== 'no' ) { $notices[] = $notice; } } } if ( ( ! extension_loaded( 'imagick' ) && ! extension_loaded( 'gd' ) ) && $gateway->get_option( 'enabled' ) != 'no' ) { $fatal_error = true; $notice = array( 'class' => 'notice-error', 'text' => __( '"Aircash for WooCommerce" gateway is disabled because neither GD or Imagick extension are not installed.', 'aircash-for-woocommerce' ) . '
' . __( 'Please install GD or Imagick PHP extension in order to use "Aircash for WooCommerce".', 'aircash-for-woocommerce' ) . '
' . __( 'Contact your web server administrator or your web hosting provider if not sure how to install PHP extensions.', 'aircash-for-woocommerce' ), 'is_dismissable' => false, 'dismiss_action' => 'dismiss_notice_gd_imagick_extension_missinzg', ); if ( ! $notice['is_dismissable'] ) { $notices[] = $notice; } else { if ( get_option( $notice['dismiss_action'] ) !== 'no' ) { $notices[] = $notice; } } } if ( $gateway->is_in_test_mode() ) { $notice = array( 'class' => 'notice-warning', 'text' => __( '"Aircash for WooCommerce" is in test mode.', 'aircash-for-woocommerce' ), 'is_dismissable' => true, 'dismiss_action' => 'dismiss_notice_aircash_test_mode', ); $notices[] = $notice; $account_status = $gateway->get_test_account_request_status(); } else { $account_status = $gateway->get_account_request_status(); } if ( ! $fatal_error ) { if ( $account_status == 'plugin_installed' ) { $notice = array( 'class' => 'notice-info', 'text' => __( '"Aircash for WooCommerce" is almost ready.', 'aircash-for-woocommerce' ) . '
' . sprintf( __( 'Connect with Aircash to submit a new account request or configure Aircash settings manually.', 'aircash-for-woocommerce' ), get_admin_url( null, 'admin.php?page=wc-settings&tab=checkout&aircash=new_account_request&width=700' ), get_admin_url( null, 'admin.php?page=wc-settings&tab=checkout&aircash=manual_configuration&width=700&height=700' ) ) . '
' . sprintf( __( 'If you want to test "Aircash for WooCommerce", enable the "Test mode" in the payment gateway settings.', 'aircash-for-woocommerce' ), get_admin_url( null, 'admin.php?page=wc-settings&tab=checkout§ion=aircash-woocommerce' ) ), 'is_dismissable' => false, ); $notices[] = $notice; } elseif ( $account_status == 'sent' ) { $notice = array( 'class' => 'notice-info', 'text' => __( '"Aircash for WooCommerce" is almost ready.', 'aircash-for-woocommerce' ) . '
' . sprintf( __( 'You have successfully submitted a new account request. Please wait until Aircash verifies your account and then update account status request by checking the configuration.', 'aircash-for-woocommerce' ), get_admin_url( null, 'admin.php?page=wc-settings&tab=checkout&aircash=check_configuration&width=700&height=700' ) ) . '
' . '', 'is_dismissable' => true, 'dismiss_action' => 'dismiss_notice_aircash_account_request_sent' ); $notices[] = $notice; #} elseif ( $account_status == 'declined' ) { } elseif ( $account_status == 'error_sending' ) { $notice = array( 'class' => 'notice-error', 'text' => sprintf( __( 'There has been an error while sending new account request to Aircash. Please check the log file for details.', 'aircash-for-woocommerce' ), get_admin_url( null, 'admin.php?page=wc-settings&tab=checkout§ion=aircash-woocommerce' ) ), 'is_dismissable' => true, 'dismiss_action' => 'dismiss_notice_aircash_account_request_error_sending', ); $notices[] = $notice; } } return $notices; } public function admin_notices() { foreach ( $this->get_admin_notices() as $notice ) { $show = true; if ( $notice['is_dismissable'] ) { $dismissable_class = 'is-dismissible'; if ( isset( $notice['dismiss_action'] ) && get_option( $notice['dismiss_action'] ) ) { $show = false; } } else { $dismissable_class = ''; } if ( ! $show ) { continue; } ?>

array(), 'a' => array( 'href' => array(), 'title' => array(), 'class' => array(), 'data-toggle' => array(), ), 'strong' => array(), 'em' => array(), ) ); ?>

' . __( 'Settings', 'aircash-for-woocommerce' ) . ''; array_unshift( $links, $settings_link ); return $links; } /** * @return WC_Aircash */ public static function get_instance(): self { if ( is_null( self::$instance ) ) { self::$instance = new WC_Aircash(); } return self::$instance; } public static function on_install() { } public static function on_uninstall() { delete_option( 'woocommerce_aircash-woocommerce_settings' ); } public static function on_deactivate() { } public function aircash_order_check() { $this->get_aircash_payment_gateway()->check_order(); } public function deactivate() { } } } register_activation_hook( __FILE__, array( 'WC_Aircash', 'on_install' ) ); register_uninstall_hook( __FILE__, array( 'WC_Aircash', 'on_uninstall' ) ); register_deactivation_hook( __FILE__, array( 'WC_Aircash', 'on_deactivate' ) ); add_action( 'plugins_loaded', array( 'WC_Aircash', 'get_instance' ), 0 );