예제 #1
0
 /**
  * Get subdomains URL of all languages
  *
  * @since 2.0
  * @deprecated 2.2
  * @deprecated Use get_rocket_i18n_subdomains()
  *
  */
 function get_rocket_subdomains_langs()
 {
     _deprecated_function(__FUNCTION__, '2.2', 'get_rocket_i18n_subdomains()');
     return get_rocket_i18n_subdomains();
 }
예제 #2
0
/**
 * Generates the configuration file for the current domain based on the values ​​of options
 *
 * @since 2.0
 *
 * @return array Names of all config files & The content that will be printed
 */
function get_rocket_config_file()
{
    $options = get_option(WP_ROCKET_SLUG);
    if (!$options) {
        return;
    }
    $buffer = '<?php' . "\n";
    $buffer .= 'defined( \'ABSPATH\' ) or die( \'Cheatin\\\' uh?\' );' . "\n\n";
    if (apply_filters('rocket_override_min_documentRoot', false)) {
        $buffer .= '$min_documentRoot = \'' . ABSPATH . '\';' . "\n";
    }
    $buffer .= '$rocket_cookie_hash = \'' . COOKIEHASH . '\'' . ";\n";
    foreach ($options as $option => $value) {
        if ($option == 'cache_ssl' || $option == 'cache_mobile' || $option == 'secret_cache_key') {
            $buffer .= '$rocket_' . $option . ' = \'' . $value . '\';' . "\n";
        }
        if ($option == 'cache_reject_uri') {
            $buffer .= '$rocket_' . $option . ' = \'' . get_rocket_cache_reject_uri() . '\';' . "\n";
        }
        if ($option == 'cache_query_strings') {
            $buffer .= '$rocket_' . $option . ' = ' . var_export(get_rocket_cache_query_string(), true) . ';' . "\n";
        }
        if ($option == 'cache_reject_cookies') {
            $cookies = get_rocket_cache_reject_cookies();
            if (get_rocket_option('cache_logged_user')) {
                $logged_in_cookie = str_replace(COOKIEHASH, '', LOGGED_IN_COOKIE);
                $cookies = str_replace($logged_in_cookie . '|', '', $cookies);
                $cookies = trim($cookies, '|');
            }
            $buffer .= '$rocket_' . $option . ' = \'' . $cookies . '\';' . "\n";
        }
        if ($option == 'cache_reject_ua') {
            $buffer .= '$rocket_' . $option . ' = \'' . get_rocket_cache_reject_ua() . '\';' . "\n";
        }
    }
    /** This filter is documented in inc/front/htaccess.php */
    if (apply_filters('rocket_url_no_dots', false)) {
        $buffer .= '$rocket_url_no_dots = \'1\';';
    }
    $config_files_path = array();
    $urls = array(home_url());
    // Check if a translation plugin is activated and this configuration is in subdomain
    if ($subdomains = get_rocket_i18n_subdomains()) {
        $urls = $subdomains;
    }
    foreach ($urls as $url) {
        list($host, $path) = get_rocket_parse_url(rtrim($url, '/'));
        if (!isset($path)) {
            $config_files_path[] = WP_ROCKET_CONFIG_PATH . strtolower($host) . '.php';
        } else {
            $config_files_path[] = WP_ROCKET_CONFIG_PATH . strtolower($host) . str_replace('/', '.', rtrim($path, '/')) . '.php';
        }
    }
    /**
     * Filter the content of all config files
     *
     * @since 2.1
     *
     * @param string $buffer The content that will be printed
     * @param array $config_files_path 	Names of all config files
     */
    $buffer = apply_filters('rocket_config_file', $buffer, $config_files_path);
    return array($config_files_path, $buffer);
}