コード例 #1
0
 public static function add_admin_bar_nodes(&$wp_admin_bar = FALSE)
 {
     do_action("ws_plugin__qcache_before_add_admin_bar_nodes", get_defined_vars());
     /**/
     if (!is_multisite() && current_user_can("edit_plugins") || is_multisite() && (is_super_admin() || apply_filters("ws_plugin__qcache_ms_user_can_see_admin_header_controls", false))) {
         if (is_object($wp_admin_bar) && version_compare(get_bloginfo("version"), "3.3-RC1", ">=")) {
             $clear = '<form onsubmit="return false;"><input type="button" id="ws-plugin--qcache-ajax-clear" style="outline:none; min-width:115px; padding-left:22px; padding-right:5px; color:#000000; text-shadow:none; background-repeat:no-repeat; background-position:5px center; background-image:url(\'' . c_ws_plugin__qcache_utils_strings::esc_js_sq(esc_attr($GLOBALS["WS_PLUGIN__"]["qcache"]["c"]["dir_url"])) . '/images/ajax-clear.png\');" value="Clear Cache" title="Clear Cache Manually" onclick="jQuery (this).css (\'background-image\', \'url(\\\'' . c_ws_plugin__qcache_utils_strings::esc_js_sq(esc_attr($GLOBALS["WS_PLUGIN__"]["qcache"]["c"]["dir_url"]), 3) . '/images/ajax-loader.gif\\\')\'); jQuery.post (ajaxurl, {action: \'ws_plugin__qcache_ajax_clear\', ws_plugin__qcache_ajax_clear: \'' . c_ws_plugin__qcache_utils_strings::esc_js_sq(esc_attr(wp_create_nonce("ws-plugin--qcache-ajax-clear"))) . '\'}, function (response){ eval (response); });" /></form>';
             $wp_admin_bar->add_node(array("parent" => "top-secondary", "id" => "ws-plugin--qcache-ajax-clear-menu", "title" => $clear, "meta" => array("class" => "ws-plugin--qcache-ajax-clear-menu", "tabindex" => -1)));
         }
         do_action("ws_plugin__qcache_during_add_admin_bar_nodes", get_defined_vars());
     }
     do_action("ws_plugin__qcache_after_add_admin_bar_nodes", get_defined_vars());
     /**/
     return;
     /* Return for uniformity. */
 }
コード例 #2
0
 public static function ajax_clear()
 {
     global $current_site, $current_blog;
     /* Multisite details. */
     /**/
     do_action("ws_plugin__qcache_before_ajax_clear", get_defined_vars());
     /**/
     status_header(200);
     /* Send a 200 OK status header. */
     header("Content-Type: text/plain; charset=utf-8");
     /* Content-Type text/plain with UTF-8. */
     eval('while (@ob_end_clean ());');
     /* End/clean all output buffers that may or may not exist. */
     /**/
     if (($nonce = $_POST["ws_plugin__qcache_ajax_clear"]) && wp_verify_nonce($nonce, "ws-plugin--qcache-ajax-clear")) {
         if (is_multisite() && !is_main_site() && is_object($current_blog) && $current_blog->blog_id) {
             c_ws_plugin__qcache_purging_routines::purge_cache_dir($current_blog);
             /**/
             $status = 'Cleared ( this blog )';
             /* Indicate "this blog" to the Super Admin. */
             /**/
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').css ('background-image', 'url(\\'" . c_ws_plugin__qcache_utils_strings::esc_js_sq($GLOBALS["WS_PLUGIN__"]["qcache"]["c"]["dir_url"], 3) . "/images/ajax-clear.png\\')');";
             echo "setTimeout (function (){ jQuery ('input#ws-plugin--qcache-ajax-clear').val ('Clear Cache'); }, 2000);";
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').val ('" . c_ws_plugin__qcache_utils_strings::esc_js_sq($status) . "');";
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').each (function (){ this.blur(); });";
         } else {
             c_ws_plugin__qcache_purging_routines::purge_cache_dir();
             /**/
             $status = is_multisite() ? 'Cleared ( all blogs )' : '( Cleared )';
             /**/
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').css ('background-image', 'url(\\'" . c_ws_plugin__qcache_utils_strings::esc_js_sq($GLOBALS["WS_PLUGIN__"]["qcache"]["c"]["dir_url"], 3) . "/images/ajax-clear.png\\')');";
             echo "setTimeout (function (){ jQuery ('input#ws-plugin--qcache-ajax-clear').val ('Clear Cache'); }, 2000);";
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').val ('" . c_ws_plugin__qcache_utils_strings::esc_js_sq($status) . "');";
             echo "jQuery ('input#ws-plugin--qcache-ajax-clear').each (function (){ this.blur(); });";
         }
         /**/
         do_action("ws_plugin__qcache_during_ajax_clear", get_defined_vars());
     }
     /**/
     do_action("ws_plugin__qcache_after_ajax_clear", get_defined_vars());
     /**/
     exit;
     /* Clean exit. */
 }