Skip to content

Commit b588e47

Browse files
committed
Merge branch 'development' into improve_lcp
2 parents 71b9259 + f8856ba commit b588e47

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

inc/media_offload.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,21 +2782,23 @@ public function add_new_actions() {
27822782

27832783
// Filter loaded data in the editors to use local attachments.
27842784
add_filter( 'content_edit_pre', [ self::$instance, 'replace_urls_in_editor_content' ], 10, 1 );
2785-
$types = get_post_types_by_support( 'editor' );
2786-
foreach ( $types as $type ) {
2787-
$post_type = get_post_type_object( $type );
2788-
if ( property_exists( $post_type, 'show_in_rest' ) && true === $post_type->show_in_rest ) {
2789-
add_filter(
2790-
'rest_prepare_' . $type,
2791-
[
2792-
self::$instance,
2793-
'pre_filter_rest_content',
2794-
],
2795-
10,
2796-
3
2797-
);
2798-
}
2799-
}
2785+
2786+
add_action(
2787+
'init',
2788+
function() {
2789+
$types = get_post_types_by_support( 'editor' );
2790+
2791+
foreach ( $types as $type ) {
2792+
2793+
$post_type = get_post_type_object( $type );
2794+
2795+
if ( property_exists( $post_type, 'show_in_rest' ) && true === $post_type->show_in_rest ) {
2796+
add_filter( 'rest_prepare_' . $type, [ self::$instance, 'pre_filter_rest_content' ], 10, 3 );
2797+
}
2798+
}
2799+
},
2800+
PHP_INT_MAX
2801+
);
28002802

28012803
add_filter( 'get_attached_file', [ $this, 'alter_attached_file_response' ], 10, 2 );
28022804
add_filter(

0 commit comments

Comments
 (0)