Example #1
0
 public static function get_instance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
 /**
  * Flush proxy caches.
  *
  * ## OPTIONS
  *
  * [--cache=<url>]
  * : The name of the person to greet.
  *
  * [--format=<format>]
  * : Accepted values: csv, json. Default: csv
  *
  * ## EXAMPLES
  *
  *     wp nginx list --format=json
  *     wp nginx flush
  *     wp nginx flush --cache=http://example.com/archives/10
  *
  * @synopsis [--cache=<url>]
  * @subcommand flush
  */
 function flush($args, $assoc_args)
 {
     global $nginxchampuru;
     if (isset($assoc_args['cache']) && $assoc_args['cache']) {
         $id = url_to_postid($assoc_args['cache']);
         if ($id) {
             NginxChampuru_FlushCache::flush_by_post($id);
             WP_CLI::success("Proxy caches are flushed on " . $assoc_args['cache']);
             exit;
         } else {
             WP_CLI::error('Cache url is not found.');
             exit;
         }
     } else {
         $nginxchampuru->transientExec("flush_cache", 'all', 0);
         WP_CLI::success("All proxy caches are flushed.");
         exit;
     }
 }
Version: 3.1.1
Author URI: http://ninjax.cc/
Domain Path: /languages
Text Domain: nginxchampuru
*/
if (defined('WP_CLI') && WP_CLI) {
    require_once dirname(__FILE__) . "/includes/wp-cli.php";
}
$nginxchampuru = NginxChampuru::get_instance();
$nginxchampuru->add_hook();
register_activation_hook(__FILE__, array($nginxchampuru, 'activation'));
require_once dirname(__FILE__) . "/includes/caching.class.php";
$nginxchampuru_cache = NginxChampuru_Caching::get_instance();
$nginxchampuru_cache->add_hook();
require_once dirname(__FILE__) . "/includes/flush-cache.class.php";
$nginxchampuru_flushcache = NginxChampuru_FlushCache::get_instance();
$nginxchampuru_flushcache->add_hook();
require_once dirname(__FILE__) . "/includes/admin.class.php";
$nginxchampuru_admin = NginxChampuru_Admin::get_instance();
$nginxchampuru_admin->add_hook();
define("NGINX_CACHE_CONTROLER_URL", plugins_url('', __FILE__));
define("NGINX_CACHE_CONTROLER_BASE_NAME", plugin_basename(__FILE__));
class NginxChampuru
{
    private $version;
    private $db_version;
    private $table;
    private $expire = 86400;
    private $cache_dir = "/var/cache/nginx";
    private $cache_levels = "1:2";
    private $transient_timeout = 60;