Beispiel #1
0
 private function __construct()
 {
     if (is_admin()) {
         //Add the admin page and settings
         add_action('admin_menu', array($this, 'addmenu'));
         add_action('admin_init', array($this, 'registersettings'));
         //Set meta info
         if (function_exists('plugin_row_meta')) {
             //2.8+
             add_filter('plugin_row_meta', array($this, 'setmeta'), 10, 2);
         } elseif (function_exists('post_class')) {
             //2.7
             $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR . 'autoptimize.php');
             add_filter('plugin_action_links_' . $plugin, array($this, 'setmeta'));
         }
         //Clean cache?
         if (get_option('autoptimize_cache_clean')) {
             autoptimizeCache::clearall();
             update_option('autoptimize_cache_clean', 0);
         }
     }
     //Add the Autoptimize Toolbar to the Admin bar
     //(we loaded outside the verification of is_admin to also be displayed on the frontend toolbar)
     $toolbar = new autoptimizeToolbar();
 }
 public function delete_cache()
 {
     check_ajax_referer('ao_delcache_nonce', 'nonce');
     if (current_user_can('manage_options')) {
         // We call the function for cleaning the Autoptimize cache
         autoptimizeCache::clearall();
     }
     wp_die();
     // NOTE: Remember that any return values of this function must be in JSON format
 }
 private function __construct()
 {
     if (is_admin()) {
         //Add the admin page and settings
         add_action('admin_menu', array($this, 'addmenu'));
         add_action('admin_init', array($this, 'registersettings'));
         //Set meta info
         if (function_exists('plugin_row_meta')) {
             //2.8+
             add_filter('plugin_row_meta', array($this, 'setmeta'), 10, 2);
         } elseif (function_exists('post_class')) {
             //2.7
             $plugin = plugin_basename(AUTOPTIMIZE_PLUGIN_DIR . '/autoptimize.php');
             add_filter('plugin_action_links_' . $plugin, array($this, 'setmeta'));
         }
         //Clean cache?
         if (get_option('autoptimize_cache_clean')) {
             autoptimizeCache::clearall();
             update_option('autoptimize_cache_clean', 0);
         }
     }
 }
Beispiel #4
0
function autoptimize_uninstall()
{
    autoptimizeCache::clearall();
    $delete_options = array("autoptimize_cache_clean", "autoptimize_cache_nogzip", "autoptimize_css", "autoptimize_css_datauris", "autoptimize_css_justhead", "autoptimize_css_defer", "autoptimize_css_defer_inline", "autoptimize_css_inline", "autoptimize_css_exclude", "autoptimize_html", "autoptimize_html_keepcomments", "autoptimize_js", "autoptimize_js_exclude", "autoptimize_js_forcehead", "autoptimize_js_justhead", "autoptimize_js_trycatch", "autoptimize_version", "autoptimize_show_adv", "autoptimize_cdn_url", "autoptimize_cachesize_notice", "autoptimize_css_include_inline", "autoptimize_js_include_inline", "autoptimize_css_nogooglefont");
    if (!is_multisite()) {
        foreach ($delete_options as $del_opt) {
            delete_option($del_opt);
        }
    } else {
        global $wpdb;
        $blog_ids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}");
        $original_blog_id = get_current_blog_id();
        foreach ($blog_ids as $blog_id) {
            switch_to_blog($blog_id);
            foreach ($delete_options as $del_opt) {
                delete_option($del_opt);
            }
        }
        switch_to_blog($original_blog_id);
    }
    if (wp_get_schedule('ao_cachechecker')) {
        wp_clear_scheduled_hook('ao_cachechecker');
    }
}
define('AUTOPTIMIZE_CACHE_DIR', WP_CONTENT_DIR . '/cache/autoptimize/');
define('AUTOPTIMIZE_CACHE_URL', content_url() . '/cache/autoptimize/');
define('AUTOPTIMIZE_CACHE_DELAY', true);
define('WP_ROOT_URL', str_replace('/wp-content', '', content_url()));
define('WP_ROOT_DIR', str_replace('/wp-content', '', WP_CONTENT_DIR));
// Initialize the cache at least once
$conf = autoptimizeConfig::instance();
/* Check if we're updating, in which case we need to flush the cache
to avoid old versions of aggregated files lingering around */
$autoptimize_version = "1.6.6";
$autoptimize_db_version = get_option('autoptimize_version', 'none');
if ($autoptimize_db_version !== $autoptimize_version) {
    if ($autoptimize_db_version === "none") {
        add_action('admin_notices', 'config_autoptimize_notice');
    }
    autoptimizeCache::clearall();
    update_option('autoptimize_version', $autoptimize_version);
    $autoptimize_db_version = $autoptimize_version;
}
// Do we gzip when caching?
define('AUTOPTIMIZE_CACHE_NOGZIP', (bool) $conf->get('autoptimize_cache_nogzip'));
// Load translations
$plugin_dir = basename(dirname(__FILE__));
load_plugin_textdomain('autoptimize', 'wp-content/plugins/' . $plugin_dir . '/localization', $plugin_dir . '/localization');
function config_autoptimize_notice()
{
    echo '<div class="updated"><p>';
    _e('Thank you for installing and activating Autoptimize. Please configure it under "Settings" -> "Autoptimize" to start improving your site\'s performance.', 'autoptimize');
    echo '</p></div>';
}
// Set up the buffering
 /**
  * Clear cache
  */
 public function clear_pagecache()
 {
     if (class_exists('autoptimizeCache')) {
         // clean the Autoptimize cache
         autoptimizeCache::clearall();
     }
 }