Ticket #37376: 37376.2.patch
| File 37376.2.patch, 7.0 KB (added by , 6 weeks ago) |
|---|
-
src/wp-admin/edit-form-advanced.php
a b 113 113 114 114 $preview_url = get_preview_post_link( $post ); 115 115 116 $viewable = is_post_type_viewable( $post_type_object ) ;116 $viewable = is_post_type_viewable( $post_type_object ) && $post_type_object->has_single; 117 117 118 118 if ( $viewable ) { 119 119 -
src/wp-admin/includes/class-wp-posts-list-table.php
a b 1580 1580 } 1581 1581 } 1582 1582 1583 if ( is_post_type_viewable( $post_type_object ) ) {1583 if ( is_post_type_viewable( $post_type_object ) && $post_type_object->has_single ) { 1584 1584 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) { 1585 1585 if ( $can_edit_post ) { 1586 1586 $preview_link = get_preview_post_link( $post ); -
src/wp-admin/includes/meta-boxes.php
a b 62 62 </div> 63 63 64 64 <?php 65 if ( is_post_type_viewable( $post_type_object ) ) :65 if ( is_post_type_viewable( $post_type_object ) && $post_type_object->has_single ) : 66 66 ?> 67 67 <div id="preview-action"> 68 68 <?php -
src/wp-includes/class-wp-post-type.php
a b 247 247 public $has_archive = false; 248 248 249 249 /** 250 * Whether there should be post type singles. 251 * 252 * Will generate the proper rewrite rules if $rewrite is enabled. Default true. 253 * 254 * @since 6.9.0 255 * @var bool $has_single 256 */ 257 public $has_single = true; 258 259 /** 250 260 * Sets the query_var key for this post type. 251 261 * 252 262 * Defaults to $post_type key. If false, a post type cannot be loaded at `?{query_var}={post_slug}`. … … 546 556 'register_meta_box_cb' => null, 547 557 'taxonomies' => array(), 548 558 'has_archive' => false, 559 'has_single' => true, 549 560 'rewrite' => true, 550 561 'query_var' => true, 551 562 'can_export' => true, … … 716 727 } 717 728 718 729 if ( false !== $this->rewrite && ( is_admin() || get_option( 'permalink_structure' ) ) ) { 719 if ( $this->hierarchical ) { 720 add_rewrite_tag( "%$this->name%", '(.+?)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&pagename=" ); 721 } else { 722 add_rewrite_tag( "%$this->name%", '([^/]+)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&name=" ); 730 if ( $this->has_single ) { 731 if ( $this->hierarchical ) { 732 add_rewrite_tag( "%$this->name%", '(.+?)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&pagename=" ); 733 } else { 734 add_rewrite_tag( "%$this->name%", '([^/]+)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&name=" ); 735 } 723 736 } 724 737 725 738 if ( $this->has_archive ) { -
src/wp-includes/link-template.php
a b 319 319 * @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`. 320 320 * @param bool $leavename Optional. Whether to keep post name. Default false. 321 321 * @param bool $sample Optional. Is it a sample permalink. Default false. 322 * @return string|false The post permalink URL. False if the post does not exist .322 * @return string|false The post permalink URL. False if the post does not exist or has no single. 323 323 */ 324 324 function get_post_permalink( $post = 0, $leavename = false, $sample = false ) { 325 325 global $wp_rewrite; … … 332 332 333 333 $post_link = $wp_rewrite->get_extra_permastruct( $post->post_type ); 334 334 335 $slug = $post->post_name;336 337 335 $force_plain_link = wp_force_plain_post_permalink( $post ); 338 336 339 337 $post_type = get_post_type_object( $post->post_type ); 340 338 339 if ( ! $post_type->has_single ) { 340 return false; 341 } 342 343 $slug = $post->post_name; 344 341 345 if ( $post_type->hierarchical ) { 342 346 $slug = get_page_uri( $post ); 343 347 } … … 1413 1417 } 1414 1418 1415 1419 $post_type_object = get_post_type_object( $post->post_type ); 1416 if ( is_post_type_viewable( $post_type_object ) ) {1420 if ( is_post_type_viewable( $post_type_object ) && $post_type_object->has_single ) { 1417 1421 if ( ! $preview_link ) { 1418 1422 $preview_link = set_url_scheme( get_permalink( $post ) ); 1419 1423 } … … 4187 4191 if ( ! empty( $post_id ) ) { 4188 4192 $post_type = get_post_type_object( $post->post_type ); 4189 4193 4194 if ( false === $post_type->has_single ) { 4195 return ''; 4196 } 4197 4190 4198 if ( 'page' === $post->post_type 4191 4199 && 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID 4192 4200 ) { -
src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
a b 669 669 $data = $this->prepare_item_for_response( $post, $request ); 670 670 $response = rest_ensure_response( $data ); 671 671 672 if ( is_post_type_viewable( get_post_type_object( $post->post_type ) ) ) { 672 $post_type_object = get_post_type_object( $post->post_type ); 673 if ( is_post_type_viewable( $post_type_object ) && $post_type_object->has_single ) { 673 674 $response->link_header( 'alternate', get_permalink( $post->ID ), array( 'type' => 'text/html' ) ); 674 675 } 675 676 … … 2115 2116 } 2116 2117 2117 2118 $post_type_obj = get_post_type_object( $post->post_type ); 2118 if ( is_post_type_viewable( $post_type_obj ) && $post_type_obj->public ) {2119 if ( is_post_type_viewable( $post_type_obj ) && $post_type_obj->public && $post_type_obj->has_single ) { 2119 2120 $permalink_template_requested = rest_is_field_included( 'permalink_template', $fields ); 2120 2121 $generated_slug_requested = rest_is_field_included( 'generated_slug', $fields ); 2121 2122 … … 2507 2508 ); 2508 2509 2509 2510 $post_type_obj = get_post_type_object( $this->post_type ); 2510 if ( is_post_type_viewable( $post_type_obj ) && $post_type_obj->public ) {2511 if ( is_post_type_viewable( $post_type_obj ) && $post_type_obj->public && $post_type_obj->has_single ) { 2511 2512 $schema['properties']['permalink_template'] = array( 2512 2513 'description' => __( 'Permalink template for the post.' ), 2513 2514 'type' => 'string', -
src/wp-includes/sitemaps/providers/class-wp-sitemaps-posts.php
a b 37 37 $post_types = get_post_types( array( 'public' => true ), 'objects' ); 38 38 unset( $post_types['attachment'] ); 39 39 40 $post_types = array_filter( $post_types, 'is_post_type_viewable' ); 40 $post_types = array_filter( 41 $post_types, 42 static function ( $post_type ) { 43 return is_post_type_viewable( $post_type ) && $post_type->has_single; 44 } 45 ); 41 46 42 47 /** 43 48 * Filters the list of post object sub types available within the sitemap.