функция
since 1.5.0
save_mod_rewrite_rules()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
save_mod_rewrite_rules(): bool|null
Описание
Всегда выполняет запись в файл, если он существует и доступен для записи, чтобы гарантированно очистить старые правила.
Оригинал (английский)
Always writes to the file if it exists and is writable to ensure that we blank out old rules.
Возвращаемое значение
bool|null
Исходный код
wp-admin/includes/misc.php:262
function save_mod_rewrite_rules() {
global $wp_rewrite;
if ( is_multisite() ) {
return null;
}
// Ensure get_home_path() is declared.
require_once ABSPATH . 'wp-admin/includes/file.php';
$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;
}
История изменений
| Версия | Описание |
|---|---|
| 1.5.0 | Introduced. |

