Submit
Path:
~
/
home
/
caidadmin
/
dev.defense.sca-caid.org
/
wp-includes
/
blocks
/
File Content:
latest-posts.php
<?php /** * Server-side rendering of the `core/latest-posts` block. * * @package WordPress */ /** * The excerpt length set by the Latest Posts core block * set at render time and used by the block itself. * * @var int */ global $block_core_latest_posts_excerpt_length; $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. * * @param array $attributes The block attributes. * * @return string Returns the post content with latest posts added. */ function render_block_core_latest_posts( $attributes ) { global $post, $block_core_latest_posts_excerpt_length; $args = array( 'posts_per_page' => $attributes['postsToShow'], 'post_status' => 'publish', 'order' => $attributes['order'], 'orderby' => $attributes['orderBy'], 'ignore_sticky_posts' => true, 'no_found_rows' => true, ); $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__in'] = array_column( $attributes['categories'], 'id' ); } if ( isset( $attributes['selectedAuthor'] ) ) { $args['author'] = $attributes['selectedAuthor']; } $query = new WP_Query; $recent_posts = $query->query( $args ); if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) { update_post_thumbnail_cache( $query ); } $list_items_markup = ''; foreach ( $recent_posts as $post ) { $post_link = esc_url( get_permalink( $post ) ); $title = get_the_title( $post ); if ( ! $title ) { $title = __( '(no title)' ); } $list_items_markup .= '<li>'; if ( $attributes['displayFeaturedImage'] && has_post_thumbnail( $post ) ) { $image_style = ''; if ( isset( $attributes['featuredImageSizeWidth'] ) ) { $image_style .= sprintf( 'max-width:%spx;', $attributes['featuredImageSizeWidth'] ); } if ( isset( $attributes['featuredImageSizeHeight'] ) ) { $image_style .= sprintf( 'max-height:%spx;', $attributes['featuredImageSizeHeight'] ); } $image_classes = 'wp-block-latest-posts__featured-image'; if ( isset( $attributes['featuredImageAlign'] ) ) { $image_classes .= ' align' . $attributes['featuredImageAlign']; } $featured_image = get_the_post_thumbnail( $post, $attributes['featuredImageSizeSlug'], array( 'style' => esc_attr( $image_style ), ) ); if ( $attributes['addLinkToFeaturedImage'] ) { $featured_image = sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', esc_url( $post_link ), esc_attr( $title ), $featured_image ); } $list_items_markup .= sprintf( '<div class="%1$s">%2$s</div>', esc_attr( $image_classes ), $featured_image ); } $list_items_markup .= sprintf( '<a class="wp-block-latest-posts__post-title" href="%1$s">%2$s</a>', esc_url( $post_link ), $title ); if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) { $author_display_name = get_the_author_meta( 'display_name', $post->post_author ); /* translators: byline. %s: current author. */ $byline = sprintf( __( 'by %s' ), $author_display_name ); if ( ! empty( $author_display_name ) ) { $list_items_markup .= sprintf( '<div class="wp-block-latest-posts__post-author">%1$s</div>', $byline ); } } if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { $list_items_markup .= sprintf( '<time datetime="%1$s" class="wp-block-latest-posts__post-date">%2$s</time>', esc_attr( get_the_date( 'c', $post ) ), get_the_date( '', $post ) ); } if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] && isset( $attributes['displayPostContentRadio'] ) && 'excerpt' === $attributes['displayPostContentRadio'] ) { $trimmed_excerpt = get_the_excerpt( $post ); if ( post_password_required( $post ) ) { $trimmed_excerpt = __( 'This content is password protected.' ); } $list_items_markup .= sprintf( '<div class="wp-block-latest-posts__post-excerpt">%1$s</div>', $trimmed_excerpt ); } if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] && isset( $attributes['displayPostContentRadio'] ) && 'full_post' === $attributes['displayPostContentRadio'] ) { $post_content = html_entity_decode( $post->post_content, ENT_QUOTES, get_option( 'blog_charset' ) ); if ( post_password_required( $post ) ) { $post_content = __( 'This content is password protected.' ); } $list_items_markup .= sprintf( '<div class="wp-block-latest-posts__post-full-content">%1$s</div>', wp_kses_post( $post_content ) ); } $list_items_markup .= "</li>\n"; } remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 ); $class = 'wp-block-latest-posts__list'; if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) { $class .= ' is-grid'; } if ( isset( $attributes['columns'] ) && 'grid' === $attributes['postLayout'] ) { $class .= ' columns-' . $attributes['columns']; } if ( isset( $attributes['displayPostDate'] ) && $attributes['displayPostDate'] ) { $class .= ' has-dates'; } if ( isset( $attributes['displayAuthor'] ) && $attributes['displayAuthor'] ) { $class .= ' has-author'; } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $class ) ); return sprintf( '<ul %1$s>%2$s</ul>', $wrapper_attributes, $list_items_markup ); } /** * Registers the `core/latest-posts` block on server. */ function register_block_core_latest_posts() { register_block_type_from_metadata( __DIR__ . '/latest-posts', array( 'render_callback' => 'render_block_core_latest_posts', ) ); } add_action( 'init', 'register_block_core_latest_posts' ); /** * Handles outdated versions of the `core/latest-posts` block by converting * attribute `categories` from a numeric string to an array with key `id`. * * This is done to accommodate the changes introduced in #20781 that sought to * add support for multiple categories to the block. However, given that this * block is dynamic, the usual provisions for block migration are insufficient, * as they only act when a block is loaded in the editor. * * TODO: Remove when and if the bottom client-side deprecation for this block * is removed. * * @param array $block A single parsed block object. * * @return array The migrated block object. */ function block_core_latest_posts_migrate_categories( $block ) { if ( 'core/latest-posts' === $block['blockName'] && ! empty( $block['attrs']['categories'] ) && is_string( $block['attrs']['categories'] ) ) { $block['attrs']['categories'] = array( array( 'id' => absint( $block['attrs']['categories'] ) ), ); } return $block; } add_filter( 'render_block_data', 'block_core_latest_posts_migrate_categories' );
Submit
FILE
FOLDER
Name
Size
Permission
Action
archives
---
0777
audio
---
0777
avatar
---
0777
block
---
0777
button
---
0777
buttons
---
0777
calendar
---
0777
categories
---
0777
classic
---
0777
code
---
0777
column
---
0777
columns
---
0777
comment-author-name
---
0777
comment-content
---
0777
comment-date
---
0777
comment-edit-link
---
0777
comment-reply-link
---
0777
comment-template
---
0777
comments
---
0777
comments-pagination
---
0777
comments-pagination-next
---
0777
comments-pagination-numbers
---
0777
comments-pagination-previous
---
0777
comments-title
---
0777
cover
---
0777
embed
---
0777
file
---
0777
freeform
---
0777
gallery
---
0777
group
---
0777
heading
---
0777
home-link
---
0777
html
---
0777
image
---
0777
latest-comments
---
0777
latest-posts
---
0777
legacy-widget
---
0777
list
---
0777
list-item
---
0777
loginout
---
0777
media-text
---
0777
missing
---
0777
more
---
0777
navigation
---
0777
navigation-link
---
0777
navigation-submenu
---
0777
nextpage
---
0777
page-list
---
0777
paragraph
---
0777
pattern
---
0777
post-author
---
0777
post-author-biography
---
0777
post-comments-form
---
0777
post-content
---
0755
post-date
---
0777
post-excerpt
---
0777
post-featured-image
---
0777
post-navigation-link
---
0777
post-template
---
0777
post-terms
---
0777
post-title
---
0777
preformatted
---
0777
pullquote
---
0777
query
---
0777
query-no-results
---
0777
query-pagination
---
0777
query-pagination-next
---
0777
query-pagination-numbers
---
0777
query-pagination-previous
---
0777
query-title
---
0777
quote
---
0777
read-more
---
0777
rss
---
0777
search
---
0777
separator
---
0777
shortcode
---
0777
site-logo
---
0777
site-tagline
---
0777
site-title
---
0777
social-link
---
0777
social-links
---
0777
spacer
---
0777
table
---
0777
tag-cloud
---
0777
template-part
---
0777
term-description
---
0777
text-columns
---
0777
verse
---
0777
video
---
0777
widget-group
---
0777
.htaccess
148 bytes
0444
archives.php
3688 bytes
0644
avatar.php
5419 bytes
0644
block.php
1665 bytes
0644
blocks-json.php
107584 bytes
0644
calendar.php
4668 bytes
0644
categories.php
2848 bytes
0644
comment-author-name.php
1960 bytes
0644
comment-content.php
2286 bytes
0644
comment-date.php
1504 bytes
0644
comment-edit-link.php
1540 bytes
0644
comment-reply-link.php
1902 bytes
0644
comment-template.php
3722 bytes
0644
comments-pagination-next.php
1846 bytes
0644
comments-pagination-numbers.php
1594 bytes
0644
comments-pagination-previous.php
1638 bytes
0644
comments-pagination.php
967 bytes
0644
comments-title.php
2734 bytes
0644
comments.php
6714 bytes
0644
cover.php
2497 bytes
0644
file.php
1598 bytes
0644
gallery.php
4689 bytes
0644
home-link.php
4855 bytes
0644
image.php
1294 bytes
0644
index.php
7172 bytes
0200
latest-comments.php
5002 bytes
0644
latest-posts.php
7457 bytes
0644
legacy-widget.php
3902 bytes
0644
loginout.php
1380 bytes
0644
navigation-link.php
11321 bytes
0644
navigation-submenu.php
10256 bytes
0644
navigation.php
26961 bytes
0644
page-list.php
13016 bytes
0644
pattern.php
921 bytes
0644
post-author-biography.php
1448 bytes
0644
post-author.php
2142 bytes
0644
post-comments-form.php
2611 bytes
0644
post-content.php
2395 bytes
0644
post-date.php
1881 bytes
0644
post-excerpt.php
2489 bytes
0644
post-featured-image.php
6797 bytes
0644
post-navigation-link.php
3598 bytes
0644
post-template.php
4034 bytes
0644
post-terms.php
3149 bytes
0644
post-title.php
1721 bytes
0644
query-no-results.php
1614 bytes
0644
query-pagination-next.php
2720 bytes
0644
query-pagination-numbers.php
3815 bytes
0644
query-pagination-previous.php
2166 bytes
0644
query-pagination.php
990 bytes
0644
query-title.php
2125 bytes
0644
query.php
304 bytes
0644
read-more.php
1345 bytes
0644
require-dynamic-blocks.php
3710 bytes
0644
require-static-blocks.php
536 bytes
0644
rss.php
3940 bytes
0644
search.php
20400 bytes
0644
shortcode.php
697 bytes
0644
site-logo.php
5803 bytes
0644
site-tagline.php
994 bytes
0644
site-title.php
1675 bytes
0644
social-link.php
60798 bytes
0644
tag-cloud.php
1641 bytes
0644
template-part.php
9354 bytes
0644
term-description.php
1172 bytes
0644
widget-group.php
2166 bytes
0644
N4ST4R_ID | Naxtarrr