PHP Класс WP_Customize_Nav_Menus, wordpress

Implements menu management in the Customizer.
См. также: WP_Customize_Manager
С версии: 4.3.0
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$manager WP_Customize_Manager WP_Customize_Manager instance.
$preview_nav_menu_instance_args array Nav menu args used for each instance, keyed by the args HMAC.
$previewed_menus array Previewed Menus.

Открытые методы

Метод Описание
__construct ( object $manager ) Constructor.
ajax_insert_auto_draft_post ( ) Ajax handler for adding a new auto-draft post.
ajax_load_available_items ( ) Ajax handler for loading available menu items.
ajax_search_available_items ( ) Ajax handler for searching available menu items.
available_item_types ( ) : array Return an array of all the available item types.
available_items_template ( ) Print the html template used to render the add-menu-item frame.
customize_dynamic_partial_args ( array | false $partial_args, string $partial_id ) : array Filters arguments for dynamic nav_menu selective refresh partials.
customize_preview_enqueue_deps ( ) Enqueue scripts for the Customizer preview.
customize_preview_init ( ) Add hooks for the Customizer preview.
customize_register ( ) Add the customizer settings and controls.
enqueue_scripts ( ) Enqueue scripts and styles for Customizer pane.
export_partial_rendered_nav_menu_instances ( array $response ) : array Export any wp_nav_menu() calls during the rendering of any partials.
export_preview_data ( ) Exports data from PHP to JS.
filter_dynamic_setting_args ( false | array $setting_args, string $setting_id ) : array | false Filters a dynamic setting's constructor args.
filter_dynamic_setting_class ( string $setting_class, string $setting_id, array $setting_args ) : string Allow non-statically created settings to be constructed with custom WP_Customize_Setting subclass.
filter_nonces ( array $nonces ) : array Adds a nonce for customizing menus.
filter_wp_nav_menu ( string $nav_menu_content, object $args ) : null Prepares wp_nav_menu() calls for partial refresh.
filter_wp_nav_menu_args ( array $args ) : array Keep track of the arguments that are being passed to wp_nav_menu().
hash_nav_menu_args ( array $args ) : string Hashes (hmac) the nav menu arguments to ensure they are not tampered with when submitted in the Ajax request.
insert_auto_draft_post ( array $postarr ) : WP_Post | WP_Error Add a new auto-draft post.
intval_base10 ( mixed $value ) : integer Get the base10 intval.
load_available_items_query ( string $type = 'post_type', string $object = 'page', integer $page ) : WP_Error | array Performs the post_type and taxonomy queries for loading available menu items.
make_auto_draft_status_previewable ( ) Make the auto-draft status protected so that it can be queried.
print_templates ( ) Print the JavaScript templates used to render Menu Customizer components.
render_nav_menu_partial ( WP_Customize_Partial $partial, array $nav_menu_args ) : string | false Render a specific menu via wp_nav_menu() using the supplied arguments.
sanitize_nav_menus_created_posts ( array $value ) Sanitize post IDs for auto-draft posts created for nav menu items to be published.
save_nav_menus_created_posts ( WP_Customize_Setting $setting ) Publish the auto-draft posts that were created for nav menu items.
search_available_items_query ( array $args = [] ) : array Performs post queries for available-item searching.

Защищенные методы

Метод Описание
print_custom_links_available_menu_item ( ) : void Print the markup for available menu item custom links.
print_post_type_container ( array $available_item_type ) : void Print the markup for new menu items.

Описание методов

__construct() публичный Метод

Constructor.
С версии: 4.3.0
public __construct ( object $manager )
$manager object An instance of the WP_Customize_Manager class.

ajax_insert_auto_draft_post() публичный Метод

Ajax handler for adding a new auto-draft post.
С версии: 4.7.0

ajax_load_available_items() публичный Метод

Ajax handler for loading available menu items.
С версии: 4.3.0

ajax_search_available_items() публичный Метод

Ajax handler for searching available menu items.
С версии: 4.3.0

available_item_types() публичный Метод

Return an array of all the available item types.
С версии: 4.3.0
С версии: 4.7.0 Each array item now includes a `$type_label` in in addition to `$title`, `$type`, and `$object`.
public available_item_types ( ) : array
Результат array The available menu item types.

available_items_template() публичный Метод

Print the html template used to render the add-menu-item frame.
С версии: 4.3.0

customize_dynamic_partial_args() публичный Метод

Filters arguments for dynamic nav_menu selective refresh partials.
С версии: 4.5.0
public customize_dynamic_partial_args ( array | false $partial_args, string $partial_id ) : array
$partial_args array | false Partial args.
$partial_id string Partial ID.
Результат array Partial args.

customize_preview_enqueue_deps() публичный Метод

Enqueue scripts for the Customizer preview.
С версии: 4.3.0

customize_preview_init() публичный Метод

Add hooks for the Customizer preview.
С версии: 4.3.0

customize_register() публичный Метод

Add the customizer settings and controls.
С версии: 4.3.0
public customize_register ( )

enqueue_scripts() публичный Метод

Enqueue scripts and styles for Customizer pane.
С версии: 4.3.0
public enqueue_scripts ( )

export_partial_rendered_nav_menu_instances() публичный Метод

Export any wp_nav_menu() calls during the rendering of any partials.
С версии: 4.5.0
public export_partial_rendered_nav_menu_instances ( array $response ) : array
$response array Response.
Результат array Response.

export_preview_data() публичный Метод

Exports data from PHP to JS.
С версии: 4.3.0
public export_preview_data ( )

filter_dynamic_setting_args() публичный Метод

For a dynamic setting to be registered, this filter must be employed to override the default false value with an array of args to pass to the WP_Customize_Setting constructor.
С версии: 4.3.0
public filter_dynamic_setting_args ( false | array $setting_args, string $setting_id ) : array | false
$setting_args false | array The arguments to the WP_Customize_Setting constructor.
$setting_id string ID for dynamic setting, usually coming from `$_POST['customized']`.
Результат array | false

filter_dynamic_setting_class() публичный Метод

Allow non-statically created settings to be constructed with custom WP_Customize_Setting subclass.
С версии: 4.3.0
public filter_dynamic_setting_class ( string $setting_class, string $setting_id, array $setting_args ) : string
$setting_class string WP_Customize_Setting or a subclass.
$setting_id string ID for dynamic setting, usually coming from `$_POST['customized']`.
$setting_args array WP_Customize_Setting or a subclass.
Результат string

filter_nonces() публичный Метод

Adds a nonce for customizing menus.
С версии: 4.5.0
public filter_nonces ( array $nonces ) : array
$nonces array Array of nonces.
Результат array $nonces Modified array of nonces.

filter_wp_nav_menu() публичный Метод

Injects attributes into container element.
См. также: wp_nav_menu()
С версии: 4.3.0
public filter_wp_nav_menu ( string $nav_menu_content, object $args ) : null
$nav_menu_content string The HTML content for the navigation menu.
$args object An object containing wp_nav_menu() arguments.
Результат null

filter_wp_nav_menu_args() публичный Метод

Keep track of the arguments that are being passed to wp_nav_menu().
См. также: wp_nav_menu()
См. также: WP_Customize_Widgets_Partial_Refresh::filter_dynamic_sidebar_params()
С версии: 4.3.0
public filter_wp_nav_menu_args ( array $args ) : array
$args array An array containing wp_nav_menu() arguments.
Результат array Arguments.

hash_nav_menu_args() публичный Метод

Note that the array is expected to be pre-sorted.
С версии: 4.3.0
public hash_nav_menu_args ( array $args ) : string
$args array The arguments to hash.
Результат string Hashed nav menu arguments.

insert_auto_draft_post() публичный Метод

Add a new auto-draft post.
С версии: 4.7.0
public insert_auto_draft_post ( array $postarr ) : WP_Post | WP_Error
$postarr array { Post array. Note that post_status is overridden to be `auto-draft`. @var string $post_title Post title. Required. @var string $post_type Post type. Required. @var string $post_name Post name. @var string $post_content Post content. }
Результат WP_Post | WP_Error Inserted auto-draft post object or error.

intval_base10() публичный Метод

This is used as a setting's sanitize_callback; we can't use just plain intval because the second argument is not what intval() expects.
С версии: 4.3.0
public intval_base10 ( mixed $value ) : integer
$value mixed Number to convert.
Результат integer Integer.

load_available_items_query() публичный Метод

Performs the post_type and taxonomy queries for loading available menu items.
С версии: 4.3.0
public load_available_items_query ( string $type = 'post_type', string $object = 'page', integer $page ) : WP_Error | array
$type string Optional. Accepts any custom object type and has built-in support for 'post_type' and 'taxonomy'. Default is 'post_type'.
$object string Optional. Accepts any registered taxonomy or post type name. Default is 'page'.
$page integer Optional. The page number used to generate the query offset. Default is '0'.
Результат WP_Error | array Returns either a WP_Error object or an array of menu items.

make_auto_draft_status_previewable() публичный Метод

Make the auto-draft status protected so that it can be queried.
С версии: 4.7.0

print_post_type_container() защищенный Метод

To be used in the template #available-menu-items.
С версии: 4.7.0
protected print_post_type_container ( array $available_item_type ) : void
$available_item_type array Menu item data to output, including title, type, and label.
Результат void

print_templates() публичный Метод

Templates are imported into the JS use wp.template.
С версии: 4.3.0
public print_templates ( )

render_nav_menu_partial() публичный Метод

Render a specific menu via wp_nav_menu() using the supplied arguments.
См. также: wp_nav_menu()
С версии: 4.3.0
public render_nav_menu_partial ( WP_Customize_Partial $partial, array $nav_menu_args ) : string | false
$partial WP_Customize_Partial Partial.
$nav_menu_args array Nav menu args supplied as container context.
Результат string | false

sanitize_nav_menus_created_posts() публичный Метод

Sanitize post IDs for auto-draft posts created for nav menu items to be published.
С версии: 4.7.0
public sanitize_nav_menus_created_posts ( array $value )
$value array Post IDs.

save_nav_menus_created_posts() публичный Метод

The post IDs will have been sanitized by already by WP_Customize_Nav_Menu_Items::sanitize_nav_menus_created_posts() to remove any post IDs for which the user cannot publish or for which the post is not an auto-draft.
С версии: 4.7.0
public save_nav_menus_created_posts ( WP_Customize_Setting $setting )
$setting WP_Customize_Setting Customizer setting object.

search_available_items_query() публичный Метод

Based on WP_Editor::wp_link_query().
С версии: 4.3.0
public search_available_items_query ( array $args = [] ) : array
$args array Optional. Accepts 'pagenum' and 's' (search) arguments.
Результат array Menu items.

Описание свойств

$manager публичное свойство

WP_Customize_Manager instance.
С версии: 4.3.0
public WP_Customize_Manager $manager
Результат WP_Customize_Manager

$preview_nav_menu_instance_args публичное свойство

Nav menu args used for each instance, keyed by the args HMAC.
С версии: 4.3.0
public array $preview_nav_menu_instance_args
Результат array

$previewed_menus публичное свойство

Previewed Menus.
С версии: 4.3.0
public array $previewed_menus
Результат array