WP_Rewrite::refresh_rewrite_rules()privateWP 6.4.0

Refreshes the rewrite rules, saving the fresh value to the database.

If the wp_loaded action has not occurred yet, will postpone saving to the database.

Метод класса: WP_Rewrite{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->refresh_rewrite_rules();

Список изменений

С версии 6.4.0 Введена.

Код WP_Rewrite::refresh_rewrite_rules() WP 6.7.1

private function refresh_rewrite_rules() {
	$this->rules   = '';
	$this->matches = 'matches';

	$this->rewrite_rules();

	if ( ! did_action( 'wp_loaded' ) ) {
		/*
		 * It is not safe to save the results right now, as the rules may be partial.
		 * Need to give all rules the chance to register.
		 */
		add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
	} else {
		update_option( 'rewrite_rules', $this->rules );
	}
}