Edit File by line
/home/zeestwma/richards.../wp-inclu.../blocks
File: post-author.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Server-side rendering of the `core/post-author` block.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Renders the `core/post-author` block on the server.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 5.9.0
[10] Fix | Delete
*
[11] Fix | Delete
* @param array $attributes Block attributes.
[12] Fix | Delete
* @param string $content Block default content.
[13] Fix | Delete
* @param WP_Block $block Block instance.
[14] Fix | Delete
* @return string Returns the rendered author block.
[15] Fix | Delete
*/
[16] Fix | Delete
function render_block_core_post_author( $attributes, $content, $block ) {
[17] Fix | Delete
if ( ! isset( $block->context['postId'] ) ) {
[18] Fix | Delete
$author_id = get_query_var( 'author' );
[19] Fix | Delete
} else {
[20] Fix | Delete
$author_id = get_post_field( 'post_author', $block->context['postId'] );
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
if ( empty( $author_id ) ) {
[24] Fix | Delete
return '';
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
if ( isset( $block->context['postType'] ) && ! post_type_supports( $block->context['postType'], 'author' ) ) {
[28] Fix | Delete
return '';
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
$avatar = ! empty( $attributes['avatarSize'] ) ? get_avatar(
[32] Fix | Delete
$author_id,
[33] Fix | Delete
$attributes['avatarSize']
[34] Fix | Delete
) : null;
[35] Fix | Delete
[36] Fix | Delete
$link = get_author_posts_url( $author_id );
[37] Fix | Delete
$author_name = get_the_author_meta( 'display_name', $author_id );
[38] Fix | Delete
if ( ! empty( $attributes['isLink'] && ! empty( $attributes['linkTarget'] ) ) ) {
[39] Fix | Delete
$author_name = sprintf( '<a href="%1$s" target="%2$s">%3$s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $author_name );
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
$byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false;
[43] Fix | Delete
$classes = array();
[44] Fix | Delete
if ( isset( $attributes['itemsJustification'] ) ) {
[45] Fix | Delete
$classes[] = 'items-justified-' . $attributes['itemsJustification'];
[46] Fix | Delete
}
[47] Fix | Delete
if ( isset( $attributes['textAlign'] ) ) {
[48] Fix | Delete
$classes[] = 'has-text-align-' . $attributes['textAlign'];
[49] Fix | Delete
}
[50] Fix | Delete
if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
[51] Fix | Delete
$classes[] = 'has-link-color';
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) );
[55] Fix | Delete
[56] Fix | Delete
return sprintf( '<div %1$s>', $wrapper_attributes ) .
[57] Fix | Delete
( ! empty( $attributes['showAvatar'] ) ? '<div class="wp-block-post-author__avatar">' . $avatar . '</div>' : '' ) .
[58] Fix | Delete
'<div class="wp-block-post-author__content">' .
[59] Fix | Delete
( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' . wp_kses_post( $byline ) . '</p>' : '' ) .
[60] Fix | Delete
'<p class="wp-block-post-author__name">' . $author_name . '</p>' .
[61] Fix | Delete
( ! empty( $attributes['showBio'] ) ? '<p class="wp-block-post-author__bio">' . get_the_author_meta( 'user_description', $author_id ) . '</p>' : '' ) .
[62] Fix | Delete
'</div>' .
[63] Fix | Delete
'</div>';
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Registers the `core/post-author` block on the server.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 5.9.0
[70] Fix | Delete
*/
[71] Fix | Delete
function register_block_core_post_author() {
[72] Fix | Delete
register_block_type_from_metadata(
[73] Fix | Delete
__DIR__ . '/post-author',
[74] Fix | Delete
array(
[75] Fix | Delete
'render_callback' => 'render_block_core_post_author',
[76] Fix | Delete
)
[77] Fix | Delete
);
[78] Fix | Delete
}
[79] Fix | Delete
add_action( 'init', 'register_block_core_post_author' );
[80] Fix | Delete
[81] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function