diff --git src/wp-includes/embed.php src/wp-includes/embed.php
index cdeaf79..f59443f 100644
|
|
function wp_oembed_register_route() { |
341 | 341 | * Adds oEmbed discovery links in the website <head>. |
342 | 342 | * |
343 | 343 | * @since 4.4.0 |
| 344 | * @since x.x.x Test post type is embeddable with `is_post_type_embeddable`. |
344 | 345 | */ |
345 | 346 | function wp_oembed_add_discovery_links() { |
| 347 | $post_type = get_post_type(); |
346 | 348 | $output = ''; |
347 | 349 | |
348 | | if ( is_singular() ) { |
349 | | $output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n"; |
| 350 | if ( is_singular() && $post_type ) { |
| 351 | if( is_post_type_embeddable($post_type) ) { |
| 352 | $output .= '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n"; |
350 | 353 | |
351 | | if ( class_exists( 'SimpleXMLElement' ) ) { |
352 | | $output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n"; |
| 354 | if ( class_exists( 'SimpleXMLElement' ) ) { |
| 355 | $output .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n"; |
| 356 | } |
353 | 357 | } |
354 | 358 | } |
355 | 359 | |
… |
… |
JS; |
510 | 514 | * Retrieves the oEmbed response data for a given post. |
511 | 515 | * |
512 | 516 | * @since 4.4.0 |
| 517 | * @since x.x.x Test post type is embeddable with `is_post_type_embeddable`. |
513 | 518 | * |
514 | | * @param WP_Post|int $post Post object or ID. |
515 | | * @param int $width The requested width. |
516 | | * @return array|false Response data on success, false if post doesn't exist. |
| 519 | * @param WP_Post|int $post Post object or ID. |
| 520 | * @param int $width The requested width. |
| 521 | * @return array|false Response data on success, false if post doesn't exist, or if post is not embeddable. |
517 | 522 | */ |
518 | 523 | function get_oembed_response_data( $post, $width ) { |
519 | | $post = get_post( $post ); |
| 524 | $post_type = get_post_type( $post ); |
520 | 525 | |
521 | 526 | if ( ! $post ) { |
522 | 527 | return false; |
… |
… |
function get_oembed_response_data( $post, $width ) { |
526 | 531 | return false; |
527 | 532 | } |
528 | 533 | |
| 534 | if( ! is_post_type_embeddable($post_type) ) { |
| 535 | return false; |
| 536 | } |
| 537 | |
529 | 538 | /** |
530 | 539 | * Filter the allowed minimum and maximum widths for the oEmbed response. |
531 | 540 | * |
diff --git src/wp-includes/post.php src/wp-includes/post.php
index 70a7d73..f1c9438 100644
|
|
function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) |
890 | 890 | * @since 2.9.0 |
891 | 891 | * @since 3.0.0 The `show_ui` argument is now enforced on the new post screen. |
892 | 892 | * @since 4.4.0 The `show_ui` argument is now enforced on the post type listing screen and post editing screen. |
| 893 | * @since x.x.x The `is_embeddable` argument has been added. |
893 | 894 | * |
894 | 895 | * @global array $wp_post_types List of post types. |
895 | 896 | * @global WP_Rewrite $wp_rewrite Used for default feeds. |
… |
… |
function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) |
962 | 963 | * @type bool|string $has_archive Whether there should be post type archives, or if a string, the |
963 | 964 | * archive slug to use. Will generate the proper rewrite rules if |
964 | 965 | * $rewrite is enabled. Default false. |
| 966 | * @type bool $is_embeddable Whether this post type should be embeddable through oembed. |
| 967 | * Default is value of $public. |
965 | 968 | * @type bool|array $rewrite { |
966 | 969 | * Triggers the handling of rewrites for this post type. To prevent rewrite, set to false. |
967 | 970 | * Defaults to true, using $post_type as slug. To specify rewrite rules, an array can be |
… |
… |
function register_post_type( $post_type, $args = array() ) { |
1039 | 1042 | 'register_meta_box_cb' => null, |
1040 | 1043 | 'taxonomies' => array(), |
1041 | 1044 | 'has_archive' => false, |
| 1045 | 'is_embeddable' => null, |
1042 | 1046 | 'rewrite' => true, |
1043 | 1047 | 'query_var' => true, |
1044 | 1048 | 'can_export' => true, |
… |
… |
function register_post_type( $post_type, $args = array() ) { |
1163 | 1167 | add_permastruct( $post_type, "{$args->rewrite['slug']}/%$post_type%", $permastruct_args ); |
1164 | 1168 | } |
1165 | 1169 | |
| 1170 | // If not set, default to the setting for public. |
| 1171 | if ( null === $args->is_embeddable ) |
| 1172 | $args->is_embeddable = $args->public; |
| 1173 | |
1166 | 1174 | // Register the post type meta box if a custom callback was specified. |
1167 | 1175 | if ( $args->register_meta_box_cb ) |
1168 | 1176 | add_action( 'add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1 ); |
… |
… |
function is_post_type_viewable( $post_type ) { |
1687 | 1695 | } |
1688 | 1696 | |
1689 | 1697 | /** |
| 1698 | * Determines whether a post type is considered "embeddable". |
| 1699 | * |
| 1700 | * For all post types the 'is_embeddable' value will be evaluated. |
| 1701 | * |
| 1702 | * @param object $post_type Post type name or object. |
| 1703 | * @return bool Whether the post type should be considered embeddable. |
| 1704 | */ |
| 1705 | function is_post_type_embeddable( $post_type ) { |
| 1706 | if ( ! post_type_exists( $post_type ) ) |
| 1707 | return false; |
| 1708 | |
| 1709 | $post_type = get_post_type_object( $post_type ); |
| 1710 | return $post_type->is_embeddable; |
| 1711 | } |
| 1712 | |
| 1713 | /** |
1690 | 1714 | * Retrieve list of latest posts or posts matching criteria. |
1691 | 1715 | * |
1692 | 1716 | * The defaults are as follows: |