version = '1.1.2'; $this->db = new wpc_an_db(); $this->plugins = new wpc_an_plugins(); $this->media = new wpc_an_media(); $this->posts = new wpc_an_posts(); $this->pages = new wpc_an_pages(); $this->view = new wpc_an_data_view(); $this->login = new wpc_an_login(); $this->cron = new wpc_an_cron(); } public function init() { add_action('admin_menu', [$this, 'adminMenu']); // Various Scripts & Styles add_action('admin_enqueue_scripts', [$this, 'enqueues']); // Option Tracking add_action('updated_option', [$this, 'optionTrackerLogUpdate'], 10, 3); add_action('added_option', [$this, 'optionTrackerLogUpdate'], 10, 2); // Media add_filter('wp_handle_upload', [$this->media, 'uploadFile']); add_filter('add_attachment', [$this->media, 'addAttachment']); // Plugin activation tracking add_action('activated_plugin', [$this->plugins, 'pluginActivation'], 10, 2); add_action('deactivated_plugin', [$this->plugins, 'pluginDeactivation'], 10, 2); // Post/Page Tracking add_action('save_post', [$this->posts, 'postCreation'], 10, 3); add_action('save_post', [$this->pages, 'pageCreation'], 10, 3); // Login Tracking add_action('wp_login', [$this->login, 'successfulLogin'], 10, 2); add_action('wp_login_failed', [$this->login, 'failedLogin'], 10, 2); } public function enqueues() { wp_enqueue_style('wpc-activity-ninja', plugin_dir_url(__FILE__) . 'assets/style.css', array(), $this->version); wp_enqueue_script('wpc-activity-ninja', plugin_dir_url(__FILE__) . 'assets/scripts.js', array('jquery'), $this->version, true); } public function activation() { $this->db->activation(); } // Add admin menu public function adminMenu() { add_menu_page( 'Activity Ninja', 'Activity Ninja', 'manage_options', 'activity-ninja', [$this, 'displayHistory'] ); } // Display option update history public function displayHistory() { echo '
'; echo '

Activity Ninja

'; echo ''; echo '
'; $this->view->viewOverview(); echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; } public function optionTrackerLogUpdate($option, $old_value, $value = '') { if ($old_value !== $value) { global $wpdb; $table_name = $wpdb->prefix . 'an_history'; $user_id = get_current_user_id(); $wpdb->insert( $table_name, array( 'option_name' => $option, 'old_value' => maybe_serialize($old_value), 'new_value' => maybe_serialize($value), 'user_id' => $user_id, 'timestamp' => current_time('mysql') ) ); } } } // Attach to Cron Run $cron = new wpc_an_cron(); add_action("plugins_loaded", [$cron, 'cronLoggerRegister']); // Plugin Core $anTracker = new wpc_an_tracker(); add_action('init', [$anTracker, 'init']); register_activation_hook(__FILE__, [$anTracker, 'activation']);