Ticket #19958: CustomPostTypeAsHomePages.3.patch
File CustomPostTypeAsHomePages.3.patch, 8.1 KB (added by , 12 years ago) |
---|
-
.
-
wp-admin/includes/nav-menu.php
Property changes on: . ___________________________________________________________________ Added: svn:ignore ## -0,0 +1,2 ## +wordpress +wp-config.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( array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li> 117 <?php 118 // this is in the wwrong place here for code and test need to be moved - not sure where 119 120 /** 121 * this fillter adds all the post types that have 'show_in_home_page_list' => true set 122 * to the 'post_type' array in the past in $args array 123 * 124 * @uses get_post_types 125 * 126 * @param array $args 127 * @return $args 128 * 129 */ 130 function filter_register_post_type_add_to_front_or_home_list($args) { 131 // do we have any custom post types to add in to the list 132 //var $custom_post_types_for_homePage = null; 133 $custom_post_types_for_homePage = get_post_types(array('show_in_home_page_list' => true, )); 134 foreach ($custom_post_types_for_homePage as $custom_post_type) { 135 if(array_key_exists('post_type', $args) && in_array('page',$args ) ){ 136 if(is_array($args['post_type'])){ 137 $args['post_type'] = array_merge( $args['post_type'], array($custom_post_type )); 138 }else{ 139 $args['post_type'] = array($args['post_type'] ,$custom_post_type ); 140 } 141 }else{ 142 $args['post_type'] = array('page', $custom_post_type ); 143 } 144 } 145 //print_r($args); 146 return $args; 147 } 148 // add via filter for now 149 add_filter('options-front-page' , 'filter_register_post_type_add_to_front_or_home_list'); 150 ?> 151 <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 152 <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 153 </ul> 120 154 <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?> -
wp-content/themes
-
wp-includes/link-template.php
Property changes on: wp-content/themes ___________________________________________________________________ Added: svn:ignore ## -0,0 +1 ## +twentytwelveTesting
103 103 if ( empty($post->ID) ) 104 104 return false; 105 105 106 if ( $post->post_type == 'page' ) 106 // check we don't have a custom home page and if so get the post type 107 $post_type_show_on_front = 'page' == get_option('show_on_front') ? get_post_type((int) get_option( 'page_on_front' )) : 'page'; 108 109 if ( $post->post_type == $post_type_show_on_front ) 107 110 return get_page_link($post->ID, $leavename, $sample); 108 111 elseif ( $post->post_type == 'attachment' ) 109 112 return get_attachment_link( $post->ID, $leavename ); -
wp-includes/post.php
1226 1226 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 1227 1227 'can_export' => true, 1228 1228 'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null, 1229 'delete_with_user' => null, 1229 'delete_with_user' => null,'show_in_home_page_list'=> null, 1230 1230 ); 1231 1231 $args = wp_parse_args($args, $defaults); 1232 1232 $args = (object) $args; … … 1267 1267 1268 1268 if ( null === $args->map_meta_cap ) 1269 1269 $args->map_meta_cap = false; 1270 // where to show this custom page type as an option for the home page 1271 if ( null === $args->show_in_home_page_list ) 1272 $args->show_in_home_page_list = false; 1270 1273 1271 1274 $args->cap = get_post_type_capabilities( $args ); 1272 1275 unset($args->capabilities); … … 1310 1313 1311 1314 if ( $args->hierarchical ) 1312 1315 add_rewrite_tag("%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name="); 1316 // check for if it can shown as home 1313 1317 else 1314 1318 add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name="); 1315 1319 … … 3606 3610 } 3607 3611 3608 3612 /** 3613 * Checks for value is in the hierarchical_post_types 3614 * 3615 *@return bool 3616 */ 3617 function filter_hierarchical_post_types($post_types){ 3618 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); 3619 return in_array( $post_types, $hierarchical_post_types ); 3620 } 3621 3622 3623 /** 3609 3624 * Retrieve a list of pages. 3610 3625 * 3611 3626 * The defaults that can be overridden are the following: 'child_of', … … 3638 3653 $number = (int) $number; 3639 3654 $offset = (int) $offset; 3640 3655 3641 // Make sure the post type is hierarchical 3656 // Make sure we have a valid post type 3657 if ( !is_array( $post_type ) ) 3658 $post_type = explode( ',', $post_type ); 3659 if ( array_diff( $post_type, get_post_types() ) ) 3660 return $pages; 3661 // Make sure the all post types are hierarchical 3642 3662 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); 3643 if ( !in_array( $post_type, $hierarchical_post_types ) ) 3663 // remove any elemnts not in $hierarchical_post_types 3664 $post_type = array_filter($post_type, "filter_hierarchical_post_types"); 3665 //then check one last time to make sure 3666 if ( !$post_type ) 3644 3667 return $pages; 3645 3668 3646 3669 // Make sure we have a valid post status … … 3746 3769 if ( $parent >= 0 ) 3747 3770 $where .= $wpdb->prepare(' AND post_parent = %d ', $parent); 3748 3771 3772 // Check if post_type is an array so that Custom Page types can be added to dropdowns and lists 3773 if ( 1 == count( $post_type ) ) { 3774 $where_post_type = $wpdb->prepare("post_type = %s" , array_shift( $post_type ) ); 3775 } else{ 3776 $post_type = implode( "', '", $post_type ); 3777 $where_post_type = "post_type IN ('$post_type')"; 3778 } 3779 3749 3780 if ( 1 == count( $post_status ) ) { 3750 $where_post_type = $wpdb->prepare( "post_type = %s AND post_status = %s", $post_type,array_shift( $post_status ) );3781 $where_post_type .= $wpdb->prepare( " AND post_status = %s", array_shift( $post_status ) ); 3751 3782 } else { 3752 3783 $post_status = implode( "', '", $post_status ); 3753 $where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $post_type );3784 $where_post_type .= "AND post_status IN ('$post_status')" ; 3754 3785 } 3755 3786 3756 3787 $orderby_array = array();