activity_types = include plugin_dir_path( ATKAI_PLUGIN_FILE ) . '/activities/types.php'; $this->logger = $logger; add_filter( 'updated_option', array( $this, 'atk_track_option_updates' ), 9999, 3 ); add_action('admin_init', array( $this, 'atk_track_other_settings_save') ); } public function atk_track_option_updates ($option_name, $old_value, $new_value) { // List of option names you want to track. $options_to_track = array( //General settings 'blogname', // Site title 'blogdescription', // Tagline 'siteurl', // WordPress Address (URL) 'home', // Site Address (URL) 'admin_email', // Email Address 'users_can_register', // Membership 'default_role', // New User Default Role 'timezone_string', // Timezone 'date_format', // Date Format 'time_format', // Time Format 'start_of_week', // Week Starts On 'use_smilies', // Convert emoticons to graphics 'WPLANG', // Site Language //Writing Settings 'default_category', // Default Post Category 'default_post_format', // Default Post Format 'mailserver_url', // Mail Server 'mailserver_login', // Mail Server Login 'mailserver_pass', // Mail Server Password 'mailserver_port', // Mail Server Port 'default_email_category', // Default Mail Category 'ping_sites', // Update Services 'use_balanceTags', // Correct invalidly nested XHTML automatically //Reading settings 'show_on_front', // Your homepage displays 'page_on_front', // A static page (select below) - Front page 'page_for_posts', // A static page (select below) - Posts page 'posts_per_page', // Blog pages show at most 'posts_per_rss', // Syndication feeds show the most recent 'rss_use_excerpt', // For each post in a feed, include 'blog_public', // Search engine visibility // 'discourage_search_engines', // This option is represented by 'blog_public' but with inverted logic // Permalink settings 'permalink_structure', 'category_base', 'tag_base', // Media settings 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', // Discussion 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'require_name_email', 'comment_registration', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comments_notify', 'moderation_notify', 'comment_moderation', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', //Privacy Policy Settings 'wp_page_for_privacy_policy', // Privacy Policy page ); if (in_array($option_name, $options_to_track)) { $description = 'Option Updated: '. $option_name .''; $activity_type = $this->activity_types['settings']['update']; $user_id = get_current_user_id(); // Get the current user ID $this->logger->insert_log( $user_id, 'Settings', $activity_type, $description, 'update' ); } } public function atk_track_other_settings_save(){ // Make sure we are in the admin area and there is a POST submission if (!is_admin() || empty($_POST)) { return; } if (defined('DOING_AJAX') && DOING_AJAX) { return; } $referrer = wp_get_referer(); if (strpos($referrer, 'page=') !== false) { $query_string = wp_parse_url( $referrer, PHP_URL_QUERY ); // Initialize an array to store the parsed query string $qs_vars = array(); // Parse the query string into variables parse_str($query_string, $qs_vars); // Check if the 'page' parameter exists and assign it to a variable $page = isset($qs_vars['page']) ? $qs_vars['page'] : 'N/A'; // Define a list of page prefixes or names to exclude $exclude_pages = array( 'atk-', // Example prefix // Add more page prefixes or full names as needed 'activity-track-', 'specific-page-name', ); // Check if the current page matches any exclude options foreach ($exclude_pages as $exclude) { if (strpos($page, $exclude) !== false) { return; // Skip logging for this page } } $description = 'Option Updated: page name '. $page .''; $activity_type = $this->activity_types['settings']['other']; $user_id = get_current_user_id(); // Get the current user ID $this->logger->insert_log( $user_id, 'Settings', $activity_type, $description, 'other', $referrer ); } } }