本文整理汇总了PHP中extract_from_markers函数的典型用法代码示例。如果您正苦于以下问题:PHP extract_from_markers函数的具体用法?PHP extract_from_markers怎么用?PHP extract_from_markers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extract_from_markers函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: uncode_add_h5bp_htaccess
/**
* Add HTML5 Boilerplate's .htaccess via WordPress
*/
function uncode_add_h5bp_htaccess()
{
$options = get_option(ot_options_id());
$theme_opt = $options['_uncode_htaccess'];
$saved_opt = get_option("_uncode_htaccess_performace");
if ($theme_opt === 'on' && $saved_opt !== 'on' || $theme_opt === 'off' && $saved_opt === 'on') {
global $wp_rewrite;
$home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
$htaccess_file = $home_path . '.htaccess';
$mod_rewrite_enabled = function_exists('got_mod_rewrite') ? got_mod_rewrite() : false;
if (!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() || is_writable($htaccess_file)) {
if ($mod_rewrite_enabled) {
$h5bp_rules = extract_from_markers($htaccess_file, 'HTML5 Boilerplate');
if ($h5bp_rules === array()) {
$filename = dirname(__FILE__) . '/h5bp-htaccess';
update_option("_uncode_htaccess_performace", $theme_opt);
return insert_with_markers($htaccess_file, 'HTML5 Boilerplate', extract_from_markers($filename, 'HTML5 Boilerplate'));
} else {
if ($theme_opt === 'off') {
update_option("_uncode_htaccess_performace", $theme_opt);
return insert_with_markers($htaccess_file, 'HTML5 Boilerplate', '');
}
}
}
}
}
}
开发者ID:b0123498765,项目名称:fithealthyandwealthy,代码行数:30,代码来源:performance.php
示例2: write
protected function write()
{
$server_config_rules = extract_from_markers(self::$wp_htaccess_file, self::MARKER);
if (empty($server_config_rules)) {
$server_config_rules = implode('', file(self::$roots_htaccess_file));
$server_config_rules = str_replace(array_keys(self::$rules_filters), array_values(self::$rules_filters), $server_config_rules);
$server_config_rules = apply_filters('roots/h5bp-htaccess-rules', $server_config_rules);
insert_with_markers(self::$wp_htaccess_file, self::MARKER, explode(PHP_EOL, $server_config_rules));
}
}
开发者ID:webbab,项目名称:wp-h5bp-htaccess,代码行数:10,代码来源:wp-h5bp-htaccess.php
示例3: htaccess_add_rules
/**
* Adds extra goodness whenever WP writes to .htaccess
*
* @global object $wp_rewrite
* @param string $content
* @return boolean
*/
function htaccess_add_rules($content)
{
global $wp_rewrite;
$home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
$htaccess_file = $home_path . '.htaccess';
$mod_rewrite_enabled = function_exists('got_mod_rewrite') ? got_mod_rewrite() : false;
$firewall_rules = extract_from_markers($htaccess_file, 'Tabula Rasa');
if ($firewall_rules === array()) {
$filename = dirname(__FILE__) . '/TR-htaccess';
return $this->prepend_with_markers($htaccess_file, 'Tabula Rasa', extract_from_markers($filename, 'Tabula Rasa'));
}
return $content;
}
开发者ID:renaissance-design,项目名称:tabularasa,代码行数:20,代码来源:htaccess.php
示例4: roots_add_h5bp_htaccess
function roots_add_h5bp_htaccess($content)
{
global $wp_rewrite;
$home_path = get_home_path();
$htaccess_file = $home_path . '.htaccess';
if (!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() || is_writable($htaccess_file)) {
if (got_mod_rewrite()) {
$h5bp_rules = extract_from_markers($htaccess_file, 'HTML5 Boilerplate');
if ($h5bp_rules === array()) {
$filename = __DIR__ . '/h5bp-htaccess';
return insert_with_markers($htaccess_file, 'HTML5 Boilerplate', extract_from_markers($filename, 'HTML5 Boilerplate'));
}
}
}
return $content;
}
开发者ID:regancarver,项目名称:TEDxYYC-Wordpress-Theme,代码行数:16,代码来源:roots-htaccess.php
示例5: roots_add_h5bp_htaccess
/**
* Add HTML5 Boilerplate's .htaccess via WordPress
*/
function roots_add_h5bp_htaccess($content)
{
global $wp_rewrite;
$home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
$htaccess_file = $home_path . '.htaccess';
$mod_rewrite_enabled = function_exists('got_mod_rewrite') ? got_mod_rewrite() : false;
if (!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() || is_writable($htaccess_file)) {
if ($mod_rewrite_enabled) {
$h5bp_rules = extract_from_markers($htaccess_file, 'HTML5 Boilerplate');
if ($h5bp_rules === array()) {
$filename = dirname(__FILE__) . '/h5bp-htaccess';
return insert_with_markers($htaccess_file, 'HTML5 Boilerplate', extract_from_markers($filename, 'HTML5 Boilerplate'));
}
}
}
return $content;
}
开发者ID:AndrGelmini,项目名称:ItalyStrap,代码行数:20,代码来源:wp-h5bp-htaccess.php
示例6: wsc_mod_rewrite
function wsc_mod_rewrite()
{
global $super_cache_enabled, $cache_compression, $cache_compression_changed, $valid_nonce, $cache_path;
if ($super_cache_enabled == false) {
return;
}
?>
<br /><fieldset class="options">
<h3>Super Cache Compression</h3>
<form name="wp_manager" action="<?php
echo $_SERVER["REQUEST_URI"];
?>
" method="post">
<label><input type="radio" name="cache_compression" value="1" <?php
if ($cache_compression) {
echo "checked=checked";
}
?>
> Enabled</label>
<label><input type="radio" name="cache_compression" value="0" <?php
if (!$cache_compression) {
echo "checked=checked";
}
?>
> Disabled</label>
<p>Compression is disabled by default because some hosts have problems with compressed files. Switching this on and off clears the cache.</p>
<?php
if (isset($cache_compression_changed) && isset($_POST['cache_compression']) && !$cache_compression) {
?>
<p><strong>Super Cache compression is now disabled.</strong></p> <?php
} elseif (isset($cache_compression_changed) && isset($_POST['cache_compression']) && $cache_compression) {
?>
<p><strong>Super Cache compression is now enabled.</strong></p><?php
}
echo '<div><input ' . SUBMITDISABLED . 'type="submit" value="Update Compression »" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
?>
</fieldset><br />
<a name="modrewrite"></a><fieldset class="options">
<h3>Mod Rewrite Rules</h3><?php
$home_path = get_home_path();
$home_root = parse_url(get_bloginfo('url'));
$home_root = trailingslashit($home_root['path']);
$inst_root = parse_url(get_bloginfo('wpurl'));
$inst_root = trailingslashit($inst_root['path']);
$wprules = implode("\n", extract_from_markers($home_path . '.htaccess', 'WordPress'));
$wprules = str_replace("RewriteEngine On\n", '', $wprules);
$wprules = str_replace("RewriteBase {$home_root}\n", '', $wprules);
$scrules = implode("\n", extract_from_markers($home_path . '.htaccess', 'WPSuperCache'));
if (substr(get_option('permalink_structure'), -1) == '/') {
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]\$";
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*\$";
}
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !=POST";
$condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*";
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*\$";
$condition_rules = apply_filters('supercacherewriteconditions', $condition_rules);
$rules = "<IfModule mod_rewrite.c>\n";
$rules .= "RewriteEngine On\n";
$rules .= "RewriteBase {$home_root}\n";
// props Chris Messina
$charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset');
$rules .= "AddDefaultCharset {$charset}\n";
$rules .= "CONDITION_RULES";
$rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
$rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}\$1/index.html.gz -f\n";
$rules .= "RewriteRule ^(.*) {$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}\$1/index.html.gz [L]\n\n";
$rules .= "CONDITION_RULES";
$rules .= "RewriteCond %{DOCUMENT_ROOT}{$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}\$1/index.html -f\n";
$rules .= "RewriteRule ^(.*) {$inst_root}wp-content/cache/supercache/%{HTTP_HOST}{$home_root}\$1/index.html [L]\n";
$rules .= "</IfModule>\n";
$rules = apply_filters('supercacherewriterules', $rules);
$rules = str_replace("CONDITION_RULES", implode("\n", $condition_rules) . "\n", $rules);
$dohtaccess = true;
if (function_exists('is_site_admin')) {
echo "<h4 style='color: #a00'>WordPress MU Detected</h4><p>Unfortunately the rewrite rules cannot be updated automatically when running WordPress MU. Please open your .htaccess and add the following mod_rewrite rules above any other rules in that file.</p>";
} elseif (!$wprules || $wprules == '') {
echo "<h4 style='color: #a00'>Mod Rewrite rules cannot be updated!</h4>";
echo "<p>You must have <strong>BEGIN</strong> and <strong>END</strong> markers in {$home_path}.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:\n\t\t<blockquote><code><em># BEGIN WordPress</em><br /> RewriteCond %{REQUEST_FILENAME} !-f<br /> RewriteCond %{REQUEST_FILENAME} !-d<br /> RewriteRule . /index.php [L]<br /> <em># END WordPress</em></code></blockquote>\n\t\tRefresh this page when you have updated your .htaccess file.";
echo "</fieldset></div>";
return;
} elseif (strpos($wprules, 'wordpressuser')) {
// Need to clear out old mod_rewrite rules
echo "<p><strong>Thank you for upgrading.</strong> The mod_rewrite rules changed since you last installed this plugin. Unfortunately you must remove the old supercache rules before the new ones are updated. Refresh this page when you have edited your .htaccess file. If you wish to manually upgrade, change the following line: <blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*\$</code></blockquote> so it looks like this: <blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*\$</code></blockquote> The only changes are 'HTTP_COOKIE' becomes 'HTTP:Cookie' and 'wordpressuser' becomes 'wordpress'. This is a WordPress 2.5 change but it's backwards compatible with older versions if you're brave enough to use them.</p>";
echo "</fieldset></div>";
return;
} elseif ($scrules != '' && strpos($scrules, '%{REQUEST_URI} !^.*[^/]$') === false && substr(get_option('permalink_structure'), -1) == '/') {
// permalink structure has a trailing slash, need slash check in rules.
echo "<div style='padding: 2px; background: #ff0'><h4>Trailing slash check required.</h4><p>It looks like your blog has URLs that end with a '/'. Unfortunately since you installed this plugin a duplicate content bug has been found where URLs not ending in a '/' end serve the same content as those with the '/' and do not redirect to the proper URL.<br />";
echo "To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:</p>";
echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]\$<br />RewriteCond %{REQUEST_URI} !^.*//.*\$<br /></code></blockquote>";
echo "<p>You can see where the rules go and examine the complete rules by clicking the 'View mod_rewrite rules' link below.</p></div>";
$dohtaccess = false;
} elseif (strpos($scrules, 'supercache') || strpos($wprules, 'supercache')) {
// only write the rules once
$dohtaccess = false;
}
if ($dohtaccess && !$_POST['updatehtaccess']) {
//.........这里部分代码省略.........
开发者ID:alx,项目名称:alexgirard.com-blog,代码行数:101,代码来源:wp-cache.php
示例7: wsc_mod_rewrite
function wsc_mod_rewrite()
{
global $cache_enabled, $super_cache_enabled, $cache_compression, $cache_compression_changed, $valid_nonce, $cache_path;
if ($super_cache_enabled == false && $cache_enabled == true) {
?>
<h3><?php
_e('Super Cache Compression', 'wp-super-cache');
?>
</h3>
<p><?php
_e('Compression is enabled by default when in <em>HALF ON</em> mode.', 'wp-super-cache');
?>
</p>
<?php
return;
} elseif ($super_cache_enabled == false) {
return;
}
if (false == defined('WPSC_DISABLE_COMPRESSION')) {
?>
<a name='rewrite'></a>
<fieldset class="options">
<h3><?php
_e('Super Cache Compression', 'wp-super-cache');
?>
</h3>
<form name="wp_manager" action="#rewrite" method="post">
<label><input type="radio" name="cache_compression" value="1" <?php
if ($cache_compression) {
echo "checked=checked";
}
?>
> <?php
_e('Enabled', 'wp-super-cache');
?>
</label>
<label><input type="radio" name="cache_compression" value="0" <?php
if (!$cache_compression) {
echo "checked=checked";
}
?>
> <?php
_e('Disabled', 'wp-super-cache');
?>
</label>
<p><?php
_e('Compression is disabled by default because some hosts have problems with compressed files. Switching this on and off clears the cache.', 'wp-super-cache');
?>
</p>
<?php
if (isset($cache_compression_changed) && isset($_POST['cache_compression']) && !$cache_compression) {
?>
<p><strong><?php
_e('Super Cache compression is now disabled.', 'wp-super-cache');
?>
</strong></p> <?php
} elseif (isset($cache_compression_changed) && isset($_POST['cache_compression']) && $cache_compression) {
?>
<p><strong><?php
_e('Super Cache compression is now enabled.', 'wps-uper-cache');
?>
</strong></p><?php
}
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __('Update Compression', 'wp-super-cache') . ' »" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
?>
</fieldset>
<?php
}
?>
<a name="modrewrite"></a><fieldset class="options">
<h3><?php
_e('Mod Rewrite Rules', 'wp-super-cache');
?>
</h3><?php
if (isset($_SERVER["PHP_DOCUMENT_ROOT"])) {
$document_root = $_SERVER["PHP_DOCUMENT_ROOT"];
$apache_root = $_SERVER["PHP_DOCUMENT_ROOT"];
} else {
$document_root = $_SERVER["DOCUMENT_ROOT"];
$apache_root = '%{DOCUMENT_ROOT}';
}
$home_path = get_home_path();
$home_root = parse_url(get_bloginfo('url'));
$home_root = isset($home_root['path']) ? trailingslashit($home_root['path']) : '/';
$inst_root = str_replace('//', '/', '/' . trailingslashit(str_replace($document_root, '', str_replace('\\', '/', WP_CONTENT_DIR))));
$wprules = implode("\n", extract_from_markers($home_path . '.htaccess', 'WordPress'));
$wprules = str_replace("RewriteEngine On\n", '', $wprules);
$wprules = str_replace("RewriteBase {$home_root}\n", '', $wprules);
$scrules = implode("\n", extract_from_markers($home_path . '.htaccess', 'WPSuperCache'));
if (substr(get_option('permalink_structure'), -1) == '/') {
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]\$";
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*\$";
}
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
$condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*";
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*\$";
$condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(Android|2.0\\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\\ Wii|Nitro|Nokia|Opera\\ Mini|Palm|Playstation\\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\\ CE|WinWAP).*";
//.........这里部分代码省略.........
开发者ID:jeremylightsmith,项目名称:blog,代码行数:101,代码来源:wp-cache.php
示例8: wpsc_get_htaccess_info
function wpsc_get_htaccess_info()
{
global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers;
if (isset($_SERVER["PHP_DOCUMENT_ROOT"])) {
$document_root = $_SERVER["PHP_DOCUMENT_ROOT"];
$apache_root = $_SERVER["PHP_DOCUMENT_ROOT"];
} else {
$document_root = $_SERVER["DOCUMENT_ROOT"];
$apache_root = '%{DOCUMENT_ROOT}';
}
$content_dir_root = $document_root;
if (strpos($document_root, '/kunden/') === 0) {
// http://wordpress.org/support/topic/plugin-wp-super-cache-how-to-get-mod_rewrite-working-on-1and1-shared-hosting?replies=1
// On 1and1, PHP's directory structure starts with '/homepages'. The
// Apache directory structure has an extra '/kunden' before it.
// Also 1and1 does not support the %{DOCUMENT_ROOT} variable in
// .htaccess files.
// This prevents the $inst_root from being calculated correctly and
// means that the $apache_root is wrong.
//
// e.g. This is an example of how Apache and PHP see the directory
// structure on 1and1:
// Apache: /kunden/homepages/xx/dxxxxxxxx/htdocs/site1/index.html
// PHP: /homepages/xx/dxxxxxxxx/htdocs/site1/index.html
// Here we fix up the paths to make mode_rewrite work on 1and1 shared hosting.
$content_dir_root = substr($content_dir_root, 7);
$apache_root = $document_root;
}
$home_path = get_home_path();
$home_root = parse_url(get_bloginfo('url'));
$home_root = isset($home_root['path']) ? trailingslashit($home_root['path']) : '/';
$home_root_lc = str_replace('//', '/', strtolower($home_root));
$inst_root = str_replace('//', '/', '/' . trailingslashit(str_replace($content_dir_root, '', str_replace('\\', '/', WP_CONTENT_DIR))));
$wprules = implode("\n", extract_from_markers($home_path . '.htaccess', 'WordPress'));
$wprules = str_replace("RewriteEngine On\n", '', $wprules);
$wprules = str_replace("RewriteBase {$home_root}\n", '', $wprules);
$scrules = implode("\n", extract_from_markers($home_path . '.htaccess', 'WPSuperCache'));
if (substr(get_option('permalink_structure'), -1) == '/') {
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]\$";
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*\$";
}
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
$condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*";
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*\$";
$condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
$condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
if ($wp_cache_mobile_enabled) {
$condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes(implode('|', $wp_cache_mobile_browsers), ' ') . ").* [NC]";
$condition_rules[] = "RewriteCond %{HTTP_user_agent} !^(" . addcslashes(implode('|', $wp_cache_mobile_prefixes), ' ') . ").* [NC]";
}
$condition_rules = apply_filters('supercacherewriteconditions', $condition_rules);
$rules = "<IfModule mod_rewrite.c>\n";
$rules .= "RewriteEngine On\n";
$rules .= "RewriteBase {$home_root}\n";
// props Chris Messina
$rules .= "#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible\n";
$rules .= "CONDITION_RULES";
$rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
$rules .= "RewriteCond %{HTTPS} on\n";
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root_lc}\$1/index-https.html.gz -f\n";
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root_lc}\$1/index-https.html.gz\" [L]\n\n";
$rules .= "CONDITION_RULES";
$rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
$rules .= "RewriteCond %{HTTPS} !on\n";
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root_lc}\$1/index.html.gz -f\n";
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root_lc}\$1/index.html.gz\" [L]\n\n";
$rules .= "CONDITION_RULES";
$rules .= "RewriteCond %{HTTPS} on\n";
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root_lc}\$1/index-https.html -f\n";
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root_lc}\$1/index-https.html\" [L]\n\n";
$rules .= "CONDITION_RULES";
$rules .= "RewriteCond %{HTTPS} !on\n";
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root_lc}\$1/index.html -f\n";
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root_lc}\$1/index.html\" [L]\n";
$rules .= "</IfModule>\n";
$rules = apply_filters('supercacherewriterules', $rules);
$rules = str_replace("CONDITION_RULES", implode("\n", $condition_rules) . "\n", $rules);
$gziprules = "<IfModule mod_mime.c>\n <FilesMatch \"\\.html\\.gz\$\">\n ForceType text/html\n FileETag None\n </FilesMatch>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n";
$gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \\.gz\$ no-gzip\n</IfModule>\n";
$gziprules .= "<IfModule mod_headers.c>\n Header set Vary \"Accept-Encoding, Cookie\"\n Header set Cache-Control 'max-age=3, must-revalidate'\n</IfModule>\n";
$gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A3\n</IfModule>\n";
return array("document_root" => $document_root, "apache_root" => $apache_root, "home_path" => $home_path, "home_root" => $home_root, "home_root_lc" => $home_root_lc, "inst_root" => $inst_root, "wprules" => $wprules, "scrules" => $scrules, "condition_rules" => $condition_rules, "rules" => $rules, "gziprules" => $gziprules);
}
开发者ID:popovdenis,项目名称:kmst,代码行数:83,代码来源:wp-cache.php
示例9: upgrade
/**
* Upgrade
* Check options, perform any necessary data conversions
*/
public static function upgrade()
{
// Get the current version
$version = get_option('p3-profiler_version');
// Upgrading from < 1.1.0
if (empty($version) || version_compare($version, '1.1.0') < 0) {
update_option('p3-profiler_disable_opcode_cache', true);
update_option('p3-profiler_use_current_ip', true);
update_option('p3-profiler_ip_address', '');
update_option('p3-profiler_version', '1.1.0');
}
// Upgrading from < 1.1.2
if (empty($version) || version_compare($version, '1.1.2') < 0) {
update_option('p3-profiler_cache_buster', true);
update_option('p3-profiler_version', '1.1.2');
}
// Upgrading from < 1.2.0
if (empty($version) || version_compare($version, '1.2.0') < 0) {
// Set profiling option
update_option('p3-profiler_profiling_enabled', false);
update_option('p3-profiler_version', '1.2.0');
update_option('p3-profiler_debug', false);
update_option('p3-profiler_debug_log', array());
// Remove any .htaccess modifications
$file = ABSPATH . '/.htaccess';
if (file_exists($file) && array() !== extract_from_markers($file, 'p3-profiler')) {
insert_with_markers($file, 'p3-profiler', array('# removed during 1.2.0 upgrade'));
}
// Remove .profiling_enabled if it's still present
if (file_exists(P3_PATH . '/.profiling_enabled')) {
@unlink(P3_PATH . '/.profiling_enabled');
}
}
// Upgrading from < 1.3.0
if (empty($version) || version_compare($version, '1.3.0') < 0) {
update_option('p3-profiler_version', '1.3.0');
// Move to a serialized single option
$opts = array('profiling_enabled' => get_option('p3-profiler_profiling_enabled'), 'disable_opcode_cache' => get_option('p3-profiler_disable_opcode_cache'), 'use_current_ip' => get_option('p3-profiler_use_current_ip'), 'ip_address' => get_option('p3-profiler_ip_address'), 'cache_buster' => get_option('p3-profiler_cache_buster'), 'debug' => get_option('p3-profiler_debug'));
update_option('p3-profiler_options', $opts);
// Delete the extra options
delete_option('p3-profiler_disable_opcode_cache');
delete_option('p3-profiler_use_current_ip');
delete_option('p3-profiler_ip_address');
delete_option('p3-profiler_cache_buster');
delete_option('p3-profiler_debug');
delete_option('p3-profiler_profiling_enabled');
}
// Upgrading from < 1.5.0
if (empty($version) || version_compare($version, '1.5.0') < 0) {
update_option('p3-profiler_version', '1.5.0');
}
// Ensure the profiles folder is there
$uploads_dir = wp_upload_dir();
$folder = $uploads_dir['basedir'] . DIRECTORY_SEPARATOR . 'profiles';
self::make_profiles_folder($folder);
}
开发者ID:hkarriche,项目名称:wordpress,代码行数:60,代码来源:class.p3-profiler-plugin-admin.php
示例10: wpsc_get_htaccess_info
function wpsc_get_htaccess_info()
{
global $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers;
if (isset($_SERVER["PHP_DOCUMENT_ROOT"])) {
$document_root = $_SERVER["PHP_DOCUMENT_ROOT"];
$apache_root = $_SERVER["PHP_DOCUMENT_ROOT"];
} else {
$document_root = $_SERVER["DOCUMENT_ROOT"];
$apache_root = '%{DOCUMENT_ROOT}';
}
$home_path = get_home_path();
$home_root = parse_url(get_bloginfo('url'));
$home_root = isset($home_root['path']) ? trailingslashit($home_root['path']) : '/';
$inst_root = str_replace('//', '/', '/' . trailingslashit(str_replace($document_root, '', str_replace('\\', '/', WP_CONTENT_DIR))));
$wprules = implode("\n", extract_from_markers($home_path . '.htaccess', 'WordPress'));
$wprules = str_replace("RewriteEngine On\n", '', $wprules);
$wprules = str_replace("RewriteBase {$home_root}\n", '', $wprules);
$scrules = implode("\n", extract_from_markers($home_path . '.htaccess', 'WPSuperCache'));
if (substr(get_option('permalink_structure'), -1) == '/') {
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*[^/]\$";
$condition_rules[] = "RewriteCond %{REQUEST_URI} !^.*//.*\$";
}
$condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST";
$condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*";
$condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*\$";
$condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]";
$condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]";
$condition_rules[] = "RewriteCond %{HTTP_USER_AGENT} !^.*(" . addcslashes(implode('|', $wp_cache_mobile_browsers), ' ') . ").*";
$condition_rules[] = "RewriteCond %{HTTP_user_agent} !^(" . addcslashes(implode('|', $wp_cache_mobile_prefixes), ' ') . ").*";
$condition_rules = apply_filters('supercacherewriteconditions', $condition_rules);
$rules = "<IfModule mod_rewrite.c>\n";
$rules .= "RewriteEngine On\n";
$rules .= "RewriteBase {$home_root}\n";
// props Chris Messina
$charset = get_option('blog_charset') == '' ? 'UTF-8' : get_option('blog_charset');
$rules .= "AddDefaultCharset {$charset}\n";
$rules .= "CONDITION_RULES";
$rules .= "RewriteCond %{HTTP:Accept-Encoding} gzip\n";
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}\$1/index.html.gz -f\n";
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}\$1/index.html.gz\" [L]\n\n";
$rules .= "CONDITION_RULES";
$rules .= "RewriteCond {$apache_root}{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}\$1/index.html -f\n";
$rules .= "RewriteRule ^(.*) \"{$inst_root}cache/supercache/%{HTTP_HOST}{$home_root}\$1/index.html\" [L]\n";
$rules .= "</IfModule>\n";
$rules = apply_filters('supercacherewriterules', $rules);
$rules = str_replace("CONDITION_RULES", implode("\n", $condition_rules) . "\n", $rules);
$gziprules = "<IfModule mod_mime.c>\n <FilesMatch \"\\.html\\.gz\$\">\n ForceType text/html\n FileETag None\n </FilesMatch>\n AddEncoding gzip .gz\n AddType text/html .gz\n</IfModule>\n";
$gziprules .= "<IfModule mod_deflate.c>\n SetEnvIfNoCase Request_URI \\.gz\$ no-gzip\n</IfModule>\n";
$gziprules .= "<IfModule mod_headers.c>\n Header set Vary \"Accept-Encoding, Cookie\"\n Header set Cache-Control 'max-age=300, must-revalidate'\n</IfModule>\n";
$gziprules .= "<IfModule mod_expires.c>\n ExpiresActive On\n ExpiresByType text/html A300\n</IfModule>\n";
return array("document_root" => $document_root, "apache_root" => $apache_root, "home_path" => $home_path, "home_root" => $home_root, "inst_root" => $inst_root, "wprules" => $wprules, "scrules" => $scrules, "condition_rules" => $condition_rules, "rules" => $rules, "gziprules" => $gziprules);
}
开发者ID:hoonio,项目名称:wordpress,代码行数:52,代码来源:wp-cache.php
示例11: get_restrictions
function get_restrictions()
{
$htaccess_file = $this->get_htaccess();
return extract_from_markers($htaccess_file, 'e4d');
}
开发者ID:amgxyz,项目名称:geo-mashup-trail-story-add-on,代码行数:5,代码来源:require-email-for-download.php
示例12: bad_bots_201603
/**
* Remove overzealous 'DOC' entry which is causing false-positive bad
* bot blocking.
*/
function bad_bots_201603()
{
global $aiosp, $aioseop_options;
// Remove 'DOC' from bad bots list to avoid false positives
if (isset($aioseop_options['modules']['aiosp_bad_robots_options']['aiosp_bad_robots_blocklist'])) {
$list = $aioseop_options['modules']['aiosp_bad_robots_options']['aiosp_bad_robots_blocklist'];
$list = str_replace(array("DOC\r\n", "DOC\n"), '', $list);
$aioseop_options['modules']['aiosp_bad_robots_options']['aiosp_bad_robots_blocklist'] = $list;
update_option('aioseop_options', $aioseop_options);
$aiosp->update_class_option($aioseop_options);
if (isset($aioseop_options['modules']['aiosp_bad_robots_options']['aiosp_bad_robots_htaccess_rules']) && 'on' === $aioseop_options['modules']['aiosp_bad_robots_options']['aiosp_bad_robots_htaccess_rules']) {
if (!class_exists('All_in_One_SEO_Pack_Bad_Robots')) {
require_once AIOSEOP_PLUGIN_DIR . 'admin/aioseop_module_class.php';
require_once AIOSEOP_PLUGIN_DIR . 'modules/aioseop_bad_robots.php';
}
$aiosp_reset_htaccess = new All_in_One_SEO_Pack_Bad_Robots();
$aiosp_reset_htaccess->generate_htaccess_blocklist();
}
if (!isset($aioseop_options['modules']['aiosp_bad_robots_options']['aiosp_bad_robots_htaccess_rules']) && extract_from_markers(get_home_path() . '.htaccess', 'Bad Bot Blocker')) {
insert_with_markers(get_home_path() . '.htaccess', 'Bad Bot Blocker', '');
}
}
}
开发者ID:jun200,项目名称:wordpress,代码行数:27,代码来源:aioseop_updates_class.php
示例13: regenerate_htaccess_file
public static function regenerate_htaccess_file()
{
if (!function_exists('save_mod_rewrite_rules')) {
if (!function_exists('mysql2date')) {
require ABSPATH . '/wp-includes/functions.php';
}
if (!function_exists('get_home_path')) {
require ABSPATH . '/wp-admin/includes/file.php';
}
require ABSPATH . '/wp-admin/includes/misc.php';
}
global $is_nginx, $wp_rewrite;
$home_path = get_home_path();
$htaccess_file = $home_path . '.htaccess';
if (file_exists($htaccess_file)) {
unlink($htaccess_file);
}
$home_path = get_home_path();
$iis7_permalinks = iis7_supports_permalinks();
$prefix = $blog_prefix = '';
if (!got_url_rewrite()) {
$prefix = '/index.php';
}
if (is_multisite() && !is_subdomain_install() && is_main_site()) {
$blog_prefix = '/blog';
}
$permalink_structure = get_option('permalink_structure');
$category_base = get_option('category_base');
$tag_base = get_option('tag_base');
$update_required = false;
if ($iis7_permalinks) {
if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) {
$writable = true;
} else {
$writable = false;
}
} elseif ($is_nginx) {
$writable = false;
} else {
if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
$writable = true;
} else {
$writable = false;
$existing_rules = array_filter(extract_from_markers($home_path . '.htaccess', 'WordPress'));
$new_rules = array_filter(explode("\n", $wp_rewrite->mod_rewrite_rules()));
$update_required = $new_rules !== $existing_rules;
}
}
if ($wp_rewrite->using_index_permalinks()) {
$usingpi = true;
} else {
$usingpi = false;
}
flush_rewrite_rules();
save_mod_rewrite_rules();
}
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:56,代码来源:class-sb-core.php
示例14: WriteRobotsFile
/**
* Creates or opens the robots.txt in blog root and inserts the sitemap location
*
* @since 3.0b8
* @access private
* @author Arne Brachhold
* @return true on success
*/
function WriteRobotsFile()
{
$file = $this->GetRobotsFilePath();
$marker = 'XML-SITEMAP-PLUGIN';
$current = extract_from_markers($file, $marker);
if (is_array($current)) {
$current = $current[0];
}
$smUrl = $this->GetXmlUrl();
if ($this->IsGzipEnabled()) {
$smUrl = $this->GetZipUrl();
}
$new = "Sitemap: " . $smUrl;
if ($current != $new) {
if ($this->IsFileWritable($file)) {
return insert_with_markers($file, $marker, array($new));
} else {
return false;
}
}
return true;
}
开发者ID:prabhu,项目名称:desistartups,代码行数:30,代码来源:sitemap.php
示例15: get_option
$tag_base = get_option('tag_base');
$update_required = false;
if ($iis7_permalinks) {
if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) {
$writable = true;
} else {
$writable = false;
}
} elseif ($is_nginx) {
$writable = false;
} else {
if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
$writable = true;
} else {
$writable = false;
$existing_rules = array_filter(extract_from_markers($home_path . '.htaccess', 'WordPress'));
$new_rules = array_filter(explode("\n", $wp_rewrite->mod_rewrite_rules()));
$update_required = $new_rules !== $existing_rules;
}
}
if ($wp_rewrite->using_index_permalinks()) {
$usingpi = true;
} else {
$usingpi = false;
}
flush_rewrite_rules();
require ABSPATH . 'wp-admin/admin-header.php';
if (!empty($_GET['settings-updated'])) {
?>
<div id="message" class="updated notice is-dismissible"><p><?php
if (!is_multisite()) {
开发者ID:nmeiser,项目名称:WordPress,代码行数:31,代码来源:options-permalink.php
示例16: ewww_image_optimizer_webp_rewrite_verify
function ewww_image_optimizer_webp_rewrite_verify()
{
$current_rules = extract_from_markers(get_home_path() . '.htaccess', 'EWWWIO');
$ewww_rules = array("<IfModule mod_rewrite.c>", "RewriteEngine On", "RewriteCond %{HTTP_ACCEPT} image/webp", "RewriteCond %{REQUEST_FILENAME} (.*)\\.(jpe?g|png)\$", "RewriteCond %{REQUEST_FILENAME}.webp -f", "RewriteRule (.+)\\.(jpe?g|png)\$ %{REQUEST_FILENAME}.webp [T=image/webp,E=accept:1]", "</IfModule>", "<IfModule mod_headers.c>", "Header append Vary Accept env=REDIRECT_accept", "</IfModule>", "AddType image/webp .webp");
if (array_diff($ewww_rules, $current_rules)) {
ewwwio_memory(__FUNCTION__);
return $ewww_rules;
} else {
ewwwio_memory(__FUNCTION__);
return;
}
}
开发者ID:goodbayscott,项目名称:wwr-temp,代码行数:12,代码来源:common.php
示例17: show_browser_caching_field
public function show_browser_caching_field()
{
global $is_iis7, $is_apache;
if ($is_iis7) {
if (file_exists($this->_web_config_path) && is_readable($this->_web_config_path)) {
$caching = false !== strpos(file_get_contents($this->_web_config_path), '<urlCompression');
} else {
$caching = false;
}
} elseif ($is_apache) {
$caching = array() != extract_from_markers($this->_htaccess_path, 'wtwp_cache');
} else {
$caching = false;
}
?>
<fieldset>
<legend class="screen-reader-text browser-title">
<?php
_e('Browser caching rules', 'welcome-to-wordpress');
?>
</legend>
</fieldset>
<label for="wtwp_use_caching_rules" class="browser-label">
<input type="checkbox" id="wtwp_use_caching_rules" name="wtwp_use_caching_rules" <?php
disabled(!$is_iis7 && !$is_apache);
?>
<?php
checked($caching);
?>
/>
<?php
if ($is_iis7) {
?>
<?php
_e('Enable browser caching web.config rules', 'welcome-to-wordpress');
?>
<?php
} elseif ($is_apache) {
?>
<?php
_e('Enable browser caching .htaccess rules', 'welcome-to-wordpress');
?>
<?php
} else {
?>
<?php
_e('Browser caching rules are not available on this platform', 'welcome-to-wordpress');
?>
<?php
}
?>
</label>
<p class="description browser-de
|
请发表评论