本文整理汇总了PHP中w3_get_home_url函数的典型用法代码示例。如果您正苦于以下问题:PHP w3_get_home_url函数的具体用法?PHP w3_get_home_url怎么用?PHP w3_get_home_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了w3_get_home_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flush
/**
* Flush varnish cache
*/
function flush()
{
if (!is_network_admin()) {
$this->_purge(w3_get_home_url() . '/.*');
} else {
global $wpdb;
$protocall = w3_is_https() ? 'https://' : 'http://';
// If WPMU Domain Mapping plugin is installed and active
if (defined('SUNRISE_LOADED') && SUNRISE_LOADED && isset($wpdb->dmtable) && !empty($wpdb->dmtable)) {
$blogs = $wpdb->get_results("SELECT {$wpdb->blogs}.domain, {$wpdb->blogs}.path, {$wpdb->dmtable}.domain AS mapped_domain\n FROM {$wpdb->dmtable}\n RIGHT JOIN {$wpdb->blogs} ON {$wpdb->dmtable}.blog_id = {$wpdb->blogs}.blog_id\n WHERE site_id = {$wpdb->siteid}\n AND spam = 0\n AND deleted = 0\n AND archived = '0'\n ");
foreach ($blogs as $blog) {
if (!isset($blog->mapped_domain)) {
$url = $protocall . $blog->domain . (strlen($blog->path) > 1 ? '/' . trim($blog->path, '/') : '') . '/.*';
} else {
$url = $protocall . $blog->mapped_domain . '/.*';
}
$this->_purge($url);
}
} else {
if (!w3_is_subdomain_install()) {
$this->_purge(w3_get_home_url() . '/.*');
} else {
$blogs = $wpdb->get_results("\n SELECT domain, path\n FROM {$wpdb->blogs}\n WHERE site_id = '{$wpdb->siteid}'\n AND spam = 0\n AND deleted = 0\n AND archived = '0'\n ");
foreach ($blogs as $blog) {
$url = $protocall . $blog->domain . (strlen($blog->path) > 1 ? '/' . trim($blog->path, '/') : '') . '/.*';
$this->_purge($url);
}
}
}
}
}
示例2: action_config_export
/**
* Export config action
*
* @return void
*/
function action_config_export()
{
$filename = substr(w3_get_home_url(), strpos(w3_get_home_url(), '//') + 2);
@header(sprintf(__('Content-Disposition: attachment; filename=%s.php', 'w3-total-cache'), $filename));
echo $this->_config->export();
die;
}
示例3: widget_pagespeed
/**
* PageSpeed widget
*
* @return void
*/
function widget_pagespeed()
{
w3_require_once(W3TC_LIB_W3_DIR . '/PageSpeed.php');
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$key = $this->_config->get_string('widget.pagespeed.key');
$force = W3_Request::get_boolean('w3tc_widget_pagespeed_force');
$results = null;
if ($key) {
$w3_pagespeed = new W3_PageSpeed();
$results = $w3_pagespeed->analyze(w3_get_home_url(), $force);
}
include W3TC_INC_DIR . '/widget/pagespeed.php';
}
示例4: view
/**
* CDN tab
*
* @return void
*/
function view()
{
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
$cdn_enabled = $this->_config->get_boolean('cdn.enabled');
$cdn_engine = $this->_config->get_string('cdn.engine');
$cdn_mirror = w3_is_cdn_mirror($cdn_engine);
$cdn_mirror_purge_all = w3_cdn_can_purge_all($cdn_engine);
$cdn_common = w3_instance('W3_Plugin_CdnCommon');
$cdn = $cdn_common->get_cdn();
$cdn_supports_header = $cdn->headers_support() == W3TC_CDN_HEADER_MIRRORING;
$cdn_supports_full_page_mirroring = $cdn->supports_full_page_mirroring();
$minify_enabled = $this->_config->get_boolean('minify.enabled') && $this->_config->get_boolean('minify.rewrite') && (!$this->_config->get_boolean('minify.auto') || w3_is_cdn_mirror($this->_config->get_string('cdn.engine')));
$cookie_domain = $this->get_cookie_domain();
$set_cookie_domain = $this->is_cookie_domain_enabled();
// 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') || $this->_config->get_boolean('browsercache.other.replace');
if (in_array($cdn_engine, array('netdna', 'maxcdn'))) {
$pull_zones = array();
$authorization_key = $this->_config->get_string("cdn.{$cdn_engine}.authorization_key");
$zone_id = $this->_config->get_integer("cdn.{$cdn_engine}.zone_id");
$alias = $consumerkey = $consumersecret = '';
if ($authorization_key) {
$keys = explode('+', $authorization_key);
if (sizeof($keys) == 3) {
list($alias, $consumerkey, $consumersecret) = $keys;
}
}
$authorized = $authorization_key != '' && $alias && $consumerkey && $consumersecret;
$have_zone = $zone_id != 0;
if ($authorized) {
w3_require_once(W3TC_LIB_NETDNA_DIR . '/NetDNA.php');
try {
$api = new NetDNA($alias, $consumerkey, $consumersecret);
$pull_zones = $api->get_zones_by_url(w3_get_home_url());
} catch (Exception $ex) {
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php');
w3_e_error_box('<p>There is an error with your CDN settings: ' . $ex->getMessage() . '</p>');
}
}
}
include W3TC_INC_DIR . '/options/cdn.php';
}
示例5: w3_get_pgcache_rules_cache_path
/**
* Returns path of pgcache cache rules file
* Moved to separate file to not load rule.php for each disk enhanced request
*
* @return string
*/
function w3_get_pgcache_rules_cache_path()
{
switch (true) {
case w3_is_apache():
case w3_is_litespeed():
if (w3_is_network()) {
$url = w3_get_home_url();
$match = null;
if (preg_match('~http(s)?://(.+?)(/)?$~', $url, $match)) {
$home_path = $match[2];
return W3TC_CACHE_PAGE_ENHANCED_DIR . '/' . $home_path . '/.htaccess';
}
}
return W3TC_CACHE_PAGE_ENHANCED_DIR . '/.htaccess';
case w3_is_nginx():
return w3_get_nginx_rules_path();
}
return false;
}
示例6: action_cdn_create_netdna_maxcdn_pull_zone
/**
* Create NetDNA/MaxCDN pullzone
*/
function action_cdn_create_netdna_maxcdn_pull_zone()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
$type = W3_Request::get_string('type');
$name = W3_Request::get_string('name');
$label = W3_Request::get_string('label');
w3_require_once(W3TC_LIB_NETDNA_DIR . '/NetDNA.php');
$cdn_engine = $this->_config->get_string('cdn.engine');
$authorization_key = $this->_config->get_string("cdn.{$cdn_engine}.authorization_key");
$alias = $consumerkey = $consumersecret = '';
if ($authorization_key) {
$keys = explode('+', $authorization_key);
if (sizeof($keys) == 3) {
list($alias, $consumerkey, $consumersecret) = $keys;
}
}
$api = new NetDNA($alias, $consumerkey, $consumersecret);
$url = w3_get_home_url();
$zone = array();
$zone['name'] = $name;
$zone['label'] = $label;
$zone['url'] = $url;
try {
$response = $api->create_pull_zone($zone);
try {
$this->_config->set('cdn.enabled', true);
if (!$this->_config->get_array("cdn.{$cdn_engine}.domain")) {
$this->_config->set("cdn.{$cdn_engine}.domain", array("{$name}.{$alias}.netdna-cdn.com"));
}
$this->_config->save();
} catch (Exception $ex) {
}
echo json_encode(array('status' => 'success', 'message' => 'Pull Zone created.', 'temporary_url' => "{$name}.{$alias}.netdna-cdn.com", 'data' => $response));
} catch (Exception $ex) {
echo json_encode(array('status' => 'error', 'message' => $ex->getMessage()));
}
}
示例7: purge_all
/**
* Purge CDN completely
* @param $results
* @return bool
*/
function purge_all(&$results)
{
if (empty($this->_config['authorization_key'])) {
$results = $this->_get_results(array(), W3TC_CDN_RESULT_HALT, __('Empty Authorization Key.', 'w3-total-cache'));
return false;
}
if (empty($this->_config['alias']) || empty($this->_config['consumerkey']) || empty($this->_config['consumersecret'])) {
$results = $this->_get_results(array(), W3TC_CDN_RESULT_HALT, __('Malformed Authorization Key.', 'w3-total-cache'));
return false;
}
if (!class_exists('NetDNA')) {
w3_require_once(W3TC_LIB_NETDNA_DIR . '/NetDNA.php');
}
$api = new NetDNA($this->_config['alias'], $this->_config['consumerkey'], $this->_config['consumersecret']);
$results = array();
$local_path = $remote_path = '';
$domain_is_valid = 0;
$found_domain = false;
try {
if ($this->_config['zone_id'] != 0) {
$zone_id = $this->_config['zone_id'];
} else {
$zone_id = $api->get_zone_id(w3_get_home_url());
}
if ($zone_id == 0) {
$zone_id = $api->get_zone_id(w3_get_domain_url());
}
if ($zone_id == 0) {
$zone_id = $api->get_zone_id(str_replace('://', '://www.', w3_get_domain_url()));
}
if ($zone_id == 0 || is_null($zone_id)) {
if (w3_get_domain_url() == w3_get_home_url()) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf(__('No zones match site: %s.', 'w3-total-cache'), trim(w3_get_home_url(), '/')));
} else {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf(__('No zones match site: %s or %s.', 'w3-total-cache'), trim(w3_get_home_url(), '/'), trim(w3_get_domain_url(), '/')));
}
return !$this->_is_error($results);
}
$pullzone = json_decode($api->get('/zones/pull.json/' . $zone_id));
try {
if (preg_match("(200|201)", $pullzone->code)) {
$custom_domains_full = json_decode($api->get('/zones/pull/' . $pullzone->data->pullzone->id . '/customdomains.json'));
$custom_domains = array();
foreach ($custom_domains_full->data->customdomains as $custom_domain_full) {
$custom_domains[] = $custom_domain_full->custom_domain;
}
$local_path = 'all';
$remote_path = 'all';
$domain_is_valid = 0;
$found_domain = false;
if ($pullzone->data->pullzone->name . '.' . $this->_config['alias'] . '.' . W3TC_CDN_NETDNA_URL === $this->get_domain($local_path) || in_array($this->get_domain($local_path), $custom_domains)) {
try {
$params = array('file' => '/' . $local_path);
$file_purge = json_decode($api->delete('/zones/pull.json/' . $pullzone->data->pullzone->id . '/cache'));
if (preg_match("(200|201)", $file_purge->code)) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_OK, __('OK', 'w3-total-cache'));
} else {
if (preg_match("(401|500)", $file_purge->code)) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf(__('Failed with error code %s. Please check your alias, consumer key, and private key.', 'w3-total-cache'), $file_purge->code));
} else {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, __('Failed with error code ', 'w3-total-cache') . $file_purge->code);
}
}
$found_domain = true;
} catch (CurlException $e) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_HALT, sprintf(__('Unable to purge (%s).', 'w3-total-cache'), $e->getMessage()));
}
} else {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf(__('No registered CNAMEs match %s.', 'w3-total-cache'), $this->get_domain($local_path)));
return !$this->_is_error($results);
}
} else {
if (preg_match("(401|500)", $pullzone->code)) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf(__('Failed with error code %s. Please check your alias, consumer key, and private key.', 'w3-total-cache'), $pullzone->code));
} else {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, __('Failed with error code ', 'w3-total-cache') . $pullzone->code);
}
}
} catch (CurlException $e) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_HALT, sprintf(__('Unable to purge (%s).', 'w3-total-cache'), $e->getMessage()));
}
} catch (CurlException $e) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_HALT, __('Failure to pull zone: ', 'w3-total-cache') . $e->getMessage());
}
if ($domain_is_valid > 0 && !$found_domain) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, __('No zones match custom domain.', 'w3-total-cache'));
} elseif (!$found_domain) {
$results[] = $this->_get_result($local_path, $remote_path, W3TC_CDN_RESULT_ERROR, sprintf(__('No zones match site: %s.', 'w3-total-cache'), trim(w3_get_home_url(), '/')));
}
return !$this->_is_error($results);
}
示例8: _e
?>
</label></th>
<td><input type="text" id="name" name="name"/><div class="name_message w3tc-error inline"></div>
<p><span class="description"><?php
_e('Pull Zone Name. Length: 3-32 chars; only letters, digits, and dash (-) accepted', 'w3-total-cache');
?>
</span></p>
</td>
</tr>
<tr>
<th><label for="url"><?php
_e('Origin <acronym title="Uniform Resource Indicator">URL</acronym>:', 'w3-total-cache');
?>
</label></th>
<td><?php
echo w3_get_home_url();
?>
<p><span class="description"><?php
_e('Your server\'s hostname or domain', 'w3-total-cache');
?>
</span></p>
</td>
</tr>
<tr>
<th><label for="label"><?php
_e('Description:', 'w3-total-cache');
?>
</label></th>
<td><textarea id="label" name="label" cols="40"></textarea><div class="label_message w3tc-error inline"></div>
<p><span class="description"><?php
_e('Something that describes your zone. Length: 1-255 chars', 'w3-total-cache');
示例9: w3_get_home_path
/**
* Returns home path
*
* Example:
*
* home=http://domain.com/site/
* siteurl=http://domain.com/site/blog
* return /site/
*
* With trailing slash!
*
* @return string
*/
function w3_get_home_path()
{
$home_url = w3_get_home_url();
$parse_url = @parse_url($home_url);
if ($parse_url && isset($parse_url['path'])) {
$home_path = '/' . ltrim($parse_url['path'], '/');
} else {
$home_path = '/';
}
if (substr($home_path, -1) != '/') {
$home_path .= '/';
}
return $home_path;
}
示例10: action_support_request
//.........这里部分代码省略.........
}
/**
* Attach other files
*/
if (!empty($_FILES['files'])) {
$files = (array) $_FILES['files'];
for ($i = 0, $l = count($files); $i < $l; $i++) {
if (isset($files['tmp_name'][$i]) && isset($files['name'][$i]) && isset($files['error'][$i]) && $files['error'][$i] == UPLOAD_ERR_OK) {
$path = W3TC_CACHE_TMP_DIR . '/' . $files['name'][$i];
if (@move_uploaded_file($files['tmp_name'][$i], $path)) {
$attachments[] = $path;
}
}
}
}
$data = array();
if (!empty($wp_login) && !empty($wp_password)) {
$data['WP Admin login'] = $wp_login;
$data['WP Admin password'] = $wp_password;
}
if (!empty($ftp_host) && !empty($ftp_login) && !empty($ftp_password)) {
$data['SSH / FTP host'] = $ftp_host;
$data['SSH / FTP login'] = $ftp_login;
$data['SSH / FTP password'] = $ftp_password;
}
/**
* Store request data for future access
*/
if (count($data)) {
$hash = md5(microtime());
$request_data = get_option('w3tc_request_data', array());
$request_data[$hash] = $data;
update_option('w3tc_request_data', $request_data);
$request_data_url = sprintf('%s/w3tc_request_data/%s', w3_get_home_url(), $hash);
} else {
$request_data_url = '';
}
$nonce = wp_create_nonce('w3tc_support_request');
if (is_network_admin()) {
update_site_option('w3tc_support_request', $nonce);
} else {
update_option('w3tc_support_request', $nonce);
}
$file_access = WP_PLUGIN_URL . '/' . dirname(W3TC_FILE) . '/pub/files.php';
if (w3_get_domain(w3_get_home_url()) != w3_get_domain(w3_get_site_url())) {
$file_access = str_replace(w3_get_domain(w3_get_home_url()), w3_get_domain(w3_get_site_url()), $file_access);
}
$post['file_access'] = $file_access;
$post['nonce'] = $nonce;
$post['request_data_url'] = $request_data_url;
$post['ip'] = $_SERVER['REMOTE_ADDR'];
$post['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
$post['version'] = W3TC_VERSION;
$post['plugin'] = 'W3 Total Cache';
$post['request_id'] = $request_id;
$license_level = 'community';
if (w3_is_pro($this->_config)) {
$license_level = 'pro';
} elseif (w3_is_enterprise($this->_config)) {
$license_level = 'enterprise';
}
$post['license_level'] = $license_level;
$unset = array('wp_login', 'wp_password', 'ftp_host', 'ftp_login', 'ftp_password');
foreach ($unset as $key) {
unset($post[$key]);
}
示例11: action_test_pagespeed_results
/**
* Page Speed results action
*
* @return void
*/
function action_test_pagespeed_results()
{
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php');
w3_require_once(W3TC_LIB_W3_DIR . '/PageSpeed.php');
$force = W3_Request::get_boolean('force');
$title = 'Google Page Speed';
$w3_pagespeed = new W3_PageSpeed();
$results = $w3_pagespeed->analyze(w3_get_home_url(), $force);
if ($force) {
w3_admin_redirect(array('w3tc_pagespeed_results' => 1, '_wpnonce' => wp_create_nonce('w3tc')));
}
include W3TC_INC_POPUP_DIR . '/pagespeed_results.php';
}
示例12: print_script
function print_script()
{
?>
<script type="text/javascript">
var w3_use_network_link = <?php
echo is_network_admin() || w3_is_multisite() && w3_force_master() ? 'true' : 'false';
?>
;
function w3tc_start_minify_try_solve() {
var testUrl = '<?php
echo w3_filename_to_url(w3_cache_blog_dir('minify') . '/', w3_get_domain(w3_get_home_url()) != w3_get_domain(w3_get_site_url()));
?>
';
w3tc_filename_auto_solve(testUrl);
}
</script>
<?php
}
示例13: get
/**
* Returns config value
*
* @param string $key
* @param mixed $default
* @return mixed
*/
function get($key, $default = null)
{
if (array_key_exists($key, $this->_keys) && array_key_exists($key, $this->_config)) {
$value = $this->_config[$key];
} else {
if ($default === null && array_key_exists($key, $this->_defaults)) {
$value = $this->_defaults[$key];
} else {
$value = $default;
}
}
switch ($key) {
/**
* Check cache engines
*/
case 'pgcache.engine':
case 'dbcache.engine':
case 'minify.engine':
case 'objectcache.engine':
/**
* Legacy support
*/
if ($value == 'file_pgcache') {
$value = 'file_generic';
}
switch (true) {
case $value == 'file_generic' && !w3_can_check_rules():
case $value == 'apc' && !function_exists('apc_store'):
case $value == 'eaccelerator' && !function_exists('eaccelerator_put'):
case $value == 'xcache' && !function_exists('xcache_set'):
case $value == 'wincache' && !function_exists('wincache_ucache_set'):
case $value == 'memcached' && !class_exists('Memcache'):
return 'file';
}
break;
/**
* Check HTML minifier
*/
/**
* Check HTML minifier
*/
case 'minify.html.engine':
if ($value == 'htmltidy' && !class_exists('tidy')) {
return 'html';
}
break;
/**
* Disabled some page cache options when enhanced mode enabled
*/
/**
* Disabled some page cache options when enhanced mode enabled
*/
case 'pgcache.cache.query':
if ($this->get_string('pgcache.engine') == 'file_generic') {
return false;
}
break;
/**
* Set default value to sitemap file
*/
/**
* Set default value to sitemap file
*/
case 'pgcache.prime.sitemap':
if (!$value) {
$value = w3_get_home_url() . '/sitemap.xml';
}
break;
/**
* Disabled minify when PHP5 is not installed
*/
/**
* Disabled minify when PHP5 is not installed
*/
case 'minify.enabled':
if (!W3TC_PHP5) {
return false;
}
break;
/**
* Disable minify rewrite when server rules are not supported
*/
/**
* Disable minify rewrite when server rules are not supported
*/
case 'minify.rewrite':
if (!w3_can_check_rules()) {
return false;
}
break;
/**
* Disable minify options for auto mode
*/
//.........这里部分代码省略.........
示例14: test_rewrite_minify
/**
* Perform minify rules rewrite test
*
* @return bool
*/
function test_rewrite_minify()
{
$url = sprintf('%s/%s/w3tc_rewrite_test', w3_get_home_url(), W3TC_CONTENT_MINIFY_DIR_NAME);
return $this->test_rewrite($url);
}
示例15: _e
</tr>
<tr>
<th>Preview mode:</th>
<td>
<?php
echo $this->nonce_field('w3tc');
?>
<?php
if ($this->_config->is_preview()) {
?>
<input type="submit" name="w3tc_preview_disable" class="button-primary" value="<?php
_e('Disable', 'w3-total-cache');
?>
" />
<?php
echo $this->button_link(__('Preview', 'w3-total-cache'), w3_get_home_url() . '/?w3tc_preview=1', true);
?>
<?php
echo $this->button_link(__('Deploy', 'w3-total-cache'), wp_nonce_url(sprintf('admin.php?page=%s&w3tc_preview_deploy', $this->_page), 'w3tc'));
?>
<?php
} else {
?>
<input type="submit" name="w3tc_preview_enable" class="button-primary" value="<?php
_e('Enable', 'w3-total-cache');
?>
" />
<?php
}
?>
<br /><span class="description"><?php