返回介绍

save_mod_rewrite_rules()

发布于 2017-09-11 10:20:05 字数 1994 浏览 875 评论 0 收藏 0

save_mod_rewrite_rules()

Updates the htaccess file with the current rules if it is writable.


description

Always writes to the file if it exists and is writable to ensure that we blank out old rules.


源代码

File: wp-admin/includes/misc.php

function save_mod_rewrite_rules() {
	if ( is_multisite() )
		return;

	global $wp_rewrite;

	$home_path = get_home_path();
	$htaccess_file = $home_path.'.htaccess';

	/*
	 * If the file doesn't already exist check for write access to the directory
	 * and whether we have some rules. Else check for write access to the file.
	 */
	if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
		if ( got_mod_rewrite() ) {
			$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
			return insert_with_markers( $htaccess_file, 'WordPress', $rules );
		}
	}

	return false;
}

更新日志

Versiondescription
1.5.0Introduced.

相关函数

Uses

  • wp-admin/includes/misc.php: insert_with_markers()
  • wp-admin/includes/misc.php: got_mod_rewrite()
  • wp-admin/includes/file.php: get_home_path()
  • wp-includes/load.php: is_multisite()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::mod_rewrite_rules()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::using_mod_rewrite_permalinks()
  • Show 1 more use Hide more uses

Used By

  • wp-includes/class-wp-rewrite.php: WP_Rewrite::flush_rules()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文