~robotparade/wordpress/stable

« back to all changes in this revision

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

  • Committer: Jeff Waugh
  • Date: 2010-06-11 21:00:40 UTC
  • Revision ID: jdub@bethesignal.org-20100611210040-9narx3kdlayc8x39
WordPress 3.0 RC3

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
         * @param object $args
39
39
         */
40
40
        function start_el(&$output, $item, $depth, $args) {
 
41
                global $_wp_nav_menu_max_depth;
 
42
                $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
 
43
 
41
44
                $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
42
45
 
43
46
                ob_start();
68
71
                $title = $item->title;
69
72
 
70
73
                if ( isset( $item->post_status ) && 'draft' == $item->post_status ) {
 
74
                        $classes[] = 'draft';
 
75
                        /* translators: %s: title of menu item in draft status */
 
76
                        $title = sprintf( __('%s (Draft)'), $item->title );
 
77
                } elseif ( isset( $item->post_status ) && 'pending' == $item->post_status ) {
71
78
                        $classes[] = 'pending';
72
 
                        /* translators: %s: title of menu item in draft status */
 
79
                        /* translators: %s: title of menu item in pending status */
73
80
                        $title = sprintf( __('%s (Pending)'), $item->title );
74
81
                }
75
82
 
191
198
                                <input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
192
199
                                <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 ); ?>" />
193
200
                                <input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->menu_order ); ?>" />
 
201
                                <input class="menu-item-data-status" type="hidden" name="menu-item-status[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->post_status ); ?>" />
194
202
                                <input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->type ); ?>" />
195
203
                        </div><!-- .menu-item-settings-->
196
204
                        <ul class="menu-item-transport"></ul>
271
279
        }
272
280
 
273
281
        if ( 'get-post-item' == $type ) {
274
 
                if ( get_post_type_object( $object_type ) ) {
 
282
                if ( post_type_exists( $object_type ) ) {
275
283
                        if ( isset( $request['ID'] ) ) {
276
284
                                $object_id = (int) $request['ID'];
277
285
                                if ( 'markup' == $response_format ) {
288
296
                                        echo "\n";
289
297
                                }
290
298
                        }
291
 
                } elseif ( is_taxonomy( $object_type ) ) {
 
299
                } elseif ( taxonomy_exists( $object_type ) ) {
292
300
                        if ( isset( $request['ID'] ) ) {
293
301
                                $object_id = (int) $request['ID'];
294
302
                                if ( 'markup' == $response_format ) {
365
373
 **/
366
374
function wp_nav_menu_setup() {
367
375
        // Register meta boxes
368
 
        if ( get_registered_nav_menus() && wp_get_nav_menus() )
 
376
        if ( wp_get_nav_menus() )
369
377
                add_meta_box( 'nav-menu-theme-locations', __( 'Theme Locations' ), 'wp_nav_menu_locations_meta_box' , 'nav-menus', 'side', 'default' );
370
378
        add_meta_box( 'add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
371
379
        wp_nav_menu_post_type_meta_boxes();
460
468
 */
461
469
function wp_nav_menu_locations_meta_box() {
462
470
        global $nav_menu_selected_id;
 
471
 
 
472
        if ( ! current_theme_supports( 'menus' ) ) {
 
473
                // We must only support widgets. Leave a message and bail.
 
474
                echo '<p class="howto">' . __('The current theme does not natively support menus, but you can use the &#8220;Custom Menu&#8221; widget to add any menus you create here to the theme&#8217;s sidebar.') . '</p>';
 
475
                return;
 
476
        }
 
477
 
463
478
        $locations = get_registered_nav_menus();
464
479
        $menus = wp_get_nav_menus();
465
480
        $menu_locations = get_nav_menu_locations();
937
952
 *
938
953
 * @since 3.0.0
939
954
 *
940
 
 * @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a draft, orphaned menu item.
 
955
 * @param int $menu_id The menu ID for which to save this item. $menu_id of 0 makes a pending, orphaned menu item.
941
956
 * @param array $menu_data The unsanitized posted menu item data.
942
957
 * @return array The database IDs of the items saved
943
958
 */
1069
1084
 
1070
1085
                $some_pending_menu_items = false;
1071
1086
                foreach( (array) $menu_items as $menu_item ) {
1072
 
                        if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status )
 
1087
                        if ( isset( $menu_item->post_status ) && 'pending' == $menu_item->post_status )
1073
1088
                                $some_pending_menu_items = true;
1074
1089
                }
1075
1090
 
1107
1122
}
1108
1123
 
1109
1124
/**
1110
 
 * Deletes orphaned draft menu items
 
1125
 * Deletes orphaned pending menu items
1111
1126
 *
1112
1127
 * @access private
1113
1128
 * @since 3.0.0
1114
1129
 *
1115
1130
 */
1116
 
function _wp_delete_orphaned_draft_menu_items() {
 
1131
function _wp_delete_orphaned_pending_menu_items() {
1117
1132
        global $wpdb;
1118
1133
        $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
1119
1134
 
1120
 
        // delete orphaned draft menu items
1121
 
        $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 ) );
 
1135
        // delete orphaned pending menu items
 
1136
        $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 = 'pending' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );
1122
1137
 
1123
1138
        foreach( (array) $menu_items_to_delete as $menu_item_id )
1124
1139
                wp_delete_post( $menu_item_id, true );
1125
1140
}
1126
1141
 
1127
 
add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items');
 
1142
add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_pending_menu_items');
1128
1143
 
1129
1144
?>