コード例 #1
0
 /**
  * Minify tab
  *
  * @return void
  */
 function view()
 {
     $minify_enabled = $this->_config->get_boolean('minify.enabled');
     $config_state = Dispatcher::config_state();
     $minify_rewrite_disabled = !Util_Rule::can_check_rules() || $this->_config->is_sealed('minify.rewrite');
     $themes = Util_Theme::get_themes_by_key();
     $templates = array();
     $current_theme = Util_Theme::get_current_theme_name();
     $current_theme_key = '';
     foreach ($themes as $theme_key => $theme_name) {
         if ($theme_name == $current_theme) {
             $current_theme_key = $theme_key;
         }
         $templates[$theme_key] = Util_Theme::get_theme_templates($theme_name);
     }
     $css_imports_values = array('' => 'None', 'bubble' => 'Bubble', 'process' => 'Process');
     $auto = $this->_config->get_boolean('minify.auto');
     $js_theme = Util_Request::get_string('js_theme', $current_theme_key);
     $js_groups = $this->_config->get_array('minify.js.groups');
     $css_theme = Util_Request::get_string('css_theme', $current_theme_key);
     $css_groups = $this->_config->get_array('minify.css.groups');
     $js_engine = $this->_config->get_string('minify.js.engine');
     $css_engine = $this->_config->get_string('minify.css.engine');
     $html_engine = $this->_config->get_string('minify.html.engine');
     $css_imports = $this->_config->get_string('minify.css.imports');
     // Required for Update Media Query String button
     $browsercache_enabled = $this->_config->get_boolean('browsercache.enabled');
     $browsercache_update_media_qs = $this->_config->get_boolean('browsercache.cssjs.replace');
     include W3TC_INC_DIR . '/options/minify.php';
 }
コード例 #2
0
 /**
  *
  *
  * @param Config  $config
  * @return string
  */
 function notifications($config)
 {
     $config_state = Dispatcher::config_state();
     if (!$config_state->get_boolean('newrelic.hide_note_pageload_slow')) {
         $pl = get_option('w3tc_nr_frontend_response_time');
         if ($pl !== false && $pl > 0.3) {
             $nr_recommends = array();
             if (!$config->get_boolean('pgcache.enabled')) {
                 $nr_recommends[] = __('Page Cache', 'w3-total-cache');
             }
             if (!$config->get_boolean('minify.enabled')) {
                 $nr_recommends[] = __('Minify', 'w3-total-cache');
             }
             if (!$config->get_boolean('cdn.enabled')) {
                 $nr_recommends[] = __('CDN', 'w3-total-cache');
             }
             if (!$config->get_boolean('browsercache.enabled')) {
                 $nr_recommends[] = __('Browser Cache and use compression', 'w3-total-cache');
             }
             if ($nr_recommends) {
                 $message = sprintf(__('Application monitoring has detected that your page load time is higher than 300ms. It is recommended that you enable the following features: %s %s', 'w3-total-cache'), implode(', ', $nr_recommends), Util_Ui::button_link('Hide this message', Util_Ui::url(array('w3tc_default_config_state' => 'y', 'key' => 'newrelic.hide_note_pageload_slow', 'value' => 'true'))));
                 return array('newrelic_recommends' => $message);
             }
         }
     }
     return array();
 }
コード例 #3
0
 /**
  * Reset config action
  *
  * @return void
  */
 function w3tc_config_reset()
 {
     $config = new Config();
     $config->set_defaults();
     Util_Admin::config_save($this->_config, $config);
     $config_state = Dispatcher::config_state();
     $config_state->reset();
     $config_state->save();
     $config_state = Dispatcher::config_state_master();
     $config_state->reset();
     $config_state->save();
     Util_Admin::redirect(array('w3tc_note' => 'config_reset'), true);
 }
コード例 #4
0
 private static function show_notice()
 {
     $config = Dispatcher::config();
     if ($config->is_extension_active('wpml')) {
         return false;
     }
     if (!self::base_plugin_active()) {
         return false;
     }
     $state = Dispatcher::config_state();
     if ($state->get_boolean('wpml.hide_note_suggest_activation')) {
         return false;
     }
     return true;
 }
 private static function show_notice()
 {
     $config = Dispatcher::config();
     if ($config->is_extension_active('wordpress-seo')) {
         return false;
     }
     if (!self::criteria_match()) {
         return false;
     }
     $state = Dispatcher::config_state();
     if ($state->get_boolean('wordpress_seo.hide_note_suggest_activation')) {
         return false;
     }
     return true;
 }
 private static function show_notice()
 {
     $config = Dispatcher::config();
     if ($config->is_extension_active('genesis.theme')) {
         return false;
     }
     if (!self::is_theme_found()) {
         return false;
     }
     $state = Dispatcher::config_state();
     if ($state->get_boolean('genesis.theme.hide_note_suggest_activation')) {
         return false;
     }
     return true;
 }
コード例 #7
0
 function w3tc_cdn_google_drive_auth_set()
 {
     // thanks wp core for wp_magic_quotes hell
     $client_id = stripslashes($_POST['client_id']);
     $access_token = stripslashes($_POST['access_token']);
     $refresh_token = stripslashes($_POST['refresh_token']);
     $client = new \W3TCG_Google_Client();
     $client->setClientId($client_id);
     $client->setAccessToken($access_token);
     //
     // get folder details
     //
     $service = new \W3TCG_Google_Service_Drive($client);
     if (empty($_POST['folder'])) {
         $file = new \W3TCG_Google_Service_Drive_DriveFile(array('title' => $_POST['folder_new'], 'mimeType' => 'application/vnd.google-apps.folder'));
         $created_file = $service->files->insert($file);
         $used_folder_id = $created_file->id;
     } else {
         $used_folder_id = $_POST['folder'];
     }
     $permission = new \W3TCG_Google_Service_Drive_Permission();
     $permission->setValue('');
     $permission->setType('anyone');
     $permission->setRole('reader');
     $service->permissions->insert($used_folder_id, $permission);
     $used_folder = $service->files->get($used_folder_id);
     //
     // save new configuration
     //
     delete_transient('w3tc_cdn_google_drive_folder_ids');
     $this->_config->set('cdn.google_drive.client_id', $client_id);
     $this->_config->set('cdn.google_drive.refresh_token', $refresh_token);
     $this->_config->set('cdn.google_drive.folder.id', $used_folder->id);
     $this->_config->set('cdn.google_drive.folder.title', $used_folder->title);
     $this->_config->set('cdn.google_drive.folder.url', $used_folder->webViewLink);
     $this->_config->save();
     $cs = Dispatcher::config_state();
     $cs->set('cdn.google_drive.access_token', $access_token);
     $cs->save();
     wp_redirect('admin.php?page=w3tc_cdn', false);
 }
コード例 #8
0
 public function w3tc_errors($errors)
 {
     $state = Dispatcher::config_state();
     $c = Dispatcher::config();
     /**
      * Check permalinks
      */
     if (!$state->get_boolean('common.hide_note_no_permalink_rules') && ($c->get_boolean('pgcache.enabled') && $c->get_string('pgcache.engine') == 'file_generic' || $c->get_boolean('browsercache.enabled') && $c->get_boolean('browsercache.no404wp')) && !Util_Rule::is_permalink_rules()) {
         $errors['generic_no_permalinks'] = sprintf(__('The required directives for fancy permalinks could not be detected, please confirm they are available: <a href="http://codex.wordpress.org/Using_Permalinks#Creating_and_editing_.28.htaccess.29">Creating and editing</a> %s', 'w3-total-cache'), Util_Ui::button_hide_note2(array('w3tc_default_config_state_master' => 'y', 'key' => 'common.hide_note_no_permalink_rules', 'value' => 'true')));
     }
     /**
      * Check memcached
      */
     if (isset($errors['memcache_not_responding.details'])) {
         $memcache_error = __('The following memcached servers are not responding or not running:</p><ul>', 'w3-total-cache');
         foreach ($errors['memcache_not_responding.details'] as $memcaches_error) {
             $memcache_error .= '<li>' . $memcaches_error . '</li>';
         }
         $memcache_error .= __('</ul><p>This message will automatically disappear once the issue is resolved.', 'w3-total-cache');
         $errors['memcache_not_responding'] = $memcache_error;
         unset($errors['memcache_not_responding.details']);
     }
     return $errors;
 }
コード例 #9
0
 function w3tc_cdn_netdna_authorize()
 {
     try {
         $state = Dispatcher::config_state();
         if ($state->get_integer('track.maxcdn_authorize', 0) == 0) {
             $state->set('track.maxcdn_authorize', time());
             $state->save();
         }
     } catch (\Exception $ex) {
     }
     Util_Environment::redirect(NETDNA_AUTHORIZE_URL);
 }
コード例 #10
0
?>
</label>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<label><input id="cdn_import_library_redirect_cdn" type="checkbox" /> <?php 
_e('Create a list of redirects to <acronym title="Content Delivery Network">CDN</acronym> (hostname specified in hostname field #1.)', 'w3-total-cache');
?>
</label>
		</td>
	</tr>
        <tr>
                <td colspan="2">
                    <?php 
$config_state = Dispatcher::config_state();
?>
                    <label><input id="cdn_import_external" type="checkbox" name="cdn.import.external" <?php 
checked($config_state->get_boolean('cdn.import.external'), true);
?>
/> <?php 
Util_Ui::e_config_label('cdn.import.external');
?>
</label>
                </td>
        </tr>
</table>

<p>
	<input id="cdn_import_library_start" class="button-primary" type="button" value="<?php 
_e('Start', 'w3-total-cache');
コード例 #11
0
 function w3tc_errors($errors)
 {
     $c = Dispatcher::config();
     $state = Dispatcher::config_state();
     $cdn_engine = $c->get_string('cdn.engine');
     if (Cdn_Util::is_engine_push($cdn_engine)) {
         /**
          * Show notification if upload queue is not empty
          */
         try {
             if (!($error = get_transient('w3tc_cdn_error')) && !$this->_is_queue_empty()) {
                 $errors['cdn_unsuccessful_queue'] = sprintf(__('The %s has unresolved errors. Empty the queue to restore normal operation.', 'w3-total-cache'), Util_Ui::button_popup(__('unsuccessful transfer queue', 'w3-total-cache'), 'cdn_queue'));
             } elseif ($error) {
                 $errors['cdn_generic'] = $error;
             }
         } catch (\Exception $ex) {
             $errors[] = $ex->getMessage();
             set_transient('w3tc_cdn_error', $ex->getMessage(), 30);
         }
         /**
          * Check upload settings
          */
         $upload_info = Util_Http::upload_info();
         if (!$upload_info) {
             $upload_path = get_option('upload_path');
             $upload_path = trim($upload_path);
             if (empty($upload_path)) {
                 $upload_path = WP_CONTENT_DIR . '/uploads';
                 $errors['cdn_uploads_folder_empty'] = sprintf(__('The uploads directory is not available. Default WordPress directories will be created: <strong>%s</strong>.', 'w3-total-cache'), $upload_path);
             }
             if (!Util_Environment::is_wpmu()) {
                 $errors['cdn_uploads_folder_not_found'] = sprintf(__('The uploads path found in the database (%s) is inconsistent with the actual path. Please manually adjust the upload path either in miscellaneous settings or if not using a custom path %s automatically to resolve the issue.', 'w3-total-cache'), $upload_path, Util_Ui::button_link(__('update the path', 'w3-total-cache'), Util_Ui::url(array('w3tc_config_update_upload_path' => 'y'))));
             }
         }
     }
     /**
      * Check CDN settings
      */
     $error = '';
     switch (true) {
         case $cdn_engine == 'ftp' && !count($c->get_array('cdn.ftp.domain')):
             $errors['cdn_ftp_empty'] = __('A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working:
                                     The <strong>"Replace default hostname with"</strong>
                                     field cannot be empty. Enter <acronym
                                     title="Content Delivery Network">CDN</acronym>
                                     provider hostname <a href="?page=w3tc_cdn#configuration">here</a>.
                                     <em>(This is the hostname used in order to view objects
                                     in a browser.)</em>', 'w3-total-cache');
             break;
         case $cdn_engine == 's3' && ($c->get_string('cdn.s3.key') == '' || $c->get_string('cdn.s3.secret') == '' || $c->get_string('cdn.s3.bucket') == ''):
             $error = __('The <strong>"Access key", "Secret key" and "Bucket"</strong> fields cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'cf' && ($c->get_string('cdn.cf.key') == '' || $c->get_string('cdn.cf.secret') == '' || $c->get_string('cdn.cf.bucket') == '' || $c->get_string('cdn.cf.id') == '' && !count($c->get_array('cdn.cf.cname'))):
             $error = __('The <strong>"Access key", "Secret key", "Bucket" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'cf2' && ($c->get_string('cdn.cf2.key') == '' || $c->get_string('cdn.cf2.secret') == '' || $c->get_string('cdn.cf2.id') == '' && !count($c->get_array('cdn.cf2.cname'))):
             $error = __('The <strong>"Access key", "Secret key" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'rscf' && ($c->get_string('cdn.rscf.user') == '' || $c->get_string('cdn.rscf.key') == '' || $c->get_string('cdn.rscf.container') == ''):
             $error = __('The <strong>"Username", "API key", "Container" and "Replace default hostname with"</strong> fields cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'azure' && ($c->get_string('cdn.azure.user') == '' || $c->get_string('cdn.azure.key') == '' || $c->get_string('cdn.azure.container') == ''):
             $error = __('The <strong>"Account name", "Account key" and "Container"</strong> fields cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'mirror' && !count($c->get_array('cdn.mirror.domain')):
             $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'netdna':
             $fields = array();
             if ($c->get_string('cdn.netdna.authorization_key') == '') {
                 $fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"';
             }
             if (!count($c->get_array('cdn.netdna.domain'))) {
                 $fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"';
             }
             if ($fields) {
                 $error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields));
             }
             if ($c->get_string('cdn.netdna.authorization_key') != '' && sizeof(explode('+', $c->get_string('cdn.netdna.authorization_key'))) != 3) {
                 $error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache');
             } elseif ($c->get_integer('cdn.netdna.zone_id', 0) <= 0) {
                 $error .= __('You need to select / create a pull zone.', 'w3-total-cache');
             }
             break;
         case $cdn_engine == 'maxcdn':
             $fields = array();
             if ($c->get_string('cdn.maxcdn.authorization_key') == '') {
                 $fields[] = '"' . __('Authorization key', 'w3-total-cache') . '"';
             }
             if (!count($c->get_array('cdn.maxcdn.domain'))) {
                 $fields[] = '"' . __('Replace default hostname with', 'w3-total-cache') . '"';
             }
             if ($fields) {
                 $error = sprintf(__('The <strong>%s</strong> field(s) cannot be empty.', 'w3-total-cache'), implode(__(' and ', 'w3-total-cache'), $fields));
             }
             if ($c->get_string('cdn.maxcdn.authorization_key') != '' && sizeof(explode('+', $c->get_string('cdn.maxcdn.authorization_key'))) != 3) {
                 $error .= __('The <strong>"Authorization key"</strong> is not correct.', 'w3-total-cache');
             } elseif ($c->get_integer('cdn.maxcdn.zone_id', 0) <= 0) {
                 $error .= __('You need to select / create a pull zone.', 'w3-total-cache');
             }
             break;
         case $cdn_engine == 'cotendo' && !count($c->get_array('cdn.cotendo.domain')):
             $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'edgecast' && !count($c->get_array('cdn.edgecast.domain')):
             $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'att' && !count($c->get_array('cdn.att.domain')):
             $error = __('The <strong>"Replace default hostname with"</strong> field cannot be empty.', 'w3-total-cache');
             break;
         case $cdn_engine == 'akamai' && !count($c->get_array('cdn.akamai.domain')):
             $error = 'The <strong>"Replace default hostname with"</strong> field cannot be empty.';
             break;
     }
     if ($error) {
         $errors['cdn_not_configured'] = __('A configuration issue prevents <acronym title="Content Delivery Network">CDN</acronym> from working: ', 'w3-total-cache') . $error . __(' <a href="?page=w3tc_cdn#configuration">Specify it here</a>.', 'w3-total-cache');
     }
     return $errors;
 }
コード例 #12
0
 /**
  * Imports library
  *
  * @param integer $limit
  * @param integer $offset
  * @param integer $count
  * @param integer $total
  * @param array   $results
  * @return boolean
  */
 function import_library($limit, $offset, &$count, &$total, &$results)
 {
     global $wpdb;
     $count = 0;
     $total = 0;
     $results = array();
     $upload_info = Util_Http::upload_info();
     $uploads_use_yearmonth_folders = get_option('uploads_use_yearmonth_folders');
     $document_root = Util_Environment::document_root();
     @set_time_limit($this->_config->get_integer('timelimit.cdn_import'));
     if ($upload_info) {
         /**
          * Search for posts with links or images
          */
         $sql = sprintf('SELECT
     		ID,
     		post_content,
     		post_date
         FROM
             %sposts
         WHERE
             post_status = "publish"
             AND (post_type = "post" OR post_type = "page")
             AND (post_content LIKE "%%src=%%"
             	OR post_content LIKE "%%href=%%")
    		', $wpdb->prefix);
         if ($limit) {
             $sql .= sprintf(' LIMIT %d', $limit);
             if ($offset) {
                 $sql .= sprintf(' OFFSET %d', $offset);
             }
         }
         $posts = $wpdb->get_results($sql);
         if ($posts) {
             $count = count($posts);
             $total = $this->get_import_posts_count();
             $regexp = '~(' . $this->get_regexp_by_mask($this->_config->get_string('cdn.import.files')) . ')$~';
             $config_state = Dispatcher::config_state();
             $import_external = $config_state->get_boolean('cdn.import.external');
             foreach ($posts as $post) {
                 $matches = null;
                 $replaced = array();
                 $attachments = array();
                 $post_content = $post->post_content;
                 /**
                  * Search for all link and image sources
                  */
                 if (preg_match_all('~(href|src)=[\'"]?([^\'"<>\\s]+)[\'"]?~', $post_content, $matches, PREG_SET_ORDER)) {
                     foreach ($matches as $match) {
                         list($search, $attribute, $origin) = $match;
                         /**
                          * Check if $search is already replaced
                          */
                         if (isset($replaced[$search])) {
                             continue;
                         }
                         $error = '';
                         $result = false;
                         $src = Util_Environment::normalize_file_minify($origin);
                         $dst = '';
                         /**
                          * Check if file exists in the library
                          */
                         if (stristr($origin, $upload_info['baseurl']) === false) {
                             /**
                              * Check file extension
                              */
                             $check_src = $src;
                             if (Util_Environment::is_url($check_src)) {
                                 $qpos = strpos($check_src, '?');
                                 if ($qpos !== false) {
                                     $check_src = substr($check_src, 0, $qpos);
                                 }
                             }
                             if (preg_match($regexp, $check_src)) {
                                 /**
                                  * Check for already uploaded attachment
                                  */
                                 if (isset($attachments[$src])) {
                                     list($dst, $dst_url) = $attachments[$src];
                                     $result = true;
                                 } else {
                                     if ($uploads_use_yearmonth_folders) {
                                         $upload_subdir = date('Y/m', strtotime($post->post_date));
                                         $upload_dir = sprintf('%s/%s', $upload_info['basedir'], $upload_subdir);
                                         $upload_url = sprintf('%s/%s', $upload_info['baseurl'], $upload_subdir);
                                     } else {
                                         $upload_subdir = '';
                                         $upload_dir = $upload_info['basedir'];
                                         $upload_url = $upload_info['baseurl'];
                                     }
                                     $src_filename = pathinfo($src, PATHINFO_FILENAME);
                                     $src_extension = pathinfo($src, PATHINFO_EXTENSION);
                                     /**
                                      * Get available filename
                                      */
                                     for ($i = 0;; $i++) {
                                         $dst = sprintf('%s/%s%s%s', $upload_dir, $src_filename, $i ? $i : '', $src_extension ? '.' . $src_extension : '');
                                         if (!file_exists($dst)) {
                                             break;
                                         }
                                     }
                                     $dst_basename = basename($dst);
                                     $dst_url = sprintf('%s/%s', $upload_url, $dst_basename);
                                     $dst_path = ltrim(str_replace($document_root, '', Util_Environment::normalize_path($dst)), '/');
                                     if ($upload_subdir) {
                                         Util_File::mkdir($upload_subdir, 0777, $upload_info['basedir']);
                                     }
                                     $download_result = false;
                                     /**
                                      * Check if file is remote URL
                                      */
                                     if (Util_Environment::is_url($src)) {
                                         /**
                                          * Download file
                                          */
                                         if ($import_external) {
                                             $download_result = Util_Http::download($src, $dst);
                                             if (!$download_result) {
                                                 $error = 'Unable to download file';
                                             }
                                         } else {
                                             $error = 'External file import is disabled';
                                         }
                                     } else {
                                         /**
                                          * Otherwise copy file from local path
                                          */
                                         $src_path = $document_root . '/' . urldecode($src);
                                         if (file_exists($src_path)) {
                                             $download_result = @copy($src_path, $dst);
                                             if (!$download_result) {
                                                 $error = 'Unable to copy file';
                                             }
                                         } else {
                                             $error = 'Source file doesn\'t exists';
                                         }
                                     }
                                     /**
                                      * Check if download or copy was successful
                                      */
                                     if ($download_result) {
                                         $title = $dst_basename;
                                         $guid = ltrim($upload_info['baseurlpath'] . $title, ',');
                                         $mime_type = Util_Mime::get_mime_type($dst);
                                         $GLOBALS['wp_rewrite'] = new WP_Rewrite();
                                         /**
                                          * Insert attachment
                                          */
                                         $id = wp_insert_attachment(array('post_mime_type' => $mime_type, 'guid' => $guid, 'post_title' => $title, 'post_content' => '', 'post_parent' => $post->ID), $dst);
                                         if (!is_wp_error($id)) {
                                             /**
                                              * Generate attachment metadata and upload to CDN
                                              */
                                             require_once ABSPATH . 'wp-admin/includes/image.php';
                                             wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $dst));
                                             $attachments[$src] = array($dst, $dst_url);
                                             $result = true;
                                         } else {
                                             $error = 'Unable to insert attachment';
                                         }
                                     }
                                 }
                                 /**
                                  * If attachment was successfully created then replace links
                                  */
                                 if ($result) {
                                     $replace = sprintf('%s="%s"', $attribute, $dst_url);
                                     // replace $search with $replace
                                     $post_content = str_replace($search, $replace, $post_content);
                                     $replaced[$search] = $replace;
                                     $error = 'OK';
                                 }
                             } else {
                                 $error = 'File type rejected';
                             }
                         } else {
                             $error = 'File already exists in the media library';
                         }
                         /**
                          * Add new entry to the log file
                          */
                         $results[] = array('src' => $src, 'dst' => $dst_path, 'result' => $result, 'error' => $error);
                     }
                 }
                 /**
                  * If post content was chenged then update DB
                  */
                 if ($post_content != $post->post_content) {
                     wp_update_post(array('ID' => $post->ID, 'post_content' => $post_content));
                 }
             }
         }
     }
 }
コード例 #13
0
 function w3tc_notes($notes)
 {
     $state_note = Dispatcher::config_state();
     /**
      * Show notification when minify needs to be emptied
      */
     if ($state_note->get_boolean('minify.show_note.need_flush') && !is_network_admin() && !$this->_config->is_preview()) {
         $notes['minify_flush_needed'] = sprintf(__('The setting change(s) made either invalidate the cached data or modify the behavior of the site. %s now to provide a consistent user experience.', 'w3-total-cache'), Util_Ui::button_link(__('Empty the minify cache', 'w3-total-cache'), Util_Ui::url(array('w3tc_flush_minify' => 'y'))));
     }
     return $notes;
 }
コード例 #14
0
ファイル: Util_Admin.php プロジェクト: developmentDM2/Whohaha
 /**
  * Save config, can't decline save process. (difference from action_save)
  *
  * Do some actions on config keys update
  * Used in several places such as:
  *
  * 1. common config save
  * 2. import settings
  *
  * @param Config  $current_config
  * @param Config  $new_config
  * @return bool
  * @throws Exception
  */
 public static function config_save($current_config, $new_config)
 {
     $master_config = $new_config->is_master() ? $new_config : Dispatcher::config_master();
     if ($master_config->get_integer('common.instance_id', 0) == 0) {
         $master_config->set('common.instance_id', mt_rand());
         if (!$new_config->is_master()) {
             $master_config->save();
         }
     }
     $old_config = new Config();
     $browsercache_dependencies = array();
     if ($new_config->get_boolean('browsercache.enabled')) {
         $browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.rewrite', 'browsercache.cssjs.replace', 'browsercache.html.replace', 'browsercache.other.replace'));
         if ($new_config->get_boolean('browsercache.cssjs.replace')) {
             $browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.cssjs.compression', 'browsercache.cssjs.expires', 'browsercache.cssjs.lifetime', 'browsercache.cssjs.cache.control', 'browsercache.cssjs.cache.policy', 'browsercache.cssjs.etag', 'browsercache.cssjs.w3tc'));
         }
         if ($new_config->get_boolean('browsercache.html.replace')) {
             $browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.html.compression', 'browsercache.html.expires', 'browsercache.html.lifetime', 'browsercache.html.cache.control', 'browsercache.html.cache.policy', 'browsercache.html.etag', 'browsercache.html.w3tc'));
         }
         if ($new_config->get_boolean('browsercache.other.replace')) {
             $browsercache_dependencies = array_merge($browsercache_dependencies, array('browsercache.other.compression', 'browsercache.other.expires', 'browsercache.other.lifetime', 'browsercache.other.cache.control', 'browsercache.other.cache.policy', 'browsercache.other.etag', 'browsercache.other.w3tc'));
         }
         $old_bc_dependencies_values = array();
         $new_bc_dependencies_values = array();
         foreach ($browsercache_dependencies as $key) {
             $old_bc_dependencies_values[] = $old_config->get($key);
             $new_bc_dependencies_values[] = $new_config->get($key);
         }
         if (serialize($old_bc_dependencies_values) != serialize($new_bc_dependencies_values)) {
             $state_note = Dispatcher::config_state_note();
             $state_note->set('common.show_note.flush_statics_needed', true);
         }
     }
     /**
      * Show need empty page cache notification
      */
     $cache_flush = Dispatcher::component('CacheFlush');
     if ($cache_flush->flushable_posts()) {
         $pgcache_dependencies = array_merge($browsercache_dependencies, array('pgcache.debug', 'pgcache.cache.query', 'pgcache.cache.home', 'pgcache.cache.feed', 'pgcache.cache.nginx_handle_xml', 'pgcache.cache.ssl', 'pgcache.cache.404', 'pgcache.cache.headers', 'pgcache.compatibility', 'pgcache.remove_charset', 'pgcache.accept.uri', 'pgcache.accept.files', 'pgcache.accept.qs', 'pgcache.late_init', 'pgcache.mirrors.enabled', 'pgcache.reject.front_page', 'pgcache.reject.logged', 'pgcache.reject.logged_roles', 'pgcache.reject.uri', 'pgcache.reject.ua', 'pgcache.reject.cookie', 'pgcache.reject.request_head', 'dbcache.enabled', 'objectcache.enabled', 'minify.enabled', 'mobile.enabled', 'referrer.enabled'));
         if ($new_config->get_boolean('pgcache.mirrors.enabled')) {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('pgcache.mirrors.home_urls'));
         }
         if ($new_config->get_boolean('dbcache.enabled')) {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('dbcache.debug'));
         }
         if ($new_config->get_boolean('objectcache.enabled')) {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('objectcache.debug'));
         }
         if ($new_config->get_boolean('minify.enabled')) {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('minify.auto', 'minify.debug', 'minify.rewrite', 'minify.html.enable', 'minify.html.engine', 'minify.html.inline.css', 'minify.html.inline.js', 'minify.html.strip.crlf', 'minify.html.comments.ignore', 'minify.css.enable', 'minify.css.engine', 'minify.css.groups', 'minify.js.enable', 'minify.js.engine', 'minify.js.groups', 'minify.htmltidy.options.clean', 'minify.htmltidy.options.hide-comments', 'minify.htmltidy.options.wrap', 'minify.reject.logged', 'minify.reject.ua', 'minify.reject.uri'));
         }
         /**
          *
          *
          * @var W3_ModuleStatus $modules
          */
         $modules = Dispatcher::component('ModuleStatus');
         if ($modules->is_running('cdn')) {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('cdn.enabled', 'cdn.debug', 'cdn.engine', 'cdn.uploads.enable', 'cdn.includes.enable', 'cdn.includes.files', 'cdn.theme.enable', 'cdn.theme.files', 'cdn.minify.enable', 'cdn.custom.enable', 'cdn.custom.files', 'cdn.ftp.domain', 'cdn.ftp.ssl', 'cdn.s3.cname', 'cdn.s3.ssl', 'cdn.cf.cname', 'cdn.cf.ssl', 'cdn.cf2.cname', 'cdn.cf2.ssl', 'cdn.rscf.cname', 'cdn.rscf.ssl', 'cdn.azure.cname', 'cdn.azure.ssl', 'cdn.mirror.domain', 'cdn.mirror.ssl', 'cdn.netdna.domain', 'cdn.netdna.ssl', 'cdn.cotendo.domain', 'cdn.cotendo.ssl', 'cdn.edgecast.domain', 'cdn.edgecast.ssl', 'cdn.att.domain', 'cdn.att.ssl', 'cdn.reject.logged_roles', 'cdn.reject.roles', 'cdn.reject.ua', 'cdn.reject.uri', 'cdn.reject.files'));
         } elseif ($old_config->get_boolean('cdn.enabled') && !$new_config->get_boolean('cdn.enabled')) {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('cdn.enabled'));
         }
         if ($new_config->get_boolean('mobile.enabled')) {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('mobile.rgroups'));
         }
         if ($new_config->get_boolean('referrer.enabled')) {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('referrer.rgroups'));
         }
         if ($new_config->get_boolean('browsercache.enabled') && $new_config->get_string('pgcache.engine') == 'file_generic') {
             $pgcache_dependencies = array_merge($pgcache_dependencies, array('browsercache.html.last_modified', 'browsercache.other.last_modified'));
         }
         $old_pgcache_dependencies_values = array();
         $new_pgcache_dependencies_values = array();
         foreach ($pgcache_dependencies as $pgcache_dependency) {
             $old_pgcache_dependencies_values[] = $old_config->get($pgcache_dependency);
             $new_pgcache_dependencies_values[] = $new_config->get($pgcache_dependency);
         }
         if (serialize($old_pgcache_dependencies_values) != serialize($new_pgcache_dependencies_values)) {
             $state_note = Dispatcher::config_state_note();
             $state_note->set('common.show_note.flush_posts_needed', true);
         }
     }
     /**
      * Show need empty minify notification
      */
     if ($current_config->get_boolean('minify.enabled') && $new_config->get_boolean('minify.enabled') && ($new_config->get_boolean('minify.css.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.css.groups'))) || $new_config->get_boolean('minify.js.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.js.groups'))))) {
         $minify_dependencies = array_merge($browsercache_dependencies, array('minify.auto', 'minify.debug', 'minify.options', 'minify.symlinks', 'minify.css.enable', 'minify.js.enable'));
         if ($new_config->get_boolean('minify.css.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.css.groups')))) {
             $minify_dependencies = array_merge($minify_dependencies, array('minify.css.engine', 'minify.css.combine', 'minify.css.strip.comments', 'minify.css.strip.crlf', 'minify.css.imports', 'minify.css.groups', 'minify.yuicss.path.java', 'minify.yuicss.path.jar', 'minify.yuicss.options.line-break', 'minify.csstidy.options.remove_bslash', 'minify.csstidy.options.compress_colors', 'minify.csstidy.options.compress_font-weight', 'minify.csstidy.options.lowercase_s', 'minify.csstidy.options.optimise_shorthands', 'minify.csstidy.options.remove_last_;', 'minify.csstidy.options.case_properties', 'minify.csstidy.options.sort_properties', 'minify.csstidy.options.sort_selectors', 'minify.csstidy.options.merge_selectors', 'minify.csstidy.options.discard_invalid_properties', 'minify.csstidy.options.css_level', 'minify.csstidy.options.preserve_css', 'minify.csstidy.options.timestamp', 'minify.csstidy.options.template'));
         }
         if ($new_config->get_boolean('minify.js.enable') && ($new_config->get_boolean('minify.auto') || count($new_config->get_array('minify.js.groups')))) {
             $minify_dependencies = array_merge($minify_dependencies, array('minify.js.engine', 'minify.js.combine.header', 'minify.js.combine.body', 'minify.js.combine.footer', 'minify.js.strip.comments', 'minify.js.strip.crlf', 'minify.js.groups', 'minify.yuijs.path.java', 'minify.yuijs.path.jar', 'minify.yuijs.options.line-break', 'minify.yuijs.options.nomunge', 'minify.yuijs.options.preserve-semi', 'minify.yuijs.options.disable-optimizations', 'minify.ccjs.path.java', 'minify.ccjs.path.jar', 'minify.ccjs.options.compilation_level', 'minify.ccjs.options.formatting'));
         }
         /**
          *
          *
          * @var W3_ModuleStatus $modules
          */
         $modules = Dispatcher::component('ModuleStatus');
         if ($modules->is_running('cdn')) {
             $minify_dependencies = array_merge($minify_dependencies, array('cdn.engine', 'cdn.enabled'));
         } elseif ($old_config->get_boolean('cdn.enabled') && !$new_config->get_boolean('cdn.enabled')) {
             $minify_dependencies = array_merge($minify_dependencies, array('cdn.enabled'));
         }
         $old_minify_dependencies_values = array();
         $new_minify_dependencies_values = array();
         foreach ($minify_dependencies as $minify_dependency) {
             $old_minify_dependencies_values[] = $old_config->get($minify_dependency);
             $new_minify_dependencies_values[] = $new_config->get($minify_dependency);
         }
         if (serialize($old_minify_dependencies_values) != serialize($new_minify_dependencies_values)) {
             $state_note = Dispatcher::config_state_note();
             $state_note->set('minify.show_note.need_flush', true);
         }
     }
     if ($new_config->get_boolean('cdn.enabled') && !Cdn_Util::is_engine_mirror($new_config->get_string('cdn.engine'))) {
         /**
          * Show notification when CDN enabled
          */
         if (!$old_config->get_boolean('cdn.enabled')) {
             $state = Dispatcher::config_state();
             $state->set('cdn.show_note_cdn_upload', true);
             $state->save();
         }
         /**
          * Show notification when Browser Cache settings changes
          */
         $cdn_dependencies = array('browsercache.enabled');
         if ($new_config->get_boolean('cdn.enabled')) {
             $cdn_dependencies = array('browsercache.cssjs.compression', 'browsercache.cssjs.expires', 'browsercache.cssjs.lifetime', 'browsercache.cssjs.cache.control', 'browsercache.cssjs.cache.policy', 'browsercache.cssjs.etag', 'browsercache.cssjs.w3tc', 'browsercache.html.compression', 'browsercache.html.expires', 'browsercache.html.lifetime', 'browsercache.html.cache.control', 'browsercache.html.cache.policy', 'browsercache.html.etag', 'browsercache.html.w3tc', 'browsercache.other.compression', 'browsercache.other.expires', 'browsercache.other.lifetime', 'browsercache.other.cache.control', 'browsercache.other.cache.policy', 'browsercache.other.etag', 'browsercache.other.w3tc');
         }
         $old_cdn_dependencies_values = array();
         $new_cdn_dependencies_values = array();
         foreach ($cdn_dependencies as $cdn_dependency) {
             $old_cdn_dependencies_values[] = $old_config->get($cdn_dependency);
             $new_cdn_dependencies_values[] = $new_config->get($cdn_dependency);
         }
         if (serialize($old_cdn_dependencies_values) != serialize($new_cdn_dependencies_values)) {
             $state = Dispatcher::config_state();
             $state->set('cdn.show_note_cdn_reupload', true);
             $state->save();
         }
     }
     /**
      * Show need empty object cache notification
      */
     if ($current_config->get_boolean('objectcache.enabled')) {
         $objectcache_dependencies = array('objectcache.groups.global', 'objectcache.groups.nonpersistent');
         $old_objectcache_dependencies_values = array();
         $new_objectcache_dependencies_values = array();
         foreach ($objectcache_dependencies as $objectcache_dependency) {
             $old_objectcache_dependencies_values[] = $old_config->get($objectcache_dependency);
             $new_objectcache_dependencies_values[] = $new_config->get($objectcache_dependency);
         }
         if (serialize($old_objectcache_dependencies_values) != serialize($new_objectcache_dependencies_values)) {
             $state_note = Dispatcher::config_state_note();
             $state_note->set('objectcache.show_note.flush_needed', true);
         }
     }
     do_action('w3tc_saved_options', $new_config);
     /**
      * Save config
      */
     try {
         $new_config->save();
     } catch (\Exception $ex) {
         // try to fix environment, it potentially can be fixed silently
         // dont show error here, it will be called again later
         // in admin_notices
         try {
             $environment = Dispatcher::component('Root_Environment');
             $environment->fix_in_wpadmin($new_config);
         } catch (\Exception $ex) {
         }
         // retry save process and complain now on failure
         try {
             $new_config->save();
         } catch (\Exception $ex) {
             throw new \Exception('<strong>Can\'t change configuration</strong>: ' . $ex->getMessage());
         }
     }
     $w3_plugin_cdn = Dispatcher::component('Cdn_Core_Admin');
     /**
      * Empty caches on engine change or cache enable/disable
      */
     if ($old_config->get_string('pgcache.engine') != $new_config->get_string('pgcache.engine') || $old_config->get_string('pgcache.enabled') != $new_config->get_string('pgcache.enabled')) {
         $pgcacheflush = Dispatcher::component('PgCache_Flush');
         $v = $pgcacheflush->flush();
     }
     if ($old_config->get_string('dbcache.engine') != $new_config->get_string('dbcache.engine') || $old_config->get_string('dbcache.enabled') != $new_config->get_string('dbcache.enabled')) {
         w3tc_dbcache_flush();
     }
     if ($old_config->get_string('objectcache.engine') != $new_config->get_string('objectcache.engine') || $old_config->get_string('objectcache.enabled') != $new_config->get_string('objectcache.enabled')) {
         w3tc_objectcache_flush();
     }
     if ($old_config->get_string('minify.engine') != $new_config->get_string('minify.engine') || $old_config->get_string('minify.enabled') != $new_config->get_string('minify.enabled')) {
         w3tc_minify_flush();
     }
     /**
      * Update CloudFront CNAMEs
      */
     $update_cf_cnames = false;
     if ($new_config->get_boolean('cdn.enabled') && in_array($new_config->get_string('cdn.engine'), array('cf', 'cf2'))) {
         if ($new_config->get_string('cdn.engine') == 'cf') {
             $old_cnames = $old_config->get_array('cdn.cf.cname');
             $new_cnames = $new_config->get_array('cdn.cf.cname');
         } else {
             $old_cnames = $old_config->get_array('cdn.cf2.cname');
             $new_cnames = $new_config->get_array('cdn.cf2.cname');
         }
         if (count($old_cnames) != count($new_cnames) || count(array_diff($old_cnames, $new_cnames))) {
             $update_cf_cnames = true;
         }
     }
     /**
      * Refresh config
      */
     $current_config->load();
     /**
      * React to config changes
      */
     $environment = Dispatcher::component('Root_Environment');
     $environment->fix_on_event($new_config, 'config_change', $old_config);
     /**
      * Update support us option
      */
     Generic_AdminLinks::link_update($current_config);
     /**
      * Auto upload browsercache files to CDN
      */
     if ($new_config->get_boolean('cdn.enabled') && $new_config->get_string('cdn.engine') == 'ftp') {
         Util_Admin::cdn_delete_browsercache($current_config);
         Util_Admin::cdn_upload_browsercache($current_config);
     }
     /**
      * Update CloudFront CNAMEs
      */
     if ($update_cf_cnames) {
         $error = null;
         $w3_plugin_cdn->update_cnames($error);
     }
     return true;
 }
コード例 #15
0
 private function _save_config()
 {
     $user_name = $_REQUEST['user_name'];
     $api_key = $_REQUEST['api_key'];
     $access_token = $_REQUEST['access_token'];
     $access_region_descriptor = json_decode(strtr($_REQUEST['access_region_descriptor'], '!^', '"\\'), true);
     $region = $_REQUEST['region'];
     $service_id = $_REQUEST['service_id'];
     $api = new Cdn_RackSpace_Api_Cdn(array('access_token' => $access_token, 'access_region_descriptor' => $access_region_descriptor, 'new_access_required' => ''));
     $service = $api->service_get($service_id);
     $access_url = $service['links_by_rel']['access_url']['href'];
     $protocol = 'http';
     $domain = '';
     if (isset($service['domains']) && $service['domains'][0]['protocol']) {
         $protocol = $service['domains'][0]['protocol'];
         $domain = $service['domains'][0]['domain'];
     }
     $c = Dispatcher::config();
     $c->set('cdn.rackspace_cdn.user_name', $user_name);
     $c->set('cdn.rackspace_cdn.api_key', $api_key);
     $c->set('cdn.rackspace_cdn.region', $region);
     $c->set('cdn.rackspace_cdn.service.name', $service['name']);
     $c->set('cdn.rackspace_cdn.service.id', $service_id);
     $c->set('cdn.rackspace_cdn.service.access_url', $access_url);
     $c->set('cdn.rackspace_cdn.service.protocol', $protocol);
     if ($protocol != 'https') {
         $c->set('cdn.rackspace_cdn.domains', array($domain));
     }
     $c->save();
     // reset calculated state
     $state = Dispatcher::config_state();
     $state->set('cdn.rackspace_cdn.access_state', '');
     $state->save();
     $postfix = Util_Admin::custom_message_id(array(), array('cdn_configuration_saved' => 'CDN credentials are saved successfully'));
     echo 'Location admin.php?page=w3tc_cdn&' . $postfix;
     exit;
 }
コード例 #16
0
 public function w3tc_save_options($data)
 {
     $new_config = $data['new_config'];
     $old_config = $data['old_config'];
     if (!$new_config->get_boolean('pgcache.cache.home') && $old_config->get_boolean('pgcache.cache.home') || $new_config->get_boolean('pgcache.reject.front_page') && !$old_config->get_boolean('pgcache.reject.front_page') || !$new_config->get_boolean('pgcache.cache.feed') && $old_config->get_boolean('pgcache.cache.feed') || !$new_config->get_boolean('pgcache.cache.query') && $old_config->get_boolean('pgcache.cache.query') || !$new_config->get_boolean('pgcache.cache.ssl') && $old_config->get_boolean('pgcache.cache.ssl')) {
         $state = Dispatcher::config_state();
         $state->set('common.show_note.flush_posts_needed', true);
         $state->save();
     }
     return $data;
 }
コード例 #17
0
ファイル: Cdn_Core.php プロジェクト: developmentDM2/Whohaha
 /**
  * Called when new access state is issued by cdnengine
  */
 public function on_rackspace_cf_new_access_state($access_state)
 {
     $state = Dispatcher::config_state();
     $state->set('cdn.rackspace_cf.access_state', $access_state);
     $state->save();
 }
コード例 #18
0
ファイル: Cdn_Plugin.php プロジェクト: developmentDM2/Whohaha
 /**
  * WP Upgrade action hack
  *
  * @param string  $message
  */
 function update_feedback($message)
 {
     if ($message == __('Upgrading database')) {
         $state = Dispatcher::config_state();
         $state->set('cdn.show_note_wp_upgraded', true);
         $state->save();
     }
 }
コード例 #19
0
 /**
  * Apply new default values when version changes
  */
 private function upgrade($file_data)
 {
     if (!isset($file_data['version'])) {
         $file_data['version'] = '0.0.0';
     }
     if (!function_exists('bb2_start')) {
         $file_data['pgcache.bad_behavior_path'] = '';
     } else {
         if (file_exists(WP_PLUGIN_DIR . '/bad-behavior/bad-behavior-generic.php')) {
             $bb_file = WP_PLUGIN_DIR . '/bad-behavior/bad-behavior-generic.php';
         } elseif (file_exists(WP_PLUGIN_DIR . '/Bad-Behavior/bad-behavior-generic.php')) {
             $bb_file = WP_PLUGIN_DIR . '/Bad-Behavior/bad-behavior-generic.php';
         } else {
             $bb_file = false;
         }
         if ($bb_file) {
             $file_data['pgcache.bad_behavior_path'] = $bb_file;
         }
     }
     //
     // changes in 0.9.5
     //
     if (!isset($file_data['extensions.active_frontend']) || !is_array($file_data['extensions.active_frontend'])) {
         $file_data['extensions.active_frontend'] = array();
     }
     if (version_compare($file_data['version'], '0.9.5', '<')) {
         // dont show minify tips if already enabled
         if (isset($file_data['minify.enabled']) && $file_data['minify.enabled'] == 'true' && function_exists('get_option')) {
             $cs = Dispatcher::config_state();
             $cs->set('minify.hide_minify_help', true);
             $cs->save();
         }
         $file_data['pgcache.mirrors.enabled'] = true;
         // map regions in rackspace
         if (isset($file_data['cdn.rscf.location'])) {
             if ($file_data['cdn.rscf.location'] == 'uk') {
                 $file_data['cdn.rscf.location'] = 'LON';
             }
             if ($file_data['cdn.rscf.location'] == 'us') {
                 $file_data['cdn.rscf.location'] = 'ORD';
             }
         }
         // change filenames
         $active = array();
         if (isset($file_data['extensions.active']) && is_array($file_data['extensions.active'])) {
             if (isset($file_data['extensions.active']['cloudflare'])) {
                 $active['cloudflare'] = 'w3-total-cache/Extension_CloudFlare_Plugin.php';
             }
             if (isset($file_data['extensions.active']['feedburner'])) {
                 $active['feedburner'] = 'w3-total-cache/Extension_FeedBurner_Plugin.php';
             }
             if (isset($file_data['extensions.active']['genesis.theme'])) {
                 $active['genesis.theme'] = 'w3-total-cache/Extension_Genesis_Plugin.php';
             }
             if (isset($file_data['extensions.active']['wordpress-seo'])) {
                 $active['wordpress-seo'] = 'w3-total-cache/Extension_WordPressSeo_Plugin.php';
             }
         }
         $file_data['extensions.active'] = $active;
         $active_frontend = array();
         foreach ($active as $key => $value) {
             $active_frontend[$key] = '*';
         }
         $file_data['extensions.active_frontend'] = $active_frontend;
         // keep those active by default
         $file_data['extensions.active']['newrelic'] = 'w3-total-cache/Extension_NewRelic_Plugin.php';
         $file_data['extensions.active']['fragmentcache'] = 'w3-total-cache/Extension_FragmentCache_Plugin.php';
     }
     // newrelic settings - migrate to extension
     if (isset($file_data['newrelic.enabled']) && $file_data['newrelic.enabled']) {
         // make new relic extension enabled
         if (!isset($file_data['extensions.active_frontend']['newrelic'])) {
             $file_data['extensions.active_frontend']['newrelic'] = '*';
         }
     }
     if (!isset($file_data['newrelic']) || !is_array($file_data['newrelic'])) {
         $file_data['newrelic'] = array('monitoring_type' => 'apm');
     }
     $this->_set_if_exists($file_data, 'newrelic.api_key', 'newrelic', 'api_key');
     $this->_set_if_exists($file_data, 'newrelic.appname', 'newrelic', 'apm.application_name');
     $this->_set_if_exists($file_data, 'newrelic.accept.logged_roles', 'newrelic', 'accept.logged_roles');
     $this->_set_if_exists($file_data, 'newrelic.accept.roles', 'newrelic', 'accept.roles');
     $this->_set_if_exists($file_data, 'newrelic.use_php_function', 'newrelic', 'use_php_function');
     $this->_set_if_exists($file_data, 'newrelic.cache_time', 'newrelic', 'cache_time');
     $this->_set_if_exists($file_data, 'newrelic.enable_xmit', 'newrelic', 'enable_xmit');
     $this->_set_if_exists($file_data, 'newrelic.include_rum', 'newrelic', 'include_rum');
     // extensions - kept in separate key now
     $this->_set_if_exists_extension($file_data, 'cloudflare');
     $this->_set_if_exists_extension($file_data, 'genesis.theme');
     $this->_set_if_exists_extension($file_data, 'feedburner');
     // fragmentcache to extension
     if (isset($file_data['fragmentcache.enabled']) && $file_data['fragmentcache.enabled']) {
         // make new relic extension enabled
         if (!isset($file_data['extensions.active_frontend']['fragmentcache'])) {
             $file_data['extensions.active_frontend']['fragmentcache'] = '*';
         }
     }
     $this->_set_if_exists($file_data, 'fragmentcache.debug', 'fragmentcache', 'debug');
     $this->_set_if_exists($file_data, 'fragmentcache.engine', 'fragmentcache', 'engine');
     $this->_set_if_exists($file_data, 'fragmentcache.file.gc', 'fragmentcache', 'file.gc');
     $this->_set_if_exists($file_data, 'fragmentcache.file.locking', 'fragmentcache', 'file.locking');
     $this->_set_if_exists($file_data, 'fragmentcache.memcached.servers', 'fragmentcache', 'memcached.servers');
     $this->_set_if_exists($file_data, 'fragmentcache.memcached.persistent', 'fragmentcache', 'memcached.persistent');
     $this->_set_if_exists($file_data, 'fragmentcache.memcached.aws_autodiscovery', 'fragmentcache', 'memcached.aws_autodiscovery');
     $this->_set_if_exists($file_data, 'fragmentcache.memcached.username', 'fragmentcache', 'memcached.username');
     $this->_set_if_exists($file_data, 'fragmentcache.memcached.password', 'fragmentcache', 'memcached.password');
     $this->_set_if_exists($file_data, 'fragmentcache.redis.persistent', 'fragmentcache', 'redis.persistent');
     $this->_set_if_exists($file_data, 'fragmentcache.redis.servers', 'fragmentcache', 'redis.servers');
     $this->_set_if_exists($file_data, 'fragmentcache.redis.password', 'fragmentcache', 'redis.password');
     $this->_set_if_exists($file_data, 'fragmentcache.redis.dbid', 'fragmentcache', 'redis.dbid');
     $this->_set_if_exists($file_data, 'fragmentcache.lifetime', 'fragmentcache', 'lifetime');
     $file_data['version'] = W3TC_VERSION;
     return $file_data;
 }
コード例 #20
0
 public function w3tc_ajax_cdn_rackspace_containers_done()
 {
     $user_name = $_REQUEST['user_name'];
     $api_key = $_REQUEST['api_key'];
     $access_token = $_REQUEST['access_token'];
     $access_region_descriptor = json_decode(strtr($_REQUEST['access_region_descriptor'], '!^', '"\\'), true);
     $region = $_REQUEST['region'];
     $container = Util_Request::get('container');
     $api_files = new Cdn_RackSpace_Api_CloudFiles(array('access_token' => $access_token, 'access_region_descriptor' => $access_region_descriptor, 'new_access_required' => ''));
     $api_cdn = new Cdn_RackSpace_Api_CloudFilesCdn(array('access_token' => $access_token, 'access_region_descriptor' => $access_region_descriptor, 'new_access_required' => ''));
     try {
         if (empty($container)) {
             $container_new = $_REQUEST['container_new'];
             if (empty($container_new)) {
                 throw new \Exception('Please select container');
             }
             $api_files->container_create($container_new);
             $api_cdn->container_cdn_enable($container_new);
             $container = $container_new;
         }
     } catch (\Exception $ex) {
         $containers = $api_cdn->containers();
         $details = array('user_name' => $user_name, 'api_key' => $api_key, 'access_token' => $access_token, 'access_region_descriptor_serialized' => strtr(json_encode($access_region_descriptor), '"\\', '!^'), 'region' => $region, 'containers' => $containers);
         $details['error_message'] = $ex->getMessage();
         include W3TC_DIR . '/Cdn_RackSpaceCloudFiles_Popup_View_Containers.php';
         exit;
     }
     $c = Dispatcher::config();
     $c->set('cdn.rscf.user', $user_name);
     $c->set('cdn.rscf.key', $api_key);
     $c->set('cdn.rscf.location', $region);
     $c->set('cdn.rscf.container', $container);
     $c->save();
     // reset calculated state
     $state = Dispatcher::config_state();
     $state->set('cdn.rackspace_cf.access_state', '');
     $state->save();
     $postfix = Util_Admin::custom_message_id(array(), array('cdn_configuration_saved' => 'CDN credentials are saved successfully'));
     echo 'Location admin.php?page=w3tc_cdn&' . $postfix;
     exit;
 }