Ticket #19958: CustomPostTypeAsHomePages.2.patch
File CustomPostTypeAsHomePages.2.patch, 4.5 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/nav-menu.php
724 724 $args['walker'] = $walker; 725 725 726 726 // if we're dealing with pages, let's put a checkbox for the front page at the top of the list 727 if ( 'page' == $post_type_name ) { 727 // do we have a custom homepage? if not inject a Home page link into the pages list 728 //what page type is it add the front_or_home = true to the set page 729 730 // check we don't have a custom home page and if so get the post type 731 $post_type_show_on_front = 'page' == get_option('show_on_front') ? get_post_type((int) get_option( 'page_on_front' )) : 'page'; 732 733 if ( $post_type_show_on_front == $post_type_name ) { 728 734 $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0; 729 735 if ( ! empty( $front_page ) ) { 730 736 $front_page_obj = get_post( $front_page ); -
wp-admin/options-reading.php
114 114 </label> 115 115 </p> 116 116 <ul> 117 <li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( a rray( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front') ) ) ); ?></label></li>117 <li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( apply_filters('options-front-page',array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ) ); ?></label></li> 118 118 <li><label for="page_for_posts"><?php printf( __( 'Posts page: %s' ), wp_dropdown_pages( array( 'name' => 'page_for_posts', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) ) ) ); ?></label></li> 119 119 </ul> 120 120 <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?> -
wp-includes/post.php
3596 3596 } 3597 3597 3598 3598 /** 3599 * Checks for value is in the hierarchical_post_types 3600 * 3601 *@return bool 3602 */ 3603 function filter_hierarchical_post_types($post_types){ 3604 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); 3605 return in_array( $post_types, $hierarchical_post_types ); 3606 } 3607 3608 3609 /** 3599 3610 * Retrieve a list of pages. 3600 3611 * 3601 3612 * The defaults that can be overridden are the following: 'child_of', … … 3628 3639 $number = (int) $number; 3629 3640 $offset = (int) $offset; 3630 3641 3631 // Make sure the post type is hierarchical 3642 // Make sure we have a valid post type 3643 if ( !is_array( $post_type ) ) 3644 $post_type = explode( ',', $post_type ); 3645 if ( array_diff( $post_type, get_post_types() ) ) 3646 return $pages; 3647 // Make sure the all post types are hierarchical 3632 3648 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); 3633 if ( !in_array( $post_type, $hierarchical_post_types ) ) 3649 // remove any elemnts not in $hierarchical_post_types 3650 $post_type = array_filter($post_type, "filter_hierarchical_post_types"); 3651 //then check one last time to make sure 3652 if ( !$post_type ) 3634 3653 return $pages; 3635 3654 3636 3655 // Make sure we have a valid post status … … 3733 3752 if ( $parent >= 0 ) 3734 3753 $where .= $wpdb->prepare(' AND post_parent = %d ', $parent); 3735 3754 3755 // Check if post_type is an array so that Custom Page types can be added to dropdowns and lists 3756 if ( 1 == count( $post_type ) ) { 3757 $where_post_type = $wpdb->prepare("post_type = %s" , array_shift( $post_type ) ); 3758 } else{ 3759 $post_type = implode( "', '", $post_type ); 3760 $where_post_type = "post_type IN ('$post_type')"; 3761 } 3762 3736 3763 if ( 1 == count( $post_status ) ) { 3737 $where_post_type = $wpdb->prepare( "post_type = %s AND post_status = %s", $post_type,array_shift( $post_status ) );3764 $where_post_type .= $wpdb->prepare( " AND post_status = %s", array_shift( $post_status ) ); 3738 3765 } else { 3739 3766 $post_status = implode( "', '", $post_status ); 3740 $where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $post_type );3767 $where_post_type .= "AND post_status IN ('$post_status')" ; 3741 3768 } 3742 3769 3743 3770 $orderby_array = array();