Block Editor: Rename the gutenberg_ functions in blocks/latest-comments.php.
This was ported manually from https://github.com/WordPress/gutenberg/pull/12326 Props pento, swissspidy. See #45145. Built from https://develop.svn.wordpress.org/branches/5.0@43950 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3dd6578998
commit
50b094e3b0
|
@ -32,7 +32,7 @@ function render_block_core_archives( $attributes ) {
|
||||||
$class .= ' wp-block-archives-dropdown';
|
$class .= ' wp-block-archives-dropdown';
|
||||||
|
|
||||||
$dropdown_id = esc_attr( uniqid( 'wp-block-archives-' ) );
|
$dropdown_id = esc_attr( uniqid( 'wp-block-archives-' ) );
|
||||||
$title = __( 'Archives', 'default' );
|
$title = __( 'Archives' );
|
||||||
|
|
||||||
/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
|
/** This filter is documented in wp-includes/widgets/class-wp-widget-archives.php */
|
||||||
$dropdown_args = apply_filters(
|
$dropdown_args = apply_filters(
|
||||||
|
@ -50,19 +50,19 @@ function render_block_core_archives( $attributes ) {
|
||||||
|
|
||||||
switch ( $dropdown_args['type'] ) {
|
switch ( $dropdown_args['type'] ) {
|
||||||
case 'yearly':
|
case 'yearly':
|
||||||
$label = __( 'Select Year', 'default' );
|
$label = __( 'Select Year' );
|
||||||
break;
|
break;
|
||||||
case 'monthly':
|
case 'monthly':
|
||||||
$label = __( 'Select Month', 'default' );
|
$label = __( 'Select Month' );
|
||||||
break;
|
break;
|
||||||
case 'daily':
|
case 'daily':
|
||||||
$label = __( 'Select Day', 'default' );
|
$label = __( 'Select Day' );
|
||||||
break;
|
break;
|
||||||
case 'weekly':
|
case 'weekly':
|
||||||
$label = __( 'Select Week', 'default' );
|
$label = __( 'Select Week' );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$label = __( 'Select Post', 'default' );
|
$label = __( 'Select Post' );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ function render_block_core_archives( $attributes ) {
|
||||||
$block_content = sprintf(
|
$block_content = sprintf(
|
||||||
'<div class="%1$s">%2$s</div>',
|
'<div class="%1$s">%2$s</div>',
|
||||||
$classnames,
|
$classnames,
|
||||||
__( 'No archives to show.', 'default' )
|
__( 'No archives to show.' )
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ function render_block_core_categories( $attributes ) {
|
||||||
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
|
if ( ! empty( $attributes['displayAsDropdown'] ) ) {
|
||||||
$id = 'wp-block-categories-' . $block_id;
|
$id = 'wp-block-categories-' . $block_id;
|
||||||
$args['id'] = $id;
|
$args['id'] = $id;
|
||||||
$args['show_option_none'] = __( 'Select Category', 'default' );
|
$args['show_option_none'] = __( 'Select Category' );
|
||||||
$wrapper_markup = '<div class="%1$s">%2$s</div>';
|
$wrapper_markup = '<div class="%1$s">%2$s</div>';
|
||||||
$items_markup = wp_dropdown_categories( $args );
|
$items_markup = wp_dropdown_categories( $args );
|
||||||
$type = 'dropdown';
|
$type = 'dropdown';
|
||||||
|
|
|
@ -26,10 +26,10 @@ if ( ! function_exists( 'gutenberg_draft_or_post_title' ) ) {
|
||||||
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
|
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
|
||||||
* @return string The post title if set; "(no title)" if no title is set.
|
* @return string The post title if set; "(no title)" if no title is set.
|
||||||
*/
|
*/
|
||||||
function gutenberg_draft_or_post_title( $post = 0 ) {
|
function wp_latest_comments_draft_or_post_title( $post = 0 ) {
|
||||||
$title = get_the_title( $post );
|
$title = get_the_title( $post );
|
||||||
if ( empty( $title ) ) {
|
if ( empty( $title ) ) {
|
||||||
$title = __( '(no title)', 'default' );
|
$title = __( '(no title)' );
|
||||||
}
|
}
|
||||||
return esc_html( $title );
|
return esc_html( $title );
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ if ( ! function_exists( 'gutenberg_draft_or_post_title' ) ) {
|
||||||
*
|
*
|
||||||
* @return string Returns the post content with latest comments added.
|
* @return string Returns the post content with latest comments added.
|
||||||
*/
|
*/
|
||||||
function gutenberg_render_block_core_latest_comments( $attributes = array() ) {
|
function render_block_core_latest_comments( $attributes = array() ) {
|
||||||
// This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php.
|
// This filter is documented in wp-includes/widgets/class-wp-widget-recent-comments.php.
|
||||||
$comments = get_comments(
|
$comments = get_comments(
|
||||||
apply_filters(
|
apply_filters(
|
||||||
|
@ -94,11 +94,11 @@ function gutenberg_render_block_core_latest_comments( $attributes = array() ) {
|
||||||
|
|
||||||
// `_draft_or_post_title` calls `esc_html()` so we don't need to wrap that call in
|
// `_draft_or_post_title` calls `esc_html()` so we don't need to wrap that call in
|
||||||
// `esc_html`.
|
// `esc_html`.
|
||||||
$post_title = '<a class="wp-block-latest-comments__comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '">' . gutenberg_draft_or_post_title( $comment->comment_post_ID ) . '</a>';
|
$post_title = '<a class="wp-block-latest-comments__comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '">' . wp_latest_comments_draft_or_post_title( $comment->comment_post_ID ) . '</a>';
|
||||||
|
|
||||||
$list_items_markup .= sprintf(
|
$list_items_markup .= sprintf(
|
||||||
/* translators: 1: author name (inside <a> or <span> tag, based on if they have a URL), 2: post title related to this comment */
|
/* translators: 1: author name (inside <a> or <span> tag, based on if they have a URL), 2: post title related to this comment */
|
||||||
__( '%1$s on %2$s', 'default' ),
|
__( '%1$s on %2$s' ),
|
||||||
$author_markup,
|
$author_markup,
|
||||||
$post_title
|
$post_title
|
||||||
);
|
);
|
||||||
|
@ -143,7 +143,7 @@ function gutenberg_render_block_core_latest_comments( $attributes = array() ) {
|
||||||
) : sprintf(
|
) : sprintf(
|
||||||
'<div class="%1$s">%2$s</div>',
|
'<div class="%1$s">%2$s</div>',
|
||||||
$classnames,
|
$classnames,
|
||||||
__( 'No comments to show.', 'default' )
|
__( 'No comments to show.' )
|
||||||
);
|
);
|
||||||
|
|
||||||
return $block_content;
|
return $block_content;
|
||||||
|
@ -179,6 +179,6 @@ register_block_type(
|
||||||
'enum' => array( 'center', 'left', 'right', 'wide', 'full', '' ),
|
'enum' => array( 'center', 'left', 'right', 'wide', 'full', '' ),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'render_callback' => 'gutenberg_render_block_core_latest_comments',
|
'render_callback' => 'render_block_core_latest_comments',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -33,7 +33,7 @@ function render_block_core_latest_posts( $attributes ) {
|
||||||
|
|
||||||
$title = get_the_title( $post_id );
|
$title = get_the_title( $post_id );
|
||||||
if ( ! $title ) {
|
if ( ! $title ) {
|
||||||
$title = __( '(Untitled)', 'default' );
|
$title = __( '(Untitled)' );
|
||||||
}
|
}
|
||||||
$list_items_markup .= sprintf(
|
$list_items_markup .= sprintf(
|
||||||
'<li><a href="%1$s">%2$s</a>',
|
'<li><a href="%1$s">%2$s</a>',
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.0-RC1-43949';
|
$wp_version = '5.0-RC1-43950';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue