monsterinsights_admin_scripts

Loads scripts for all MonsterInsights-based Administration Screens.

Description

(null) monsterinsights_admin_scripts(); 

Returns (null)

Return early if not on the proper screen.


Usage

  1. if ( !function_exists( 'monsterinsights_admin_scripts' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/common.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = monsterinsights_admin_scripts(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/admin/common.php  
  1. function monsterinsights_admin_scripts() { 
  2.  
  3. // Get current screen. 
  4. $screen = get_current_screen(); 
  5.  
  6. // Bail if we're not on a MonsterInsights screen. 
  7. if ( empty( $screen->id ) || strpos( $screen->id, 'monsterinsights' ) === false ) { 
  8. return; 
  9.  
  10. // Get the base class object. 
  11. $base = MonsterInsights(); 
  12.  
  13. // Load necessary admin scripts 
  14. // Clipboard.js 
  15. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-clipboard-script', plugins_url( 'assets/js/clipboard/clipboard.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() ); 
  16. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-clipboard-script' ); 
  17.  
  18. // List.js 
  19. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-list-script', plugins_url( 'assets/js/list/list.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() ); 
  20. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-list-script' ); 
  21.  
  22. // Charts.js 
  23. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-chartjs-script', plugins_url( 'assets/js/chartjs/Chart.bundle.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() ); 
  24. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-chartjs-script' ); 
  25.  
  26. // Maps 
  27. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-jvectormap-script', plugins_url( 'assets/js/jvectormap/jquery-jvectormap-2.0.3.min.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() ); 
  28. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-jvectormap-script' ); 
  29. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-jvectormap-world-script', plugins_url( 'assets/js/jvectormap/jquery-jvectormap-world-mill.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery', MONSTERINSIGHTS_PLUGIN_SLUG . '-jvectormap-script' ), monsterinsights_get_asset_version() ); 
  30. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-jvectormap-world-script' ); 
  31.  
  32. // Select300 
  33. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-select300-script', plugins_url( 'assets/js/select300/select300.full.js', MONSTERINSIGHTS_PLUGIN_FILE ), array( 'jquery' ), monsterinsights_get_asset_version() ); 
  34. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-select300-script' ); 
  35.  
  36. // Our Admin JS 
  37. $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; 
  38. if ( ! file_exists( MONSTERINSIGHTS_PLUGIN_DIR . 'assets/js/admin.min.js' ) ) { 
  39. $suffix = ''; 
  40.  
  41. $deps = array(  
  42. 'jquery',  
  43. MONSTERINSIGHTS_PLUGIN_SLUG . '-select300-script',  
  44. MONSTERINSIGHTS_PLUGIN_SLUG . '-jvectormap-script',  
  45. MONSTERINSIGHTS_PLUGIN_SLUG . '-chartjs-script',  
  46. MONSTERINSIGHTS_PLUGIN_SLUG . '-list-script' 
  47. ); 
  48.  
  49. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-admin-script', plugins_url( 'assets/js/admin' . $suffix . '.js', MONSTERINSIGHTS_PLUGIN_FILE ), $deps, monsterinsights_get_asset_version() ); 
  50. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-admin-script' ); 
  51. wp_localize_script( 
  52. MONSTERINSIGHTS_PLUGIN_SLUG . '-admin-script',  
  53. 'monsterinsights_admin',  
  54. array( 
  55. 'ajax' => admin_url( 'admin-ajax.php' ),  
  56. 'dismiss_notice_nonce' => wp_create_nonce( 'monsterinsights-dismiss-notice' ),  
  57. 'loadingtext' => esc_html__( 'Loading...', 'google-analytics-for-wordpress' ),  
  58. 'settings_changed_confirm' => esc_html__( 'Warning: You have unsaved setting changes. If you leave the settings page without saving your changes will be lost. Did you still want to leave the page?', 'google-analytics-for-wordpress' ),  
  59. 'activate_nonce' => wp_create_nonce( 'monsterinsights-activate' ),  
  60. 'active' => esc_html__( 'Status: Active', 'google-analytics-for-wordpress' ),  
  61. 'activate' => esc_html__( 'Activate', 'google-analytics-for-wordpress' ),  
  62. 'networkactive' => esc_html__( 'Status: Network Activated', 'google-analytics-for-wordpress' ),  
  63. 'networkactivate' => esc_html__( 'Network activate', 'google-analytics-for-wordpress' ),  
  64. 'get_addons_nonce' => wp_create_nonce( 'monsterinsights-get-addons' ),  
  65. 'activating' => esc_html__( 'Activating...', 'google-analytics-for-wordpress' ),  
  66. 'deactivate' => esc_html__( 'Deactivate', 'google-analytics-for-wordpress' ),  
  67. 'networkdeactivate'=> esc_html__( 'Network deactivate', 'google-analytics-for-wordpress' ),  
  68. 'deactivate_nonce' => wp_create_nonce( 'monsterinsights-deactivate' ),  
  69. 'deactivating' => esc_html__( 'Deactivating...', 'google-analytics-for-wordpress' ),  
  70. 'inactive' => esc_html__( 'Status: Inactive', 'google-analytics-for-wordpress' ),  
  71. 'networkinactive' => esc_html__( 'Status: Network inactive', 'google-analytics-for-wordpress' ),  
  72. 'install' => esc_html__( 'Install', 'google-analytics-for-wordpress' ),  
  73. 'install_nonce' => wp_create_nonce( 'monsterinsights-install' ),  
  74. 'installing' => esc_html__( 'Installing...', 'google-analytics-for-wordpress' ),  
  75. 'proceed' => esc_html__( 'Proceed', 'google-analytics-for-wordpress' ),  
  76. 'isnetwork' => is_network_admin(),  
  77. 'copied' => esc_html__( 'Copied!', 'google-analytics-for-wordpress' ),  
  78. 'copytoclip' => esc_html__( 'Copy to Clipboard', 'google-analytics-for-wordpress' ),  
  79. 'failed' => esc_html__( 'Failed!', 'google-analytics-for-wordpress' ),  
  80. 'admin_nonce' => wp_create_nonce( 'mi-admin-nonce' ),  
  81. 'shorten' => esc_html__( 'Shorten URL' , 'google-analytics-for-wordpress'),  
  82. 'shortened' => esc_html__( 'Shortened!' , 'google-analytics-for-wordpress'),  
  83. 'working' => esc_html__( 'Working...' , 'google-analytics-for-wordpress'),  
  84. 'importtext' => esc_html__( 'Import' , 'google-analytics-for-wordpress'),  
  85. 'imported' => esc_html__( 'Imported!' , 'google-analytics-for-wordpress'),  
  86. ); 
  87.  
  88. // See if there's an admin.js file for this plugin version 
  89. if ( file_exists( MONSTERINSIGHTS_PLUGIN_DIR . 'pro/assets/js/admin.js' ) ) { 
  90. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-pro-admin-script', plugins_url( 'pro/assets/js/admin.js', MONSTERINSIGHTS_PLUGIN_FILE ), $deps, monsterinsights_get_asset_version() ); 
  91. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-pro-admin-script' ); 
  92. wp_localize_script( 
  93. MONSTERINSIGHTS_PLUGIN_SLUG . '-pro-admin-script',  
  94. 'monsterinsights_admin',  
  95. array( 
  96. 'ajax' => admin_url( 'admin-ajax.php' ) 
  97. ); 
  98. } else if ( file_exists( MONSTERINSIGHTS_PLUGIN_DIR . 'lite/assets/js/admin.js' ) ) { 
  99. wp_register_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-lite-admin-script', plugins_url( 'lite/assets/js/admin.js', MONSTERINSIGHTS_PLUGIN_FILE ), $deps, monsterinsights_get_asset_version() ); 
  100. wp_enqueue_script( MONSTERINSIGHTS_PLUGIN_SLUG . '-lite-admin-script' ); 
  101. wp_localize_script( 
  102. MONSTERINSIGHTS_PLUGIN_SLUG . '-lite-admin-script',  
  103. 'monsterinsights_admin',  
  104. array( 
  105. 'ajax' => admin_url( 'admin-ajax.php' ) 
  106. ); 
  107. }  
  108.  
  109. // ublock notice