wpseo_save_what()
Save titles & descriptions.
Хуков нет.
Возвращает
null. Ничего (null).
Использование
wpseo_save_what( $what );
- $what(строка) (обязательный)
- Type of item to save (title, description).
Код wpseo_save_what() wpseo save what Yoast 26.3
function wpseo_save_what( $what ) {
check_ajax_referer( 'wpseo-bulk-editor' );
if ( ! isset( $_POST['new_value'], $_POST['wpseo_post_id'], $_POST['existing_value'] ) || ! is_string( $_POST['new_value'] ) || ! is_string( $_POST['existing_value'] ) ) {
exit( '-1' );
}
$new = sanitize_text_field( wp_unslash( $_POST['new_value'] ) );
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are casting the unsafe value to an integer.
$post_id = (int) wp_unslash( $_POST['wpseo_post_id'] );
$original = sanitize_text_field( wp_unslash( $_POST['existing_value'] ) );
if ( $post_id === 0 ) {
exit( '-1' );
}
$results = wpseo_upsert_new( $what, $post_id, $new, $original );
wpseo_ajax_json_echo_die( $results );
}