/** * Initialize variables and actions */ public static function init() { // Current screen if (!empty($_GET['page'])) { self::$current_tab = intval(str_replace('power-stats-view-', '', $_GET['page'])); } elseif (!empty($_POST['current_tab'])) { self::$current_tab = intval($_POST['current_tab']); } // Settings URL self::$config_url = 'admin.php?page=wp-power-stats-settings&tab='; self::$view_url = 'admin.php?page=wp-power-stats-view-' . self::$current_tab; // Load language files load_plugin_textdomain('wp-power-stats', POWER_STATS_DIR . '/admin/lang', '/wp-power-stats/admin/lang'); // WPMU - New blog created $active_sitewide_plugins = get_site_option('active_sitewide_plugins'); if (!empty($active_sitewide_plugins['wp-power-stats/wp-power-stats.php'])) { add_action('wpmu_new_blog', array(__CLASS__, 'new_blog')); } // WPMU - Blog Deleted add_filter('wpmu_drop_tables', array(__CLASS__, 'drop_tables'), 10, 2); // Display a notice if conditions are met if (!empty($_GET['page']) && strpos($_GET['page'], 'wp-power-stats') !== false && !empty(self::$admin_notice) && PowerStats::$options['show_admin_notice'] != PowerStats::$version && get_option('power_stats_internal', 0) > 199) { add_action('admin_notices', array(__CLASS__, 'show_admin_notice')); } // Remove spam hits from the database if (PowerStats::$options['ignore_spam_visitors'] == 'yes') { add_action('transition_comment_status', array(__CLASS__, 'remove_spam'), 15, 3); } if (function_exists('is_network_admin') && !is_network_admin()) { add_action('admin_menu', array(__CLASS__, 'wp_power_stats_add_main_menu')); // Add the appropriate entries to the admin menu, if this user can view/admin WP Power Statss add_action('admin_menu', array(__CLASS__, 'wp_power_stats_add_view_menu')); add_action('admin_menu', array(__CLASS__, 'wp_power_stats_add_config_menu')); // Update the table structure and options, if needed if (!empty(PowerStats::$options['version']) && PowerStats::$options['version'] != PowerStats::$version || get_option('wp_power_stats_plugin_version')) { self::update_tables_and_options(); } } if (!isset($_POST['_nonce'])) { update_option('power_stats_internal', get_option('power_stats_internal', 0) + 1); } // AJAX Handlers if (defined('DOING_AJAX') && DOING_AJAX) { add_action('wp_ajax_power_stats_hide_admin_notice', array(__CLASS__, 'hide_admin_notice')); } }