本文整理汇总了PHP中insert_with_markers函数的典型用法代码示例。如果您正苦于以下问题:PHP insert_with_markers函数的具体用法?PHP insert_with_markers怎么用?PHP insert_with_markers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了insert_with_markers函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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', '');
}
}
}
}
}
}
示例2: job_board_rewrite
/**
* job_board_rewrite function.
*
* @access public
* @return void
*/
public function job_board_rewrite()
{
if (!function_exists('get_home_path')) {
require_once ABSPATH . 'wp-admin/includes/file.php';
}
$root_path = get_home_path();
$file_existing_permission = '';
/* Getting Rules */
$rules = 'yes' === get_option('job_board_anti_hotlinking') ? $this->job_board_rewrite_rules() : '';
/* Rules Force Files to be Downloaded */
$forcedownload_rule = "AddType application/octet-stream .pdf .txt\n";
/* Changing File to Writable Mode */
if (file_exists($root_path . '.htaccess') && !is_writable($root_path . '.htaccess')) {
$file_existing_permission = substr(decoct(fileperms($root_path . '.htaccess')), -4);
chmod($root_path . '.htaccess', 0777);
}
/* Appending .htaccess */
if (file_exists($root_path . '.htaccess') && is_writable($root_path . '.htaccess')) {
$rules = explode("\n", $rules);
$forcedownload_rule = explode("\n", $forcedownload_rule);
// Anti-Hotlinking Rules Writing in .htaccess file
if (!function_exists('insert_with_markers')) {
require_once ABSPATH . 'wp-admin/includes/misc.php';
}
insert_with_markers($root_path . '.htaccess', 'Hotlinking', $rules);
// Force Download Rules Writing in .htaccess file
insert_with_markers($root_path . '.htaccess', 'Force Download', $forcedownload_rule);
/* Revert File Permission */
if (!empty($file_existing_permission)) {
chmod($root_path . '.htaccess', $file_existing_permission);
}
}
}
示例3: custom_admin_url
function custom_admin_url()
{
if (isset($_POST['custom_wpadmin_slug'])) {
// sanitize input
$wpadmin_slug = trim(sanitize_key(wp_strip_all_tags($_POST['custom_wpadmin_slug'])));
$home_path = get_home_path();
// check if permalinks are turned off, if so force push rules to .htaccess
if (isset($_POST['selection']) && $_POST['selection'] == '' && $wpadmin_slug != '') {
// check if .htaccess is writable
if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
// taken from wp-includes/rewrite.php
$home_root = parse_url(home_url());
if (isset($home_root['path'])) {
$home_root = trailingslashit($home_root['path']);
} else {
$home_root = '/';
}
// create rules
$rules = "<IfModule mod_rewrite.c>\n";
$rules .= "RewriteEngine On\n";
$rules .= "RewriteRule ^{$wpadmin_slug}/?\$ " . $home_root . "wp-login.php [QSA,L]\n";
$rules .= "</IfModule>";
// write to .htaccess
insert_with_markers($home_path . '.htaccess', 'WPAdminURL', explode("\n", $rules));
}
} else {
if (isset($_POST['selection']) || isset($_POST['selection']) && $_POST['selection'] == '' && $wpadmin_slug == '') {
// remove rules if permalinks were enabled
$markerdata = explode("\n", implode('', file($home_path . '.htaccess')));
$found = false;
$newdata = '';
foreach ($markerdata as $line) {
if ($line == '# BEGIN WPAdminURL') {
$found = true;
}
if (!$found) {
$newdata .= "{$line}\n";
}
if ($line == '# END WPAdminURL') {
$found = false;
}
}
// write back
$f = @fopen($home_path . '.htaccess', 'w');
fwrite($f, $newdata);
}
}
// save to db
update_option('custom_wpadmin_slug', $wpadmin_slug);
// write rewrite rules right away
if ($wpadmin_slug != '') {
add_rewrite_rule($wpadmin_slug . '/?$', 'wp-login.php', 'top');
} else {
flush_rewrite_rules();
}
}
add_settings_field('custom_wpadmin_slug', 'WP-Admin slug', array($this, 'options_page'), 'permalink', 'optional', array('label_for' => 'custom_wpadmin_slug'));
register_setting('permalink', 'custom_wpadmin_slug', 'strval');
}
示例4: 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));
}
}
示例5: insert_with_markers
function insert_with_markers($file_path, $marker_text, $insertion)
{
if (!function_exists('insert_with_markers')) {
if (file_exists(ABSPATH . '/wp-admin/includes/misc.php')) {
include_once ABSPATH . '/wp-admin/includes/misc.php';
} else {
return;
}
}
if ($insertion || file_exists($file_path)) {
insert_with_markers($file_path, $marker_text, explode("\n", $insertion));
}
}
示例6: handle_rhc_uninstall
function handle_rhc_uninstall()
{
$WP_Roles = new WP_Roles();
foreach (array('calendarize_author', 'edit_' . RHC_CAPABILITY_TYPE, 'read_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE . 's', 'edit_' . RHC_CAPABILITY_TYPE . 's', 'edit_others_' . RHC_CAPABILITY_TYPE . 's', 'edit_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_private_' . RHC_CAPABILITY_TYPE . 's', 'delete_others_' . RHC_CAPABILITY_TYPE . 's', 'publish_' . RHC_CAPABILITY_TYPE . 's', 'read_private_' . RHC_CAPABILITY_TYPE . 's', 'manage_' . RHC_VENUE, 'manage_' . RHC_CALENDAR, 'manage_' . RHC_ORGANIZER) as $cap) {
$WP_Roles->remove_cap(RHC_ADMIN_ROLE, $cap);
}
//-----
delete_site_transient('update_plugins');
delete_option('rhc_dismiss_help_notice');
$filename = get_home_path() . '.htaccess';
if (file_exists($filename)) {
insert_with_markers($filename, 'RHC', array());
}
}
示例7: groundup_compression
function groundup_compression($rewrites)
{
global $wp_rewrite;
$mod_rewrite_enabled = function_exists('got_mod_rewrite') ? got_mod_rewrite() : false;
$home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
$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 ($mod_rewrite_enabled) {
$gzip = "<IfModule mod_headers.c>\n\t# Make sure proxies don't deliver the wrong content\n\tHeader append Vary User-Agent env=!dont-vary\n\t</IfModule>\n\t<IfModule mod_deflate.c>\n\t# Insert filters\n\tAddOutputFilterByType DEFLATE text/plain\n\tAddOutputFilterByType DEFLATE text/html\n\tAddOutputFilterByType DEFLATE text/xml\n\tAddOutputFilterByType DEFLATE text/css\n\tAddOutputFilterByType DEFLATE text/javascript\n\tAddOutputFilterByType DEFLATE application/xml\n\tAddOutputFilterByType DEFLATE application/xhtmlxml\n\tAddOutputFilterByType DEFLATE application/rssxml\n\tAddOutputFilterByType DEFLATE application/javascript\n\tAddOutputFilterByType DEFLATE application/x-javascript\n\tAddOutputFilterByType DEFLATE application/json\n\tAddOutputFilterByType DEFLATE application/x-json\n\tAddOutputFilterByType DEFLATE application/x-httpd-php\n\tAddOutputFilterByType DEFLATE application/x-httpd-fastphp\n\tAddOutputFilterByType DEFLATE image/svgxml\n\t# Drop problematic browsers\n\tBrowserMatch ^Mozilla/4 gzip-only-text/html\n\tBrowserMatch ^Mozilla/4\\.0[678] no-gzip\n\t# IE5.x and IE6 get no gzip, but 7 should\n\tBrowserMatch \\bMSIE\\s[789] !no-gzip !gzip-only-text/html\n\t# IE 6.0 after SP2 has no gzip bugs\n\tBrowserMatch \\bMSIE.SV !no-gzip\n\t# Opera occasionally pretends to be IE with Mozilla/4.0\n\tBrowserMatch \\bOpera !no-gzip\n\t</IfModule>";
$gzip = explode("\n", $gzip);
return insert_with_markers($htaccess_file, 'gzip', $gzip);
}
}
return $rewrites;
}
示例8: 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;
}
示例9: 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;
}
示例10: insert_with_markers
function insert_with_markers($file_path, $marker_text, $insertion)
{
if (!function_exists('insert_with_markers')) {
if (file_exists(ABSPATH . '/wp-admin/includes/misc.php')) {
include_once ABSPATH . '/wp-admin/includes/misc.php';
} else {
return;
}
}
if ($insertion || file_exists($file_path)) {
if (!$insertion) {
// if no insertion and no existing entry, don't mess
$htcontent = file_get_contents($file_path);
if (false === strpos($htcontent, $marker_text)) {
return;
}
}
insert_with_markers($file_path, $marker_text, explode("\n", $insertion));
}
}
示例11: _remove_htaccess_security
/**
* Remove security rules from .htaccess
* @return void
*/
protected function _remove_htaccess_security()
{
if (!insert_with_markers($this->_htaccess_path, 'wtwp_security', array())) {
return new WP_Error('generic', sprintf(__('Failed to update %s', 'welcome-to-wordpress'), $this->_htaccess_path));
}
return true;
}
示例12: wsc_mod_rewrite
//.........这里部分代码省略.........
$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);
$dohtaccess = true;
if (function_exists('is_site_admin')) {
echo "<h4 style='color: #a00'>" . __('WordPress MU Detected', 'wp-super-cache') . "</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.", 'wp-super-cache') . "</p>";
} elseif (!$wprules || $wprules == '') {
echo "<h4 style='color: #a00'>" . __('Mod Rewrite rules cannot be updated!', 'wp-super-cache') . "</h4>";
echo "<p>" . sprintf(__("You must have <strong>BEGIN</strong> and <strong>END</strong> markers in %s.htaccess for the auto update to work. They look like this and surround the main WordPress mod_rewrite rules:", 'wp-super-cache'), $home_path);
echo "<blockquote><pre><em># BEGIN WordPress</em>\n RewriteCond %{REQUEST_FILENAME} !-f\n RewriteCond %{REQUEST_FILENAME} !-d\n RewriteRule . /index.php [L]\n <em># END WordPress</em></pre></blockquote>";
_e('Refresh this page when you have updated your .htaccess file.', 'wp-super-cache');
echo "</fieldset></div>";
return;
} elseif (strpos($wprules, 'wordpressuser')) {
// Need to clear out old mod_rewrite rules
echo "<p><strong>" . __('Thank you for upgrading.', 'wp-super-cache') . "</strong> " . sprintf(__('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: %1$s so it looks like this: %2$s 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.', 'wp-super-cache'), '<blockquote><code>RewriteCond %{HTTP_COOKIE} !^.*wordpressuser.*$</code></blockquote>', '<blockquote><code>RewriteCond %{HTTP:Cookie} !^.*wordpress.*$</code></blockquote>') . "</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:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __('Trailing slash check required.', 'wp-super-cache') . "</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. To fix, you must edit your .htaccess file and add these two rules to the two groups of Super Cache rules:', 'wp-super-cache') . "</p>";
echo "<blockquote><code>RewriteCond %{REQUEST_URI} !^.*[^/]{$RewriteCond} %{REQUEST_URI} !^.*//.*\$</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.', 'wp-super-cache') . "</p></div>";
$dohtaccess = false;
} elseif (strpos($scrules, 'supercache') || strpos($wprules, 'supercache')) {
// only write the rules once
$dohtaccess = false;
}
// cache/.htaccess 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";
if ($dohtaccess && !$_POST['updatehtaccess']) {
if (!is_writeable_ACLSafe($home_path . ".htaccess")) {
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h4>" . __('Cannot update .htaccess', 'wp-super-cache') . "</h4><p>" . sprintf(__('The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache'), $home_path) . "</p><p>" . __('Refresh this page when the file permissions have been modified.') . "</p><p>" . sprintf(__('Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache'), $home_path) . "</p>";
echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars($rules) . "# END WPSuperCache</pre></p></div>";
} else {
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><p>" . sprintf(__('To serve static html files your server must have the correct mod_rewrite rules added to a file called <code>%s.htaccess</code>', 'wp-super-cache'), $home_path) . " ";
if (!function_exists('is_site_admin')) {
_e("You must edit the file yourself add the following rules.", 'wp-super-cache');
} else {
_e("You can edit the file yourself add the following rules.", 'wp-super-cache');
}
echo __(" Make sure they appear before any existing WordPress rules. ", 'wp-super-cache') . "</p>";
echo "<pre># BEGIN WPSuperCache\n" . wp_specialchars($rules) . "# END WPSuperCache</pre></p>";
echo "<p>" . sprintf(__('Rules must be added to %s too:', 'wp-super-cache'), WP_CONTENT_DIR . "/cache/.htaccess") . "</p>";
echo "<pre># BEGIN supercache\n" . wp_specialchars($gziprules) . "# END supercache</pre></p>";
if (!function_exists('is_site_admin')) {
echo '<form name="updatehtaccess" action="#modrewrite" method="post">';
echo '<input type="hidden" name="updatehtaccess" value="1" />';
echo '<div class="submit"><input type="submit" ' . SUBMITDISABLED . 'id="updatehtaccess" value="' . __('Update Mod_Rewrite Rules', 'wp-super-cache') . ' »" /></div>';
wp_nonce_field('wp-cache');
echo "</form></div>\n";
}
}
} elseif ($dohtaccess && $valid_nonce && $_POST['updatehtaccess']) {
wpsc_remove_marker($home_path . '.htaccess', 'WordPress');
// remove original WP rules so SuperCache rules go on top
echo "<div style='padding:0 8px;color:#4f8a10;background-color:#dff2bf;border:1px solid #4f8a10;'>";
if (insert_with_markers($home_path . '.htaccess', 'WPSuperCache', explode("\n", $rules)) && insert_with_markers($home_path . '.htaccess', 'WordPress', explode("\n", $wprules))) {
echo "<h4>" . __('Mod Rewrite rules updated!', 'wp-super-cache') . "</h4>";
echo "<p><strong>" . sprintf(__('%s.htaccess has been updated with the necessary mod_rewrite rules. Please verify they are correct. They should look like this:', 'wp-super-cache'), $home_path) . "</strong></p>\n";
} else {
echo "<h4>" . __('Mod Rewrite rules must be updated!', 'wp-super-cache') . "</h4>";
echo "<p><strong>" . sprintf(__('Your %s.htaccess is not writable by the webserver and must be updated with the necessary mod_rewrite rules. The new rules go above the regular WordPress rules as shown in the code below:', 'wp-super-cache'), $home_path) . "</strong></p>\n";
}
echo "<p><pre>" . wp_specialchars($rules) . "</pre></p>\n</div>";
} else {
?>
<p><?php
printf(__('WP Super Cache mod rewrite rules were detected in your %s.htaccess file.<br /> Click the following link to see the lines added to that file. If you have upgraded the plugin make sure these rules match.', 'wp-super-cache'), $home_path);
?>
<br /><br />
<a href="javascript:toggleLayer('rewriterules');" class="button"><?php
_e('View Mod_Rewrite Rules', 'wp-super-cache');
?>
</a>
<div id='rewriterules' style='display: none;'>
<?php
echo "<p><pre># BEGIN WPSuperCache\n" . wp_specialchars($rules) . "# END WPSuperCache</pre></p>\n";
echo "<p>" . sprintf(__('Rules must be added to %s too:', 'wp-super-cache'), WP_CONTENT_DIR . "/cache/.htaccess") . "</p>";
echo "<pre># BEGIN supercache\n" . wp_specialchars($gziprules) . "# END supercache</pre></p>";
?>
</div>
<?php
}
// http://allmybrain.com/2007/11/08/making-wp-super-cache-gzip-compression-work/
if (!is_file($cache_path . '.htaccess')) {
$gziprules = insert_with_markers($cache_path . '.htaccess', 'supercache', explode("\n", $gziprules));
echo "<h4>" . sprintf(__('Gzip encoding rules in %s.htaccess created.', 'wp-super-cache'), $cache_path) . "</h4>";
}
?>
</fieldset><?php
}
示例13: save_file_cache
function save_file_cache()
{
if (iis7_supports_permalinks()) {
return;
}
global $rhc_plugin;
if ('1' == $rhc_plugin->get_option('file_cache', '', true)) {
$content = $this->get_htaccess();
$rules_arr = explode("\n", $content);
} else {
$rules_arr = array();
}
$filename = get_home_path() . '.htaccess';
if (file_exists($filename) && is_writeable($filename)) {
$str = file_get_contents($filename);
if (false === strpos($str, 'BEGIN RHC')) {
$prepend = "# BEGIN RHC\n";
$prepend .= "# END RHC\n";
$str = $prepend . $str;
file_put_contents($filename, $str);
}
}
insert_with_markers($filename, 'RHC', $rules_arr);
}
示例14: update_htaccess
function update_htaccess($hard = false)
{
if (defined('DOING_CRON') && DOING_CRON) {
return;
}
if ('hidden' === get_option('mainwp_child_pluginDir') && ($hard || 'yes' !== get_option('mainwp_child_htaccess_set'))) {
include_once ABSPATH . '/wp-admin/includes/misc.php';
$snPluginDir = basename($this->plugin_dir);
$rules = null;
if ('1' !== get_option('heatMapsIndividualOverrideSetting') && '0' !== get_option('heatMapEnabled') || '1' === get_option('heatMapsIndividualOverrideSetting') && '1' !== get_option('heatMapsIndividualDisable') || get_option('mainwp_kwl_enable_statistic')) {
//Heatmap enabled
//Make the plugin invisible, except heatmap
$rules = $this->mod_rewrite_rules(array('wp-content/plugins/' . $snPluginDir . '/([^js\\/]*)$' => 'wp-content/plugins/THIS_PLUGIN_DOES_NOT_EXIST'));
} else {
//Make the plugin invisible
$rules = $this->mod_rewrite_rules(array('wp-content/plugins/' . $snPluginDir . '/(.*)$' => 'wp-content/plugins/THIS_PLUGIN_DOES_NOT_EXIST'));
}
$home_path = ABSPATH;
$htaccess_file = $home_path . '.htaccess';
if (function_exists('save_mod_rewrite_rules')) {
$rules = explode("\n", $rules);
// $ch = @fopen($htaccess_file,'w');
// if (@flock($ch, LOCK_EX))
// {
insert_with_markers($htaccess_file, 'MainWP', $rules);
// }
// @flock($ch, LOCK_UN);
// @fclose($ch);
if (get_option('mainwp_child_onetime_htaccess') === false) {
MainWP_Helper::update_option('mainwp_child_onetime_htaccess', true);
}
}
MainWP_Helper::update_option('mainwp_child_htaccess_set', 'yes', 'yes');
} else {
if ($hard) {
include_once ABSPATH . '/wp-admin/includes/misc.php';
$home_path = ABSPATH;
$htaccess_file = $home_path . '.htaccess';
if (function_exists('save_mod_rewrite_rules')) {
$rules = explode("\n", '');
// $ch = @fopen($htaccess_file,'w');
// if (@flock($ch, LOCK_EX))
// {
insert_with_markers($htaccess_file, 'MainWP', $rules);
// }
// @flock($ch, LOCK_UN);
// @fclose($ch);
if (get_option('mainwp_child_onetime_htaccess') === false) {
MainWP_Helper::update_option('mainwp_child_onetime_htaccess', true);
}
}
}
}
}
示例15: wp_cache_disable_plugin
function wp_cache_disable_plugin()
{
global $wp_cache_config_file, $wp_rewrite;
if (file_exists(ABSPATH . 'wp-config.php')) {
$global_config_file = ABSPATH . 'wp-config.php';
} else {
$global_config_file = dirname(ABSPATH) . '/wp-config.php';
}
$line = 'define(\'WP_CACHE\', true);';
if (strpos(file_get_contents($global_config_file), $line) && (!is_writeable_ACLSafe($global_config_file) || !wp_cache_replace_line('define *\\( *\'WP_CACHE\'', '//' . $line, $global_config_file))) {
wp_die("Could not remove WP_CACHE define from {$global_config_file}. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page.");
}
uninstall_supercache(WP_CONTENT_DIR . '/cache');
$file_not_deleted = false;
if (@file_exists(WP_CONTENT_DIR . "/advanced-cache.php")) {
if (false == @unlink(WP_CONTENT_DIR . "/advanced-cache.php")) {
$file_not_deleted[] = 'advanced-cache.php';
}
}
if (@file_exists(WP_CONTENT_DIR . "/wp-cache-config.php")) {
if (false == unlink(WP_CONTENT_DIR . "/wp-cache-config.php")) {
$file_not_deleted[] = 'wp-cache-config.php';
}
}
if ($file_not_deleted) {
$msg = "<p>One or more files could not be deleted. These files and directories must be made writeable:</p>\n <ol><li>" . WP_CONTENT_DIR . "</li>\n";
$code = "<ul>\n";
foreach ((array) $file_not_deleted as $filename) {
$msg .= "<li>" . WP_CONTENT_DIR . "/{$filename}</li>";
$code .= "<li><code>chmod 666 " . WP_CONTENT_DIR . "/{$filename}</code></li>\n";
}
$code .= "</ul>\n";
$msg .= "</ol>\n<p>First try fixing the directory permissions with this command and refresh this page:<br /><br /><code>chmod 777 " . WP_CONTENT_DIR . "</code><br /><br />If you still see this error, you have to fix the permissions on the files themselves and refresh this page again:</p> {$code}\n<p>Don't forgot to fix things later:<br /><code>chmod 755 " . WP_CONTENT_DIR . "</code></p><p>If you don't know what <strong>chmod</strong> is use <a href='http://www.google.ie/search?hl=en&q=ftp+chmod+777'>this Google search</a> to find out all about it.</p><p>Please refresh this page when the permissions have been modified.</p>";
wp_die($msg);
}
extract(wpsc_get_htaccess_info());
if ($scrules != '' && insert_with_markers($home_path . '.htaccess', 'WPSuperCache', array())) {
$wp_rewrite->flush_rules();
} elseif ($scrules != '') {
wp_mail(get_option('admin_email'), __('Supercache Uninstall Problems', 'wp-super-cache'), sprintf(__("Dear User,\n\nWP Super Cache was removed from your blog but the mod_rewrite rules\nin your .htaccess were not.\n\nPlease edit the following file and remove the code\nbetween 'BEGIN WPSuperCache' and 'END WPSuperCache'. Please backup the file first!\n\n%s\n\nRegards,\nWP Super Cache Plugin\nhttp://wordpress.org/extend/plugins/wp-super-cache/", 'wp-super-cache'), ABSPATH . '/.htaccess'));
}
}