| Server IP : 43.130.17.34 / Your IP : 216.73.217.6 Web Server : nginx/1.28.0 System : Linux VM-4-12-opencloudos 6.6.92-34.1.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 21:32:13 CST 2025 x86_64 User : www ( 1000) PHP Version : 8.0.26 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/yespkg.com/wp-content/plugins/mail-manager-wpforms/includes/ |
Upload File : |
<?php
/**
* Defines the core plugin class.
*
* This class includes attributes and functions used both on the
* public-facing side of the site and in the admin area.
*
* @link https://mmw.diviaccessories.com/
* @since 1.0.0
*
* @package mail-manager-wpforms
* @subpackage mail-manager-wpforms/core
*/
namespace MMWPF\Core;
use MMWPF\Core\Translate;
use MMWPF\Frontend\Action;
use MMWPF\Admin\Admin;
/**
* Defines internationalization, admin-specific hooks, and public-facing site hooks.
*
* Also maintains the plugin's unique identifier and current version.
*
* @since 1.0.0
* @author nishanmazumder<arosh019@gmail.com>
*/
class Manager {
/**
* The loader responsible for maintaining and registering all hooks that power the plugin.
*
* @since 1.0.0
* @access protected
* @var Loader $loader Maintains and registers all hooks for the plugin.
*/
protected $loader;
/**
* The unique identifier of this plugin.
*
* @since 1.0.0
* @access protected
* @var string $plugin_name The string used to uniquely identify this plugin.
*/
protected $plugin_name;
/**
* The current version of the plugin.
*
* @since 1.0.0
* @access protected
* @var string $version The current version of the plugin.
*/
protected $version;
/**
* Defines the core functionality of the plugin.
*
* Sets the plugin name and version for use throughout the plugin.
* Loads dependencies, defines the locale, and sets hooks for both
* the admin area and the public-facing side of the site.
*
* @since 1.0.0
*/
public function __construct() {
$this->plugin_name = MMWPF_NAME;
$this->version = MMWPF_VERSION;
$this->load_dependencies();
$this->set_locale();
$this->plugin_action();
}
/**
* Loads the required dependencies for this plugin.
*
* Includes the following files that comprise the plugin:
*
* - Loader: Manages the hooks of the plugin.
* - Translate: Provides internationalization functionality.
*
* Creates an instance of the loader, which will be used to register the hooks
* with WordPress.
*
* @since 1.0.0
* @access private
*/
private function load_dependencies() {
// Traits - Singleton, Database, Manager.
require_once MMWPF_PATH . 'includes/traits/trait-database.php';
require_once MMWPF_PATH . 'includes/traits/trait-singleton.php';
require_once MMWPF_PATH . 'includes/traits/trait-manager.php';
// Manage admin notice.
require_once MMWPF_PATH . 'includes/class-notice.php';
// The class responsible for orchestrating the actions and filters of the core plugin.
require_once MMWPF_PATH . 'includes/class-loader.php';
// The class responsible for defining internationalization functionality of the plugin.
require_once MMWPF_PATH . 'includes/class-translate.php';
// The class responsible for defining all actions that occur in the site.
require_once MMWPF_PATH . 'includes/class-action.php';
// The class responsible for defining all actions that occur in the admin.
require_once MMWPF_PATH . 'admin/class-form-list-table.php';
require_once MMWPF_PATH . 'admin/class-form-entries-table.php';
require_once MMWPF_PATH . 'admin/class-admin.php';
// Instance dependency for this class.
$this->loader = Loader::get_instance();
}
/**
* Defines the locale for this plugin for internationalization.
*
* Utilizes the Translate class to set the domain and register the hook
* with WordPress.
*
* @since 1.0.0
* @access private
*/
private function set_locale() {
$plugin_i18n = Translate::get_instance();
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
}
/**
* Registers all functionality related to hooks within the plugin.
*
* @since 1.0.0
* @access private
*/
private function plugin_action() {
/**
* ================================================
* NOTICE
* ================================================
*/
$notice = Notice::get_instance();
// Hook to display admin notices.
$this->loader->add_action( 'admin_notices', $notice, 'display_notices' );
// Transient notices on install.
$this->loader->add_action( 'admin_notices', $notice, 'mail_manager_wpf_notice' );
// Review rescheduled.
$this->loader->add_action( 'wp_ajax_mmwpf_review_dismiss', $notice, 'mmwpf_review_dismiss_action' );
// Check screen and add footer text.
$this->loader->add_action( 'current_screen', $notice, 'check_mail_manager_wpf_page' );
/**
* ================================================
* Enqueue
* ================================================
*/
$plugin_action = Action::get_instance();
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_action, 'enqueue_admin_resources' );
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_action, 'enqueue_public_resources' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_action, 'enqueue_build_resources' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_action, 'apply_admin_css_var' );
$this->loader->add_filter( 'mmwpf_default_settings', $plugin_action, 'add_default_settings' );
$this->loader->add_action( 'admin_init', $plugin_action, 'register_mmwpf_admin_settings' );
$this->loader->add_action( 'rest_api_init', $plugin_action, 'register_mmwpf_admin_settings' );
/**
* ================================================
* Admin
* ================================================
*/
$action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : null;
$form_id = isset( $_GET['formId'] ) ? absint( $_GET['formId'] ) : null;
$entry_id = isset( $_GET['eId'] ) ? absint( $_GET['eId'] ) : null;
$admin_action = Admin::get_instance( $action, $form_id, $entry_id );
// Admin menu added.
$this->loader->add_action( 'admin_menu', $admin_action, 'add_mmwpf_admin_menu' );
// Enable options for forms.
$this->loader->add_action( 'rest_api_init', $admin_action, 'register_route_for_forms_data', 30 );
// Admin screen option.
if ( null !== $form_id ) {
if ( 'view' !== $action ) {
$this->loader->add_filter( 'screen_settings', $admin_action, 'add_screen_options_for_entries', 10, 1 );
$this->loader->add_action( 'admin_head', $admin_action, 'save_screen_options_for_entries' );
}
}
// For export CSV.
$export_csv = isset( $_GET['export_csv'] ) ? sanitize_text_field( wp_unslash( $_GET['export_csv'] ) ) : null;
if ( isset( $export_csv ) && null !== $export_csv ) {
$this->loader->add_action( 'admin_init', $admin_action, 'export_csv' );
}
// Add entires column name.
$this->loader->add_filter( 'mmwpf_add_entries_column_name', $admin_action, 'entries_column_name' );
// save entry data. no need frontend.
$this->loader->add_action( 'wp_ajax_mmwpf_save_entry', $admin_action, 'mmwpf_save_entry' );
// Add entires actions.
$this->loader->add_filter( 'mmwpf_add_entries_action', $admin_action, 'mmwpf_add_entries_action' );
// Process entires actions.
$this->loader->add_action( 'admin_init', $admin_action, 'process_single_action' );
$this->loader->add_action( 'admin_init', $admin_action, 'process_bulk_action' );
// Data save after form submission.
$this->loader->add_action( 'wpforms_process_entry_save', $admin_action, 'mail_manager_wpf_insert', 10, 4 );
}
/**
* Database creation.
*
* @since 1.0.0
*/
public function db_create_mail_manager_wpf() {
global $wpdb;
$mail_manager_wpf_db = apply_filters( 'mmwpf_database', $wpdb );
$table_name = $mail_manager_wpf_db->prefix . 'mmwpf_database';
$charset_collate = $mail_manager_wpf_db->get_charset_collate();
$is_table_exist = $mail_manager_wpf_db->get_var( "SHOW TABLES LIKE '$table_name'" ) === $table_name;
if ( ! $is_table_exist ) {
$sql = "CREATE TABLE $table_name (
id bigint(20) NOT NULL AUTO_INCREMENT,
form_id bigint(20) NOT NULL,
save int(1) NOT NULL DEFAULT 0,
status int(1) DEFAULT 0 NOT NULL,
filter int(1) DEFAULT 1 NOT NULL,
form_value longtext NOT NULL,
date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql );
}
}
/**
* Executes the loader to run all hooks with WordPress.
*
* @since 1.0.0
*/
public function kick_mmwpf() {
$this->loader->mmwpf_loader();
}
/**
* Provides the plugin's name, uniquely identifying it within WordPress and defining internationalization functionality.
*
* @since 1.0.0
* @return string The name of the plugin.
*/
public function get_plugin_name() {
return $this->plugin_name;
}
/**
* Reference to the class that orchestrates the hooks within the plugin.
*
* @since 1.0.0
* @return Loader Orchestrates the hooks of the plugin.
*/
public function get_loader() {
return $this->loader;
}
/**
* Retrieves the plugin's version number.
*
* @since 1.0.0
* @return string The version number of the plugin.
*/
public function get_version() {
return $this->version;
}
}