version = ONECOM_WP_VERSION; } else { $this->version = '1.0.0'; } $this->OCVM = 'OCVM'; $this->load_dependencies(); $this->define_admin_hooks(); } /** * Load the required dependencies for this module. * * Include the following files that make up the module: * * - OCVMLoader. Orchestrates the hooks of the module. * - OCVM_Admin. Defines all hooks for the admin area. * * Create an instance of the loader which will be used to register the hooks * with WordPress. * @access private */ private function load_dependencies() { /** * The class responsible for orchestrating the actions and filters of the * core plugin. */ require_once plugin_dir_path( __DIR__ ) . 'classes/class-ocvm-loader.php'; /** * The class responsible for defining all actions that occur in the admin area. */ require_once plugin_dir_path( __DIR__ ) . 'classes/class-ocvm-settings.php'; require_once plugin_dir_path( __DIR__ ) . 'classes/trait-ocvm-vulnerabilities.php'; require_once plugin_dir_path( __DIR__ ) . 'classes/class-ocvm-notifications.php'; require_once plugin_dir_path( __DIR__ ) . 'classes/class-ocvm-send-emails.php'; require_once plugin_dir_path( __DIR__ ) . 'classes/class-ocvm-auto-updates.php'; require_once plugin_dir_path( __DIR__ ) . 'classes/class-ocvm-scan.php'; require_once plugin_dir_path( __DIR__ ) . 'classes/class-ocvm-admin-page.php'; require_once plugin_dir_path( __DIR__ ) . 'classes/class-ocvm-history-log.php'; /** * The class responsible for defining all actions that occur in the public-facing * side of the site. */ $this->loader = new OCVMLoader(); } /** * Register all of the hooks related to the admin area functionality * of the module. * @access private */ private function define_admin_hooks() { // Admin page and assets $plugin_admin = new OCVMAdmin( $this->get_OCVM(), $this->get_version() ); //TODO: restrict the resource loading to relevant pages only $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_menu', 0 ); $this->loader->add_action( 'network_admin_menu', $plugin_admin, 'add_menu', 0 ); //save vulnerability settings from admin panel $settings = new OCVMSettings(); $this->loader->add_action( 'wp_ajax_ocvm_updateSettings', $settings, 'updateSettings' ); // WPCron scan schedule (regular) $scan = new OCVMScan(); $this->loader->add_action( 'ocvm_scan', $scan, 'manageVulnerabilities' ); $this->loader->add_action( 'ocvm_scan_after_autoupdate', $scan, 'manageVulnerabilities' ); // WPCron scan scheduling after some time upon following activations, deactivations, deletions, updates $this->loader->add_action( 'ocvm_scan_schedule', $scan, 'manageVulnerabilities' ); // WPCron scan schedule on plugin activation. $this->loader->add_action( 'activated_plugin', $scan, 'scheduleOCVMScan', 0 ); // WPCron scan schedule on theme activation. $this->loader->add_action( 'switch_theme', $scan, 'scheduleOCVMScan', 0 ); // WPCron scan schedule on plugin deactivation $this->loader->add_action( 'deactivated_plugin', $scan, 'scheduleOCVMScan', 0 ); // WPCron scan schedule after plugin deletion $this->loader->add_action( 'deleted_plugin', $scan, 'scheduleOCVMScan', 0 ); // WPCron scan schedule after theme deletion $this->loader->add_action( 'deleted_theme', $scan, 'scheduleOCVMScan', 0 ); // WPCron scan schedule after update complete $this->loader->add_action( 'upgrader_process_complete', $scan, 'scheduleOCVMScan', 0 ); //show notifications $notifications = new OCVMNotifications(); $this->loader->add_action( 'admin_notices', $notifications, 'showNotifications' ); $this->loader->add_action( 'wp_ajax_ocvm_dismissNotification', $notifications, 'dismissNotifications' ); $this->loader->add_action( 'wp_ajax_ocvm_dismissNotificationHigh', $notifications, 'dismissHighNotifications' ); } /** * Run the loader to execute all of the hooks with WordPress. */ public function run() { $this->loader->run(); } /** * The name of the module used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @since 1.0.0 * @return string The name of the module. */ public function get_OCVM() { return $this->OCVM; } /** * The reference to the class that orchestrates the hooks with the module. * * @since 1.0.0 * @return OCVMLoader Orchestrates the hooks of the module. */ public function get_loader() { return $this->loader; } /** * Retrieve the version number of the module. * * @since 1.0.0 * @return string The version number of the module. */ public function get_version() { return $this->version; } }