iis7_delete_rewrite_rule() - WordPress 函数参考中文文档

返回介绍

iis7_delete_rewrite_rule()

发布于 2017-09-11 字数1897 浏览 923 评论 0

iis7_delete_rewrite_rule( string $filename )

Delete WordPress rewrite rule from web.config file if it exists there


描述


参数

$filename

(string)
(Required)
Name of the configuration file


返回值

(bool)


源代码

File: wp-admin/includes/misc.php

function iis7_delete_rewrite_rule($filename) {
	// If configuration file does not exist then rules also do not exist so there is nothing to delete
	if ( ! file_exists($filename) )
		return true;

	if ( ! class_exists( 'DOMDocument', false ) ) {
		return false;
	}

	$doc = new DOMDocument();
	$doc->preserveWhiteSpace = false;

	if ( $doc -> load($filename) === false )
		return false;
	$xpath = new DOMXPath($doc);
	$rules = $xpath->query('/configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'wordpress\')] | /configuration/system.webServer/rewrite/rules/rule[starts-with(@name,\'WordPress\')]');
	if ( $rules->length > 0 ) {
		$child = $rules->item(0);
		$parent = $child->parentNode;
		$parent->removeChild($child);
		$doc->formatOutput = true;
		saveDomDocument($doc, $filename);
	}
	return true;
}

更新日志

Version 描述
2.8.0 Introduced.

相关函数

Uses

  • wp-admin/includes/misc.php:
    saveDomDocument()

Used By

  • wp-admin/includes/misc.php:
    iis7_save_url_rewrite_rules()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!