WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Customize_Manager::grant_edit_post_capability_for_changeset() public WP 4.9.0

Re-map 'edit_post' meta cap for a customize_changeset post to be the same as 'customize' maps.

There is essentially a "meta meta" cap in play here, where 'edit_post' meta cap maps to the 'customize' meta cap which then maps to 'edit_theme_options'. This is currently required in core for wp_create_post_autosave() because it will call _wp_translate_postdata() which in turn will check if a user can 'edit_post', but the the caps for the customize_changeset post type are all mapping to the meta capability. This should be able to be removed once #40922 is addressed in core.

{} Это метод класса: WP_Customize_Manager{}

Хуков нет.

Возвращает

Массив. Capabilities.

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

$WP_Customize_Manager = new WP_Customize_Manager();
$WP_Customize_Manager->grant_edit_post_capability_for_changeset( $caps, $cap, $user_id, $args );
$caps(строка[]) (обязательный)
Array of the user's capabilities.
$cap(строка) (обязательный)
Capability name.
$user_id(число) (обязательный)
The user ID.
$args(массив) (обязательный)
Adds the context to the cap. Typically the object ID.

Заметки

  • Смотрите: WP_Customize_Manager::save_changeset_post()
  • Смотрите: _wp_translate_postdata()

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

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

Код WP_Customize_Manager::grant_edit_post_capability_for_changeset() WP 5.5.3

<?php
public function grant_edit_post_capability_for_changeset( $caps, $cap, $user_id, $args ) {
	if ( 'edit_post' === $cap && ! empty( $args[0] ) && 'customize_changeset' === get_post_type( $args[0] ) ) {
		$post_type_obj = get_post_type_object( 'customize_changeset' );
		$caps          = map_meta_cap( $post_type_obj->cap->$cap, $user_id );
	}
	return $caps;
}