本文整理汇总了PHP中domain_mapping_siteurl函数的典型用法代码示例。如果您正苦于以下问题:PHP domain_mapping_siteurl函数的具体用法?PHP domain_mapping_siteurl怎么用?PHP domain_mapping_siteurl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了domain_mapping_siteurl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rocket_replace_domain_mapping_siteurl
/**
* Get Domain Mapping URL based on origal URL.
*
* @since 2.2
*/
function rocket_replace_domain_mapping_siteurl($url)
{
$original_siteurl_host = parse_url(get_original_url('siteurl'), PHP_URL_HOST);
$domain_mapping_siteurl_host = parse_url(domain_mapping_siteurl(false), PHP_URL_HOST);
$url = str_replace($original_siteurl_host, $domain_mapping_siteurl_host, $url);
return $url;
}
示例2: domain_mapping_gc_cache
function domain_mapping_gc_cache($function, $directory)
{
global $cache_path;
if (!function_exists('domain_mapping_warning')) {
return false;
}
$siteurl = domain_mapping_siteurl(false);
if (!$siteurl) {
return false;
}
$protocol = 'on' == strtolower($_SERVER['HTTPS']) ? 'https://' : 'http://';
$siteurl = trailingslashit(str_replace($protocol, '', $siteurl));
if ($directory == 'homepage') {
$directory = '';
}
switch ($function) {
case "rebuild":
@wp_cache_rebuild_or_delete($cache_path . 'supercache/' . $siteurl . $directory . 'index.html');
@wp_cache_rebuild_or_delete($cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz');
break;
case "prune":
prune_super_cache($cache_path . 'supercache/' . $siteurl . $directory . 'index.html', true, true);
prune_super_cache($cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz', true, true);
break;
}
return $directory;
}
示例3: domain_mapping_supercachedir
function domain_mapping_supercachedir($dir)
{
global $cache_path;
if (!function_exists('domain_mapping_warning')) {
return $dir;
}
$siteurl = domain_mapping_siteurl(false);
if (!$siteurl) {
return $dir;
}
$protocol = 'on' == strtolower($_SERVER['HTTPS']) ? 'https://' : 'http://';
$siteurl = str_replace($protocol, '', $siteurl);
return $cache_path . 'supercache/' . $siteurl;
}
示例4: site_url
function site_url()
{
$site_url = '';
// compatibility for WordPress MU Domain Mapping plugin
if (defined('DOMAIN_MAPPING') && DOMAIN_MAPPING) {
if (!function_exists('domain_mapping_siteurl')) {
if (!function_exists('is_plugin_active')) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugin = 'wordpress-mu-domain-mapping/domain_mapping.php';
if (is_plugin_active($plugin)) {
include_once WP_PLUGIN_DIR . '/' . $plugin;
}
}
if (function_exists('domain_mapping_siteurl')) {
$site_url = domain_mapping_siteurl(false);
}
}
if (empty($site_url)) {
$site_url = site_url();
}
return $site_url;
}
示例5: redirect_check
/**
* Redirect Check
*
* Checks if the current page needs to be redirected
*
* @param none
* @return void
*/
public function redirect_check()
{
global $post;
$plugin = $this->getPlugin();
$force_ssl = apply_filters('force_ssl', null, $post ? $post->ID : null, ($plugin->isSsl() ? 'https' : 'http') . '://' . (isset($_SERVER['HTTP_X_FORWARDED_SERVER']) ? $_SERVER['HTTP_X_FORWARDED_SERVER'] : $_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI']);
// Domain mapping check
if (function_exists('domain_mapping_siteurl') && $force_ssl) {
$mapped_domain = domain_mapping_siteurl(false);
if (strpos($plugin->getHttpsUrl(), $mapped_domain) === false) {
if (remove_action('template_redirect', 'redirect_to_mapped_domain')) {
$plugin->getLogger()->log('[FIXED] Domain mapping redirect removed.');
} else {
$plugin->getLogger()->log('[WARNING] Unable to remove domain mapping redirect.');
}
}
}
if (!$plugin->isSsl() && isset($force_ssl) && $force_ssl) {
$scheme = 'https';
} else {
if ($plugin->isSsl() && isset($force_ssl) && !$force_ssl) {
$scheme = 'http';
}
}
if (isset($scheme)) {
$plugin->redirect($scheme);
}
}
示例6: getLocalDomains
/**
* Get domains local to the WordPress installation.
*
* @param none
* @return array $hosts Array of domains local to the WordPress installation.
*/
public function getLocalDomains()
{
global $wpdb;
$hosts = array($this->getHttpUrl()->getHost(), $this->getHttpsUrl()->getHost());
if (is_multisite() && is_subdomain_install()) {
$multisite_hosts = $wpdb->get_col($wpdb->prepare("SELECT domain FROM %d", $wpdb->blogs));
$hosts = array_merge($hosts, $multisite_hosts);
}
if (function_exists('domain_mapping_siteurl')) {
if ($mapped_host = parse_url(domain_mapping_siteurl(false), PHP_URL_HOST)) {
$hosts[] = $mapped_host;
}
}
return $hosts;
}
示例7: htsda_mu_https_domain_rewrite
/**
* Same as above, but handles all domains in a multisite
*/
function htsda_mu_https_domain_rewrite($url, $status = 0)
{
if (!is_string($url)) {
// do nothing if $url is not a string
// the customizer view seems to sometimes pass an empty array to this filter for some reason.
// this would crash the entire plugin
return $url;
}
// Rewrite only if the request is https, or the user is logged in
// to preserve cookie integrity
if (substr($url, 0, 5) == 'https' || function_exists('is_user_logged_in') && is_user_logged_in() && !(defined('DISABLE_FRONTEND_SSL') && DISABLE_FRONTEND_SSL)) {
// these won't change during the request
static $domains;
if (!isset($domains)) {
$args = array('limit' => null);
// do not limit the number of results
$blogs = wp_get_sites($args);
// get info from wp_blogs table
$domains = array();
// map the domains here
$domains[] = hstda_trim_url(parse_url(get_site_url(1), PHP_URL_HOST), 'www.');
// main site home
// special case for wpmu domain mapping plugin
if (function_exists('domain_mapping_siteurl')) {
$domains[] = hstda_trim_url(parse_url(domain_mapping_siteurl(false), PHP_URL_HOST), 'www.');
}
foreach ($blogs as $blog) {
$domains[] = hstda_trim_url($blog['domain'], 'www.');
}
// dedupe domains
$domains = array_unique($domains);
}
// Rewrite the $url
$url = hstda_rewrite_url($url, $domains);
}
return $url;
}
示例8: autoptimize_end_buffering
function autoptimize_end_buffering($content)
{
if (stripos($content, "<html") === false || stripos($content, "<xsl:stylesheet") !== false) {
return $content;
}
// load URL constants as late as possible to allow domain mapper to kick in
if (function_exists("domain_mapping_siteurl")) {
define('AUTOPTIMIZE_WP_SITE_URL', domain_mapping_siteurl(get_current_blog_id()));
define('AUTOPTIMIZE_WP_CONTENT_URL', str_replace(get_original_url(AUTOPTIMIZE_WP_SITE_URL), AUTOPTIMIZE_WP_SITE_URL, content_url()));
} else {
define('AUTOPTIMIZE_WP_SITE_URL', site_url());
define('AUTOPTIMIZE_WP_CONTENT_URL', content_url());
}
if (is_multisite()) {
$blog_id = get_current_blog_id();
define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL . AUTOPTIMIZE_CACHE_CHILD_DIR . $blog_id . '/');
} else {
define('AUTOPTIMIZE_CACHE_URL', AUTOPTIMIZE_WP_CONTENT_URL . AUTOPTIMIZE_CACHE_CHILD_DIR);
}
define('AUTOPTIMIZE_WP_ROOT_URL', str_replace(AUTOPTIMIZE_WP_CONTENT_NAME, '', AUTOPTIMIZE_WP_CONTENT_URL));
// Config element
$conf = autoptimizeConfig::instance();
// Choose the classes
$classes = array();
if ($conf->get('autoptimize_js')) {
$classes[] = 'autoptimizeScripts';
}
if ($conf->get('autoptimize_css')) {
$classes[] = 'autoptimizeStyles';
}
if ($conf->get('autoptimize_html')) {
$classes[] = 'autoptimizeHTML';
}
// Set some options
$classoptions = array('autoptimizeScripts' => array('justhead' => $conf->get('autoptimize_js_justhead'), 'forcehead' => $conf->get('autoptimize_js_forcehead'), 'trycatch' => $conf->get('autoptimize_js_trycatch'), 'js_exclude' => $conf->get('autoptimize_js_exclude'), 'cdn_url' => $conf->get('autoptimize_cdn_url')), 'autoptimizeStyles' => array('justhead' => $conf->get('autoptimize_css_justhead'), 'datauris' => $conf->get('autoptimize_css_datauris'), 'defer' => $conf->get('autoptimize_css_defer'), 'defer_inline' => $conf->get('autoptimize_css_defer_inline'), 'inline' => $conf->get('autoptimize_css_inline'), 'css_exclude' => $conf->get('autoptimize_css_exclude'), 'cdn_url' => $conf->get('autoptimize_cdn_url')), 'autoptimizeHTML' => array('keepcomments' => $conf->get('autoptimize_html_keepcomments')));
$content = apply_filters('autoptimize_filter_html_before_minify', $content);
// Run the classes
foreach ($classes as $name) {
$instance = new $name($content);
if ($instance->read($classoptions[$name])) {
$instance->minify();
$instance->cache();
$content = $instance->getcontent();
}
unset($instance);
}
$content = apply_filters('autoptimize_html_after_minify', $content);
return $content;
}
示例9: get_site_url
/**
* Gets the primary domain for the site.
*
* This function is necessary for MU sites where the URL for the backend is different than the URL for the frontend.
*
* See https://github.com/10up/PushUp/issues/9 for more information.
*
* @return string Represents the primary domain name for the domain name being used.
*/
public static function get_site_url()
{
$url = '';
// Support for WordPress MU Domain Mapping
if (function_exists('domain_mapping_siteurl')) {
$url = domain_mapping_siteurl('');
}
if (empty($url)) {
$url = site_url();
}
return apply_filters('pushup_site_url', $url);
}
示例10: WPVarnishActuallyPurgeObject
function WPVarnishActuallyPurgeObject($wpv_url)
{
global $varnish_servers;
// added this hook to enable other plugins do something when cache is purged
do_action('WPVarnishPurgeObject', $wpv_url);
if (is_array($varnish_servers)) {
foreach ($varnish_servers as $server) {
list($host, $port, $secret) = explode(':', $server);
$wpv_purgeaddr[] = $host;
$wpv_purgeport[] = $port;
$wpv_secret[] = $secret;
}
} else {
$wpv_purgeaddr = get_option($this->wpv_addr_optname);
$wpv_purgeport = get_option($this->wpv_port_optname);
$wpv_secret = get_option($this->wpv_secret_optname);
}
$wpv_timeout = get_option($this->wpv_timeout_optname);
$wpv_use_adminport = get_option($this->wpv_use_adminport_optname);
global $varnish_version;
if (isset($varnish_version) && in_array($varnish_version, array(2, 3))) {
$wpv_vversion_optval = $varnish_version;
} else {
$wpv_vversion_optval = get_option($this->wpv_vversion_optname);
}
// check for domain mapping plugin by donncha
if (function_exists('domain_mapping_siteurl')) {
$wpv_wpurl = domain_mapping_siteurl('NA');
} else {
$wpv_wpurl = get_bloginfo('url');
}
$wpv_replace_wpurl = '/^https?:\\/\\/([^\\/]+)(.*)/i';
$wpv_host = preg_replace($wpv_replace_wpurl, "\$1", $wpv_wpurl);
$wpv_blogaddr = preg_replace($wpv_replace_wpurl, "\$2", $wpv_wpurl);
$wpv_url = $wpv_blogaddr . $wpv_url;
// allow custom purge functions and stop if they return false
if (function_exists($this->wpv_custom_purge_obj_f)) {
$f = $this->wpv_custom_purge_obj_f;
if (!$f($wpv_url, $wpv_host)) {
return;
}
}
for ($i = 0; $i < count($wpv_purgeaddr); $i++) {
$varnish_sock = fsockopen($wpv_purgeaddr[$i], $wpv_purgeport[$i], $errno, $errstr, $wpv_timeout);
if (!$varnish_sock) {
error_log("wp-varnish error: {$errstr} ({$errno}) on server {$wpv_purgeaddr[$i]}:{$wpv_purgeport[$i]}");
continue;
}
if ($wpv_use_adminport) {
$buf = fread($varnish_sock, 1024);
if (preg_match('/(\\w+)\\s+Authentication required./', $buf, $matches)) {
# get the secret
$secret = $wpv_secret[$i];
fwrite($varnish_sock, "auth " . $this->WPAuth($matches[1], $secret) . "\n");
$buf = fread($varnish_sock, 1024);
if (!preg_match('/^200/', $buf)) {
error_log("wp-varnish error: authentication failed using admin port on server {$wpv_purgeaddr[$i]}:{$wpv_purgeport[$i]}");
fclose($varnish_sock);
continue;
}
}
if ($wpv_vversion_optval == 3) {
$out = "ban req.url ~ ^{$wpv_url}\$ && req.http.host == {$wpv_host}\n";
} else {
$out = "purge req.url ~ ^{$wpv_url} && req.http.host == {$wpv_host}\n";
}
} else {
$out = "BAN {$wpv_url} HTTP/1.0\r\n";
$out .= "Host: {$wpv_host}\r\n";
$out .= "User-Agent: WordPress-Varnish plugin\r\n";
$out .= "Connection: Close\r\n\r\n";
}
fwrite($varnish_sock, $out);
fclose($varnish_sock);
}
}
示例11: wpcf7_is_email_in_site_domain
function wpcf7_is_email_in_site_domain($email)
{
if (wpcf7_is_localhost()) {
return true;
}
$site_domain = strtolower($_SERVER['SERVER_NAME']);
if (preg_match('/^[0-9.]+$/', $site_domain)) {
// 123.456.789.012
return true;
}
if (wpcf7_is_email_in_domain($email, $site_domain)) {
return true;
}
$home_url = home_url();
// for interoperability with WordPress MU Domain Mapping plugin
if (is_multisite() && function_exists('domain_mapping_siteurl')) {
$domain_mapping_siteurl = domain_mapping_siteurl(false);
if ($domain_mapping_siteurl) {
$home_url = $domain_mapping_siteurl;
}
}
if (preg_match('%^https?://([^/]+)%', $home_url, $matches)) {
$site_domain = strtolower($matches[1]);
if ($site_domain != strtolower($_SERVER['SERVER_NAME']) && wpcf7_is_email_in_domain($email, $site_domain)) {
return true;
}
}
return false;
}
示例12: htsda_mu_https_domain_rewrite
/**
* Same as above, but handles all domains in a multisite
*/
function htsda_mu_https_domain_rewrite($url, $status = 0)
{
// Rewrite only if the request is https, or the user is logged in
// to preserve cookie integrity
if (substr($url, 0, 5) == 'https' || function_exists('is_user_logged_in') && is_user_logged_in() && !(defined('DISABLE_FRONTEND_SSL') && DISABLE_FRONTEND_SSL)) {
// these won't change during the request
static $domains;
if (!isset($domains)) {
$blogs = wp_get_sites();
// get info from wp_blogs table
$domains = array();
// map the domains here
$domains[] = hstda_trim_url(parse_url(get_site_url(1), PHP_URL_HOST), 'www.');
// main site home
// special case for wpmu domain mapping plugin
if (function_exists('domain_mapping_siteurl')) {
$domains[] = hstda_trim_url(parse_url(domain_mapping_siteurl(false), PHP_URL_HOST), 'www.');
}
foreach ($blogs as $blog) {
$domains[] = hstda_trim_url($blog['domain'], 'www.');
}
// dedupe domains
$domains = array_unique($domains);
}
// Rewrite the $url
$url = hstda_rewrite_url($url, $domains);
}
return $url;
}
示例13: the_url_donncha_domainmap
/**
* Try to get an canonical URL when Donncha Domain Mapping is active.
*
* @since 2.4.0
*
* @param string $path The post relative path.
* @param bool $get_scheme Output array with scheme.
* @return string|array|void The unescaped URL, the scheme
*/
public function the_url_donncha_domainmap($path, $get_scheme = false)
{
if (false === $this->is_donncha_domainmapping_active()) {
return '';
}
global $current_blog;
$scheme = is_ssl() ? 'https' : 'http';
$url = function_exists('domain_mapping_siteurl') ? domain_mapping_siteurl(false) : false;
$request_uri = '';
if ($url && untrailingslashit($scheme . '://' . $current_blog->domain . $current_blog->path) !== $url) {
if (defined('VHOST') && 'yes' !== VHOST || defined('SUBDOMAIN_INSTALL') && false === SUBDOMAIN_INSTALL) {
$request_uri = isset($_SERVER['REQUEST_URI']) ? str_replace($current_blog->path, '/', $_SERVER['REQUEST_URI']) : '';
}
$url = trailingslashit($url . $request_uri) . ltrim($path, ' \\/');
if ($get_scheme) {
return array($url, $scheme);
} else {
return $url;
}
}
return '';
}
示例14: redirect_to_mapped_domain
function redirect_to_mapped_domain()
{
global $current_blog, $wpdb, $wp_customize;
// don't redirect the main site
if (is_main_site()) {
return;
}
// don't redirect post previews
if (isset($_GET['preview']) && $_GET['preview'] == 'true') {
return;
}
// don't redirect theme customizer (WP 3.4)
if (is_a($wp_customize, 'WP_Customize_Manager')) {
return;
}
$protocol = is_ssl() ? 'https://' : 'http://';
$url = domain_mapping_siteurl(false);
if ($url && $url != untrailingslashit($protocol . $current_blog->domain . $current_blog->path)) {
$redirect = get_site_option('dm_301_redirect') ? '301' : '302';
if (defined('VHOST') && constant("VHOST") != 'yes' || defined('SUBDOMAIN_INSTALL') && constant('SUBDOMAIN_INSTALL') == false) {
$_SERVER['REQUEST_URI'] = str_replace($current_blog->path, '/', $_SERVER['REQUEST_URI']);
}
header("Location: {$url}{$_SERVER['REQUEST_URI']}", true, $redirect);
exit;
}
}
示例15: getBaseURL
/**
* Get base URL, get domain mapping if plugin exists
* @param string $path
* @return string
*/
public static function getBaseURL($path = '', $original_url = false)
{
global $current_site;
// check for domain mapping plugin by donncha
if (function_exists('domain_mapping_siteurl') && $original_url == false) {
$base_url = domain_mapping_siteurl('NA');
$base_url = untrailingslashit($base_url);
$base_url .= $path;
} elseif (is_multisite() && is_subdomain_install() == false) {
$base_url = network_site_url($path);
$base_url = str_replace($current_site->path, '', $base_url);
} else {
$base_url = home_url($path);
}
return $base_url;
}