Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../wp-inclu.../blocks
File: media-text.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/media-text` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/media-text` block on server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 6.6.0
[10] Fix | Delete
*
[11] Fix | Delete
* @param array $attributes The block attributes.
[12] Fix | Delete
* @param string $content The block rendered content.
[13] Fix | Delete
*
[14] Fix | Delete
* @return string Returns the Media & Text block markup, if useFeaturedImage is true.
[15] Fix | Delete
*/
[16] Fix | Delete
function render_block_core_media_text( $attributes, $content ) {
[17] Fix | Delete
if ( false === $attributes['useFeaturedImage'] ) {
[18] Fix | Delete
return $content;
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
if ( in_the_loop() ) {
[22] Fix | Delete
update_post_thumbnail_cache();
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
$current_featured_image = get_the_post_thumbnail_url();
[26] Fix | Delete
if ( ! $current_featured_image ) {
[27] Fix | Delete
return $content;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
$media_tag_processor = new WP_HTML_Tag_Processor( $content );
[31] Fix | Delete
$wrapping_figure_query = array(
[32] Fix | Delete
'tag_name' => 'figure',
[33] Fix | Delete
'class_name' => 'wp-block-media-text__media',
[34] Fix | Delete
);
[35] Fix | Delete
$has_media_on_right = isset( $attributes['mediaPosition'] ) && 'right' === $attributes['mediaPosition'];
[36] Fix | Delete
$image_fill = isset( $attributes['imageFill'] ) && $attributes['imageFill'];
[37] Fix | Delete
$focal_point = isset( $attributes['focalPoint'] ) ? round( $attributes['focalPoint']['x'] * 100 ) . '% ' . round( $attributes['focalPoint']['y'] * 100 ) . '%' : '50% 50%';
[38] Fix | Delete
$unique_id = 'wp-block-media-text__media-' . wp_unique_id();
[39] Fix | Delete
[40] Fix | Delete
if ( $has_media_on_right ) {
[41] Fix | Delete
// Loop through all the figure tags and set a bookmark on the last figure tag.
[42] Fix | Delete
while ( $media_tag_processor->next_tag( $wrapping_figure_query ) ) {
[43] Fix | Delete
$media_tag_processor->set_bookmark( 'last_figure' );
[44] Fix | Delete
}
[45] Fix | Delete
if ( $media_tag_processor->has_bookmark( 'last_figure' ) ) {
[46] Fix | Delete
$media_tag_processor->seek( 'last_figure' );
[47] Fix | Delete
if ( $image_fill ) {
[48] Fix | Delete
$media_tag_processor->set_attribute( 'style', 'background-image:url(' . esc_url( $current_featured_image ) . ');background-position:' . $focal_point . ';' );
[49] Fix | Delete
} else {
[50] Fix | Delete
// Insert a unique ID to identify the figure tag.
[51] Fix | Delete
$media_tag_processor->set_attribute( 'id', $unique_id );
[52] Fix | Delete
}
[53] Fix | Delete
}
[54] Fix | Delete
} else {
[55] Fix | Delete
if ( $media_tag_processor->next_tag( $wrapping_figure_query ) ) {
[56] Fix | Delete
if ( $image_fill ) {
[57] Fix | Delete
$media_tag_processor->set_attribute( 'style', 'background-image:url(' . esc_url( $current_featured_image ) . ');background-position:' . $focal_point . ';' );
[58] Fix | Delete
} else {
[59] Fix | Delete
// Insert a unique ID to identify the figure tag.
[60] Fix | Delete
$media_tag_processor->set_attribute( 'id', $unique_id );
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
$content = $media_tag_processor->get_updated_html();
[66] Fix | Delete
[67] Fix | Delete
// If the image is not set to fill, add the image tag inside the figure tag,
[68] Fix | Delete
// and update the image attributes in order to display the featured image.
[69] Fix | Delete
if ( ! $image_fill ) {
[70] Fix | Delete
$media_size_slug = isset( $attributes['mediaSizeSlug'] ) ? $attributes['mediaSizeSlug'] : 'full';
[71] Fix | Delete
$image_tag = '<img class="wp-block-media-text__featured_image">';
[72] Fix | Delete
$content = preg_replace(
[73] Fix | Delete
'/(<figure\s+id="' . preg_quote( $unique_id, '/' ) . '"\s+class="wp-block-media-text__media"\s*>)/',
[74] Fix | Delete
'$1' . $image_tag,
[75] Fix | Delete
$content
[76] Fix | Delete
);
[77] Fix | Delete
[78] Fix | Delete
$image_tag_processor = new WP_HTML_Tag_Processor( $content );
[79] Fix | Delete
if ( $image_tag_processor->next_tag(
[80] Fix | Delete
array(
[81] Fix | Delete
'tag_name' => 'figure',
[82] Fix | Delete
'id' => $unique_id,
[83] Fix | Delete
)
[84] Fix | Delete
) ) {
[85] Fix | Delete
// The ID is only used to ensure that the correct figure tag is selected,
[86] Fix | Delete
// and can now be removed.
[87] Fix | Delete
$image_tag_processor->remove_attribute( 'id' );
[88] Fix | Delete
if ( $image_tag_processor->next_tag(
[89] Fix | Delete
array(
[90] Fix | Delete
'tag_name' => 'img',
[91] Fix | Delete
'class_name' => 'wp-block-media-text__featured_image',
[92] Fix | Delete
)
[93] Fix | Delete
) ) {
[94] Fix | Delete
$image_tag_processor->set_attribute( 'src', esc_url( $current_featured_image ) );
[95] Fix | Delete
$image_tag_processor->set_attribute( 'class', 'wp-image-' . get_post_thumbnail_id() . ' size-' . $media_size_slug );
[96] Fix | Delete
$image_tag_processor->set_attribute( 'alt', trim( strip_tags( get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ) ) ) );
[97] Fix | Delete
[98] Fix | Delete
$content = $image_tag_processor->get_updated_html();
[99] Fix | Delete
}
[100] Fix | Delete
}
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
return $content;
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* Registers the `core/media-text` block renderer on server.
[108] Fix | Delete
*
[109] Fix | Delete
* @since 6.6.0
[110] Fix | Delete
*/
[111] Fix | Delete
function register_block_core_media_text() {
[112] Fix | Delete
register_block_type_from_metadata(
[113] Fix | Delete
__DIR__ . '/media-text',
[114] Fix | Delete
array(
[115] Fix | Delete
'render_callback' => 'render_block_core_media_text',
[116] Fix | Delete
)
[117] Fix | Delete
);
[118] Fix | Delete
}
[119] Fix | Delete
add_action( 'init', 'register_block_core_media_text' );
[120] Fix | Delete
[121] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function