Make WordPress Core

Changeset 61707

Timestamp:
02/20/2026 01:49:59 PM (13 days ago)
Author:
audrasjb
Message:

Editor: Enable Block Hooks for content-like Custom Post Types.

This changeset moves the Block Hooks logic from individual post type filters to the REST controller.

Props bernhard-reiter, iamadisingh, audrasjb, r1k0.
Fixes #62715.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r61703 r61707  
    801801add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' );
    802802
    803 // Update ignoredHookedBlocks postmeta for some post types.
    804 add_filter( 'rest_pre_insert_page', 'update_ignored_hooked_blocks_postmeta' );
    805 add_filter( 'rest_pre_insert_post', 'update_ignored_hooked_blocks_postmeta' );
    806 add_filter( 'rest_pre_insert_wp_block', 'update_ignored_hooked_blocks_postmeta' );
    807 add_filter( 'rest_pre_insert_wp_navigation', 'update_ignored_hooked_blocks_postmeta' );
    808 
    809 // Inject hooked blocks into the Posts endpoint REST response for some given post types.
    810 add_filter( 'rest_prepare_page', 'insert_hooked_blocks_into_rest_response', 10, 2 );
    811 add_filter( 'rest_prepare_post', 'insert_hooked_blocks_into_rest_response', 10, 2 );
    812 add_filter( 'rest_prepare_wp_block', 'insert_hooked_blocks_into_rest_response', 10, 2 );
    813 add_filter( 'rest_prepare_wp_navigation', 'insert_hooked_blocks_into_rest_response', 10, 2 );
    814 
    815803unset( $filter, $action );
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php

    r61637 r61707  
    14781478
    14791479        /**
     1480
     1481
     1482
     1483
     1484
     1485
     1486
     1487
     1488
     1489
     1490
     1491
     1492
     1493
     1494
     1495
     1496
     1497
     1498
     1499
     1500
     1501
     1502
     1503
     1504
     1505
     1506
     1507
     1508
    14801509         * Filters a post before it is inserted via the REST API.
    14811510         *
     
    21262155                }
    21272156            }
     2157
     2158
     2159
     2160
     2161
     2162
     2163
     2164
     2165
     2166
     2167
     2168
     2169
     2170
     2171
     2172
     2173
     2174
     2175
     2176
     2177
     2178
     2179
     2180
     2181
     2182
     2183
     2184
    21282185        }
    21292186
Note: See TracChangeset for help on using the changeset viewer.