admin.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. <?php
  2. /**
  3. * Admin class.
  4. *
  5. * @since 6.0.0
  6. *
  7. * @package MonsterInsights
  8. * @subpackage Admin
  9. * @author Chris Christoff
  10. */
  11. // Exit if accessed directly
  12. if ( ! defined( 'ABSPATH' ) ) {
  13. exit;
  14. }
  15. /**
  16. * Register menu items for MonsterInsights.
  17. *
  18. * @since 6.0.0
  19. * @access public
  20. *
  21. * @return void
  22. */
  23. function monsterinsights_admin_menu() {
  24. // Get the base class object.
  25. $base = MonsterInsights();
  26. $dashboards_disabled = monsterinsights_get_option( 'dashboards_disabled', false );
  27. $is_authed = ( MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed() );
  28. $hook = 'monsterinsights_settings';
  29. if ( $dashboards_disabled || ! $is_authed || ( current_user_can( 'monsterinsights_save_settings' ) && ! current_user_can( 'monsterinsights_view_dashboard' ) ) ) {
  30. // If dashboards disabled, first settings page
  31. add_menu_page( __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page', plugins_url( 'assets/css/images/menu-icon@2x.png', $base->file ), '100.00013467543' );
  32. $hook = 'monsterinsights_settings';
  33. add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings' );
  34. add_submenu_page( $hook, __( 'Settings - Tracking:', 'google-analytics-for-wordpress' ), __( 'Settings - Tracking', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_tracking', 'monsterinsights_tracking_page' );
  35. } else {
  36. // if dashboards enabled, first dashboard
  37. add_menu_page( __( 'General:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page', plugins_url( 'assets/css/images/menu-icon@2x.png', $base->file ), '100.00013467543' );
  38. $hook = 'monsterinsights_reports';
  39. add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
  40. // then settings page
  41. add_submenu_page( $hook, __( 'Settings:', 'google-analytics-for-wordpress' ), __( 'Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_settings', 'monsterinsights_settings_page' );
  42. add_submenu_page( $hook, __( 'Settings - Tracking:', 'google-analytics-for-wordpress' ), __( 'Settings - Tracking', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_tracking', 'monsterinsights_tracking_page' );
  43. }
  44. // then tools
  45. add_submenu_page( $hook, __( 'Tools:', 'google-analytics-for-wordpress' ), __( 'Tools', 'google-analytics-for-wordpress' ), 'manage_options', 'monsterinsights_tools', 'monsterinsights_tools_page' );
  46. // then addons
  47. $network_key = MonsterInsights()->license->get_network_license_key();
  48. if ( ! monsterinsights_is_network_active() || ( monsterinsights_is_network_active() && empty( $network_key ) ) ) {
  49. add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:#7cc048"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', 'monsterinsights_addons', 'monsterinsights_addons_page' );
  50. }
  51. }
  52. add_action( 'admin_menu', 'monsterinsights_admin_menu' );
  53. function monsterinsights_network_admin_menu() {
  54. // Get the base class object.
  55. $base = MonsterInsights();
  56. // First, let's see if this is an MS network enabled plugin. If it is, we should load the license
  57. // menu page and the updater on the network panel
  58. if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
  59. require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
  60. }
  61. $plugin = plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE );
  62. if ( ! is_plugin_active_for_network( $plugin ) ) {
  63. return;
  64. }
  65. $hook = 'monsterinsights_network';
  66. add_menu_page( __( 'Network Settings:', 'google-analytics-for-wordpress' ), __( 'Insights', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page', plugins_url( 'assets/css/images/menu-icon@2x.png', $base->file ), '100.00013467543' );
  67. add_submenu_page( $hook, __( 'Network Settings:', 'google-analytics-for-wordpress' ), __( 'Network Settings', 'google-analytics-for-wordpress' ), 'monsterinsights_save_settings', 'monsterinsights_network', 'monsterinsights_network_page' );
  68. add_submenu_page( $hook, __( 'General Reports:', 'google-analytics-for-wordpress' ), __( 'Reports', 'google-analytics-for-wordpress' ), 'monsterinsights_view_dashboard', 'monsterinsights_reports', 'monsterinsights_reports_page' );
  69. // then addons
  70. add_submenu_page( $hook, __( 'Addons:', 'google-analytics-for-wordpress' ), '<span style="color:#7cc048"> ' . __( 'Addons', 'google-analytics-for-wordpress' ) . '</span>', 'monsterinsights_save_settings', 'monsterinsights_addons', 'monsterinsights_addons_page' );
  71. }
  72. add_action( 'network_admin_menu', 'monsterinsights_network_admin_menu', 5 );
  73. /**
  74. * Adds one or more classes to the body tag in the dashboard.
  75. *
  76. * @param String $classes Current body classes.
  77. * @return String Altered body classes.
  78. */
  79. function monsterinsights_add_admin_body_class( $classes ) {
  80. $screen = get_current_screen();
  81. if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
  82. return $classes;
  83. }
  84. return "$classes monsterinsights_page ";
  85. }
  86. add_filter( 'admin_body_class', 'monsterinsights_add_admin_body_class', 10, 1 );
  87. /**
  88. * Add a link to the settings page to the plugins list
  89. *
  90. * @param array $links array of links for the plugins, adapted when the current plugin is found.
  91. *
  92. * @return array $links
  93. */
  94. function monsterinsights_add_action_links( $links ) {
  95. $docs = '<a title="' . esc_html__( 'MonsterInsights Knowledge Base', 'google-analytics-for-wordpress' ) . '" href="'. monsterinsights_get_url( 'all-plugins', 'kb-link', "https://www.monsterinsights.com/docs/" ) .'"">' . esc_html__( 'Documentation', 'google-analytics-for-wordpress' ) . '</a>';
  96. array_unshift( $links, $docs );
  97. // If lite, show a link where they can get pro from
  98. if ( ! monsterinsights_is_pro_version() ) {
  99. $get_pro = '<a title="' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) .'" href="'. monsterinsights_get_upgrade_link( 'all-plugins', 'upgrade-link', "https://www.monsterinsights.com/docs/" ) .'">' . esc_html__( 'Get MonsterInsights Pro', 'google-analytics-for-wordpress' ) . '</a>';
  100. array_unshift( $links, $get_pro );
  101. }
  102. // If Lite, support goes to forum. If pro, it goes to our website
  103. if ( monsterinsights_is_pro_version() ) {
  104. $support = '<a title="MonsterInsights Pro Support" href="'. monsterinsights_get_url( 'all-plugins', 'pro-support-link', "https://www.monsterinsights.com/my-account/support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
  105. array_unshift( $links, $support );
  106. } else {
  107. $support = '<a title="MonsterInsights Lite Support" href="'. monsterinsights_get_url( 'all-plugins', 'lite-support-link', "https://www.monsterinsights.com/lite-support/" ) .'">' . esc_html__( 'Support', 'google-analytics-for-wordpress' ) . '</a>';
  108. array_unshift( $links, $support );
  109. }
  110. $settings_link = '<a href="' . esc_url( admin_url( 'admin.php?page=monsterinsights_settings' ) ) . '">' . esc_html__( 'Settings', 'google-analytics-for-wordpress' ) . '</a>';
  111. array_unshift( $links, $settings_link );
  112. return $links;
  113. }
  114. add_filter( 'plugin_action_links_' . plugin_basename( MONSTERINSIGHTS_PLUGIN_FILE ), 'monsterinsights_add_action_links' );
  115. /**
  116. * Loads a partial view for the Administration screen
  117. *
  118. * @access public
  119. * @since 6.0.0
  120. *
  121. * @param string $template PHP file at includes/admin/partials, excluding file extension
  122. * @param array $data Any data to pass to the view
  123. * @return void
  124. */
  125. function monsterinsights_load_admin_partial( $template, $data = array() ) {
  126. if ( monsterinsights_is_pro_version() ) {
  127. $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'pro/includes/admin/partials' );
  128. if ( file_exists( $dir . $template . '.php' ) ) {
  129. require_once( $dir . $template . '.php' );
  130. return true;
  131. }
  132. } else {
  133. $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'lite/includes/admin/partials' );
  134. if ( file_exists( $dir . $template . '.php' ) ) {
  135. require_once( $dir . $template . '.php' );
  136. return true;
  137. }
  138. }
  139. $dir = trailingslashit( plugin_dir_path( MonsterInsights()->file ) . 'includes/admin/partials' );
  140. if ( file_exists( $dir . $template . '.php' ) ) {
  141. require_once( $dir . $template . '.php' );
  142. return true;
  143. }
  144. return false;
  145. }
  146. /**
  147. * Outputs the MonsterInsights Header.
  148. *
  149. * @since 6.0.0
  150. */
  151. function monsterinsights_admin_header() {
  152. // Get the current screen, and check whether we're viewing a MonsterInsights screen;
  153. $screen = get_current_screen();
  154. if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) {
  155. return;
  156. }
  157. // If here, we're on an MonsterInsights screen, so output the header.
  158. monsterinsights_load_admin_partial( 'header', array(
  159. 'mascot' => plugins_url( 'assets/css/images/mascot.png', MonsterInsights()->file ),
  160. 'logo' => plugins_url( 'assets/css/images/logo.png', MonsterInsights()->file ),
  161. '2xmascot' => plugins_url( 'assets/css/images/mascot@2x.png', MonsterInsights()->file ),
  162. '2xlogo' => plugins_url( 'assets/css/images/logo@2x.png', MonsterInsights()->file ),
  163. ) );
  164. }
  165. add_action( 'in_admin_header','monsterinsights_admin_header', 100 );
  166. function monsterinsights_welcome_redirect() {
  167. // Bail if no activation redirect
  168. if ( ! get_transient( '_monsterinsights_activation_redirect' ) ) {
  169. return;
  170. }
  171. // Delete the redirect transient
  172. delete_transient( '_monsterinsights_activation_redirect' );
  173. // Bail if activating from network, or bulk
  174. if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
  175. return;
  176. }
  177. $upgrade = get_option( 'monsterinsights_version_upgraded_from' );
  178. if( ! $upgrade ) { // First time install
  179. //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
  180. } else { // Update
  181. return;
  182. //wp_safe_redirect( admin_url( 'admin.php?page=monsterinsights_settings#monsterinsights-main-tab-general' ) ); exit;
  183. }
  184. }
  185. //add_action( 'admin_init', 'monsterinsights_welcome_redirect', 11 ); @todo: Investigate
  186. /**
  187. * When user is on a MonsterInsights related admin page, display footer text
  188. * that graciously asks them to rate us.
  189. *
  190. * @since 6.0.0
  191. * @param string $text
  192. * @return string
  193. */
  194. function monsterinsights_admin_footer( $text ) {
  195. global $current_screen;
  196. if ( ! empty( $current_screen->id ) && strpos( $current_screen->id, 'monsterinsights' ) !== false ) {
  197. $url = 'https://wordpress.org/support/view/plugin-reviews/google-analytics-for-wordpress?filter=5';
  198. $text = sprintf( esc_html__( 'Please rate %sMonsterInsights%s %s on %sWordPress.org%s to help us spread the word. Thank you from the MonsterInsights team!', 'google-analytics-for-wordpress' ), '<strong>', '</strong>', '<a class="monsterinsights-no-text-decoration" href="' . $url . '" target="_blank" rel="noopener noreferrer">&#9733;&#9733;&#9733;&#9733;&#9733;</a>', '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">', '</a>' );
  199. }
  200. return $text;
  201. }
  202. add_filter( 'admin_footer_text', 'monsterinsights_admin_footer', 1, 2 );
  203. function monsterinsights_admin_setup_notices() {
  204. // Don't show on MonsterInsights pages
  205. $screen = get_current_screen();
  206. if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) !== false ) {
  207. return;
  208. }
  209. // Make sure they have the permissions to do something
  210. if ( ! current_user_can( 'monsterinsights_save_settings' ) ) {
  211. return;
  212. }
  213. // Priority:
  214. // 1. Google Analytics not authenticated
  215. // 2. License key not entered for pro
  216. // 3. License key not valid/okay for pro
  217. // 4. Optin setting not configured
  218. // 5. Automatic updates not configured
  219. // 1. Google Analytics not authenticated
  220. if ( ! is_network_admin() && ! monsterinsights_get_ua() ) {
  221. $page = admin_url( 'admin.php?page=monsterinsights_settings' );
  222. $message = sprintf( esc_html__( 'Please configure your %1$sGoogle Analytics settings%2$s!', 'google-analytics-for-wordpress' ),'<a href="' . $page . '">', '</a>' );
  223. echo '<div class="error"><p>'. $message.'</p></div>';
  224. return;
  225. }
  226. // 2. License key not entered for pro
  227. $key = monsterinsights_is_pro_version() ? MonsterInsights()->license->get_license_key() : '';
  228. if ( monsterinsights_is_pro_version() && empty( $key ) ) {
  229. $page = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
  230. $message = sprintf( esc_html__( 'Warning: No valid license key has been entered for MonsterInsights. You are currently not getting updates, and are not able to view reports. %1$sPlease click here to enter your license key and begin receiving updates and reports.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. esc_url( $page ) . '">', '</a>' );
  231. echo '<div class="error"><p>'. $message.'</p></div>';
  232. return;
  233. }
  234. // 3. License key not valid/okay for pro
  235. if ( monsterinsights_is_pro_version() ) {
  236. $message = '';
  237. if ( MonsterInsights()->license->get_site_license_key() ){
  238. if ( MonsterInsights()->license->site_license_expired() ) {
  239. $message = sprintf( esc_html__( 'Your license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
  240. } else if ( MonsterInsights()->license->site_license_disabled() ) {
  241. $message = esc_html__( 'Your license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
  242. } else if ( MonsterInsights()->license->site_license_invalid() ) {
  243. $message = esc_html__( 'Your license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
  244. }
  245. } else if ( MonsterInsights()->license->get_network_license_key() ) {
  246. if ( MonsterInsights()->license->network_license_expired() ) {
  247. $message = sprintf( esc_html__( 'Your network license key for MonsterInsights has expired. %1$sPlease click here to renew your license key.%2$s', 'google-analytics-for-wordpress' ), '<a href="'. monsterinsights_get_url( 'admin-notices', 'expired-license', "https://www.monsterinsights.com/login/" ) .'" target="_blank" rel="noopener noreferrer" referrer="no-referrer">', '</a>' );
  248. } else if ( MonsterInsights()->license->network_license_disabled() ) {
  249. $message = esc_html__( 'Your network license key for MonsterInsights has been disabled. Please use a different key.', 'google-analytics-for-wordpress' );
  250. } else if ( MonsterInsights()->license->network_license_invalid() ) {
  251. $message = esc_html__( 'Your network license key for MonsterInsights is invalid. The key no longer exists or the user associated with the key has been deleted. Please use a different key.', 'google-analytics-for-wordpress' );
  252. }
  253. }
  254. if ( ! empty( $message ) ) {
  255. echo '<div class="error"><p>'. $message.'</p></div>';
  256. return;
  257. }
  258. }
  259. // 4. Optin setting not configured
  260. // if ( ! is_network_admin() ) {
  261. // if ( ! get_option( 'monsterinsights_tracking_notice' ) ) {
  262. // if ( ! monsterinsights_get_option( 'anonymous_data', false ) ) {
  263. // if ( ! monsterinsights_is_dev_url( network_site_url( '/' ) ) ) {
  264. // if ( monsterinsights_is_pro_version() ) {
  265. // monsterinsights_update_option( 'anonymous_data', 1 );
  266. // return;
  267. // }
  268. // $optin_url = add_query_arg( 'mi_action', 'opt_into_tracking' );
  269. // $optout_url = add_query_arg( 'mi_action', 'opt_out_of_tracking' );
  270. // echo '<div class="updated"><p>';
  271. // 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' );
  272. // echo '&nbsp;<a href="' . esc_url( $optin_url ) . '" class="button-secondary">' . __( 'Allow', 'google-analytics-for-wordpress' ) . '</a>';
  273. // echo '&nbsp;<a href="' . esc_url( $optout_url ) . '" class="button-secondary">' . __( 'Do not allow', 'google-analytics-for-wordpress' ) . '</a>';
  274. // echo '</p></div>';
  275. // return;
  276. // } else {
  277. // // is testing site
  278. // update_option( 'monsterinsights_tracking_notice', '1' );
  279. // }
  280. // }
  281. // }
  282. // }
  283. $notices = get_option( 'monsterinsights_notices' );
  284. if ( ! is_array( $notices ) ) {
  285. $notices = array();
  286. }
  287. // 5. Authenticate, not manual
  288. $authed = MonsterInsights()->auth->is_authed() || MonsterInsights()->auth->is_network_authed();
  289. $url = is_network_admin() ? network_admin_url( 'admin.php?page=monsterinsights_network' ) : admin_url( 'admin.php?page=monsterinsights_settings' );
  290. if ( empty( $authed ) && ! isset( $notices['monsterinsights_auth_not_manual' ] ) ) {
  291. echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_auth_not_manual">';
  292. echo '<p>';
  293. echo sprintf( esc_html__( 'Important: You are currently using manual UA code output. We highly recommend %1$sauthenticating with MonsterInsights%2$s so that you can access our new reporting area and take advantage of new MonsterInsights features.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' );
  294. echo '</p>';
  295. echo '</div>';
  296. return;
  297. }
  298. // 6. Automatic updates not configured
  299. // if ( ! is_network_admin() ) {
  300. // $updates = monsterinsights_get_option( 'automatic_updates', false );
  301. // $url = admin_url( 'admin.php?page=monsterinsights_settings' );
  302. // if ( empty( $updates) && ! isset( $notices['monsterinsights_automatic_updates' ] ) ) {
  303. // echo '<div class="notice notice-info is-dismissible monsterinsights-notice" data-notice="monsterinsights_automatic_updates">';
  304. // echo '<p>';
  305. // echo sprintf( esc_html__( 'Important: Please %1$sconfigure the Automatic Updates Settings%2$s in MonsterInsights.', 'google-analytics-for-wordpress' ), '<a href="' . $url .'">', '</a>' );
  306. // echo '</p>';
  307. // echo '</div>';
  308. // return;
  309. // }
  310. // }
  311. // 7. WooUpsell
  312. if ( ! monsterinsights_is_pro_version() && class_exists( 'WooCommerce' ) ) {
  313. if ( ! isset( $notices['monsterinsights_woocommerce_tracking_available' ] ) ) {
  314. echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_woocommerce_tracking_available">';
  315. echo '<div class="monsterinsights-wooedd-upsell-left">';
  316. echo '<p><strong>';
  317. echo esc_html( 'Enhanced Ecommerce Analytics for Your WooCommerce Store', 'google-analytics-for-wordpress' );
  318. echo '</strong></p>';
  319. echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
  320. echo '<p>';
  321. echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
  322. echo '</p>';
  323. echo '<p>';
  324. 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' );
  325. echo '</p>';
  326. echo '<p>';
  327. echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
  328. echo '</p>';
  329. echo '<p>';
  330. echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
  331. echo '</p>';
  332. echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'woocommerce-upgrade' ) .'">', ' &raquo;</a>' );
  333. echo '</p>';
  334. echo '</div><div class="monsterinsights-wooedd-upsell-right">';
  335. echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
  336. echo '</div>';
  337. echo '</div>';
  338. return;
  339. }
  340. }
  341. // 8. EDDUpsell
  342. if ( ! monsterinsights_is_pro_version() && class_exists( 'Easy_Digital_Downloads' ) ) {
  343. if ( ! isset( $notices['monsterinsights_edd_tracking_available' ] ) ) {
  344. echo '<div class="notice notice-success is-dismissible monsterinsights-notice monsterinsights-wooedd-upsell-row" data-notice="monsterinsights_edd_tracking_available">';
  345. echo '<div class="monsterinsights-wooedd-upsell-left">';
  346. echo '<p><strong>';
  347. echo esc_html( 'Enhanced Ecommerce Analytics for Your Easy Digital Downloads Store', 'google-analytics-for-wordpress' );
  348. echo '</strong></p>';
  349. echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-small" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
  350. echo '<p>';
  351. echo esc_html( 'MonsterInsights Pro gives you detailed stats and insights about your customers.', 'google-analytics-for-wordpress' );
  352. echo '</p>';
  353. echo '<p>';
  354. 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' );
  355. echo '</p>';
  356. echo '<p>';
  357. echo esc_html( 'Pro customers also get Form Tracking, Custom Dimensions Tracking, UserID Tracking and much more.', 'google-analytics-for-wordpress' );
  358. echo '</p>';
  359. echo '<p>';
  360. echo esc_html( 'Start making data-driven decisions to grow your business.', 'google-analytics-for-wordpress' );
  361. echo '</p>';
  362. echo sprintf( esc_html__( '%1$sGet MonsterInsights Pro%2$s', 'google-analytics-for-wordpress' ), '<a class="button button-primary button-hero" href="'. monsterinsights_get_upgrade_link( 'admin-notices', 'edd-upgrade' ) .'">', ' &raquo;</a>' );
  363. echo '</p>';
  364. echo '</div><div class="monsterinsights-wooedd-upsell-right">';
  365. echo '<img class="monsterinsights-wooedd-upsell-image monsterinsights-wooedd-upsell-image-large" src="' . trailingslashit( MONSTERINSIGHTS_PLUGIN_URL ) . 'assets/images/upsell/woo-edd-upsell.png">';
  366. echo '</div>';
  367. echo '</div>';
  368. return;
  369. }
  370. }
  371. }
  372. add_action( 'admin_notices', 'monsterinsights_admin_setup_notices' );
  373. add_action( 'network_admin_notices', 'monsterinsights_admin_setup_notices' );
  374. // AM Notices
  375. function monsterinsights_am_notice_optout( $super_admin ) {
  376. if ( monsterinsights_get_option( 'hide_am_notices', false ) || monsterinsights_get_option( 'network_hide_am_notices', false ) ) {
  377. return false;
  378. }
  379. return $super_admin;
  380. }
  381. add_filter( "am_notifications_display", 'monsterinsights_am_notice_optout', 10, 1 );