При обновлении до WordPress 5.1.1 мой сайт генерировал 500 ошибок сервера.В журнале мне сказали:
[19-Mar-2019 10:08:34 UTC] PHP Fatal error: Cannot redeclare has_block() (previously declared in /home/rideands/public_html/wp-includes/blocks.php:81) in /home/rideands/public_html/wp-content/plugins/multiple-content-blocks/assets/inc/template-tags.php on line 67
Похоже, что это может быть конфликт с кодом, который находится в больше не поддерживаемом плагине, множественные блоки контента.
Код, о котором идет речьв новой версии WordPress:
/**
* Determine whether a $post or a string contains a specific block type.
*
* This test optimizes for performance rather than strict accuracy, detecting
* the block type exists but not validating its structure. For strict accuracy,
* you should use the block parser on post content.
*
* @since 5.0.0
* @see parse_blocks()
*
* @param string $block_type Full Block type to look for.
* @param int|string|WP_Post|null $post Optional. Post content, post ID, or post object. Defaults to global $post.
* @return bool Whether the post content contains the specified block.
*/
function has_block( $block_type, $post = null ) {
if ( ! has_blocks( $post ) ) {
return false;
}
if ( ! is_string( $post ) ) {
$wp_post = get_post( $post );
if ( $wp_post instanceof WP_Post ) {
$post = $wp_post->post_content;
}
}
return false !== strpos( $post, '<!-- wp:' . $block_type . ' ' );
}
И код, с которым это противоречит в плагине множественных блоков контента:
/**
* Check if the block has content
*
* @param string $name
* @param array $args Optional. Additional arguments, see get_the_block for more information
*/
function has_block( $name, $args = array() ) {
if( 0 < strlen( get_the_block( $name, $args ) ) )
return true;
return false;
}
Любые идеи, как я могу получитькод в нескольких контент-блоках, отформатированный правильно, чтобы остановить эту ошибку сервера?
Любая помощь будет высоко ценится, спасибо!