Skip to content

Commit

Permalink
Merge branch 'WordPress:trunk' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakrohillas authored Sep 27, 2024
2 parents 2ba50c8 + 1e21ece commit bf670e7
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/wp-admin/admin-footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$text = sprintf(
/* translators: %s: https://wordpress.org/ */
__( 'Thank you for creating with <a href="%s">WordPress</a>.' ),
__( 'https://wordpress.org/' )
esc_url( __( 'https://wordpress.org/' ) )
);

/**
Expand Down
7 changes: 4 additions & 3 deletions src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ static function ( $classes ) {
// Set Heartbeat interval to 10 seconds, used to refresh post locks.
wp_add_inline_script(
'heartbeat',
'if ( window.wp && window.wp.heartbeat ) {
window.wp.heartbeat.interval( 10 );
}'
'jQuery( function() {
wp.heartbeat.interval( 10 );
} );',
'after'
);

/*
Expand Down
13 changes: 13 additions & 0 deletions src/wp-admin/plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,19 @@
$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/documentation/article/plugins-themes-auto-updates/">Documentation on Auto-updates</a>' ) . '</p>';
}

if ( current_user_can( 'install_plugins' ) ) {
get_current_screen()->add_help_tab(
array(
'id' => 'plugins-dependencies',
'title' => __( 'Dependencies' ),
'content' =>
'<p>' . __( 'Plugin Dependencies aims to make the process of installing and activating add-ons (dependents) and the plugins they rely on (dependencies) consistent and easy.' ) . '</p>' .
'<p>' . __( 'If a required plugin is deleted, a notice will be displayed on the Plugin administration screen informing the user that there is some missing dependencies to install and/or activate. Additionally, each plugin whose dependencies are not met will have an error notice on their plugin row.' ) . '</p>' .
'<p>' . __( 'If a dependent plugin is missing some dependencies, its activation button will be disabled until the required dependencies are activated.' ) . '</p>',
)
);
}

get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
'<p>' . __( '<a href="https://wordpress.org/documentation/article/manage-plugins/">Documentation on Managing Plugins</a>' ) . '</p>' .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class TwentyNineteen_SVG_Icons {

/**
* Gets the SVG code for a given icon.
*
* @param string $group The group of icons ('ui' or 'social').
* @param string $icon The specific icon to retrieve.
* @param int $size The desired width and height for the SVG icon.
*/
public static function get_svg( $group, $icon, $size ) {
if ( 'ui' === $group ) {
Expand All @@ -44,6 +48,9 @@ public static function get_svg( $group, $icon, $size ) {

/**
* Detects the social network from a URL and returns the SVG code for its icon.
*
* @param string $uri The URL of the social network link.
* @param int $size The desired width and height for the SVG icon.
*/
public static function get_social_link_svg( $uri, $size ) {
static $regex_map; // Only compute regex map once, for performance.
Expand Down
1 change: 1 addition & 0 deletions src/wp-content/themes/twentynineteen/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @subpackage Twenty_Nineteen
* @since Twenty Nineteen 1.0
*/

?><!doctype html>
<html <?php language_attributes(); ?>>
<head>
Expand Down
10 changes: 9 additions & 1 deletion src/wp-content/themes/twentynineteen/inc/helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ function twentynineteen_get_avatar_size() {
* Returns true if comment is by author of the post.
*
* @see get_comment_class()
*
* @param WP_Comment|null $comment The comment object to check. Defaults to the current comment.
* @return bool True if the comment is by the author of the post, false otherwise.
*/
function twentynineteen_is_comment_by_post_author( $comment = null ) {
if ( is_object( $comment ) && $comment->user_id > 0 ) {
Expand Down Expand Up @@ -82,7 +85,12 @@ function twentynineteen_get_discussion_data() {
}

/**
* Converts HSL to HEX colors.
* Converts HSL to HEX or RGB colors.
*
* @param float $h The hue component (0-360).
* @param float $s The saturation component (0-100).
* @param float $l The lightness component (0-100).
* @param bool $to_hex Whether to convert to HEX format (true) or RGB (false). Default true.
*/
function twentynineteen_hsl_hex( $h, $s, $l, $to_hex = true ) {

Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-block-supports.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function apply_block_supports() {
}

$block_attributes = array_key_exists( 'attrs', self::$block_to_render ) && is_array( self::$block_to_render['attrs'] )
? self::$block_to_render['attrs']
? $block_type->prepare_attributes_for_render( self::$block_to_render['attrs'] )
: array();

$output = array();
Expand Down
9 changes: 9 additions & 0 deletions src/wp-includes/class-wp-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public function __get( $name ) {
*
* @since 6.5.0
* @since 6.6.0 Handle the `__default` attribute for pattern overrides.
* @since 6.7.0 Return any updated bindings metadata in the computed attributes.
*
* @return array The computed block attributes for the provided block bindings.
*/
Expand Down Expand Up @@ -284,6 +285,14 @@ private function process_block_bindings() {
: array( 'source' => 'core/pattern-overrides' );
}
$bindings = $updated_bindings;
/*
* Update the bindings metadata of the computed attributes.
* This ensures the block receives the expanded __default binding metadata when it renders.
*/
$computed_attributes['metadata'] = array_merge(
$parsed_block['attrs']['metadata'],
array( 'bindings' => $bindings )
);
}

foreach ( $bindings as $attribute_name => $block_binding ) {
Expand Down
9 changes: 5 additions & 4 deletions src/wp-includes/class-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,15 @@ public function handle_404() {
$content_found = true;

if ( is_singular() ) {
$post = isset( $wp_query->post ) ? $wp_query->post : null;
$next = '<!--nextpage-->';
$post = isset( $wp_query->post ) ? $wp_query->post : null;
$next = '<!--nextpage-->';
$page_qv = is_front_page() ? 'paged' : 'page';

// Check for paged content that exceeds the max number of pages.
if ( $post && ! empty( $this->query_vars['page'] ) ) {
if ( $post && ! empty( $this->query_vars[ $page_qv ] ) ) {
// Check if content is actually intended to be paged.
if ( str_contains( $post->post_content, $next ) ) {
$page = trim( $this->query_vars['page'], '/' );
$page = trim( $this->query_vars[ $page_qv ], '/' );
$content_found = (int) $page <= ( substr_count( $post->post_content, $next ) + 1 );
} else {
$content_found = false;
Expand Down
14 changes: 8 additions & 6 deletions src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ function ( WP_HTML_Token $token ): void {
$provenance = ( ! $same_node || $is_virtual ) ? 'virtual' : 'real';
$this->element_queue[] = new WP_HTML_Stack_Event( $token, WP_HTML_Stack_Event::PUSH, $provenance );

$this->change_parsing_namespace( $token->namespace );
$this->change_parsing_namespace( $token->integration_node_type ? 'html' : $token->namespace );
}
);

Expand All @@ -403,12 +403,14 @@ function ( WP_HTML_Token $token ): void {
$same_node = isset( $this->state->current_token ) && $token->node_name === $this->state->current_token->node_name;
$provenance = ( ! $same_node || $is_virtual ) ? 'virtual' : 'real';
$this->element_queue[] = new WP_HTML_Stack_Event( $token, WP_HTML_Stack_Event::POP, $provenance );

$adjusted_current_node = $this->get_adjusted_current_node();
$this->change_parsing_namespace(
$adjusted_current_node
? $adjusted_current_node->namespace
: 'html'
);

if ( $adjusted_current_node ) {
$this->change_parsing_namespace( $adjusted_current_node->integration_node_type ? 'html' : $adjusted_current_node->namespace );
} else {
$this->change_parsing_namespace( 'html' );
}
}
);

Expand Down
22 changes: 16 additions & 6 deletions tests/phpunit/tests/block-bindings/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,31 +334,41 @@ public function test_using_symbols_in_block_bindings_value() {
}

/**
* Tests if the `__default` attribute is replaced with real attribues for
* Tests if the `__default` attribute is replaced with real attributes for
* pattern overrides.
*
* @ticket 61333
* @ticket 62069
*
* @covers WP_Block::process_block_bindings
*/
public function test_default_binding_for_pattern_overrides() {
$expected_content = 'This is the content value';

$block_content = <<<HTML
<!-- wp:paragraph {"metadata":{"bindings":{"__default":{"source":"core/pattern-overrides"}},"name":"Test"}} -->
<p>This should not appear</p>
<!-- /wp:paragraph -->
HTML;

$parsed_blocks = parse_blocks( $block_content );
$block = new WP_Block( $parsed_blocks[0], array( 'pattern/overrides' => array( 'Test' => array( 'content' => $expected_content ) ) ) );
$result = $block->render();
$expected_content = 'This is the content value';
$parsed_blocks = parse_blocks( $block_content );
$block = new WP_Block( $parsed_blocks[0], array( 'pattern/overrides' => array( 'Test' => array( 'content' => $expected_content ) ) ) );

$result = $block->render();

$this->assertSame(
"<p>$expected_content</p>",
trim( $result ),
'The `__default` attribute should be replaced with the real attribute prior to the callback.'
);

$expected_bindings_metadata = array(
'content' => array( 'source' => 'core/pattern-overrides' ),
);
$this->assertSame(
$expected_bindings_metadata,
$block->attributes['metadata']['bindings'],
'The __default binding should be updated with the individual binding attributes in the block metadata.'
);
}

/**
Expand Down
50 changes: 50 additions & 0 deletions tests/phpunit/tests/blocks/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,56 @@ public function test_dynamic_block_rendering() {
);
}

/**
* @ticket 62114
*/
public function test_dynamic_block_with_default_attributes() {
$settings = array(
'attributes' => array(
'content' => array(
'type' => 'string',
'default' => 'Default content.',
),
'align' => array(
'type' => 'string',
'default' => 'full',
),
'backgroundColor' => array(
'type' => 'string',
'default' => 'blueberry-1',
),
'textColor' => array(
'type' => 'string',
'default' => 'white',
),
),
'supports' => array(
'align' => array( 'wide', 'full' ),
'color' => array(
'background' => true,
'text' => true,
),
),
'render_callback' => function ( $attributes ) {
return '<p ' . get_block_wrapper_attributes() . '>' . $attributes['content'] . '</p>';
},
);
register_block_type( 'core/dynamic', $settings );

$post_content =
'before' .
'<!-- wp:core/dynamic --><!-- /wp:core/dynamic -->' .
'after';

$updated_post_content = do_blocks( $post_content );
$this->assertSame(
$updated_post_content,
'before' .
'<p class="alignfull wp-block-dynamic has-text-color has-white-color has-background has-blueberry-1-background-color">Default content.</p>' .
'after'
);
}

/**
* @ticket 45109
*/
Expand Down
45 changes: 45 additions & 0 deletions tests/phpunit/tests/canonical/paged.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,49 @@ public function test_redirect_canonical_with_nextpage_pagination() {
// Non-existing page should redirect to the permalink.
$this->assertCanonical( $link . '4/', $link );
}

/**
* Ensures canonical redirects are performed for sites with a static front page.
*
* @ticket 50163
*/
public function test_redirect_missing_front_page_pagination_canonical() {
update_option( 'show_on_front', 'page' );

$page_id = self::factory()->post->create(
array(
'post_title' => 'front-page-1',
'post_type' => 'page',
'post_content' => "Front Page 1\n<!--nextpage-->\nPage 2",
)
);

update_option( 'page_on_front', $page_id );

$link = parse_url( get_permalink( $page_id ), PHP_URL_PATH );

// Valid page numbers should not redirect.
$this->assertCanonical( $link, $link, 'The home page is not expected to redirect.' );
$this->assertCanonical( $link . 'page/2/', $link . 'page/2/', 'Page 2 exists and is not expected to redirect.' );

// Invalid page numbers should redirect to the front page.
$this->assertCanonical( $link . 'page/3/', $link, 'Page 3 does not exist and is expected to redirect to the home page.' );
}

/**
* Ensures that canonical redirects are not performed for sites with a blog listing home page.
*
* @ticket 50163
*/
public function test_redirect_missing_front_page_pagination_does_not_affect_posts_canonical() {
self::factory()->post->create_many( 3 );
update_option( 'posts_per_page', 2 );

// Valid page numbers should not redirect.
$this->assertCanonical( '/', '/', 'Page one of the blog archive should not redirect.' );
$this->assertCanonical( '/page/2/', '/page/2/', 'Page 2 of the blog archive exists and is not expected to redirect.' );

// Neither should invalid page numbers.
$this->assertCanonical( '/page/3/', '/page/3/', 'Page 3 of the blog archive is not populated but is not expected to redirect.' );
}
}
Loading

0 comments on commit bf670e7

Please sign in to comment.