*/ class AIO_Tools_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * * @since 1.0.0 */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->load_dependencies_frameworks(); add_filter('plugin_action_links_'. W2W_BASE_NAME, [ $this,'w2w_add_plugin_page_settings_link'], 10, 2); add_action( 'admin_bar_menu', [ $this, 'w2w_add_admin_bar_links' ], 90 ); //add_action( 'init', [ $this, 'w2w_set_notices' ] ); $this->create_settings_page(); add_action( 'admin_enqueue_scripts', 'add_thickbox' ); add_action('wp_ajax_w2wSmtpCheckHandler', [ $this,'w2wSmtpCheckHandler' ]); add_action('wp_ajax_nopriv_w2wSmtpCheckHandler', [ $this,'w2wSmtpCheckHandler' ]); } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { wp_enqueue_style( $this->plugin_name, W2W_URL . 'admin/assets/css/aio-tools-admin.css', array(), $this->version, 'all' ); wp_enqueue_style( 'mobile', W2W_URL . 'admin/assets/css/responsive.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { wp_enqueue_script( $this->plugin_name, W2W_URL . 'admin/assets/js/aio-tools-admin.js', array( 'jquery' ), $this->version, true ); wp_localize_script( $this->plugin_name , 'w2w_smtp_param', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'message' => array( 'sending' => __('Sending...','w2wvn'), 'success' => __('Success! Please check your email inbox.','w2wvn'), 'error' => __('The following error occured: ','w2wvn'), 'alertdata' => __('You have entered an invalid email address!','w2wvn'), ), ) ); } public function load_dependencies_frameworks() { require_once W2W_VENDOR_PATH . 'codestar-framework/codestar-framework.php'; require_once W2W_VENDOR_PATH . 'announce4wp/announce4wp-client.php'; } public function create_settings_page() { // Check core class for avoid errors if ( class_exists( 'CSF' ) ) { require_once W2W_ADMIN_PATH . 'section/w2w-create-options.php'; //require_once W2W_ADMIN_PATH . 'section/w2w-dashboard.php'; require_once W2W_ADMIN_PATH . 'section/w2w-contact-button.php'; //require_once W2W_ADMIN_PATH . 'section/w2w-smtp.php'; require_once W2W_ADMIN_PATH . 'section/w2w-woocommerce.php'; require_once W2W_ADMIN_PATH . 'section/w2w-header-footer.php'; require_once W2W_ADMIN_PATH . 'section/w2w-tools.php'; /* BEGIN Section: Flatsome Manager */ //if(w2w_check_active_theme('flatsome')){} /* END Section: Flatsome Manager */ } } public function w2w_add_admin_bar_links( WP_Admin_Bar $admin_bar ) { if ( current_user_can( 'manage_options' ) ) { $admin_bar->add_menu( [ 'id' => 'aio-tools', 'title' => 'AIO Tools', 'href' => admin_url( 'admin.php?page=w2w-settings' ), 'meta' => [ 'target' => '_self', 'html' => '', ], ] ); } } public function w2w_set_notices() { if ( W2W_Utils::is_plugin_active( 'wp-mail-smtp/wp_mail_smtp.php' ) ) { W2W_Notice_Manager::display_notice( 'smtp_plugin', '
' . sprintf( __( 'It looks like WP Mail SMTP is active on your site. WP Mail SMTP feature may cause conflict with %1$s.', 'w2wvn' ), W2W_PLUGIN_NAME ) . '
', 'warning' ); } } function w2w_add_plugin_page_settings_link( $links ) { $w2w_links[] = '' . __('Settings') . ''; return $w2w_links + $links; } function w2wSmtpCheckHandler(){ $recipient = sanitize_text_field($_POST['your_email']); $subject = __('AIO Tool: HTML Test email to ', 'w2wvn' ) . $recipient; $headers = array('Content-Type: text/html; charset=UTF-8'); ob_start(); $message = $this->w2w_get_email_message_html(); ob_end_clean(); try { $result = wp_mail($recipient, $subject, $message, $headers); } catch (Exception $e) { echo "Mailer Error: " . $mail->ErrorInfo; } $smtp_debug = ob_get_clean(); wp_die(); } private function w2w_get_email_message_html() { ob_start(); ?>
|