%s', __( 'NEW', 'google-analytics-for-wordpress' ) ); $menu_notification_indicator = MonsterInsights()->notifications->get_menu_count(); if ( MonsterInsights()->license->license_expired() ) { $menu_notification_indicator = MonsterInsights()->notifications->get_license_expired_indicator(); } if ($hook === 'monsterinsights_settings') { // If dashboards disabled, first settings page add_menu_page(__('MonsterInsights', 'google-analytics-for-wordpress'), __('Insights', 'google-analytics-for-wordpress') . $menu_notification_indicator, 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page', $menu_icon_inline, '100.00013467543'); $hook = 'monsterinsights_settings'; add_submenu_page($hook, __('MonsterInsights', 'google-analytics-for-wordpress'), __('Settings', 'google-analytics-for-wordpress'), 'monsterinsights_save_settings', 'monsterinsights_settings'); } else { // if dashboards enabled, first dashboard add_menu_page(__('General:', 'google-analytics-for-wordpress'), __('Insights', 'google-analytics-for-wordpress') . $menu_notification_indicator, 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page', $menu_icon_inline, '100.00013467543'); if ( ! MonsterInsights()->setup_checklist->is_dismissed() ) { add_submenu_page( $hook, __( 'Setup Checklist', 'google-analytics-for-wordpress' ), __( 'Setup Checklist', 'google-analytics-for-wordpress' ) . MonsterInsights()->setup_checklist->get_menu_count(), 'monsterinsights_save_settings', 'monsterinsights_settings#/setup-checklist', 'monsterinsights_settings_page' ); } add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' ); // then settings page add_submenu_page( $hook, __( 'MonsterInsights', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' ); // Add dashboard submenu. add_submenu_page( 'index.php', __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'admin.php?page=monsterinsights_reports' ); // If the setup checklist is not dismissed, remove the own submenu of `Insights` main menu that we added on line 52. // This way the Checklist will be the first submenu which is an important thing for onboarding. if ( ! MonsterInsights()->setup_checklist->is_dismissed() ) { // Check if the user has the capability to save settings and view dashboard. // We should skip this for editors that have only view capability have only item in the submenu, removing that would break the menu. if ( ! ( ! current_user_can( 'monsterinsights_save_settings' ) && current_user_can( 'monsterinsights_view_dashboard' ) ) ) { // Remove own submenu of `Insights` main menu. remove_submenu_page( 'monsterinsights_reports', 'monsterinsights_reports' ); } } } $submenu_base = add_query_arg('page', 'monsterinsights_settings', admin_url('admin.php')); add_submenu_page( $hook, __( 'Site Notes:', 'google-analytics-for-wordpress' ), __( 'Site Notes', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', $submenu_base . '#/site-notes' ); // Add Popular Posts menu item. add_submenu_page($hook, __('Popular Posts:', 'google-analytics-for-wordpress'), __('Popular Posts', 'google-analytics-for-wordpress'), 'monsterinsights_save_settings', $submenu_base . '#/popular-posts'); // Add submenu under `Insights` main menu for user journey report. add_submenu_page( $hook, __( 'User Journey:', 'google-analytics-for-wordpress' ), __( 'User Journey', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'admin.php?page=monsterinsights_reports#/user-journey-report' ); if ( function_exists( 'aioseo' ) ) { $seo_url = monsterinsights_aioseo_dashboard_url(); } else { $seo_url = $submenu_base . '#/seo'; } // then SEO add_submenu_page($hook, __('SEO', 'google-analytics-for-wordpress'), __('SEO', 'google-analytics-for-wordpress'), 'manage_options', $seo_url); // then tools add_submenu_page($hook, __('Tools:', 'google-analytics-for-wordpress'), __('Tools', 'google-analytics-for-wordpress'), 'manage_options', $submenu_base . '#/tools'); // then addons $network_key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_network_license_key() : ''; if (!monsterinsights_is_network_active() || (monsterinsights_is_network_active() && empty($network_key))) { add_submenu_page($hook, __('Addons:', 'google-analytics-for-wordpress'), ' ' . __('Addons', 'google-analytics-for-wordpress') . '', 'monsterinsights_save_settings', $submenu_base . '#/addons'); } add_submenu_page( $hook, __('UserFeedback:', 'google-analytics-for-wordpress'), __('UserFeedback', 'google-analytics-for-wordpress') . $newIndicator, 'manage_options', $submenu_base . '#/userfeedback' ); // then About Us page. add_submenu_page($hook, __('About Us:', 'google-analytics-for-wordpress'), __('About Us', 'google-analytics-for-wordpress'), 'manage_options', $submenu_base . '#/about'); if (!monsterinsights_is_pro_version() && !strstr(plugin_basename(__FILE__), 'dashboard-for')) { // automated promotion monsterinsights_automated_menu($hook); } add_submenu_page($hook, __('Growth Tools:', 'google-analytics-for-wordpress'), __('Growth Tools', 'google-analytics-for-wordpress'), 'manage_options', $submenu_base . '#/growth-tools'); // then Upgrade To Pro. if (!monsterinsights_is_pro_version()) { add_submenu_page($hook, __('Upgrade to Pro:', 'google-analytics-for-wordpress'), '', 'monsterinsights_save_settings', monsterinsights_get_upgrade_link('admin-menu', 'submenu', "https://www.monsterinsights.com/lite/")); } if ( class_exists( 'WooCommerce' ) ) { // Show the Payments submenu only when WooCommerce is active. add_submenu_page( $hook, __('Payments:', 'google-analytics-for-wordpress'), __('Payments', 'google-analytics-for-wordpress'), 'manage_options', $submenu_base . '#/payments' ); } } add_action('admin_menu', 'monsterinsights_admin_menu'); function monsterinsights_automated_menu($hook){ $display = false; $now = apply_filters('monsterinsights_automated_promotion_date', wp_date('M d, Y h:i:s a')); $conditions = [ [ 'title' => __('Earth Day', 'google-analytics-for-wordpress'), 'start_time' => wp_date('M d, Y h:i:s a', strtotime('Apr 17, 2023')), 'end_time' => wp_date('M d, Y h:i:s a', strtotime('Apr 18, 2023')), 'utm_campaign' => 'lite-promo', 'utm_source' => 'liteplugin', 'utm_medium' => 'earth-day', ], [ 'title' => __('Cinco De Mayo!', 'google-analytics-for-wordpress'), 'start_time' => wp_date('M d, Y h:i:s a', strtotime('May 01, 2023')), 'end_time' => wp_date('M d, Y h:i:s a', strtotime('May 08, 2023')), 'utm_campaign' => 'lite-promo', 'utm_source' => 'liteplugin', 'utm_medium' => 'cinco-de-mayo', ], [ 'title' => __('Upgrade to GA4', 'google-analytics-for-wordpress'), 'start_time' => wp_date('M d, Y h:i:s a', strtotime('Jun 01, 2023')), 'end_time' => wp_date('M d, Y h:i:s a', strtotime('July 01, 2023')), 'utm_campaign' => 'lite-promo', 'utm_source' => 'liteplugin', 'utm_medium' => 'goodbye-ga3', ], [ 'title' => __('Summer Sale', 'google-analytics-for-wordpress'), 'start_time' => wp_date('M d, Y h:i:s a', strtotime('Jul 29, 2023')), 'end_time' => wp_date('M d, Y h:i:s a', strtotime('Aug 05, 2023')), 'utm_campaign' => 'lite-promo', 'utm_source' => 'liteplugin', 'utm_medium' => 'dogdays', ], [ 'title' => __('Fortune Cookie Day', 'google-analytics-for-wordpress'), 'start_time' => wp_date('M d, Y h:i:s a', strtotime('Sep 12, 2023')), 'end_time' => wp_date('M d, Y h:i:s a', strtotime('Sep 13, 2023')), 'utm_campaign' => 'lite-promo', 'utm_source' => 'liteplugin', 'utm_medium' => 'fortune-cookie', ], [ 'title' => __('Halloween Sale', 'google-analytics-for-wordpress'), 'start_time' => wp_date('M d, Y h:i:s a', strtotime('Oct 26, 2023')), 'end_time' => wp_date('M d, Y h:i:s a', strtotime('Nov 04, 2023')), 'utm_campaign' => 'lite-promo', 'utm_source' => 'liteplugin', 'utm_medium' => 'halloween', ], ]; foreach($conditions as $key => $condition){ if(strtotime($now) >= strtotime($condition['start_time']) && strtotime($now) <= strtotime($condition['end_time'])){ add_submenu_page($hook, $condition['title'], '', 'monsterinsights_save_settings', monsterinsights_get_upgrade_link($condition['utm_medium'], $condition['utm_campaign'], "https://www.monsterinsights.com/lite-promo/")); break; } } } /** * Add this separately so all the Woo menu items are loaded and the position parameter works correctly. */ function monsterinsights_woocommerce_menu_item() { if (class_exists('WooCommerce')) { // Add "Insights" sub menu item for WooCommerce Analytics menu if (class_exists('MonsterInsights_eCommerce')) { add_submenu_page('wc-admin&path=/analytics/overview', __('Insights', 'google-analytics-for-wordpress'), __('Insights', 'google-analytics-for-wordpress'), 'monsterinsights_view_dashboard', admin_url('admin.php?page=monsterinsights_reports#/ecommerce'), '', 2); } else { $submenu_base = add_query_arg('page', 'monsterinsights_settings', admin_url('admin.php')); add_submenu_page('wc-admin&path=/analytics/overview', __('Insights', 'google-analytics-for-wordpress'), __('Insights', 'google-analytics-for-wordpress'), 'manage_options', $submenu_base . '#/woocommerce-insights', '', 1); } } } add_action('admin_menu', 'monsterinsights_woocommerce_menu_item', 11); function monsterinsights_get_menu_hook() { $dashboards_disabled = monsterinsights_get_option('dashboards_disabled', false); if ($dashboards_disabled || (current_user_can('monsterinsights_save_settings') && !current_user_can('monsterinsights_view_dashboard'))) { return 'monsterinsights_settings'; } else { return 'monsterinsights_reports'; } } function monsterinsights_network_admin_menu() { // Get the base class object. $base = MonsterInsights(); // First, let's see if this is an MS network enabled plugin. If it is, we should load the license // menu page and the updater on the network panel if (!function_exists('is_plugin_active_for_network')) { require_once(ABSPATH . '/wp-admin/includes/plugin.php'); } $plugin = plugin_basename(MONSTERINSIGHTS_PLUGIN_FILE); if (!is_plugin_active_for_network($plugin)) { return; } $menu_notification_indicator = MonsterInsights()->notifications->get_menu_count(); if ( MonsterInsights()->license->license_expired() ) { $menu_notification_indicator = MonsterInsights()->notifications->get_license_expired_indicator(); } $menu_icon_inline = monsterinsights_get_inline_menu_icon(); $hook = 'monsterinsights_network'; $submenu_base = add_query_arg('page', 'monsterinsights_network', network_admin_url('admin.php')); add_menu_page(__('Network Settings:', 'google-analytics-for-wordpress'), __('Insights', 'google-analytics-for-wordpress') . $menu_notification_indicator, 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page', $menu_icon_inline, '100.00013467543'); add_submenu_page($hook, __('Network Settings:', 'google-analytics-for-wordpress'), __('Network Settings', 'google-analytics-for-wordpress'), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page'); add_submenu_page($hook, __('General Reports:', 'google-analytics-for-wordpress'), __('Reports', 'google-analytics-for-wordpress'), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page'); if (function_exists('aioseo')) { $seo_url = monsterinsights_aioseo_dashboard_url(); } else { $seo_url = $submenu_base . '#/seo'; } // then seo add_submenu_page($hook, __('SEO:', 'google-analytics-for-wordpress'), __('SEO', 'google-analytics-for-wordpress'), 'manage_options', $seo_url, 'monsterinsights_seo_page'); // then addons add_submenu_page($hook, __('Addons:', 'google-analytics-for-wordpress'), ' ' . __('Addons', 'google-analytics-for-wordpress') . '', 'monsterinsights_save_settings', $submenu_base . '#/addons'); $submenu_base = add_query_arg('page', 'monsterinsights_network', network_admin_url('admin.php')); // Add About us page. add_submenu_page($hook, __('About Us:', 'google-analytics-for-wordpress'), __('About Us', 'google-analytics-for-wordpress'), 'manage_options', $submenu_base . '#/about'); } add_action('network_admin_menu', 'monsterinsights_network_admin_menu', 5); /** * Adds one or more classes to the body tag in the dashboard. * * @param String $classes Current body classes. * * @return String Altered body classes. */ function monsterinsights_add_admin_body_class($classes) { $screen = function_exists('get_current_screen') ? get_current_screen() : false; if (empty($screen) || empty($screen->id) || strpos($screen->id, 'monsterinsights') === false) { return $classes; } return "$classes monsterinsights_page "; } add_filter('admin_body_class', 'monsterinsights_add_admin_body_class', 10, 1); /** * Adds one or more classes to the body tag in the dashboard. * * @param String $classes Current body classes. * * @return String Altered body classes. */ function monsterinsights_add_admin_body_class_tools_page($classes) { $screen = function_exists('get_current_screen') ? get_current_screen() : false; if (empty($screen) || empty($screen->id) || strpos($screen->id, 'monsterinsights_tools') === false || 'insights_page_monsterinsights_tools' === $screen->id) { return $classes; } return "$classes insights_page_monsterinsights_tools "; } add_filter('admin_body_class', 'monsterinsights_add_admin_body_class_tools_page', 10, 1); /** * Adds one or more classes to the body tag in the dashboard. * * @param String $classes Current body classes. * * @return String Altered body classes. */ function monsterinsights_add_admin_body_class_addons_page($classes) { $screen = function_exists('get_current_screen') ? get_current_screen() : false; if (empty($screen) || empty($screen->id) || strpos($screen->id, 'monsterinsights_addons') === false || 'insights_page_monsterinsights_addons' === $screen->id) { return $classes; } return "$classes insights_page_monsterinsights_addons "; } add_filter('admin_body_class', 'monsterinsights_add_admin_body_class_addons_page', 10, 1); /** * Add a link to the settings page to the plugins list * * @param array $links array of links for the plugins, adapted when the current plugin is found. * * @return array $links */ function monsterinsights_add_action_links($links) { $docs = '' . esc_html__('Documentation', 'google-analytics-for-wordpress') . ''; array_unshift($links, $docs); // If Lite, support goes to forum. If pro, it goes to our website if (monsterinsights_is_pro_version()) { $support = '' . esc_html__('Support', 'google-analytics-for-wordpress') . ''; array_unshift($links, $support); } else { $support = '' . esc_html__('Support', 'google-analytics-for-wordpress') . ''; array_unshift($links, $support); } if (is_network_admin()) { $settings_link = '' . esc_html__('Network Settings', 'google-analytics-for-wordpress') . ''; } else { $settings_link = '' . esc_html__('Settings', 'google-analytics-for-wordpress') . ''; } array_unshift($links, $settings_link); // If lite, show a link where they can get pro from if (!monsterinsights_is_pro_version()) { $get_pro = '' . esc_html__('Get MonsterInsights Pro', 'google-analytics-for-wordpress') . ''; array_unshift($links, $get_pro); } return $links; } add_filter('plugin_action_links_' . plugin_basename(MONSTERINSIGHTS_PLUGIN_FILE), 'monsterinsights_add_action_links'); add_filter('network_admin_plugin_action_links_' . plugin_basename(MONSTERINSIGHTS_PLUGIN_FILE), 'monsterinsights_add_action_links'); /** * Loads a partial view for the Administration screen * * @access public * * @param string $template PHP file at includes/admin/partials, excluding file extension * @param array $data Any data to pass to the view * * @return void * @since 6.0.0 * */ function monsterinsights_load_admin_partial($template, $data = array()) { if (monsterinsights_is_pro_version()) { $dir = trailingslashit(plugin_dir_path(MonsterInsights()->file) . 'pro/includes/admin/partials'); if (file_exists($dir . $template . '.php')) { require_once($dir . $template . '.php'); return true; } } else { $dir = trailingslashit(plugin_dir_path(MonsterInsights()->file) . 'lite/includes/admin/partials'); if (file_exists($dir . $template . '.php')) { require_once($dir . $template . '.php'); return true; } } $dir = trailingslashit(plugin_dir_path(MonsterInsights()->file) . 'includes/admin/partials'); if (file_exists($dir . $template . '.php')) { require_once($dir . $template . '.php'); return true; } return false; } /** * When user is on a MonsterInsights related admin page, display footer text * that graciously asks them to rate us. * * @param string $text * * @return string * @since 6.0.0 */ function monsterinsights_admin_footer($text) { global $current_screen; if (!empty($current_screen->id) && strpos($current_screen->id, 'monsterinsights') !== false) { $url = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5'; // Translators: Placeholders add a link to the wordpress.org repository. $text = sprintf(esc_html__('Please rate %1$sMonsterInsights%2$s on %3$s %4$sWordPress.org%5$s to help us spread the word. Thank you from the MonsterInsights team!', 'google-analytics-for-wordpress'), '', '', '', '', ''); } return $text; } add_filter('admin_footer_text', 'monsterinsights_admin_footer', 1, 2); function monsterinsights_admin_setup_notices() { // Make sure they have the permissions to do something if (!current_user_can('monsterinsights_save_settings')) { return; } // Priority: // 0. UA sunset // 1. Google Analytics not authenticated // 2. License key not entered for pro // 3. License key not valid/okay for pro // 4. WordPress + PHP min versions // 5. (old) Optin setting not configured // 6. Manual UA code // 7. Automatic updates not configured // 8. Woo upsell // 9. EDD upsell // 0. UA sunset supported alert $profile = is_network_admin() ? MonsterInsights()->auth->get_network_analytics_profile() : MonsterInsights()->auth->get_analytics_profile(); if ( !empty($profile['ua']) && empty($profile['v4']) && !monsterinsights_is_own_admin_page() ) { $title = __('Urgent: Your Website is Not Tracking Any Google Analytics Data!', 'google-analytics-for-wordpress'); $message = __('Google Analytics 3 (UA) and support was sunset on July 1, 2023. Your website is currently NOT tracking any analytics. Create or connect a new Google Analytics 4 property immediately to start tracking.', 'google-analytics-for-wordpress'); $wizard_url = admin_url('admin.php?page=monsterinsights-onboarding'); echo '
' . $title . '
'; echo '' . $message . '
'; echo '';
echo '' .
__( 'Learn How to Create a GA4 Property', 'google-analytics-for-wordpress' ) .
'
';
echo '' .
__( 'Connect a Property', 'google-analytics-for-wordpress' ) .
'
';
echo '
' . $message . '
' . $message . '
' . wp_kses($message, [ 'br' => array(), 'b' => array(), 'strong' => array(), 'i' => array(), 'a' => array( 'href' => array(), 'target' => array(), 'title' => array(), ), ]) . '
'. $message.'
'. $message.'
'. $message.'
'; // echo esc_html__( 'Allow MonsterInsights to track plugin usage? Opt-in to tracking and our newsletter to stay informed of the latest changes to MonsterInsights and help us ensure compatibility.', 'google-analytics-for-wordpress' ); // echo ' ' . __( 'Allow', 'google-analytics-for-wordpress' ) . ''; // echo ' ' . __( 'Do not allow', 'google-analytics-for-wordpress' ) . ''; // echo '
'; echo $manual_text; // phpcs:ignore echo '
'; echo ''; // echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '', '' ); // echo '
'; // echo '%2$s
%3$s
%4$s
%5$s
%6$s
%7$s %8$s'; echo esc_html('Enhanced Ecommerce Analytics for Your Easy Digital Downloads Store', 'google-analytics-for-wordpress'); echo '
'; echo '
';
echo ''; echo esc_html('MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress'); echo '
'; echo ''; echo esc_html('This helps you make data-driven decisions about your content, and marketing strategy so you can increase your website traffic, leads, and sales.', 'google-analytics-for-wordpress'); echo '
'; echo ''; echo esc_html('Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress'); echo '
'; echo ''; echo esc_html('Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress'); echo '
'; echo sprintf(esc_html__('%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress'), '', ' »'); echo ''; echo '
';
echo '' . $message . '
' . $message . '