/**
  * Creates add-in
  * @throws FilesystemOperationException
  */
 private function create_addin()
 {
     $src = W3TC_INSTALL_FILE_DB;
     $dst = W3TC_ADDIN_FILE_DB;
     if ($this->db_installed()) {
         if ($this->is_dbcache_add_in()) {
             $script_data = @file_get_contents($dst);
             if ($script_data == @file_get_contents($src)) {
                 return;
             }
         } elseif (!$this->db_check_old_add_in()) {
             w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/other.php');
             w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
             if (isset($_GET['page'])) {
                 $url = 'admin.php?page=' . $_GET['page'] . '&';
             } else {
                 $url = basename(w3_remove_query($_SERVER['REQUEST_URI'])) . '?page=w3tc_dashboard&';
             }
             $remove_url = w3_admin_url($url . 'w3tc_default_remove_add_in=dbcache');
             throw new FilesystemOperationException(sprintf(__('The Database add-in file db.php is not a W3 Total Cache drop-in.
                 Remove it or disable Database Caching. %s', 'w3-total-cache'), w3tc_button_link(__('Remove it for me', 'w3-total-cache'), wp_nonce_url($remove_url, 'w3tc'))));
         }
     }
     w3_wp_copy_file($src, $dst);
 }
 /**
  * Creates add-in
  * @throws FilesystemOperationException
  */
 private function create_addin()
 {
     $src = W3TC_INSTALL_FILE_OBJECT_CACHE;
     $dst = W3TC_ADDIN_FILE_OBJECT_CACHE;
     if ($this->objectcache_installed()) {
         if ($this->is_objectcache_add_in()) {
             $script_data = @file_get_contents($dst);
             if ($script_data == @file_get_contents($src)) {
                 return;
             }
         } elseif (!$this->objectcache_check_old_add_in()) {
             $remove_url = is_network_admin() ? network_admin_url('admin.php?page=' . $_GET['page'] . '&w3tc_default_remove_add_in=objectcache') : admin_url('admin.php?page=' . $_GET['page'] . '&w3tc_default_remove_add_in=objectcache');
             throw new FilesystemOperationException(sprintf(__('The Object Cache add-in file object-cache.php is not a W3 Total Cache drop-in.
                 Remove it or disable Object Caching. %s', 'w3-total-cache'), w3tc_button_link(__('Yes, remove it for me', 'w3-total-cache'), wp_nonce_url($remove_url, 'w3tc'))));
         }
     }
     w3_wp_copy_file($src, $dst);
 }
 /**
  * Checks if addins in wp-content is available and correct version.
  * @throws SelfTestExceptions
  */
 private function create_required_files($config, $exs)
 {
     w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/other.php');
     w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
     $src = W3TC_INSTALL_FILE_ADVANCED_CACHE;
     $dst = W3TC_ADDIN_FILE_ADVANCED_CACHE;
     if ($this->advanced_cache_installed()) {
         if ($this->is_advanced_cache_add_in()) {
             $script_data = @file_get_contents($dst);
             if ($script_data == @file_get_contents($src)) {
                 return;
             }
         } else {
             w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/other.php');
             w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
             $remove_url = w3_admin_url('admin.php?page=w3tc_dashboard&w3tc_default_remove_add_in=pgcache');
             $exs->push(new FilesystemOperationException(sprintf(__('The Page Cache add-in file advanced-cache.php is not a W3 Total Cache drop-in.
                 It should be removed. %s', 'w3-total-cache'), w3tc_button_link(__('Yes, remove it for me', 'w3-total-cache'), wp_nonce_url($remove_url, 'w3tc')))));
             return;
         }
     }
     try {
         w3_wp_copy_file($src, $dst);
     } catch (FilesystemOperationException $ex) {
         $exs->push($ex);
     }
 }
Exemple #4
0
/**
 * Returns hide note button html
 *
 * @param string $text
 * @param string $note
 * @param string $redirect
 * @param boolean $admin if to use config admin
 * @return string
 */
function w3tc_button_hide_note($text, $note, $redirect = '', $admin = false, $page = '')
{
    if (!$page) {
        w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
        $page = W3_Request::get_string('page');
    }
    $url = sprintf('admin.php?page=%s&w3tc_hide_note&note=%s', $page, $note);
    if ($admin) {
        $url .= '&admin=1';
    }
    if ($redirect != '') {
        $url .= '&redirect=' . urlencode($redirect);
    }
    $url = wp_nonce_url($url, 'w3tc');
    return w3tc_button_link($text, $url);
}