Пример #1
0
 function cgmp_google_map_admin_add_script()
 {
     if (cgmp_should_load_admin_scripts()) {
         $whitelist = array('localhost', '127.0.0.1');
         wp_enqueue_script('cgmp-jquery-tools-tooltip', CGMP_PLUGIN_JS . '/jquery.tools.tooltip.min.js', array('jquery'), '1.2.5.a', true);
         $minified = ".min";
         if (in_array($_SERVER['HTTP_HOST'], $whitelist)) {
             $minified = "";
         }
         wp_enqueue_script('cgmp-jquery-tokeninput', CGMP_PLUGIN_JS . '/cgmp.tokeninput' . $minified . '.js', array('jquery'), CGMP_VERSION, true);
         wp_enqueue_script('comprehensive-google-map-plugin', CGMP_PLUGIN_JS . '/cgmp.admin' . $minified . '.js', array('jquery', 'media', 'wp-ajax-response'), CGMP_VERSION, true);
     }
     if (cgmp_should_find_posts_scripts()) {
         add_action('admin_footer', 'find_posts_div', 99);
     }
 }
 function cgmp_add_actions()
 {
     //http://scribu.net/wordpress/optimal-script-loading.html
     add_action('init', 'cgmp_google_map_register_scripts');
     add_action('init', 'cgmp_load_plugin_textdomain');
     add_action('admin_notices', 'cgmp_show_message');
     add_action('admin_init', 'cgmp_google_map_admin_add_style');
     add_action('admin_init', 'cgmp_google_map_admin_add_script');
     add_action('admin_footer', 'cgmp_google_map_init_global_admin_html_object');
     add_action('admin_menu', 'cgmp_google_map_plugin_menu');
     if (is_admin()) {
         $setting_plugin_menu_bar_menu = get_option(CGMP_DB_SETTINGS_PLUGIN_ADMIN_BAR_MENU);
         if (!isset($setting_plugin_menu_bar_menu) || isset($setting_plugin_menu_bar_menu) && $setting_plugin_menu_bar_menu != "false") {
             add_action('admin_bar_menu', 'cgmp_admin_bar_menu', 99999);
         }
     }
     add_action('widgets_init', create_function('', 'return register_widget("ComprehensiveGoogleMap_Widget");'));
     add_action('wp_head', 'cgmp_google_map_deregister_scripts', 200);
     add_action('wp_head', 'cgmp_generate_global_options');
     if (is_admin()) {
         global $wp_version;
         $setting_tiny_mce_button = get_option(CGMP_DB_SETTINGS_TINYMCE_BUTTON);
         if (!isset($setting_tiny_mce_button) || isset($setting_tiny_mce_button) && $setting_tiny_mce_button != "false") {
             if (cgmp_should_load_admin_scripts()) {
                 if (version_compare($wp_version, "3.9", "<")) {
                     add_action('init', 'cgmp_register_mce');
                 }
                 add_action('wp_ajax_cgmp_mce_ajax_action', 'cgmp_mce_ajax_action_callback');
             }
         }
     }
     add_action('wp_ajax_nopriv_cgmp_ajax_cache_map_action', 'cgmp_ajax_cache_map_action_callback');
     add_action('wp_ajax_cgmp_ajax_cache_map_action', 'cgmp_ajax_cache_map_action_callback');
     add_action('wp_ajax_cgmp_insert_shortcode_to_post_action', 'cgmp_insert_shortcode_to_post_action_callback');
     add_action('save_post', 'cgmp_save_post_hook');
     add_action('save_page', 'cgmp_save_page_hook');
     add_action('publish_post', 'cgmp_publish_post_hook');
     add_action('publish_page', 'cgmp_publish_page_hook');
     add_action('deleted_post', 'cgmp_deleted_post_hook');
     add_action('deleted_page', 'cgmp_deleted_page_hook');
     add_action('publish_to_draft', 'cgmp_publish_to_draft_hook');
 }