mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-30 23:30:05 +00:00
Block Editor: Update WordPress Packages WordPress 5.4 RC 1.
The following package versions were changed: @wordpress/annotations: 1.12.0 -> 1.12.1 @wordpress/block-directory: 1.5.2 -> 1.5.3 @wordpress/block-editor: 3.7.2 -> 3.7.3 @wordpress/block-library: 2.14.2 -> 2.14.3 @wordpress/blocks: 6.12.0 -> 6.12.1 @wordpress/components: 9.2.2 -> 9.2.3 @wordpress/core-data: 2.12.0 -> 2.12.1 @wordpress/data: 4.14.0 -> 4.14.1 @wordpress/data-controls: 1.8.0 -> 1.8.1 @wordpress/edit-post: 3.13.2 -> 3.13.3 @wordpress/editor: 9.12.2 -> 9.12.3 @wordpress/format-library: 1.14.2 -> 1.14.3 @wordpress/keyboard-shortcuts: 1.1.0 -> 1.1.1 @wordpress/list-reusable-blocks: 1.13.2 -> 1.13.3 @wordpress/notices: 2.0.0 -> 2.0.1 @wordpress/nux: 3.12.2 -> 3.12.3 @wordpress/priority-queue: 1.5.0 -> 1.5.1 @wordpress/rich-text: 3.12.0 -> 3.12.1 @wordpress/server-side-render: 1.8.2 -> 1.8.3 @wordpress/viewport: 2.13.0 -> 2.13.1 Props aduth. Fixes: #49567. git-svn-id: https://develop.svn.wordpress.org/trunk@47408 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -5,6 +5,26 @@
|
||||
* @package WordPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* The excerpt length set by the Latest Posts core block
|
||||
* set at render time and used by the block itself.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
$block_core_latest_posts_excerpt_length = 0;
|
||||
|
||||
/**
|
||||
* Callback for the excerpt_length filter used by
|
||||
* the Latest Posts block at render time.
|
||||
*
|
||||
* @return int Returns the global $block_core_latest_posts_excerpt_length variable
|
||||
* to allow the excerpt_length filter respect the Latest Block setting.
|
||||
*/
|
||||
function block_core_latest_posts_get_excerpt_length() {
|
||||
global $block_core_latest_posts_excerpt_length;
|
||||
return $block_core_latest_posts_excerpt_length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the `core/latest-posts` block on server.
|
||||
*
|
||||
@@ -13,6 +33,8 @@
|
||||
* @return string Returns the post content with latest posts added.
|
||||
*/
|
||||
function render_block_core_latest_posts( $attributes ) {
|
||||
global $block_core_latest_posts_excerpt_length;
|
||||
|
||||
$args = array(
|
||||
'posts_per_page' => $attributes['postsToShow'],
|
||||
'post_status' => 'publish',
|
||||
@@ -21,6 +43,9 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
'suppress_filters' => false,
|
||||
);
|
||||
|
||||
$block_core_latest_posts_excerpt_length = $attributes['excerptLength'];
|
||||
add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
|
||||
|
||||
if ( isset( $attributes['categories'] ) ) {
|
||||
$args['category'] = $attributes['categories'];
|
||||
}
|
||||
@@ -111,6 +136,8 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$list_items_markup .= "</li>\n";
|
||||
}
|
||||
|
||||
remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
|
||||
|
||||
$class = 'wp-block-latest-posts wp-block-latest-posts__list';
|
||||
if ( isset( $attributes['align'] ) ) {
|
||||
$class .= ' align' . $attributes['align'];
|
||||
|
||||
Reference in New Issue
Block a user