Exemplo n.º 1
0
 /**
  * If FeedBurner is enabled flush the registered FB feeds
  */
 function flush_feedburner($post_id)
 {
     if (!w3_is_flushable_post($post_id, 'pgcache', $this->_config)) {
         return;
     }
     $fb_urls = w3tc_get_extension_config('feedburner', 'urls');
     if ($fb_urls) {
         $fb_urls = explode("\n", $fb_urls);
     }
     $fb_urls[] = home_url();
     foreach ($fb_urls as $url) {
         wp_remote_get('http://feedburner.google.com/fb/a/pingSubmit?bloglink=' . urlencode($url));
     }
 }
Exemplo n.º 2
0
_e('find it here', 'w3-total-cache');
?>
</a>)
        </td>
    </tr>
    <tr>
        <?php 
list($name, $id) = w3tc_get_name_and_id('cloudflare', 'zone');
?>
        <th><?php 
w3_e_config_label('cloudflare.zone', 'general');
?>
</th>
        <td>
            <?php 
w3_ui_element('textbox', 'cloudflare.zone', $name, w3tc_get_extension_config('cloudflare', 'zone'), w3_extension_is_sealed('cloudflare'));
?>
        </td>
    </tr>
    <tr>
        <th><?php 
_e('Security level:', 'w3-total-cache');
?>
</th>
        <td>
            <input type="hidden" name="cloudflare_sec_lvl_old" value="<?php 
echo $cloudflare_seclvl;
?>
" />
            <select name="cloudflare_sec_lvl_new"
                    class="w3tc-ignore-change"
Exemplo n.º 3
0
 /**
  * @param $cf_values
  * @return bool
  */
 public function save_settings($cf_values)
 {
     @set_time_limit(w3tc_get_extension_config('cloudflare', 'timelimit.api_request', null, 180));
     ksort($cf_values);
     $cf_values = $this->_cleanup_settings($cf_values);
     foreach ($cf_values as $key => $settings) {
         if ($settings['old'] != $settings['new']) {
             $response = $this->api_request($key, $settings['new']);
             if (!$response || $response && $response->result != 'success') {
                 return false;
             }
         }
     }
     delete_transient('w3tc_cloudflare_settings');
     return true;
 }
Exemplo n.º 4
0
    /**
     *
     * @param $setting
     * @param $args
     */
    function print_setting($setting, $args)
    {
        w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/extensions.php');
        list($name, $id) = w3tc_get_name_and_id('genesis.theme', $setting);
        if ($args['type'] != 'custom') {
            w3_ui_element($args['type'], $setting, $name, w3tc_get_extension_config('genesis.theme', $setting), w3_extension_is_sealed('genesis.theme'));
        } else {
            if ($setting == 'reject_roles') {
                $saved_roles = w3tc_get_extension_config('genesis.theme', $setting);
                if (!is_array($saved_roles)) {
                    $saved_roles = array();
                }
                ?>
                <div id="<?php 
                echo esc_attr($id);
                ?>
">
                <input type="hidden" name="<?php 
                echo esc_attr($name);
                ?>
" value="" />
                <?php 
                foreach (get_editable_roles() as $role_name => $role_data) {
                    ?>
                    <input <?php 
                    disabled(w3_extension_is_sealed('genesis.theme'));
                    ?>
 type="checkbox" name="<?php 
                    echo esc_attr($name);
                    ?>
[]" value="<?php 
                    echo $role_name;
                    ?>
" <?php 
                    checked(in_array($role_name, $saved_roles));
                    ?>
 id="role_<?php 
                    echo $role_name;
                    ?>
" />
                    <label for="role_<?php 
                    echo $role_name;
                    ?>
"><?php 
                    echo $role_data['name'];
                    ?>
</label>
                <?php 
                }
                ?>
                </div>
            <?php 
            } else {
                $saved_hooks = w3tc_get_extension_config('genesis.theme', $setting);
                if (!is_array($saved_hooks)) {
                    $saved_hooks = array();
                }
                $hooks = array('genesis_header' => 'Header', 'genesis_footer' => 'Footer', 'genesis_sidebar' => 'Sidebar', 'genesis_loop' => 'The Loop', 'wp_head' => 'wp_head', 'wp_footer' => 'wp_footer', 'genesis_comments' => 'Comments', 'genesis_pings' => 'Pings', 'genesis_do_nav' => 'Primary navigation', 'genesis_do_subnav' => 'Secondary navigation');
                ?>
                <div id="<?php 
                echo esc_attr($id);
                ?>
">
                    <input <?php 
                disabled(w3_extension_is_sealed('genesis.theme'));
                ?>
 type="hidden" name="<?php 
                echo esc_attr($name);
                ?>
" value="" />
                <?php 
                foreach ($hooks as $hook => $hook_label) {
                    ?>
                    <input <?php 
                    disabled(w3_extension_is_sealed('genesis.theme'));
                    ?>
 type="checkbox" name="<?php 
                    echo esc_attr($name);
                    ?>
[]" value="<?php 
                    echo $hook;
                    ?>
" <?php 
                    checked(in_array($hook, $saved_hooks));
                    ?>
 id="role_<?php 
                    echo $hook;
                    ?>
" />
                    <label for="role_<?php 
                    echo $hook;
                    ?>
"><?php 
                    echo $hook_label;
                    ?>
</label><br />
                <?php 
                }
                ?>
                </div>
            <?php 
            }
        }
    }
Exemplo n.º 5
0
 /**
  * @return bool
  */
 private function cannot_cache_current_hook()
 {
     if (is_user_logged_in() && w3tc_get_extension_config('genesis.theme', 'reject_logged_roles')) {
         $roles = w3tc_get_extension_config('genesis.theme', 'reject_roles');
         if ($roles) {
             $hooks = w3tc_get_extension_config('genesis.theme', 'reject_logged_roles_on_actions');
             $hook = current_filter();
             foreach ($roles as $role) {
                 if ($hooks && current_user_can($role) && in_array($hook, $hooks)) {
                     return true;
                 }
             }
         }
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * @param W3_Config $config
  * @param $old
  * @param $config_admin
  * @return \W3_Config
  */
 public function save_settings($config, $old, $config_admin)
 {
     w3_require_once(W3TC_CORE_EXTENSION_DIR . '/CloudFlare/CloudFlareAPI.php');
     $this->cloudflareAPI = new CloudFlareAPI();
     $this->cloudflareAPI->reset_settings_cache();
     if ((bool) w3tc_get_extension_config('cloudflare', 'enabled') && $this->cloudflareAPI->minify_enabled() && $config->get_boolean('minify.enabled')) {
         $config->set('minify.enabled', false);
     }
     /**
      * Handle CloudFlare changes
      */
     if (w3_get_blog_id() == 0 || w3_get_blog_id() != 0 && !w3_extension_is_sealed('cloudflare')) {
         /**
          * @var $this->cloudflareAPI W3_CloudFlare
          */
         $cf_values = W3_Request::get_as_array('cloudflare_');
         $this->cloudflareAPI->save_settings($cf_values);
     }
     return $config;
 }
Exemplo n.º 7
0
 /**
  *
  * @param $setting
  * @param $args
  */
 function print_setting($setting, $args)
 {
     w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/extensions.php');
     list($name, $id) = w3tc_get_name_and_id('feedburner', $setting);
     w3_ui_element($args['type'], $setting, $name, w3tc_get_extension_config('feedburner', $setting), w3_extension_is_sealed('feedburner'));
 }
Exemplo n.º 8
0
 /**
  * Handle importing changed configuration from older versions
  */
 private function _backwards_import()
 {
     if ($this->_config->get_string('cdn.engine') == 'netdna' && $this->_config->get_string('cdn.netdna.authorization_key') == '') {
         $alias = $this->_config->get_string('cdn.netdna.alias');
         $consumerkey = $this->_config->get_string('cdn.netdna.consumerkey');
         $consumersecret = $this->_config->get_string('cdn.netdna.consumersecret');
         if ($alias && $consumerkey && $consumersecret) {
             $this->_config->set('cdn.maxcdn.authorization_key', "{$alias}+{$consumerkey}+{$consumersecret}");
             $this->_config->set('cdn.netdna.authorization_key', "{$alias}+{$consumerkey}+{$consumersecret}");
             $this->_config->set('cdn.engine', 'maxcdn');
             $this->_config->set('cdn.maxcdn.zone_id', $this->_config->get_integer('cdn.netdna.zone_id', 0));
             $this->_config->set('cdn.maxcdn.domain', $this->_config->get_array('cdn.netdna.domain'));
             $this->_config->set('cdn.maxcdn.ssl', $this->_config->get_string('cdn.netdna.ssl'));
             try {
                 $this->_config->save();
                 $this->_config->refresh_cache();
             } catch (Exception $ex) {
             }
         }
     }
     if (w3tc_get_extension_config('genesis.theme', 'fragment_reject_logged_roles') != null) {
         $old_extensions = $this->_config->get_array('extensions.settings');
         $genesis = $old_extensions['genesis.theme'];
         $genesis['reject_logged_roles'] = $genesis['fragment_reject_logged_roles'];
         unset($genesis['fragment_reject_logged_roles']);
         $genesis['reject_logged_roles_on_actions'] = $genesis['fragment_reject_logged_roles_on_actions'];
         unset($genesis['fragment_reject_logged_roles_on_actions']);
         $genesis['reject_roles'] = $genesis['fragment_reject_roles'];
         unset($genesis['fragment_reject_roles']);
         $old_extensions['genesis.theme'] = $genesis;
         $this->_config->set("extensions.settings", $old_extensions);
         try {
             $this->_config->save();
             $this->_config->refresh_cache();
         } catch (Exception $ex) {
         }
     }
     if ($this->_config->get_boolean('cloudflare.enabled') || $this->_config->get_string('cloudflare.email')) {
         $extensions = $this->_config->get_array('extensions.settings');
         $cloudflare = array();
         $cloudflare['enabled'] = $this->_config->get_string('cloudflare.enabled');
         $cloudflare['email'] = $this->_config->get_string('cloudflare.email');
         $cloudflare['key'] = $this->_config->get_string('cloudflare.key');
         $cloudflare['zone'] = $this->_config->get_string('cloudflare.zone');
         $extensions['cloudflare'] = $cloudflare;
         $this->_config->set("extensions.settings", $extensions);
         try {
             $this->_config->save();
             $this->_config->refresh_cache();
         } catch (Exception $ex) {
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Checks if current page is excluded from caching
  *
  * @param $group
  * @return bool
  */
 private function _exclude_page($group)
 {
     $reject_uri = w3tc_get_extension_config('genesis.theme', "{$group}_excluded");
     if ($reject_uri) {
         $reject_uri = explode("\n", $reject_uri);
     }
     if (is_null($reject_uri) || !is_array($reject_uri) || empty($reject_uri)) {
         return false;
     }
     $auto_reject_uri = array('wp-login', 'wp-register');
     foreach ($auto_reject_uri as $uri) {
         if (strstr($this->_request_uri, $uri) !== false) {
             return true;
         }
     }
     $reject_uri = array_map('w3_parse_path', $reject_uri);
     foreach ($reject_uri as $expr) {
         $expr = trim($expr);
         if ($expr != '' && preg_match('~' . $expr . '~i', $this->_request_uri)) {
             return true;
         }
     }
     return false;
 }