本文整理汇总了PHP中Util_Environment::is_https方法的典型用法代码示例。如果您正苦于以下问题:PHP Util_Environment::is_https方法的具体用法?PHP Util_Environment::is_https怎么用?PHP Util_Environment::is_https使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Util_Environment
的用法示例。
在下文中一共展示了Util_Environment::is_https方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: download
/**
* Downloads URL into a file
*
* @param string $url
* @param string $file
* @return boolean
*/
public static function download($url, $file)
{
if (strpos($url, '//') === 0) {
$url = (Util_Environment::is_https() ? 'https:' : 'http:') . $url;
}
$response = self::get($url);
if (!is_wp_error($response) && $response['response']['code'] == 200) {
return @file_put_contents($file, $response['body']);
}
return false;
}
示例2: _get_scheme
/**
* Returns scheme
*
* @return string
*/
function _get_scheme()
{
switch ($this->_config['ssl']) {
default:
case 'auto':
$scheme = Util_Environment::is_https() ? 'https' : 'http';
break;
case 'enabled':
$scheme = 'https';
break;
case 'disabled':
$scheme = 'http';
break;
case 'rejected':
$scheme = 'http';
break;
}
return $scheme;
}
示例3: action_widget_latest_ajax
/**
* Prints latest widget contents
*
* @return void
*/
function action_widget_latest_ajax()
{
// load content of feed
global $wp_version;
$items = array();
$items_count = $this->_config->get_integer('widget.latest.items');
if ($wp_version >= 2.8) {
include_once ABSPATH . WPINC . '/feed.php';
$feed = fetch_feed(W3TC_FEED_URL);
if (!is_wp_error($feed)) {
$feed_items = $feed->get_items(0, $items_count);
foreach ($feed_items as $feed_item) {
$items[] = array('link' => $feed_item->get_link(), 'title' => $feed_item->get_title(), 'description' => $feed_item->get_description());
}
}
} else {
include_once ABSPATH . WPINC . '/rss.php';
$rss = fetch_rss(W3TC_FEED_URL);
if (is_object($rss)) {
$items = array_slice($rss->items, 0, $items_count);
}
}
// Removes feedburner tracking images when site is https
if (Util_Environment::is_https()) {
$total = sizeof($items);
for ($i = 0; $i < $total; $i++) {
if (isset($items[$i]['description'])) {
$items[$i]['description'] = preg_replace('/<img[^>]+src[^>]+W3TOTALCACHE[^>]+>/', '', $items[$i]['description']);
}
}
}
ob_start();
include W3TC_INC_DIR . '/widget/latest_ajax.php';
// Default lifetime in cache of 12 hours (same as the feeds)
set_transient($this->_widget_latest_cache_key(), ob_get_flush(), 43200);
die;
}
示例4: esc_textarea
<?php
Util_Ui::sealing_disabled('browsercache.');
?>
name="browsercache__no404wp__exceptions" cols="40" rows="5"><?php
echo esc_textarea(implode("\r\n", $this->_config->get_array('browsercache.no404wp.exceptions')));
?>
</textarea><br />
<span class="description"><?php
_e('Never process 404 (not found) events for the specified URIs.', 'w3-total-cache');
?>
</span>
</td>
</tr>
<?php
Util_Ui::config_item(array('key' => 'browsercache.rewrite', 'disabled' => Util_Ui::sealing_disabled('browsercache.'), 'control' => 'checkbox', 'checkbox_label' => __('Rewrite URL structure of objects', 'w3-total-cache'), 'description' => __('Generate unique URI for each file protected from caching by browser.', 'w3-total-cache'), 'style' => '2'));
Util_Ui::config_item(array('key' => 'browsercache.hsts', 'disabled' => Util_Ui::sealing_disabled('browsercache.') || !Util_Environment::is_https(), 'value' => Util_Environment::is_https() ? null : false, 'control' => 'checkbox', 'checkbox_label' => __('Apply <acronym title="Hypertext Transfer Protocol">HTTP</acronym> Strict Transport Security policy', 'w3-total-cache'), 'description' => __('Set the <acronym title="HTTP Strict Transport Security">HSTS</acronym> header to maximize <acronym title="Secure Sockets Layer">SSL</acronym> security.', 'w3-total-cache'), 'style' => '2'));
?>
</table>
<?php
Util_Ui::button_config_save('browsercache_general');
?>
<?php
Util_Ui::postbox_footer();
?>
<?php
Util_Ui::postbox_header(__('<acronym title="Cascading Style Sheet">CSS</acronym> & <acronym title="JavaScript">JS</acronym>', 'w3-total-cache'), '', 'css_js');
?>
<p><?php
_e('Specify browser cache policy for Cascading Style Sheets and JavaScript files.', 'w3-total-cache');
示例5: can_cdn
/**
* Check if we can do CDN logic
*
* @return boolean
*/
function can_cdn()
{
/**
* Skip if admin
*/
if (defined('WP_ADMIN')) {
$this->cdn_reject_reason = 'wp-admin';
return false;
}
/**
* Check for WPMU's and WP's 3.0 short init
*/
if (defined('SHORTINIT') && SHORTINIT) {
$this->cdn_reject_reason = 'Short init';
return false;
}
/**
* Check User agent
*/
if (!$this->check_ua()) {
$this->cdn_reject_reason = 'user agent is rejected';
return false;
}
/**
* Check request URI
*/
if (!$this->_check_request_uri()) {
$this->cdn_reject_reason = 'request URI is rejected';
return false;
}
/**
* Do not replace urls if SSL and SSL support is do not replace
*/
if (Util_Environment::is_https() && $this->_config->get_boolean('cdn.reject.ssl')) {
$this->cdn_reject_reason = 'SSL is rejected';
return false;
}
return true;
}
示例6: do_flush
private function do_flush()
{
if (!is_network_admin()) {
$queued_urls[get_home_url() . '/.*'] = '*';
// add mirror urls
$queued_urls = Util_PageUrls::complement_with_mirror_urls($queued_urls);
foreach ($queued_urls as $url => $nothing) {
$this->_purge($url);
}
} else {
// todo: remove. doesnt work for all caches.
// replace with tool to flush network
global $wpdb;
$protocall = Util_Environment::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 (!Util_Environment::is_wpmu_subdomain()) {
$this->_purge(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);
}
}
}
}
}
示例7: url_to_maybe_https
/**
* Returns SSL URL if current connection is https
*
* @param string $url
* @return string
*/
public static function url_to_maybe_https($url)
{
if (Util_Environment::is_https()) {
$url = str_replace('http://', 'https://', $url);
}
return $url;
}
示例8: _get_encryption
/**
* Returns current encryption
*
* @return string
*/
function _get_encryption()
{
if (Util_Environment::is_https()) {
return 'ssl';
}
return '';
}
示例9: get_domains
/**
* Returns CDN domain
*
* @return array
*/
function get_domains()
{
if (Util_Environment::is_https()) {
if (!empty($this->_config['cname'])) {
return (array) $this->_config['cname'];
}
return array($this->get_host_https());
} else {
if (!empty($this->_config['cname'])) {
return (array) $this->_config['cname'];
}
return array($this->get_host_http());
}
}