~canonical-sysadmins/wordpress/4.5.2

« back to all changes in this revision

Viewing changes to wp-admin/includes/nav-menu.php

  • Committer: Manuel Seelaus
  • Date: 2015-12-09 17:47:18 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: manuel.seelaus@canonical.com-20151209174718-coxethm2swbeqksy
Merge WP4.4 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
 
3
2
/**
4
 
 * Create HTML list of nav menu input items.
 
3
 * Core Navigation Menu API
5
4
 *
6
5
 * @package WordPress
7
 
 * @since 3.0.0
8
 
 * @uses Walker_Nav_Menu
9
 
 */
10
 
class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
11
 
        /**
12
 
         * Starts the list before the elements are added.
13
 
         *
14
 
         * @see Walker_Nav_Menu::start_lvl()
15
 
         *
16
 
         * @since 3.0.0
17
 
         *
18
 
         * @param string $output Passed by reference.
19
 
         * @param int    $depth  Depth of menu item. Used for padding.
20
 
         * @param array  $args   Not used.
21
 
         */
22
 
        public function start_lvl( &$output, $depth = 0, $args = array() ) {}
23
 
 
24
 
        /**
25
 
         * Ends the list of after the elements are added.
26
 
         *
27
 
         * @see Walker_Nav_Menu::end_lvl()
28
 
         *
29
 
         * @since 3.0.0
30
 
         *
31
 
         * @param string $output Passed by reference.
32
 
         * @param int    $depth  Depth of menu item. Used for padding.
33
 
         * @param array  $args   Not used.
34
 
         */
35
 
        public function end_lvl( &$output, $depth = 0, $args = array() ) {}
36
 
 
37
 
        /**
38
 
         * Start the element output.
39
 
         *
40
 
         * @see Walker_Nav_Menu::start_el()
41
 
         * @since 3.0.0
42
 
         *
43
 
         * @global int $_wp_nav_menu_max_depth
44
 
         *
45
 
         * @param string $output Passed by reference. Used to append additional content.
46
 
         * @param object $item   Menu item data object.
47
 
         * @param int    $depth  Depth of menu item. Used for padding.
48
 
         * @param array  $args   Not used.
49
 
         * @param int    $id     Not used.
50
 
         */
51
 
        public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
52
 
                global $_wp_nav_menu_max_depth;
53
 
                $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
54
 
 
55
 
                ob_start();
56
 
                $item_id = esc_attr( $item->ID );
57
 
                $removed_args = array(
58
 
                        'action',
59
 
                        'customlink-tab',
60
 
                        'edit-menu-item',
61
 
                        'menu-item',
62
 
                        'page-tab',
63
 
                        '_wpnonce',
64
 
                );
65
 
 
66
 
                $original_title = '';
67
 
                if ( 'taxonomy' == $item->type ) {
68
 
                        $original_title = get_term_field( 'name', $item->object_id, $item->object, 'raw' );
69
 
                        if ( is_wp_error( $original_title ) )
70
 
                                $original_title = false;
71
 
                } elseif ( 'post_type' == $item->type ) {
72
 
                        $original_object = get_post( $item->object_id );
73
 
                        $original_title = get_the_title( $original_object->ID );
74
 
                }
75
 
 
76
 
                $classes = array(
77
 
                        'menu-item menu-item-depth-' . $depth,
78
 
                        'menu-item-' . esc_attr( $item->object ),
79
 
                        'menu-item-edit-' . ( ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? 'active' : 'inactive'),
80
 
                );
81
 
 
82
 
                $title = $item->title;
83
 
 
84
 
                if ( ! empty( $item->_invalid ) ) {
85
 
                        $classes[] = 'menu-item-invalid';
86
 
                        /* translators: %s: title of menu item which is invalid */
87
 
                        $title = sprintf( __( '%s (Invalid)' ), $item->title );
88
 
                } elseif ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
89
 
                        $classes[] = 'pending';
90
 
                        /* translators: %s: title of menu item in draft status */
91
 
                        $title = sprintf( __('%s (Pending)'), $item->title );
92
 
                }
93
 
 
94
 
                $title = ( ! isset( $item->label ) || '' == $item->label ) ? $title : $item->label;
95
 
 
96
 
                $submenu_text = '';
97
 
                if ( 0 == $depth )
98
 
                        $submenu_text = 'style="display: none;"';
99
 
 
100
 
                ?>
101
 
                <li id="menu-item-<?php echo $item_id; ?>" class="<?php echo implode(' ', $classes ); ?>">
102
 
                        <div class="menu-item-bar">
103
 
                                <div class="menu-item-handle">
104
 
                                        <span class="item-title"><span class="menu-item-title"><?php echo esc_html( $title ); ?></span> <span class="is-submenu" <?php echo $submenu_text; ?>><?php _e( 'sub item' ); ?></span></span>
105
 
                                        <span class="item-controls">
106
 
                                                <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
107
 
                                                <span class="item-order hide-if-js">
108
 
                                                        <a href="<?php
109
 
                                                                echo wp_nonce_url(
110
 
                                                                        add_query_arg(
111
 
                                                                                array(
112
 
                                                                                        'action' => 'move-up-menu-item',
113
 
                                                                                        'menu-item' => $item_id,
114
 
                                                                                ),
115
 
                                                                                remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
116
 
                                                                        ),
117
 
                                                                        'move-menu_item'
118
 
                                                                );
119
 
                                                        ?>" class="item-move-up"><abbr title="<?php esc_attr_e('Move up'); ?>">&#8593;</abbr></a>
120
 
                                                        |
121
 
                                                        <a href="<?php
122
 
                                                                echo wp_nonce_url(
123
 
                                                                        add_query_arg(
124
 
                                                                                array(
125
 
                                                                                        'action' => 'move-down-menu-item',
126
 
                                                                                        'menu-item' => $item_id,
127
 
                                                                                ),
128
 
                                                                                remove_query_arg($removed_args, admin_url( 'nav-menus.php' ) )
129
 
                                                                        ),
130
 
                                                                        'move-menu_item'
131
 
                                                                );
132
 
                                                        ?>" class="item-move-down"><abbr title="<?php esc_attr_e('Move down'); ?>">&#8595;</abbr></a>
133
 
                                                </span>
134
 
                                                <a class="item-edit" id="edit-<?php echo $item_id; ?>" title="<?php esc_attr_e('Edit Menu Item'); ?>" href="<?php
135
 
                                                        echo ( isset( $_GET['edit-menu-item'] ) && $item_id == $_GET['edit-menu-item'] ) ? admin_url( 'nav-menus.php' ) : add_query_arg( 'edit-menu-item', $item_id, remove_query_arg( $removed_args, admin_url( 'nav-menus.php#menu-item-settings-' . $item_id ) ) );
136
 
                                                ?>"><?php _e( 'Edit Menu Item' ); ?></a>
137
 
                                        </span>
138
 
                                </div>
139
 
                        </div>
140
 
 
141
 
                        <div class="menu-item-settings" id="menu-item-settings-<?php echo $item_id; ?>">
142
 
                                <?php if ( 'custom' == $item->type ) : ?>
143
 
                                        <p class="field-url description description-wide">
144
 
                                                <label for="edit-menu-item-url-<?php echo $item_id; ?>">
145
 
                                                        <?php _e( 'URL' ); ?><br />
146
 
                                                        <input type="text" id="edit-menu-item-url-<?php echo $item_id; ?>" class="widefat code edit-menu-item-url" name="menu-item-url[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->url ); ?>" />
147
 
                                                </label>
148
 
                                        </p>
149
 
                                <?php endif; ?>
150
 
                                <p class="description description-wide">
151
 
                                        <label for="edit-menu-item-title-<?php echo $item_id; ?>">
152
 
                                                <?php _e( 'Navigation Label' ); ?><br />
153
 
                                                <input type="text" id="edit-menu-item-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-title" name="menu-item-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->title ); ?>" />
154
 
                                        </label>
155
 
                                </p>
156
 
                                <p class="field-title-attribute description description-wide">
157
 
                                        <label for="edit-menu-item-attr-title-<?php echo $item_id; ?>">
158
 
                                                <?php _e( 'Title Attribute' ); ?><br />
159
 
                                                <input type="text" id="edit-menu-item-attr-title-<?php echo $item_id; ?>" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_excerpt ); ?>" />
160
 
                                        </label>
161
 
                                </p>
162
 
                                <p class="field-link-target description">
163
 
                                        <label for="edit-menu-item-target-<?php echo $item_id; ?>">
164
 
                                                <input type="checkbox" id="edit-menu-item-target-<?php echo $item_id; ?>" value="_blank" name="menu-item-target[<?php echo $item_id; ?>]"<?php checked( $item->target, '_blank' ); ?> />
165
 
                                                <?php _e( 'Open link in a new window/tab' ); ?>
166
 
                                        </label>
167
 
                                </p>
168
 
                                <p class="field-css-classes description description-thin">
169
 
                                        <label for="edit-menu-item-classes-<?php echo $item_id; ?>">
170
 
                                                <?php _e( 'CSS Classes (optional)' ); ?><br />
171
 
                                                <input type="text" id="edit-menu-item-classes-<?php echo $item_id; ?>" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php echo $item_id; ?>]" value="<?php echo esc_attr( implode(' ', $item->classes ) ); ?>" />
172
 
                                        </label>
173
 
                                </p>
174
 
                                <p class="field-xfn description description-thin">
175
 
                                        <label for="edit-menu-item-xfn-<?php echo $item_id; ?>">
176
 
                                                <?php _e( 'Link Relationship (XFN)' ); ?><br />
177
 
                                                <input type="text" id="edit-menu-item-xfn-<?php echo $item_id; ?>" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->xfn ); ?>" />
178
 
                                        </label>
179
 
                                </p>
180
 
                                <p class="field-description description description-wide">
181
 
                                        <label for="edit-menu-item-description-<?php echo $item_id; ?>">
182
 
                                                <?php _e( 'Description' ); ?><br />
183
 
                                                <textarea id="edit-menu-item-description-<?php echo $item_id; ?>" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php echo $item_id; ?>]"><?php echo esc_html( $item->description ); // textarea_escaped ?></textarea>
184
 
                                                <span class="description"><?php _e('The description will be displayed in the menu if the current theme supports it.'); ?></span>
185
 
                                        </label>
186
 
                                </p>
187
 
 
188
 
                                <p class="field-move hide-if-no-js description description-wide">
189
 
                                        <label>
190
 
                                                <span><?php _e( 'Move' ); ?></span>
191
 
                                                <a href="#" class="menus-move menus-move-up" data-dir="up"><?php _e( 'Up one' ); ?></a>
192
 
                                                <a href="#" class="menus-move menus-move-down" data-dir="down"><?php _e( 'Down one' ); ?></a>
193
 
                                                <a href="#" class="menus-move menus-move-left" data-dir="left"></a>
194
 
                                                <a href="#" class="menus-move menus-move-right" data-dir="right"></a>
195
 
                                                <a href="#" class="menus-move menus-move-top" data-dir="top"><?php _e( 'To the top' ); ?></a>
196
 
                                        </label>
197
 
                                </p>
198
 
 
199
 
                                <div class="menu-item-actions description-wide submitbox">
200
 
                                        <?php if ( 'custom' != $item->type && $original_title !== false ) : ?>
201
 
                                                <p class="link-to-original">
202
 
                                                        <?php printf( __('Original: %s'), '<a href="' . esc_attr( $item->url ) . '">' . esc_html( $original_title ) . '</a>' ); ?>
203
 
                                                </p>
204
 
                                        <?php endif; ?>
205
 
                                        <a class="item-delete submitdelete deletion" id="delete-<?php echo $item_id; ?>" href="<?php
206
 
                                        echo wp_nonce_url(
207
 
                                                add_query_arg(
208
 
                                                        array(
209
 
                                                                'action' => 'delete-menu-item',
210
 
                                                                'menu-item' => $item_id,
211
 
                                                        ),
212
 
                                                        admin_url( 'nav-menus.php' )
213
 
                                                ),
214
 
                                                'delete-menu_item_' . $item_id
215
 
                                        ); ?>"><?php _e( 'Remove' ); ?></a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php echo $item_id; ?>" href="<?php echo esc_url( add_query_arg( array( 'edit-menu-item' => $item_id, 'cancel' => time() ), admin_url( 'nav-menus.php' ) ) );
216
 
                                                ?>#menu-item-settings-<?php echo $item_id; ?>"><?php _e('Cancel'); ?></a>
217
 
                                </div>
218
 
 
219
 
                                <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
220
 
                                <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" />
221
 
                                <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
222
 
                                <input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_item_parent ); ?>" />
223
 
                                <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
224
 
                                <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
225
 
                        </div><!-- .menu-item-settings-->
226
 
                        <ul class="menu-item-transport"></ul>
227
 
                <?php
228
 
                $output .= ob_get_clean();
229
 
        }
230
 
 
231
 
} // Walker_Nav_Menu_Edit
232
 
 
233
 
/**
234
 
 * Create HTML list of nav menu input items.
235
 
 *
236
 
 * @since 3.0.0
237
 
 * @uses Walker_Nav_Menu
238
 
 */
239
 
class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
240
 
        /**
241
 
         *
242
 
         * @param array $fields
243
 
         */
244
 
        public function __construct( $fields = false ) {
245
 
                if ( $fields ) {
246
 
                        $this->db_fields = $fields;
247
 
                }
248
 
        }
249
 
 
250
 
        /**
251
 
         * Starts the list before the elements are added.
252
 
         *
253
 
         * @see Walker_Nav_Menu::start_lvl()
254
 
         *
255
 
         * @since 3.0.0
256
 
         *
257
 
         * @param string $output Passed by reference. Used to append additional content.
258
 
         * @param int    $depth  Depth of page. Used for padding.
259
 
         * @param array  $args   Not used.
260
 
         */
261
 
        public function start_lvl( &$output, $depth = 0, $args = array() ) {
262
 
                $indent = str_repeat( "\t", $depth );
263
 
                $output .= "\n$indent<ul class='children'>\n";
264
 
        }
265
 
 
266
 
        /**
267
 
         * Ends the list of after the elements are added.
268
 
         *
269
 
         * @see Walker_Nav_Menu::end_lvl()
270
 
         *
271
 
         * @since 3.0.0
272
 
         *
273
 
         * @param string $output Passed by reference. Used to append additional content.
274
 
         * @param int    $depth  Depth of page. Used for padding.
275
 
         * @param array  $args   Not used.
276
 
         */
277
 
        public function end_lvl( &$output, $depth = 0, $args = array() ) {
278
 
                $indent = str_repeat( "\t", $depth );
279
 
                $output .= "\n$indent</ul>";
280
 
        }
281
 
 
282
 
        /**
283
 
         * Start the element output.
284
 
         *
285
 
         * @see Walker_Nav_Menu::start_el()
286
 
         *
287
 
         * @since 3.0.0
288
 
         *
289
 
         * @global int $_nav_menu_placeholder
290
 
         *
291
 
         * @param string $output Passed by reference. Used to append additional content.
292
 
         * @param object $item   Menu item data object.
293
 
         * @param int    $depth  Depth of menu item. Used for padding.
294
 
         * @param array  $args   Not used.
295
 
         * @param int    $id     Not used.
296
 
         */
297
 
        public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
298
 
                global $_nav_menu_placeholder;
299
 
 
300
 
                $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
301
 
                $possible_object_id = isset( $item->post_type ) && 'nav_menu_item' == $item->post_type ? $item->object_id : $_nav_menu_placeholder;
302
 
                $possible_db_id = ( ! empty( $item->ID ) ) && ( 0 < $possible_object_id ) ? (int) $item->ID : 0;
303
 
 
304
 
                $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
305
 
 
306
 
                $output .= $indent . '<li>';
307
 
                $output .= '<label class="menu-item-title">';
308
 
                $output .= '<input type="checkbox" class="menu-item-checkbox';
309
 
 
310
 
                if ( ! empty( $item->front_or_home ) )
311
 
                        $output .= ' add-to-top';
312
 
 
313
 
                $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> ';
314
 
 
315
 
                if ( ! empty( $item->label ) ) {
316
 
                        $title = $item->label;
317
 
                } elseif ( isset( $item->post_type ) ) {
318
 
                        /** This filter is documented in wp-includes/post-template.php */
319
 
                        $title = apply_filters( 'the_title', $item->post_title, $item->ID );
320
 
                        if ( ! empty( $item->front_or_home ) && _x( 'Home', 'nav menu home label' ) !== $title )
321
 
                                $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $title );
322
 
                }
323
 
 
324
 
                $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title );
325
 
                $output .= '</label>';
326
 
 
327
 
                // Menu item hidden fields
328
 
                $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
329
 
                $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
330
 
                $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />';
331
 
                $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="'. esc_attr( $item->type ) .'" />';
332
 
                $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
333
 
                $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
334
 
                $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
335
 
                $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />';
336
 
                $output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="'. esc_attr( implode( ' ', $item->classes ) ) .'" />';
337
 
                $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="'. esc_attr( $item->xfn ) .'" />';
338
 
        }
339
 
 
340
 
} // Walker_Nav_Menu_Checklist
 
6
 * @subpackage Nav_Menus
 
7
 * @since 3.0.0
 
8
 */
 
9
 
 
10
/** Walker_Nav_Menu_Edit class */
 
11
require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php' );
 
12
 
 
13
/** Walker_Nav_Menu_Checklist class */
 
14
require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-checklist.php' );
341
15
 
342
16
/**
343
17
 * Prints the appropriate response to a menu quick search.
426
100
                        ));
427
101
                        if ( empty( $terms ) || is_wp_error( $terms ) )
428
102
                                return;
429
 
                        foreach( (array) $terms as $term ) {
 
103
                        foreach ( (array) $terms as $term ) {
430
104
                                if ( 'markup' == $response_format ) {
431
105
                                        echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
432
106
                                } elseif ( 'json' == $response_format ) {
480
154
        if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) )
481
155
                return;
482
156
 
483
 
        $initial_meta_boxes = array( 'add-page', 'add-post', 'add-custom-links', 'add-category' );
 
157
        $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
484
158
        $hidden_meta_boxes = array();
485
159
 
486
160
        foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) {
528
202
                        $id = $post_type->name;
529
203
                        // Give pages a higher priority.
530
204
                        $priority = ( 'page' == $post_type->name ? 'core' : 'default' );
531
 
                        add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
 
205
                        add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
532
206
                }
533
207
        }
534
208
}
819
493
                                        }
820
494
                                }
821
495
 
 
496
                                $post_type = get_post_type_object( $post_type_name );
 
497
                                $archive_link = get_post_type_archive_link( $post_type_name );
 
498
                                if ( $post_type->has_archive ) {
 
499
                                        $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
 
500
                                        array_unshift( $posts, (object) array(
 
501
                                                'ID' => 0,
 
502
                                                'object_id' => $_nav_menu_placeholder,
 
503
                                                'object'     => $post_type_name,
 
504
                                                'post_content' => '',
 
505
                                                'post_excerpt' => '',
 
506
                                                'post_title' => $post_type->labels->archives,
 
507
                                                'post_type' => 'nav_menu_item',
 
508
                                                'type' => 'post_type_archive',
 
509
                                                'url' => get_post_type_archive_link( $post_type_name ),
 
510
                                        ) );
 
511
                                }
 
512
 
822
513
                                /**
823
514
                                 * Filter the posts displayed in the 'View All' tab of the current
824
515
                                 * post type's menu items meta box.
1081
772
        if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
1082
773
 
1083
774
                // Loop through all the menu items' POST values.
1084
 
                foreach( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
 
775
                foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
1085
776
                        if (
1086
777
                                // Checkbox is not checked.
1087
778
                                empty( $_item_object_data['menu-item-object-id'] ) &&
1208
899
                 */
1209
900
                $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
1210
901
 
1211
 
                if ( class_exists( $walker_class_name ) )
 
902
                if ( class_exists( $walker_class_name ) ) {
1212
903
                        $walker = new $walker_class_name;
1213
 
                else
1214
 
                        return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) );
 
904
                } else {
 
905
                        return new WP_Error( 'menu_walker_not_exist',
 
906
                                /* translators: %s: walker class name */
 
907
                                sprintf( __( 'The Walker class named %s does not exist.' ),
 
908
                                        '<strong>' . $walker_class_name . '</strong>'
 
909
                                )
 
910
                        );
 
911
                }
1215
912
 
1216
913
                $some_pending_menu_items = $some_invalid_menu_items = false;
1217
 
                foreach( (array) $menu_items as $menu_item ) {
 
914
                foreach ( (array) $menu_items as $menu_item ) {
1218
915
                        if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
1219
916
                                $some_pending_menu_items = true;
1220
917
                        if ( ! empty( $menu_item->_invalid ) )
1262
959
 * @access private
1263
960
 * @since 3.0.0
1264
961
 *
1265
 
 * @global wpdb $wpdb
 
962
 * @global wpdb $wpdb WordPress database abstraction object.
1266
963
 */
1267
964
function _wp_delete_orphaned_draft_menu_items() {
1268
965
        global $wpdb;
1271
968
        // Delete orphaned draft menu items.
1272
969
        $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
1273
970
 
1274
 
        foreach( (array) $menu_items_to_delete as $menu_item_id )
 
971
        foreach ( (array) $menu_items_to_delete as $menu_item_id )
1275
972
                wp_delete_post( $menu_item_id, true );
1276
973
}
1277
974
 
1302
999
        wp_defer_term_counting( true );
1303
1000
        // Loop through all the menu items' POST variables
1304
1001
        if ( ! empty( $_POST['menu-item-db-id'] ) ) {
1305
 
                foreach( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
 
1002
                foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) {
1306
1003
 
1307
1004
                        // Menu item title can't be blank
1308
1005
                        if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] )
1352
1049
        /** This action is documented in wp-includes/nav-menu.php */
1353
1050
        do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
1354
1051
 
1355
 
        $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( '<strong>%1$s</strong> has been updated.' ), $nav_menu_selected_title ) . '</p></div>';
 
1052
        $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' .
 
1053
                /* translators: %s: nav menu title */
 
1054
                sprintf( __( '%s has been updated.' ),
 
1055
                        '<strong>' . $nav_menu_selected_title . '</strong>'
 
1056
                ) . '</p></div>';
 
1057
 
1356
1058
        unset( $menu_items, $unsorted_menu_items );
1357
1059
 
1358
1060
        return $messages;