Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
< ? php
/**
* WordPress Customize Nav Menus classes
*
* @ package WordPress
* @ subpackage Customize
* @ since 4.3 . 0
*/
/**
* Customize Nav Menus class .
*
* Implements menu management in the Customizer .
*
* @ since 4.3 . 0
*
* @ see WP_Customize_Manager
*/
final class WP_Customize_Nav_Menus {
/**
* WP_Customize_Manager instance .
*
* @ since 4.3 . 0
* @ access public
* @ var WP_Customize_Manager
*/
public $manager ;
/**
* Previewed Menus .
*
* @ since 4.3 . 0
* @ access public
* @ var array
*/
public $previewed_menus ;
/**
* Constructor .
*
* @ since 4.3 . 0
* @ access public
2015-07-13 22:39:25 +02:00
*
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
* @ param object $manager An instance of the WP_Customize_Manager class .
*/
public function __construct ( $manager ) {
$this -> previewed_menus = array ();
$this -> manager = $manager ;
2016-02-22 06:31:27 +01:00
// Skip useless hooks when the user can't manage nav menus anyway.
if ( ! current_user_can ( 'edit_theme_options' ) ) {
return ;
}
2016-01-27 18:55:26 +01:00
add_filter ( 'customize_refresh_nonces' , array ( $this , 'filter_nonces' ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
add_action ( 'wp_ajax_load-available-menu-items-customizer' , array ( $this , 'ajax_load_available_items' ) );
add_action ( 'wp_ajax_search-available-menu-items-customizer' , array ( $this , 'ajax_search_available_items' ) );
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
add_action ( 'wp_ajax_customize-nav-menus-insert-auto-draft' , array ( $this , 'ajax_insert_auto_draft_post' ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
add_action ( 'customize_controls_enqueue_scripts' , array ( $this , 'enqueue_scripts' ) );
2015-07-13 22:39:25 +02:00
add_action ( 'customize_register' , array ( $this , 'customize_register' ), 11 );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
add_filter ( 'customize_dynamic_setting_args' , array ( $this , 'filter_dynamic_setting_args' ), 10 , 2 );
add_filter ( 'customize_dynamic_setting_class' , array ( $this , 'filter_dynamic_setting_class' ), 10 , 3 );
add_action ( 'customize_controls_print_footer_scripts' , array ( $this , 'print_templates' ) );
add_action ( 'customize_controls_print_footer_scripts' , array ( $this , 'available_items_template' ) );
add_action ( 'customize_preview_init' , array ( $this , 'customize_preview_init' ) );
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
add_action ( 'customize_preview_init' , array ( $this , 'make_auto_draft_status_previewable' ) );
add_action ( 'customize_save_nav_menus_created_posts' , array ( $this , 'save_nav_menus_created_posts' ) );
2016-02-19 19:41:28 +01:00
// Selective Refresh partials.
add_filter ( 'customize_dynamic_partial_args' , array ( $this , 'customize_dynamic_partial_args' ), 10 , 2 );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2016-01-27 18:55:26 +01:00
/**
2016-03-03 17:05:27 +01:00
* Adds a nonce for customizing menus .
2016-01-27 18:55:26 +01:00
*
* @ since 4.5 . 0
* @ access public
*
2016-03-03 17:05:27 +01:00
* @ param array $nonces Array of nonces .
* @ return array $nonces Modified array of nonces .
2016-01-27 18:55:26 +01:00
*/
public function filter_nonces ( $nonces ) {
$nonces [ 'customize-menus' ] = wp_create_nonce ( 'customize-menus' );
return $nonces ;
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
/**
* Ajax handler for loading available menu items .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
public function ajax_load_available_items () {
check_ajax_referer ( 'customize-menus' , 'customize-menus-nonce' );
if ( ! current_user_can ( 'edit_theme_options' ) ) {
2015-07-11 22:00:24 +02:00
wp_die ( - 1 );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2015-07-11 22:00:24 +02:00
2015-07-22 22:29:25 +02:00
if ( empty ( $_POST [ 'type' ] ) || empty ( $_POST [ 'object' ] ) ) {
wp_send_json_error ( 'nav_menus_missing_type_or_object_parameter' );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2015-07-22 22:29:25 +02:00
$type = sanitize_key ( $_POST [ 'type' ] );
$object = sanitize_key ( $_POST [ 'object' ] );
2015-07-19 01:20:25 +02:00
$page = empty ( $_POST [ 'page' ] ) ? 0 : absint ( $_POST [ 'page' ] );
2015-07-22 22:29:25 +02:00
$items = $this -> load_available_items_query ( $type , $object , $page );
2015-07-19 01:20:25 +02:00
if ( is_wp_error ( $items ) ) {
wp_send_json_error ( $items -> get_error_code () );
} else {
wp_send_json_success ( array ( 'items' => $items ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2015-07-19 01:20:25 +02:00
}
2015-07-11 22:00:24 +02:00
2015-07-19 01:20:25 +02:00
/**
* Performs the post_type and taxonomy queries for loading available menu items .
*
* @ since 4.3 . 0
* @ access public
*
2015-07-22 22:29:25 +02:00
* @ param string $type Optional . Accepts any custom object type and has built - in support for
2015-07-19 01:20:25 +02:00
* 'post_type' and 'taxonomy' . Default is 'post_type' .
2015-07-22 22:29:25 +02:00
* @ param string $object Optional . Accepts any registered taxonomy or post type name . Default is 'page' .
* @ param int $page Optional . The page number used to generate the query offset . Default is '0' .
2015-07-19 01:20:25 +02:00
* @ return WP_Error | array Returns either a WP_Error object or an array of menu items .
*/
2015-07-22 22:29:25 +02:00
public function load_available_items_query ( $type = 'post_type' , $object = 'page' , $page = 0 ) {
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$items = array ();
2015-07-22 22:29:25 +02:00
if ( 'post_type' === $type ) {
2015-11-04 08:29:25 +01:00
$post_type = get_post_type_object ( $object );
if ( ! $post_type ) {
2015-07-19 01:20:25 +02:00
return new WP_Error ( 'nav_menus_invalid_post_type' );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2015-07-22 22:29:25 +02:00
if ( 0 === $page && 'page' === $object ) {
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
// Add "Home" link. Treat as a page, but switch to custom on add.
$items [] = array (
'id' => 'home' ,
'title' => _x ( 'Home' , 'nav menu home label' ),
'type' => 'custom' ,
'type_label' => __ ( 'Custom Link' ),
'object' => '' ,
'url' => home_url (),
);
2015-11-04 05:30:26 +01:00
} elseif ( 'post' !== $object && 0 === $page && $post_type -> has_archive ) {
// Add a post type archive link.
$items [] = array (
'id' => $object . '-archive' ,
'title' => $post_type -> labels -> archives ,
'type' => 'post_type_archive' ,
'type_label' => __ ( 'Post Type Archive' ),
'object' => $object ,
'url' => get_post_type_archive_link ( $object ),
);
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
$posts = get_posts ( array (
'numberposts' => 10 ,
'offset' => 10 * $page ,
'orderby' => 'date' ,
'order' => 'DESC' ,
2015-07-22 22:29:25 +02:00
'post_type' => $object ,
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
) );
foreach ( $posts as $post ) {
2015-06-20 21:50:26 +02:00
$post_title = $post -> post_title ;
if ( '' === $post_title ) {
/* translators: %d: ID of a post */
$post_title = sprintf ( __ ( '#%d (no title)' ), $post -> ID );
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$items [] = array (
'id' => " post- { $post -> ID } " ,
2015-06-20 21:50:26 +02:00
'title' => html_entity_decode ( $post_title , ENT_QUOTES , get_bloginfo ( 'charset' ) ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'type' => 'post_type' ,
'type_label' => get_post_type_object ( $post -> post_type ) -> labels -> singular_name ,
'object' => $post -> post_type ,
2015-07-06 07:53:26 +02:00
'object_id' => intval ( $post -> ID ),
'url' => get_permalink ( intval ( $post -> ID ) ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
}
2015-07-22 22:29:25 +02:00
} elseif ( 'taxonomy' === $type ) {
$terms = get_terms ( $object , array (
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'child_of' => 0 ,
'exclude' => '' ,
'hide_empty' => false ,
'hierarchical' => 1 ,
'include' => '' ,
'number' => 10 ,
'offset' => 10 * $page ,
'order' => 'DESC' ,
'orderby' => 'count' ,
'pad_counts' => false ,
) );
if ( is_wp_error ( $terms ) ) {
2015-07-19 01:20:25 +02:00
return $terms ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
foreach ( $terms as $term ) {
$items [] = array (
'id' => " term- { $term -> term_id } " ,
2015-06-17 21:48:25 +02:00
'title' => html_entity_decode ( $term -> name , ENT_QUOTES , get_bloginfo ( 'charset' ) ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'type' => 'taxonomy' ,
'type_label' => get_taxonomy ( $term -> taxonomy ) -> labels -> singular_name ,
'object' => $term -> taxonomy ,
2015-07-06 07:53:26 +02:00
'object_id' => intval ( $term -> term_id ),
'url' => get_term_link ( intval ( $term -> term_id ), $term -> taxonomy ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
}
}
2015-07-22 22:29:25 +02:00
/**
2016-05-22 20:10:29 +02:00
* Filters the available menu items .
2015-07-22 22:29:25 +02:00
*
* @ since 4.3 . 0
*
* @ param array $items The array of menu items .
* @ param string $type The object type .
* @ param string $object The object name .
* @ param int $page The current page number .
*/
$items = apply_filters ( 'customize_nav_menu_available_items' , $items , $type , $object , $page );
2015-07-19 01:20:25 +02:00
return $items ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
/**
* Ajax handler for searching available menu items .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
public function ajax_search_available_items () {
check_ajax_referer ( 'customize-menus' , 'customize-menus-nonce' );
2015-07-13 16:31:24 +02:00
if ( ! current_user_can ( 'edit_theme_options' ) ) {
2015-07-11 22:00:24 +02:00
wp_die ( - 1 );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2015-07-11 22:00:24 +02:00
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
if ( empty ( $_POST [ 'search' ] ) ) {
2015-07-11 22:00:24 +02:00
wp_send_json_error ( 'nav_menus_missing_search_parameter' );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
$p = isset ( $_POST [ 'page' ] ) ? absint ( $_POST [ 'page' ] ) : 0 ;
if ( $p < 1 ) {
$p = 1 ;
}
$s = sanitize_text_field ( wp_unslash ( $_POST [ 'search' ] ) );
2015-07-19 01:20:25 +02:00
$items = $this -> search_available_items_query ( array ( 'pagenum' => $p , 's' => $s ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
2015-07-19 01:20:25 +02:00
if ( empty ( $items ) ) {
2015-07-30 01:40:25 +02:00
wp_send_json_error ( array ( 'message' => __ ( 'No results found.' ) ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
} else {
2015-07-19 01:20:25 +02:00
wp_send_json_success ( array ( 'items' => $items ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
}
/**
* Performs post queries for available - item searching .
*
* Based on WP_Editor :: wp_link_query () .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ param array $args Optional . Accepts 'pagenum' and 's' ( search ) arguments .
2015-07-19 01:20:25 +02:00
* @ return array Menu items .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
public function search_available_items_query ( $args = array () ) {
2015-07-19 01:20:25 +02:00
$items = array ();
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$post_type_objects = get_post_types ( array ( 'show_in_nav_menus' => true ), 'objects' );
$query = array (
'post_type' => array_keys ( $post_type_objects ),
'suppress_filters' => true ,
'update_post_term_cache' => false ,
'update_post_meta_cache' => false ,
'post_status' => 'publish' ,
'posts_per_page' => 20 ,
);
$args [ 'pagenum' ] = isset ( $args [ 'pagenum' ] ) ? absint ( $args [ 'pagenum' ] ) : 1 ;
$query [ 'offset' ] = $args [ 'pagenum' ] > 1 ? $query [ 'posts_per_page' ] * ( $args [ 'pagenum' ] - 1 ) : 0 ;
if ( isset ( $args [ 's' ] ) ) {
$query [ 's' ] = $args [ 's' ];
}
// Query posts.
$get_posts = new WP_Query ( $query );
// Check if any posts were found.
if ( $get_posts -> post_count ) {
foreach ( $get_posts -> posts as $post ) {
2015-06-20 21:50:26 +02:00
$post_title = $post -> post_title ;
if ( '' === $post_title ) {
/* translators: %d: ID of a post */
$post_title = sprintf ( __ ( '#%d (no title)' ), $post -> ID );
}
2015-07-19 01:20:25 +02:00
$items [] = array (
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'id' => 'post-' . $post -> ID ,
2015-07-06 07:53:26 +02:00
'title' => html_entity_decode ( $post_title , ENT_QUOTES , get_bloginfo ( 'charset' ) ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'type' => 'post_type' ,
'type_label' => $post_type_objects [ $post -> post_type ] -> labels -> singular_name ,
'object' => $post -> post_type ,
'object_id' => intval ( $post -> ID ),
2015-07-06 07:53:26 +02:00
'url' => get_permalink ( intval ( $post -> ID ) ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
}
}
// Query taxonomy terms.
$taxonomies = get_taxonomies ( array ( 'show_in_nav_menus' => true ), 'names' );
$terms = get_terms ( $taxonomies , array (
'name__like' => $args [ 's' ],
'number' => 20 ,
'offset' => 20 * ( $args [ 'pagenum' ] - 1 ),
) );
// Check if any taxonomies were found.
if ( ! empty ( $terms ) ) {
foreach ( $terms as $term ) {
2015-07-19 01:20:25 +02:00
$items [] = array (
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'id' => 'term-' . $term -> term_id ,
2015-07-06 07:53:26 +02:00
'title' => html_entity_decode ( $term -> name , ENT_QUOTES , get_bloginfo ( 'charset' ) ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'type' => 'taxonomy' ,
'type_label' => get_taxonomy ( $term -> taxonomy ) -> labels -> singular_name ,
'object' => $term -> taxonomy ,
'object_id' => intval ( $term -> term_id ),
2015-07-06 07:53:26 +02:00
'url' => get_term_link ( intval ( $term -> term_id ), $term -> taxonomy ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
}
}
2016-02-24 06:57:26 +01:00
/**
2016-05-22 20:10:29 +02:00
* Filters the available menu items during a search request .
2016-02-24 06:57:26 +01:00
*
* @ since 4.5 . 0
*
* @ param array $items The array of menu items .
* @ param array $args Includes 'pagenum' and 's' ( search ) arguments .
*/
$items = apply_filters ( 'customize_nav_menu_searched_items' , $items , $args );
2015-07-19 01:20:25 +02:00
return $items ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
/**
* Enqueue scripts and styles for Customizer pane .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
public function enqueue_scripts () {
wp_enqueue_style ( 'customize-nav-menus' );
wp_enqueue_script ( 'customize-nav-menus' );
$temp_nav_menu_setting = new WP_Customize_Nav_Menu_Setting ( $this -> manager , 'nav_menu[-1]' );
$temp_nav_menu_item_setting = new WP_Customize_Nav_Menu_Item_Setting ( $this -> manager , 'nav_menu_item[-1]' );
// Pass data to JS.
$settings = array (
'allMenus' => wp_get_nav_menus (),
'itemTypes' => $this -> available_item_types (),
'l10n' => array (
2015-06-20 21:50:26 +02:00
'untitled' => _x ( '(no label)' , 'missing menu item navigation label' ),
2015-07-03 22:47:25 +02:00
'unnamed' => _x ( '(unnamed)' , 'Missing menu name.' ),
2015-06-20 20:33:26 +02:00
'custom_label' => __ ( 'Custom Link' ),
2016-02-18 18:16:27 +01:00
/* translators: %s: menu location */
2015-11-20 18:46:25 +01:00
'menuLocation' => _x ( '(Currently set to: %s)' , 'menu' ),
2015-07-21 19:02:24 +02:00
'menuNameLabel' => __ ( 'Menu Name' ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'itemAdded' => __ ( 'Menu item added' ),
'itemDeleted' => __ ( 'Menu item deleted' ),
'menuAdded' => __ ( 'Menu created' ),
'menuDeleted' => __ ( 'Menu deleted' ),
'movedUp' => __ ( 'Menu item moved up' ),
'movedDown' => __ ( 'Menu item moved down' ),
'movedLeft' => __ ( 'Menu item moved out of submenu' ),
'movedRight' => __ ( 'Menu item is now a sub-item' ),
2015-07-29 20:53:25 +02:00
/* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */
'customizingMenus' => sprintf ( __ ( 'Customizing ▸ %s' ), esc_html ( $this -> manager -> get_panel ( 'nav_menus' ) -> title ) ),
2015-06-20 20:33:26 +02:00
/* translators: %s: title of menu item which is invalid */
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'invalidTitleTpl' => __ ( '%s (Invalid)' ),
2015-06-20 20:33:26 +02:00
/* translators: %s: title of menu item in draft status */
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'pendingTitleTpl' => __ ( '%s (Pending)' ),
2015-06-20 21:22:25 +02:00
'itemsFound' => __ ( 'Number of items found: %d' ),
'itemsFoundMore' => __ ( 'Additional items found: %d' ),
'itemsLoadingMore' => __ ( 'Loading more results... please wait.' ),
2015-07-03 23:24:25 +02:00
'reorderModeOn' => __ ( 'Reorder mode enabled' ),
'reorderModeOff' => __ ( 'Reorder mode closed' ),
2015-07-21 13:37:26 +02:00
'reorderLabelOn' => esc_attr__ ( 'Reorder menu items' ),
'reorderLabelOff' => esc_attr__ ( 'Close reorder mode' ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
),
2016-03-21 22:59:29 +01:00
'settingTransport' => 'postMessage' ,
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'phpIntMax' => PHP_INT_MAX ,
'defaultSettingValues' => array (
'nav_menu' => $temp_nav_menu_setting -> default ,
'nav_menu_item' => $temp_nav_menu_item_setting -> default ,
),
2016-02-18 18:16:27 +01:00
'locationSlugMappedToName' => get_registered_nav_menus (),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
$data = sprintf ( 'var _wpCustomizeNavMenusSettings = %s;' , wp_json_encode ( $settings ) );
wp_scripts () -> add_data ( 'customize-nav-menus' , 'data' , $data );
// This is copied from nav-menus.php, and it has an unfortunate object name of `menus`.
$nav_menus_l10n = array (
'oneThemeLocationNoMenus' => null ,
'moveUp' => __ ( 'Move up one' ),
'moveDown' => __ ( 'Move down one' ),
'moveToTop' => __ ( 'Move to the top' ),
/* translators: %s: previous item name */
'moveUnder' => __ ( 'Move under %s' ),
/* translators: %s: previous item name */
'moveOutFrom' => __ ( 'Move out from under %s' ),
/* translators: %s: previous item name */
'under' => __ ( 'Under %s' ),
/* translators: %s: previous item name */
'outFrom' => __ ( 'Out from under %s' ),
/* translators: 1: item name, 2: item position, 3: total number of items */
'menuFocus' => __ ( '%1$s. Menu item %2$d of %3$d.' ),
/* translators: 1: item name, 2: item position, 3: parent item name */
'subMenuFocus' => __ ( '%1$s. Sub item number %2$d under %3$s.' ),
);
wp_localize_script ( 'nav-menu' , 'menus' , $nav_menus_l10n );
}
/**
2016-05-22 20:10:29 +02:00
* Filters a dynamic setting ' s constructor args .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* 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 .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ param false | array $setting_args The arguments to the WP_Customize_Setting constructor .
* @ param string $setting_id ID for dynamic setting , usually coming from `$_POST['customized']` .
* @ return array | false
*/
public function filter_dynamic_setting_args ( $setting_args , $setting_id ) {
if ( preg_match ( WP_Customize_Nav_Menu_Setting :: ID_PATTERN , $setting_id ) ) {
$setting_args = array (
2016-02-19 19:41:28 +01:00
'type' => WP_Customize_Nav_Menu_Setting :: TYPE ,
2016-03-21 22:59:29 +01:00
'transport' => 'postMessage' ,
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
2015-06-20 00:01:25 +02:00
} elseif ( preg_match ( WP_Customize_Nav_Menu_Item_Setting :: ID_PATTERN , $setting_id ) ) {
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$setting_args = array (
2016-02-19 19:41:28 +01:00
'type' => WP_Customize_Nav_Menu_Item_Setting :: TYPE ,
2016-03-21 22:59:29 +01:00
'transport' => 'postMessage' ,
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
}
return $setting_args ;
}
/**
* Allow non - statically created settings to be constructed with custom WP_Customize_Setting subclass .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ param string $setting_class WP_Customize_Setting or a subclass .
* @ param string $setting_id ID for dynamic setting , usually coming from `$_POST['customized']` .
* @ param array $setting_args WP_Customize_Setting or a subclass .
* @ return string
*/
public function filter_dynamic_setting_class ( $setting_class , $setting_id , $setting_args ) {
unset ( $setting_id );
if ( ! empty ( $setting_args [ 'type' ] ) && WP_Customize_Nav_Menu_Setting :: TYPE === $setting_args [ 'type' ] ) {
$setting_class = 'WP_Customize_Nav_Menu_Setting' ;
2015-06-20 00:01:25 +02:00
} elseif ( ! empty ( $setting_args [ 'type' ] ) && WP_Customize_Nav_Menu_Item_Setting :: TYPE === $setting_args [ 'type' ] ) {
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$setting_class = 'WP_Customize_Nav_Menu_Item_Setting' ;
}
return $setting_class ;
}
/**
* Add the customizer settings and controls .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
public function customize_register () {
// Require JS-rendered control types.
$this -> manager -> register_panel_type ( 'WP_Customize_Nav_Menus_Panel' );
$this -> manager -> register_control_type ( 'WP_Customize_Nav_Menu_Control' );
$this -> manager -> register_control_type ( 'WP_Customize_Nav_Menu_Name_Control' );
2015-07-13 10:40:26 +02:00
$this -> manager -> register_control_type ( 'WP_Customize_Nav_Menu_Auto_Add_Control' );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$this -> manager -> register_control_type ( 'WP_Customize_Nav_Menu_Item_Control' );
// Create a panel for Menus.
2015-07-01 21:35:25 +02:00
$description = '<p>' . __ ( 'This panel is used for managing navigation menus for content you have already published on your site. You can create menus and add items for existing content such as pages, posts, categories, tags, formats, or custom links.' ) . '</p>' ;
if ( current_theme_supports ( 'widgets' ) ) {
2016-06-29 00:44:30 +02:00
/* translators: URL to the widgets panel of the customizer */
2015-07-01 21:35:25 +02:00
$description .= '<p>' . sprintf ( __ ( 'Menus can be displayed in locations defined by your theme or in <a href="%s">widget areas</a> by adding a “Custom Menu” widget.' ), " javascript:wp.customize.panel( 'widgets' ).focus(); " ) . '</p>' ;
} else {
$description .= '<p>' . __ ( 'Menus can be displayed in locations defined by your theme.' ) . '</p>' ;
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$this -> manager -> add_panel ( new WP_Customize_Nav_Menus_Panel ( $this -> manager , 'nav_menus' , array (
'title' => __ ( 'Menus' ),
2015-07-01 21:35:25 +02:00
'description' => $description ,
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'priority' => 100 ,
// 'theme_supports' => 'menus|widgets', @todo allow multiple theme supports
) ) );
$menus = wp_get_nav_menus ();
2015-08-25 23:53:20 +02:00
// Menu locations.
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$locations = get_registered_nav_menus ();
$num_locations = count ( array_keys ( $locations ) );
2015-08-25 23:53:20 +02:00
if ( 1 == $num_locations ) {
2016-06-29 00:44:30 +02:00
$description = '<p>' . __ ( 'Your theme supports one menu. Select which menu you would like to use.' ) . '</p>' ;
2015-08-25 23:53:20 +02:00
} else {
2016-06-29 00:44:30 +02:00
/* translators: %s: number of menu locations */
$description = '<p>' . sprintf ( _n ( 'Your theme supports %s menu. Select which menu appears in each location.' , 'Your theme supports %s menus. Select which menu appears in each location.' , $num_locations ), number_format_i18n ( $num_locations ) ) . '</p>' ;
}
if ( current_theme_supports ( 'widgets' ) ) {
/* translators: URL to the widgets panel of the customizer */
$description .= '<p>' . sprintf ( __ ( 'You can also place menus in <a href="%s">widget areas</a> with the “Custom Menu” widget.' ), " javascript:wp.customize.panel( 'widgets' ).focus(); " ) . '</p>' ;
2015-08-25 23:53:20 +02:00
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$this -> manager -> add_section ( 'menu_locations' , array (
'title' => __ ( 'Menu Locations' ),
'panel' => 'nav_menus' ,
'priority' => 5 ,
'description' => $description ,
) );
2015-07-06 21:13:25 +02:00
$choices = array ( '0' => __ ( '— Select —' ) );
foreach ( $menus as $menu ) {
$choices [ $menu -> term_id ] = wp_html_excerpt ( $menu -> name , 40 , '…' );
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
2015-07-06 21:13:25 +02:00
foreach ( $locations as $location => $description ) {
$setting_id = " nav_menu_locations[ { $location } ] " ;
$setting = $this -> manager -> get_setting ( $setting_id );
if ( $setting ) {
2016-03-21 22:59:29 +01:00
$setting -> transport = 'postMessage' ;
2015-07-06 21:13:25 +02:00
remove_filter ( " customize_sanitize_ { $setting_id } " , 'absint' );
add_filter ( " customize_sanitize_ { $setting_id } " , array ( $this , 'intval_base10' ) );
} else {
$this -> manager -> add_setting ( $setting_id , array (
'sanitize_callback' => array ( $this , 'intval_base10' ),
'theme_supports' => 'menus' ,
'type' => 'theme_mod' ,
2016-03-21 22:59:29 +01:00
'transport' => 'postMessage' ,
2015-07-26 04:01:25 +02:00
'default' => 0 ,
2015-07-06 21:13:25 +02:00
) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2015-07-06 21:13:25 +02:00
$this -> manager -> add_control ( new WP_Customize_Nav_Menu_Location_Control ( $this -> manager , $setting_id , array (
'label' => $description ,
'location_id' => $location ,
'section' => 'menu_locations' ,
'choices' => $choices ,
) ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
// Register each menu as a Customizer section, and add each menu item to each menu.
foreach ( $menus as $menu ) {
$menu_id = $menu -> term_id ;
// Create a section for each menu.
$section_id = 'nav_menu[' . $menu_id . ']' ;
$this -> manager -> add_section ( new WP_Customize_Nav_Menu_Section ( $this -> manager , $section_id , array (
2015-06-17 21:48:25 +02:00
'title' => html_entity_decode ( $menu -> name , ENT_QUOTES , get_bloginfo ( 'charset' ) ),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'priority' => 10 ,
'panel' => 'nav_menus' ,
) ) );
$nav_menu_setting_id = 'nav_menu[' . $menu_id . ']' ;
2016-02-19 19:41:28 +01:00
$this -> manager -> add_setting ( new WP_Customize_Nav_Menu_Setting ( $this -> manager , $nav_menu_setting_id , array (
2016-03-21 22:59:29 +01:00
'transport' => 'postMessage' ,
2016-02-19 19:41:28 +01:00
) ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
// Add the menu contents.
$menu_items = ( array ) wp_get_nav_menu_items ( $menu_id );
foreach ( array_values ( $menu_items ) as $i => $item ) {
// Create a setting for each menu item (which doesn't actually manage data, currently).
$menu_item_setting_id = 'nav_menu_item[' . $item -> ID . ']' ;
2015-07-14 09:09:24 +02:00
$value = ( array ) $item ;
$value [ 'nav_menu_term_id' ] = $menu_id ;
$this -> manager -> add_setting ( new WP_Customize_Nav_Menu_Item_Setting ( $this -> manager , $menu_item_setting_id , array (
2016-02-19 19:41:28 +01:00
'value' => $value ,
2016-03-21 22:59:29 +01:00
'transport' => 'postMessage' ,
2015-07-14 09:09:24 +02:00
) ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
// Create a control for each menu item.
$this -> manager -> add_control ( new WP_Customize_Nav_Menu_Item_Control ( $this -> manager , $menu_item_setting_id , array (
'label' => $item -> title ,
'section' => $section_id ,
'priority' => 10 + $i ,
) ) );
}
// Note: other controls inside of this section get added dynamically in JS via the MenuSection.ready() function.
}
// Add the add-new-menu section and controls.
$this -> manager -> add_section ( new WP_Customize_New_Menu_Section ( $this -> manager , 'add_menu' , array (
'title' => __ ( 'Add a Menu' ),
'panel' => 'nav_menus' ,
'priority' => 999 ,
) ) );
$this -> manager -> add_control ( 'new_menu_name' , array (
'label' => '' ,
'section' => 'add_menu' ,
'type' => 'text' ,
2016-02-24 19:28:28 +01:00
'settings' => array (),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
'input_attrs' => array (
'class' => 'menu-name-field' ,
'placeholder' => __ ( 'New menu name' ),
),
) );
2015-08-10 20:06:25 +02:00
$this -> manager -> add_control ( new WP_Customize_New_Menu_Control ( $this -> manager , 'create_new_menu' , array (
2016-02-24 19:28:28 +01:00
'section' => 'add_menu' ,
'settings' => array (),
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
) ) );
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
$this -> manager -> add_setting ( new WP_Customize_Filter_Setting ( $this -> manager , 'nav_menus_created_posts' , array (
'transport' => 'postMessage' ,
'default' => array (),
'sanitize_callback' => array ( $this , 'sanitize_nav_menus_created_posts' ),
) ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
/**
* Get the base10 intval .
*
* 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 .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ param mixed $value Number to convert .
2015-07-13 22:39:25 +02:00
* @ return int Integer .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
2015-06-20 00:04:28 +02:00
public function intval_base10 ( $value ) {
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
return intval ( $value , 10 );
}
/**
* Return an array of all the available item types .
*
* @ since 4.3 . 0
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
* @ since 4.7 . 0 Each array item now includes a `$type_label` in in addition to `$title` , `$type` , and `$object` .
2015-07-13 22:39:25 +02:00
* @ access public
2015-07-22 22:29:25 +02:00
*
* @ return array The available menu item types .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
public function available_item_types () {
2015-07-22 22:29:25 +02:00
$item_types = array ();
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
$post_types = get_post_types ( array ( 'show_in_nav_menus' => true ), 'objects' );
2015-07-22 22:29:25 +02:00
if ( $post_types ) {
foreach ( $post_types as $slug => $post_type ) {
$item_types [] = array (
2015-09-24 11:16:25 +02:00
'title' => $post_type -> labels -> name ,
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
'type_label' => $post_type -> labels -> singular_name ,
'type' => 'post_type' ,
2015-07-22 22:29:25 +02:00
'object' => $post_type -> name ,
);
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
$taxonomies = get_taxonomies ( array ( 'show_in_nav_menus' => true ), 'objects' );
2015-07-22 22:29:25 +02:00
if ( $taxonomies ) {
foreach ( $taxonomies as $slug => $taxonomy ) {
if ( 'post_format' === $taxonomy && ! current_theme_supports ( 'post-formats' ) ) {
continue ;
}
$item_types [] = array (
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
'title' => $taxonomy -> labels -> name ,
'type_label' => $taxonomy -> labels -> singular_name ,
'type' => 'taxonomy' ,
2015-07-22 22:29:25 +02:00
'object' => $taxonomy -> name ,
);
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
}
2015-07-22 22:29:25 +02:00
/**
2016-05-22 20:10:29 +02:00
* Filters the available menu item types .
2015-07-22 22:29:25 +02:00
*
* @ since 4.3 . 0
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
* @ since 4.7 . 0 Each array item now includes a `$type_label` in in addition to `$title` , `$type` , and `$object` .
2015-07-22 22:29:25 +02:00
*
* @ param array $item_types Custom menu item types .
*/
$item_types = apply_filters ( 'customize_nav_menu_available_item_types' , $item_types );
return $item_types ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
/**
* Add a new `auto-draft` post .
*
* @ access public
* @ since 4.7 . 0
*
* @ param array $postarr {
* Abbreviated post array .
*
* @ var string $post_title Post title .
* @ var string $post_type Post type .
* }
* @ return WP_Post | WP_Error Inserted auto - draft post object or error .
*/
public function insert_auto_draft_post ( $postarr ) {
if ( ! isset ( $postarr [ 'post_type' ] ) || ! post_type_exists ( $postarr [ 'post_type' ] ) ) {
return new WP_Error ( 'unknown_post_type' , __ ( 'Unknown post type' ) );
}
if ( ! isset ( $postarr [ 'post_title' ] ) ) {
$postarr [ 'post_title' ] = '' ;
}
add_filter ( 'wp_insert_post_empty_content' , '__return_false' , 1000 );
$args = array (
'post_status' => 'auto-draft' ,
'post_type' => $postarr [ 'post_type' ],
'post_title' => $postarr [ 'post_title' ],
'post_name' => sanitize_title ( $postarr [ 'post_title' ] ), // Auto-drafts are allowed to have empty post_names, so we need to explicitly set it.
);
$r = wp_insert_post ( wp_slash ( $args ), true );
remove_filter ( 'wp_insert_post_empty_content' , '__return_false' , 1000 );
if ( is_wp_error ( $r ) ) {
return $r ;
} else {
return get_post ( $r );
}
}
/**
* Ajax handler for adding a new auto - draft post .
*
* @ access public
* @ since 4.7 . 0
*/
public function ajax_insert_auto_draft_post () {
if ( ! check_ajax_referer ( 'customize-menus' , 'customize-menus-nonce' , false ) ) {
2016-08-31 21:01:28 +02:00
wp_send_json_error ( 'bad_nonce' , 400 );
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
}
if ( ! current_user_can ( 'customize' ) ) {
2016-08-31 21:01:28 +02:00
wp_send_json_error ( 'customize_not_allowed' , 403 );
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
}
if ( empty ( $_POST [ 'params' ] ) || ! is_array ( $_POST [ 'params' ] ) ) {
2016-08-31 21:01:28 +02:00
wp_send_json_error ( 'missing_params' , 400 );
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
}
$params = wp_array_slice_assoc (
array_merge (
array (
'post_type' => '' ,
'post_title' => '' ,
),
wp_unslash ( $_POST [ 'params' ] )
),
array ( 'post_type' , 'post_title' )
);
if ( empty ( $params [ 'post_type' ] ) || ! post_type_exists ( $params [ 'post_type' ] ) ) {
status_header ( 400 );
wp_send_json_error ( 'missing_post_type_param' );
}
$post_type_object = get_post_type_object ( $params [ 'post_type' ] );
if ( ! current_user_can ( $post_type_object -> cap -> create_posts ) || ! current_user_can ( $post_type_object -> cap -> publish_posts ) ) {
status_header ( 403 );
wp_send_json_error ( 'insufficient_post_permissions' );
}
$params [ 'post_title' ] = trim ( $params [ 'post_title' ] );
if ( '' === $params [ 'post_title' ] ) {
status_header ( 400 );
wp_send_json_error ( 'missing_post_title' );
}
$r = $this -> insert_auto_draft_post ( $params );
if ( is_wp_error ( $r ) ) {
$error = $r ;
if ( ! empty ( $post_type_object -> labels -> singular_name ) ) {
$singular_name = $post_type_object -> labels -> singular_name ;
} else {
$singular_name = __ ( 'Post' );
}
$data = array (
/* translators: %1$s is the post type name and %2$s is the error message. */
'message' => sprintf ( __ ( '%1$s could not be created: %2$s' ), $singular_name , $error -> get_error_message () ),
);
wp_send_json_error ( $data );
} else {
$post = $r ;
$data = array (
'post_id' => $post -> ID ,
'url' => get_permalink ( $post -> ID ),
);
wp_send_json_success ( $data );
}
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
/**
* Print the JavaScript templates used to render Menu Customizer components .
*
* Templates are imported into the JS use wp . template .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
public function print_templates () {
?>
< script type = " text/html " id = " tmpl-available-menu-item " >
2015-07-10 00:00:25 +02:00
< li id = " menu-item-tpl- { { data.id }} " class = " menu-item-tpl " data - menu - item - id = " { { data.id }} " >
2015-06-20 20:47:27 +02:00
< div class = " menu-item-bar " >
< div class = " menu-item-handle " >
2015-07-10 00:00:25 +02:00
< span class = " item-type " aria - hidden = " true " > {{ data . type_label }} </ span >
< span class = " item-title " aria - hidden = " true " >
2015-06-21 00:33:26 +02:00
< span class = " menu-item-title<# if ( ! data.title ) { #> no-title<# } #> " > {{ data . title || wp . customize . Menus . data . l10n . untitled }} </ span >
</ span >
2015-11-13 16:47:27 +01:00
< button type = " button " class = " button-link item-add " >
2015-07-10 00:00:25 +02:00
< span class = " screen-reader-text " >< ? php
/* translators: 1: Title of a menu item, 2: Type of a menu item */
printf ( __ ( 'Add to menu: %1$s (%2$s)' ), '{{ data.title || wp.customize.Menus.data.l10n.untitled }}' , '{{ data.type_label }}' );
?> </span>
</ button >
2015-06-20 20:47:27 +02:00
</ div >
</ div >
2015-07-10 00:00:25 +02:00
</ li >
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
</ script >
< script type = " text/html " id = " tmpl-menu-item-reorder-nav " >
< div class = " menu-item-reorder-nav " >
< ? php
printf (
'<button type="button" class="menus-move-up">%1$s</button><button type="button" class="menus-move-down">%2$s</button><button type="button" class="menus-move-left">%3$s</button><button type="button" class="menus-move-right">%4$s</button>' ,
2015-06-20 20:40:25 +02:00
__ ( 'Move up' ),
__ ( 'Move down' ),
__ ( 'Move one level up' ),
__ ( 'Move one level down' )
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
?>
</ div >
</ script >
< ? php
}
/**
* Print the html template used to render the add - menu - item frame .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
public function available_items_template () {
?>
< div id = " available-menu-items " class = " accordion-container " >
< div class = " customize-section-title " >
< button type = " button " class = " customize-section-back " tabindex = " -1 " >
< span class = " screen-reader-text " >< ? php _e ( 'Back' ); ?> </span>
</ button >
< h3 >
< span class = " customize-action " >
< ? php
/* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */
printf ( __ ( 'Customizing ▸ %s' ), esc_html ( $this -> manager -> get_panel ( 'nav_menus' ) -> title ) );
?>
</ span >
< ? php _e ( 'Add Menu Items' ); ?>
</ h3 >
</ div >
< div id = " available-menu-items-search " class = " accordion-section cannot-expand " >
< div class = " accordion-section-title " >
< label class = " screen-reader-text " for = " menu-items-search " >< ? php _e ( 'Search Menu Items' ); ?> </label>
2015-06-20 21:22:25 +02:00
< input type = " text " id = " menu-items-search " placeholder = " <?php esc_attr_e( 'Search menu items…' ) ?> " aria - describedby = " menu-items-search-desc " />
< p class = " screen-reader-text " id = " menu-items-search-desc " >< ? php _e ( 'The search results will be updated as you type.' ); ?> </p>
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
< span class = " spinner " ></ span >
</ div >
2016-06-10 23:22:28 +02:00
< button type = " button " class = " clear-results " >< span class = " screen-reader-text " >< ? php _e ( 'Clear Results' ); ?> </span></button>
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
< ul class = " accordion-section-content available-menu-items-list " data - type = " search " ></ ul >
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
</ div >
< div id = " new-custom-menu-item " class = " accordion-section " >
2015-07-24 22:28:25 +02:00
< h4 class = " accordion-section-title " role = " presentation " >
< ? php _e ( 'Custom Links' ); ?>
2015-11-13 16:47:27 +01:00
< button type = " button " class = " button-link " aria - expanded = " false " >
2015-07-24 22:28:25 +02:00
< span class = " screen-reader-text " >< ? php _e ( 'Toggle section: Custom Links' ); ?> </span>
< span class = " toggle-indicator " aria - hidden = " true " ></ span >
</ button >
</ h4 >
2016-01-22 15:26:27 +01:00
< div class = " accordion-section-content customlinkdiv " >
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
< input type = " hidden " value = " custom " id = " custom-menu-item-type " name = " menu-item[-1][menu-item-type] " />
2016-01-30 14:46:27 +01:00
< p id = " menu-item-url-wrap " class = " wp-clearfix " >
2016-01-22 15:26:27 +01:00
< label class = " howto " for = " custom-menu-item-url " >< ? php _e ( 'URL' ); ?> </label>
< input id = " custom-menu-item-url " name = " menu-item[-1][menu-item-url] " type = " text " class = " code menu-item-textbox " value = " http:// " >
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
</ p >
2016-01-30 14:46:27 +01:00
< p id = " menu-item-name-wrap " class = " wp-clearfix " >
2016-01-22 15:26:27 +01:00
< label class = " howto " for = " custom-menu-item-name " >< ? php _e ( 'Link Text' ); ?> </label>
< input id = " custom-menu-item-name " name = " menu-item[-1][menu-item-title] " type = " text " class = " regular-text menu-item-textbox " >
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
</ p >
< p class = " button-controls " >
< span class = " add-to-menu " >
< input type = " submit " class = " button-secondary submit-add-to-menu right " value = " <?php esc_attr_e( 'Add to Menu' ); ?> " name = " add-custom-menu-item " id = " custom-menu-item-submit " >
< span class = " spinner " ></ span >
</ span >
</ p >
</ div >
</ div >
< ? php
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
// Containers for per-post-type item browsing; items are added with JS.
2015-07-22 22:29:25 +02:00
foreach ( $this -> available_item_types () as $available_item_type ) {
$id = sprintf ( 'available-menu-items-%s-%s' , $available_item_type [ 'type' ], $available_item_type [ 'object' ] );
?>
< div id = " <?php echo esc_attr( $id ); ?> " class = " accordion-section " >
2015-07-24 22:28:25 +02:00
< h4 class = " accordion-section-title " role = " presentation " >
< ? php echo esc_html ( $available_item_type [ 'title' ] ); ?>
< span class = " spinner " ></ span >
< span class = " no-items " >< ? php _e ( 'No items' ); ?> </span>
2015-11-13 16:47:27 +01:00
< button type = " button " class = " button-link " aria - expanded = " false " >
2015-07-24 22:28:25 +02:00
< span class = " screen-reader-text " >< ? php
/* translators: %s: Title of a section with menu items */
2015-07-28 15:25:25 +02:00
printf ( __ ( 'Toggle section: %s' ), esc_html ( $available_item_type [ 'title' ] ) ); ?> </span>
2015-07-24 22:28:25 +02:00
< span class = " toggle-indicator " aria - hidden = " true " ></ span >
</ button >
</ h4 >
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
< div class = " accordion-section-content " >
< ? php if ( 'post_type' === $available_item_type [ 'type' ] ) : ?>
< ? php $post_type_obj = get_post_type_object ( $available_item_type [ 'object' ] ); ?>
< ? php if ( current_user_can ( $post_type_obj -> cap -> create_posts ) && current_user_can ( $post_type_obj -> cap -> publish_posts ) ) : ?>
< div class = " new-content-item " >
2016-08-31 21:15:28 +02:00
< input type = " text " class = " create-item-input " placeholder = " <?php echo esc_attr( $post_type_obj->labels ->add_new_item ); ?> " >
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
< button type = " button " class = " button add-content " >< ? php _e ( 'Add' ); ?> </button>
</ div >
< ? php endif ; ?>
< ? php endif ; ?>
< ul class = " available-menu-items-list " data - type = " <?php echo esc_attr( $available_item_type['type'] ); ?> " data - object = " <?php echo esc_attr( $available_item_type['object'] ); ?> " data - type_label = " <?php echo esc_attr( isset( $available_item_type['type_label'] ) ? $available_item_type['type_label'] : $available_item_type['type'] ); ?> " ></ ul >
</ div >
2015-07-22 22:29:25 +02:00
</ div >
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
< ? php
2015-07-22 22:29:25 +02:00
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
?>
</ div ><!-- #available-menu-items -->
< ? php
}
2016-02-19 19:41:28 +01:00
//
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
// Start functionality specific to partial-refresh of menu changes in Customizer preview.
2016-02-19 19:41:28 +01:00
//
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
2016-03-09 01:09:26 +01:00
/**
* Nav menu args used for each instance , keyed by the args HMAC .
*
* @ since 4.3 . 0
* @ access public
* @ var array
*/
public $preview_nav_menu_instance_args = array ();
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
/**
2016-05-22 20:10:29 +02:00
* Filters arguments for dynamic nav_menu selective refresh partials .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
2016-02-19 19:41:28 +01:00
* @ since 4.5 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
2016-02-19 19:41:28 +01:00
* @ param array | false $partial_args Partial args .
* @ param string $partial_id Partial ID .
2016-03-03 17:07:26 +01:00
* @ return array Partial args .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
2016-02-19 19:41:28 +01:00
public function customize_dynamic_partial_args ( $partial_args , $partial_id ) {
if ( preg_match ( '/^nav_menu_instance\[[0-9a-f]{32}\]$/' , $partial_id ) ) {
if ( false === $partial_args ) {
$partial_args = array ();
}
$partial_args = array_merge (
$partial_args ,
array (
'type' => 'nav_menu_instance' ,
'render_callback' => array ( $this , 'render_nav_menu_partial' ),
'container_inclusive' => true ,
2016-02-24 19:28:28 +01:00
'settings' => array (), // Empty because the nav menu instance may relate to a menu or a location.
'capability' => 'edit_theme_options' ,
2016-02-19 19:41:28 +01:00
)
);
}
return $partial_args ;
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
/**
* Add hooks for the Customizer preview .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
2015-06-20 00:04:28 +02:00
public function customize_preview_init () {
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
add_action ( 'wp_enqueue_scripts' , array ( $this , 'customize_preview_enqueue_deps' ) );
2016-02-19 19:41:28 +01:00
add_filter ( 'wp_nav_menu_args' , array ( $this , 'filter_wp_nav_menu_args' ), 1000 );
add_filter ( 'wp_nav_menu' , array ( $this , 'filter_wp_nav_menu' ), 10 , 2 );
2016-03-09 01:09:26 +01:00
add_filter ( 'wp_footer' , array ( $this , 'export_preview_data' ), 1 );
add_filter ( 'customize_render_partials_response' , array ( $this , 'export_partial_rendered_nav_menu_instances' ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
Customize: Allow users to more seamlessly create page-based nav menus during customization.
Introduces the ability to create stubs for the various post types to add to a given menu. This eliminates the need to leave the customizer to first create the post in the admin and then return to managing menus. Only the title of the newly-created post can be supplied; the post content will be blank and will need to be provided in the normal edit post screen outside the customizer, unless a plugin enables a post editing in the customizer experience. When a post is created and added to a nav menu in the customizer, the newly created post that is added to a menu is given the `auto-draft` status, and if the changes are not published, the `auto-draft` post will be automatically deleted within 7 days via `wp_delete_auto_drafts()`. However, if the customizer changes are saved, then these nav menu item `auto-draft` post stubs will be transitioned to `publish`.
Includes portions of code from the Customize Posts <https://github.com/xwp/wp-customize-posts> and Front-end Editor <https://github.com/iseulde/wp-front-end-editor> plugins.
For more information, see https://make.wordpress.org/core/2016/06/16/feature-proposal-content-authorship-in-menus-with-live-preview/
Props celloexpressions, westonruter, valendesigns, afercia, melchoyce, mapk, iseulde, mrahmadawais.
Fixes #34923.
Built from https://develop.svn.wordpress.org/trunk@38436
git-svn-id: http://core.svn.wordpress.org/trunk@38377 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-30 00:59:28 +02:00
/**
* Make the auto - draft status protected so that it can be queried .
*
* @ since 4.7 . 0
* @ access public
*/
public function make_auto_draft_status_previewable () {
global $wp_post_statuses ;
$wp_post_statuses [ 'auto-draft' ] -> protected = true ;
}
/**
* Sanitize post IDs for auto - draft posts created for nav menu items to be published .
*
* @ since 4.7 . 0
* @ access public
*
* @ param array $value Post IDs .
* @ returns array Post IDs .
*/
public function sanitize_nav_menus_created_posts ( $value ) {
$post_ids = array ();
foreach ( wp_parse_id_list ( $value ) as $post_id ) {
if ( empty ( $post_id ) ) {
continue ;
}
$post = get_post ( $post_id );
if ( 'auto-draft' !== $post -> post_status ) {
continue ;
}
$post_type_obj = get_post_type_object ( $post -> post_type );
if ( ! $post_type_obj ) {
continue ;
}
if ( ! current_user_can ( $post_type_obj -> cap -> publish_posts ) || ! current_user_can ( $post_type_obj -> cap -> edit_post , $post_id ) ) {
continue ;
}
$post_ids [] = $post -> ID ;
}
return $post_ids ;
}
/**
* Publish the auto - draft posts that were created for nav menu items .
*
* 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 .
*
* @ since 4.7 . 0
* @ access public
*
* @ param WP_Customize_Setting $setting Customizer setting object .
*/
public function save_nav_menus_created_posts ( $setting ) {
$post_ids = $setting -> post_value ();
if ( ! empty ( $post_ids ) ) {
foreach ( $post_ids as $post_id ) {
wp_publish_post ( $post_id );
}
}
}
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
/**
* Keep track of the arguments that are being passed to wp_nav_menu () .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
* @ see wp_nav_menu ()
2016-02-19 19:41:28 +01:00
* @ see WP_Customize_Widgets_Partial_Refresh :: filter_dynamic_sidebar_params ()
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
2015-07-13 22:39:25 +02:00
* @ param array $args An array containing wp_nav_menu () arguments .
* @ return array Arguments .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
2015-06-20 00:04:28 +02:00
public function filter_wp_nav_menu_args ( $args ) {
2016-02-19 19:41:28 +01:00
/*
* The following conditions determine whether or not this instance of
* wp_nav_menu () can use selective refreshed . A wp_nav_menu () can be
* selective refreshed if ...
*/
2016-03-09 01:09:26 +01:00
$can_partial_refresh = (
2016-02-19 19:41:28 +01:00
// ...if wp_nav_menu() is directly echoing out the menu (and thus isn't manipulating the string after generated),
2015-07-01 21:08:24 +02:00
! empty ( $args [ 'echo' ] )
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
&&
2016-02-19 19:41:28 +01:00
// ...and if the fallback_cb can be serialized to JSON, since it will be included in the placement context data,
2015-07-01 21:08:24 +02:00
( empty ( $args [ 'fallback_cb' ] ) || is_string ( $args [ 'fallback_cb' ] ) )
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
&&
2016-02-19 19:41:28 +01:00
// ...and if the walker can also be serialized to JSON, since it will be included in the placement context data as well,
2015-07-01 21:08:24 +02:00
( empty ( $args [ 'walker' ] ) || is_string ( $args [ 'walker' ] ) )
2016-02-19 19:41:28 +01:00
// ...and if it has a theme location assigned or an assigned menu to display,
&& (
2015-07-08 23:30:24 +02:00
! empty ( $args [ 'theme_location' ] )
||
( ! empty ( $args [ 'menu' ] ) && ( is_numeric ( $args [ 'menu' ] ) || is_object ( $args [ 'menu' ] ) ) )
)
2016-02-19 19:41:28 +01:00
&&
// ...and if the nav menu would be rendered with a wrapper container element (upon which to attach data-* attributes).
(
! empty ( $args [ 'container' ] )
||
( isset ( $args [ 'items_wrap' ] ) && '<' === substr ( $args [ 'items_wrap' ], 0 , 1 ) )
)
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
);
2016-03-09 01:09:26 +01:00
$args [ 'can_partial_refresh' ] = $can_partial_refresh ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
2016-02-19 19:41:28 +01:00
$exported_args = $args ;
2016-03-09 01:09:26 +01:00
// Empty out args which may not be JSON-serializable.
if ( ! $can_partial_refresh ) {
$exported_args [ 'fallback_cb' ] = '' ;
$exported_args [ 'walker' ] = '' ;
}
2016-02-19 19:41:28 +01:00
/*
* Replace object menu arg with a term_id menu arg , as this exports better
* to JS and is easier to compare hashes .
*/
if ( ! empty ( $exported_args [ 'menu' ] ) && is_object ( $exported_args [ 'menu' ] ) ) {
$exported_args [ 'menu' ] = $exported_args [ 'menu' ] -> term_id ;
2015-07-08 23:30:24 +02:00
}
2016-02-19 19:41:28 +01:00
ksort ( $exported_args );
$exported_args [ 'args_hmac' ] = $this -> hash_nav_menu_args ( $exported_args );
$args [ 'customize_preview_nav_menus_args' ] = $exported_args ;
2016-03-09 01:09:26 +01:00
$this -> preview_nav_menu_instance_args [ $exported_args [ 'args_hmac' ] ] = $exported_args ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
return $args ;
}
/**
2016-02-19 19:41:28 +01:00
* Prepares wp_nav_menu () calls for partial refresh .
*
* Injects attributes into container element .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ see wp_nav_menu ()
*
* @ param string $nav_menu_content The HTML content for the navigation menu .
* @ param object $args An object containing wp_nav_menu () arguments .
* @ return null
*/
2015-06-20 00:04:28 +02:00
public function filter_wp_nav_menu ( $nav_menu_content , $args ) {
2016-03-09 01:09:26 +01:00
if ( isset ( $args -> customize_preview_nav_menus_args [ 'can_partial_refresh' ] ) && $args -> customize_preview_nav_menus_args [ 'can_partial_refresh' ] ) {
2016-02-19 19:41:28 +01:00
$attributes = sprintf ( ' data-customize-partial-id="%s"' , esc_attr ( 'nav_menu_instance[' . $args -> customize_preview_nav_menus_args [ 'args_hmac' ] . ']' ) );
$attributes .= ' data-customize-partial-type="nav_menu_instance"' ;
$attributes .= sprintf ( ' data-customize-partial-placement-context="%s"' , esc_attr ( wp_json_encode ( $args -> customize_preview_nav_menus_args ) ) );
$nav_menu_content = preg_replace ( '#^(<\w+)#' , '$1 ' . $attributes , $nav_menu_content , 1 );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
return $nav_menu_content ;
}
/**
2016-02-19 19:41:28 +01:00
* Hashes ( hmac ) the nav menu arguments to ensure they are not tampered with when
* submitted in the Ajax request .
*
* Note that the array is expected to be pre - sorted .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ param array $args The arguments to hash .
2016-02-19 19:41:28 +01:00
* @ return string Hashed nav menu arguments .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
2015-06-20 00:04:28 +02:00
public function hash_nav_menu_args ( $args ) {
2016-02-19 19:41:28 +01:00
return wp_hash ( serialize ( $args ) );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
/**
* Enqueue scripts for the Customizer preview .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
2015-06-20 00:04:28 +02:00
public function customize_preview_enqueue_deps () {
2016-02-19 19:41:28 +01:00
wp_enqueue_script ( 'customize-preview-nav-menus' ); // Note that we have overridden this.
wp_enqueue_style ( 'customize-preview' );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
/**
2016-02-19 19:41:28 +01:00
* Exports data from PHP to JS .
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
2015-06-20 00:04:28 +02:00
public function export_preview_data () {
2016-03-09 01:09:26 +01:00
// Why not wp_localize_script? Because we're not localizing, and it forces values into strings.
$exports = array (
'navMenuInstanceArgs' => $this -> preview_nav_menu_instance_args ,
);
printf ( '<script>var _wpCustomizePreviewNavMenusExports = %s;</script>' , wp_json_encode ( $exports ) );
}
/**
* Export any wp_nav_menu () calls during the rendering of any partials .
*
* @ since 4.5 . 0
* @ access public
*
* @ param array $response Response .
* @ return array Response .
*/
public function export_partial_rendered_nav_menu_instances ( $response ) {
$response [ 'nav_menu_instance_args' ] = $this -> preview_nav_menu_instance_args ;
return $response ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
/**
* Render a specific menu via wp_nav_menu () using the supplied arguments .
*
* @ since 4.3 . 0
2015-07-13 22:39:25 +02:00
* @ access public
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*
* @ see wp_nav_menu ()
2016-02-19 19:41:28 +01:00
*
* @ param WP_Customize_Partial $partial Partial .
* @ param array $nav_menu_args Nav menu args supplied as container context .
* @ return string | false
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
*/
2016-02-19 19:41:28 +01:00
public function render_nav_menu_partial ( $partial , $nav_menu_args ) {
unset ( $partial );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
2016-02-19 19:41:28 +01:00
if ( ! isset ( $nav_menu_args [ 'args_hmac' ] ) ) {
// Error: missing_args_hmac.
return false ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2016-02-19 19:41:28 +01:00
$nav_menu_args_hmac = $nav_menu_args [ 'args_hmac' ];
unset ( $nav_menu_args [ 'args_hmac' ] );
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
2016-02-19 19:41:28 +01:00
ksort ( $nav_menu_args );
if ( ! hash_equals ( $this -> hash_nav_menu_args ( $nav_menu_args ), $nav_menu_args_hmac ) ) {
// Error: args_hmac_mismatch.
return false ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
2016-02-19 19:41:28 +01:00
ob_start ();
wp_nav_menu ( $nav_menu_args );
$content = ob_get_clean ();
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
2016-02-19 19:41:28 +01:00
return $content ;
Add menu management to the Customizer.
This brings in the Menu Customizer plugin: https://wordpress.org/plugins/menu-customizer/.
props celloexpressions, westonruter, valendesigns, voldemortensen, ocean90, adamsilverstein, kucrut, jorbin, designsimply, afercia, davidakennedy, obenland.
see #32576.
Built from https://develop.svn.wordpress.org/trunk@32806
git-svn-id: http://core.svn.wordpress.org/trunk@32777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 00:08:26 +02:00
}
}