245 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; |
245 $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; |
246 |
246 |
247 $output .= $indent . '<li>'; |
247 $output .= $indent . '<li>'; |
248 $output .= '<label class="menu-item-title">'; |
248 $output .= '<label class="menu-item-title">'; |
249 $output .= '<input type="checkbox" class="menu-item-checkbox'; |
249 $output .= '<input type="checkbox" class="menu-item-checkbox'; |
250 if ( ! empty( $item->_add_to_top ) ) { |
250 if ( property_exists( $item, 'front_or_home' ) && $item->front_or_home ) { |
|
251 $title = sprintf( _x( 'Home: %s', 'nav menu front page title' ), $item->post_title ); |
251 $output .= ' add-to-top'; |
252 $output .= ' add-to-top'; |
252 } |
253 } |
253 $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; |
254 $output .= '" name="menu-item[' . $possible_object_id . '][menu-item-object-id]" value="'. esc_attr( $item->object_id ) .'" /> '; |
254 $output .= empty( $item->label ) ? esc_html( $item->title ) : esc_html( $item->label ); |
255 $output .= isset( $title ) ? esc_html( $title ) : esc_html( $item->title ); |
255 $output .= '</label>'; |
256 $output .= '</label>'; |
256 |
257 |
257 // Menu item hidden fields |
258 // Menu item hidden fields |
258 $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />'; |
259 $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />'; |
259 $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />'; |
260 $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />'; |
509 </p> |
510 </p> |
510 <?php |
511 <?php |
511 } |
512 } |
512 ?> |
513 ?> |
513 <p class="button-controls"> |
514 <p class="button-controls"> |
514 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
515 <?php submit_button( __( 'Save' ), 'primary right', 'nav-menu-locations', false, disabled( $nav_menu_selected_id, 0, false ) ); ?> |
515 <?php submit_button( __( 'Save' ), 'primary', 'nav-menu-locations', false, disabled( $nav_menu_selected_id, 0, false ) ); ?> |
516 <span class="spinner"></span> |
516 </p> |
517 </p> |
517 <?php |
518 <?php |
518 } |
519 } |
519 |
520 |
520 /** |
521 /** |
558 </label> |
559 </label> |
559 </p> |
560 </p> |
560 |
561 |
561 <p class="button-controls"> |
562 <p class="button-controls"> |
562 <span class="add-to-menu"> |
563 <span class="add-to-menu"> |
563 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
564 <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> |
564 <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> |
565 <span class="spinner"></span> |
565 </span> |
566 </span> |
566 </p> |
567 </p> |
567 |
568 |
568 </div><!-- /.customlinkdiv --> |
569 </div><!-- /.customlinkdiv --> |
569 <?php |
570 <?php |
690 $search_results = array(); |
691 $search_results = array(); |
691 } |
692 } |
692 ?> |
693 ?> |
693 <p class="quick-search-wrap"> |
694 <p class="quick-search-wrap"> |
694 <input type="search" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" /> |
695 <input type="search" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" /> |
695 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
696 <span class="spinner"></span> |
696 <?php submit_button( __( 'Search' ), 'quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?> |
697 <?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?> |
697 </p> |
698 </p> |
698 |
699 |
699 <ul id="<?php echo $post_type_name; ?>-search-checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear"> |
700 <ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear"> |
700 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
701 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
701 <?php |
702 <?php |
702 $args['walker'] = $walker; |
703 $args['walker'] = $walker; |
703 echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); |
704 echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); |
704 ?> |
705 ?> |
716 <?php if ( ! empty( $page_links ) ) : ?> |
717 <?php if ( ! empty( $page_links ) ) : ?> |
717 <div class="add-menu-item-pagelinks"> |
718 <div class="add-menu-item-pagelinks"> |
718 <?php echo $page_links; ?> |
719 <?php echo $page_links; ?> |
719 </div> |
720 </div> |
720 <?php endif; ?> |
721 <?php endif; ?> |
721 <ul id="<?php echo $post_type_name; ?>checklist" class="list:<?php echo $post_type_name?> categorychecklist form-no-clear"> |
722 <ul id="<?php echo $post_type_name; ?>checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear"> |
722 <?php |
723 <?php |
723 $args['walker'] = $walker; |
724 $args['walker'] = $walker; |
724 |
725 |
725 // if we're dealing with pages, let's put a checkbox for the front page at the top of the list |
726 // if we're dealing with pages, let's put a checkbox for the front page at the top of the list |
726 if ( 'page' == $post_type_name ) { |
727 if ( 'page' == $post_type_name ) { |
727 $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0; |
728 $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0; |
728 if ( ! empty( $front_page ) ) { |
729 if ( ! empty( $front_page ) ) { |
729 $front_page_obj = get_post( $front_page ); |
730 $front_page_obj = get_post( $front_page ); |
730 $front_page_obj->_add_to_top = true; |
731 $front_page_obj->front_or_home = true; |
731 $front_page_obj->label = sprintf( _x('Home: %s', 'nav menu front page title'), $front_page_obj->post_title ); |
|
732 array_unshift( $posts, $front_page_obj ); |
732 array_unshift( $posts, $front_page_obj ); |
733 } else { |
733 } else { |
734 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; |
734 $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; |
735 array_unshift( $posts, (object) array( |
735 array_unshift( $posts, (object) array( |
736 '_add_to_top' => true, |
736 'front_or_home' => true, |
737 'ID' => 0, |
737 'ID' => 0, |
738 'object_id' => $_nav_menu_placeholder, |
738 'object_id' => $_nav_menu_placeholder, |
739 'post_content' => '', |
739 'post_content' => '', |
740 'post_excerpt' => '', |
740 'post_excerpt' => '', |
741 'post_parent' => '', |
741 'post_parent' => '', |
777 )); |
777 )); |
778 ?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a> |
778 ?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a> |
779 </span> |
779 </span> |
780 |
780 |
781 <span class="add-to-menu"> |
781 <span class="add-to-menu"> |
782 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
782 <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="submit-posttype-<?php echo $post_type_name; ?>" /> |
783 <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="submit-posttype-<?php echo $post_type_name; ?>" /> |
783 <span class="spinner"></span> |
784 </span> |
784 </span> |
785 </p> |
785 </p> |
786 |
786 |
787 </div><!-- /.posttypediv --> |
787 </div><!-- /.posttypediv --> |
788 <?php |
788 <?php |
894 <?php if ( ! empty( $page_links ) ) : ?> |
894 <?php if ( ! empty( $page_links ) ) : ?> |
895 <div class="add-menu-item-pagelinks"> |
895 <div class="add-menu-item-pagelinks"> |
896 <?php echo $page_links; ?> |
896 <?php echo $page_links; ?> |
897 </div> |
897 </div> |
898 <?php endif; ?> |
898 <?php endif; ?> |
899 <ul id="<?php echo $taxonomy_name; ?>checklist" class="list:<?php echo $taxonomy_name?> categorychecklist form-no-clear"> |
899 <ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear"> |
900 <?php |
900 <?php |
901 $args['walker'] = $walker; |
901 $args['walker'] = $walker; |
902 echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args ); |
902 echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args ); |
903 ?> |
903 ?> |
904 </ul> |
904 </ul> |
921 $search_results = array(); |
921 $search_results = array(); |
922 } |
922 } |
923 ?> |
923 ?> |
924 <p class="quick-search-wrap"> |
924 <p class="quick-search-wrap"> |
925 <input type="search" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" /> |
925 <input type="search" class="quick-search input-with-default-title" title="<?php esc_attr_e('Search'); ?>" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" /> |
926 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
926 <span class="spinner"></span> |
927 <?php submit_button( __( 'Search' ), 'quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?> |
927 <?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?> |
928 </p> |
928 </p> |
929 |
929 |
930 <ul id="<?php echo $taxonomy_name; ?>-search-checklist" class="list:<?php echo $taxonomy_name?> categorychecklist form-no-clear"> |
930 <ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear"> |
931 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
931 <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
932 <?php |
932 <?php |
933 $args['walker'] = $walker; |
933 $args['walker'] = $walker; |
934 echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); |
934 echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); |
935 ?> |
935 ?> |
953 )); |
953 )); |
954 ?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all"><?php _e('Select All'); ?></a> |
954 ?>#taxonomy-<?php echo $taxonomy_name; ?>" class="select-all"><?php _e('Select All'); ?></a> |
955 </span> |
955 </span> |
956 |
956 |
957 <span class="add-to-menu"> |
957 <span class="add-to-menu"> |
958 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> |
958 <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="submit-taxonomy-<?php echo $taxonomy_name; ?>" /> |
959 <input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="submit-taxonomy-<?php echo $taxonomy_name; ?>" /> |
959 <span class="spinner"></span> |
960 </span> |
960 </span> |
961 </p> |
961 </p> |
962 |
962 |
963 </div><!-- /.taxonomydiv --> |
963 </div><!-- /.taxonomydiv --> |
964 <?php |
964 <?php |
1148 * @since 3.0.0 |
1148 * @since 3.0.0 |
1149 * |
1149 * |
1150 */ |
1150 */ |
1151 function _wp_delete_orphaned_draft_menu_items() { |
1151 function _wp_delete_orphaned_draft_menu_items() { |
1152 global $wpdb; |
1152 global $wpdb; |
1153 $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS); |
1153 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
1154 |
1154 |
1155 // delete orphaned draft menu items |
1155 // delete orphaned draft menu items |
1156 $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 ) ); |
1156 $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 ) ); |
1157 |
1157 |
1158 foreach( (array) $menu_items_to_delete as $menu_item_id ) |
1158 foreach( (array) $menu_items_to_delete as $menu_item_id ) |