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 Jun 4, 2024
2 parents f296585 + 1e208fc commit 1cf6ece
Show file tree
Hide file tree
Showing 74 changed files with 2,069 additions and 457 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/reusable-end-to-end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ on:
required: false
type: 'boolean'
default: false
php-version:
description: 'The PHP version to use.'
required: false
type: 'string'
default: 'latest'
install-gutenberg:
description: 'Whether to install the Gutenberg plugin.'
required: false
Expand All @@ -22,6 +27,7 @@ on:

env:
LOCAL_DIR: build
LOCAL_PHP: ${{ inputs.php-version }}${{ 'latest' != inputs.php-version && '-fpm' || '' }}

jobs:
# Runs the end-to-end test suite.
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/reusable-phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ on:
required: false
type: 'boolean'
default: false
allow-errors:
description: 'Whether to continue when test errors occur.'
required: false
type: boolean
default: false
env:
LOCAL_PHP: ${{ inputs.php }}-fpm
LOCAL_DB_TYPE: ${{ inputs.db-type }}
Expand Down Expand Up @@ -156,22 +161,27 @@ jobs:
run: npm run env:install

- name: Run PHPUnit tests
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }}

- name: Run AJAX tests
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ajax

- name: Run ms-files tests as a multisite install
if: ${{ inputs.multisite }}
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group ms-files

- name: Run external HTTP tests
if: ${{ ! inputs.multisite }}
continue-on-error: ${{ inputs.allow-errors }}
run: node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit --verbose -c ${{ env.PHPUNIT_CONFIG }} --group external-http

# __fakegroup__ is excluded to force PHPUnit to ignore the <exclude> settings in phpunit.xml.dist.
- name: Run (Xdebug) tests
if: ${{ inputs.php != '8.3' }}
continue-on-error: ${{ inputs.allow-errors }}
run: LOCAL_PHP_XDEBUG=true node ./tools/local-env/scripts/docker.js run php ./vendor/bin/phpunit -v --group xdebug --exclude-group __fakegroup__

- name: Ensure version-controlled files are not modified or deleted
Expand Down
6 changes: 6 additions & 0 deletions src/wp-admin/css/l10n.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ body.locale-he-il .press-this a.wp-switch-editor {
.locale-de-de-formal #customize-header-actions .spinner {
margin: 16px 3px 0; /* default 16px 4px 0 5px */
}
body[class*="locale-de-"] .inline-edit-row fieldset label span.title {
width: 7em; /* default 6em */
}
body[class*="locale-de-"] .inline-edit-row fieldset label span.title{
margin-left: 7em; /* default 6em */
}

/* ru_RU: Text needs more room to breathe. */
.locale-ru-ru #adminmenu {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-core-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function upgrade( $current, $args = array() ) {
return new WP_Error( 'locked', $this->strings['locked'] );
}

$download = $this->download_package( $current->packages->$to_download, true );
$download = $this->download_package( $current->packages->$to_download, false );

/*
* Allow for signature soft-fail.
Expand Down
102 changes: 102 additions & 0 deletions src/wp-admin/includes/class-wp-site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -2586,6 +2586,104 @@ public function get_test_persistent_object_cache() {
return $result;
}

/**
* Calculates total amount of autoloaded data.
*
* @since 6.6.0
*
* @return int Autoloaded data in bytes.
*/
public function get_autoloaded_options_size() {
$alloptions = wp_load_alloptions();

$total_length = 0;

foreach ( $alloptions as $option_name => $option_value ) {
$total_length += strlen( $option_value );
}

return $total_length;
}

/**
* Tests the number of autoloaded options.
*
* @since 6.6.0
*
* @return array The test results.
*/
public function get_test_autoloaded_options() {
$autoloaded_options_size = $this->get_autoloaded_options_size();
$autoloaded_options_count = count( wp_load_alloptions() );

$base_description = __( 'Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. Having too many autoloaded options can slow down your site.' );

$result = array(
'label' => __( 'Autoloaded options are acceptable' ),
'status' => 'good',
'badge' => array(
'label' => __( 'Performance' ),
'color' => 'blue',
),
'description' => sprintf(
/* translators: 1: Number of autoloaded options, 2: Autoloaded options size. */
'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which is acceptable.' ) . '</p>',
$autoloaded_options_count,
size_format( $autoloaded_options_size )
),
'actions' => '',
'test' => 'autoloaded_options',
);

/**
* Filters max bytes threshold to trigger warning in Site Health.
*
* @since 6.6.0
*
* @param int $limit Autoloaded options threshold size. Default 800000.
*/
$limit = apply_filters( 'site_status_autoloaded_options_size_limit', 800000 );

if ( $autoloaded_options_size < $limit ) {
return $result;
}

$result['status'] = 'critical';
$result['label'] = __( 'Autoloaded options could affect performance' );
$result['description'] = sprintf(
/* translators: 1: Number of autoloaded options, 2: Autoloaded options size. */
'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which could cause your site to be slow. You can review the options being autoloaded in your database and remove any options that are no longer needed by your site.' ) . '</p>',
$autoloaded_options_count,
size_format( $autoloaded_options_size )
);

/**
* Filters description to be shown on Site Health warning when threshold is met.
*
* @since 6.6.0
*
* @param string $description Description message when autoloaded options bigger than threshold.
*/
$result['description'] = apply_filters( 'site_status_autoloaded_options_limit_description', $result['description'] );

$result['actions'] = sprintf(
/* translators: 1: HelpHub URL, 2: Link description. */
'<p><a target="_blank" rel="noopener" href="%1$s">%2$s</a></p>',
esc_url( __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#autoloaded-options' ) ),
__( 'More info about optimizing autoloaded options' )
);

/**
* Filters actionable information to tackle the problem. It can be a link to an external guide.
*
* @since 6.6.0
*
* @param string $actions Call to Action to be used to point to the right direction to solve the issue.
*/
$result['actions'] = apply_filters( 'site_status_autoloaded_options_action_to_perform', $result['actions'] );
return $result;
}

/**
* Returns a set of tests that belong to the site status page.
*
Expand Down Expand Up @@ -2670,6 +2768,10 @@ public static function get_tests() {
'label' => __( 'Available disk space' ),
'test' => 'available_updates_disk_space',
),
'autoloaded_options' => array(
'label' => __( 'Autoloaded options' ),
'test' => 'autoloaded_options',
),
),
'async' => array(
'dotorg_communication' => array(
Expand Down
2 changes: 1 addition & 1 deletion src/wp-admin/includes/class-wp-upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ public function run( $options ) {
* Download the package. Note: If the package is the full path
* to an existing local file, it will be returned untouched.
*/
$download = $this->download_package( $options['package'], true, $options['hook_extra'] );
$download = $this->download_package( $options['package'], false, $options['hook_extra'] );

/*
* Allow for signature soft-fail.
Expand Down
6 changes: 6 additions & 0 deletions src/wp-includes/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ function get_block_editor_theme_styles() {
* Returns the classic theme supports settings for block editor.
*
* @since 6.2.0
* @since 6.6.0 Add support for 'editor-spacing-sizes' theme support.
*
* @return array The classic theme supports settings.
*/
Expand Down Expand Up @@ -844,5 +845,10 @@ function get_classic_theme_supports_block_editor_settings() {
$theme_settings['gradients'] = $gradient_presets;
}

$spacing_sizes = current( (array) get_theme_support( 'editor-spacing-sizes' ) );
if ( false !== $spacing_sizes ) {
$theme_settings['spacingSizes'] = $spacing_sizes;
}

return $theme_settings;
}
21 changes: 20 additions & 1 deletion src/wp-includes/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function wp_register_typography_support( $block_type ) {
$has_font_weight_support = isset( $typography_supports['__experimentalFontWeight'] ) ? $typography_supports['__experimentalFontWeight'] : false;
$has_letter_spacing_support = isset( $typography_supports['__experimentalLetterSpacing'] ) ? $typography_supports['__experimentalLetterSpacing'] : false;
$has_line_height_support = isset( $typography_supports['lineHeight'] ) ? $typography_supports['lineHeight'] : false;
$has_text_align_support = isset( $typography_supports['textAlign'] ) ? $typography_supports['textAlign'] : false;
$has_text_columns_support = isset( $typography_supports['textColumns'] ) ? $typography_supports['textColumns'] : false;
$has_text_decoration_support = isset( $typography_supports['__experimentalTextDecoration'] ) ? $typography_supports['__experimentalTextDecoration'] : false;
$has_text_transform_support = isset( $typography_supports['__experimentalTextTransform'] ) ? $typography_supports['__experimentalTextTransform'] : false;
Expand All @@ -42,6 +43,7 @@ function wp_register_typography_support( $block_type ) {
|| $has_font_weight_support
|| $has_letter_spacing_support
|| $has_line_height_support
|| $has_text_align_support
|| $has_text_columns_support
|| $has_text_decoration_support
|| $has_text_transform_support
Expand Down Expand Up @@ -106,6 +108,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
$has_font_weight_support = isset( $typography_supports['__experimentalFontWeight'] ) ? $typography_supports['__experimentalFontWeight'] : false;
$has_letter_spacing_support = isset( $typography_supports['__experimentalLetterSpacing'] ) ? $typography_supports['__experimentalLetterSpacing'] : false;
$has_line_height_support = isset( $typography_supports['lineHeight'] ) ? $typography_supports['lineHeight'] : false;
$has_text_align_support = isset( $typography_supports['textAlign'] ) ? $typography_supports['textAlign'] : false;
$has_text_columns_support = isset( $typography_supports['textColumns'] ) ? $typography_supports['textColumns'] : false;
$has_text_decoration_support = isset( $typography_supports['__experimentalTextDecoration'] ) ? $typography_supports['__experimentalTextDecoration'] : false;
$has_text_transform_support = isset( $typography_supports['__experimentalTextTransform'] ) ? $typography_supports['__experimentalTextTransform'] : false;
Expand All @@ -117,6 +120,7 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
$should_skip_font_style = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontStyle' );
$should_skip_font_weight = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'fontWeight' );
$should_skip_line_height = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'lineHeight' );
$should_skip_text_align = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textAlign' );
$should_skip_text_columns = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textColumns' );
$should_skip_text_decoration = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textDecoration' );
$should_skip_text_transform = wp_should_skip_block_supports_serialization( $block_type, 'typography', 'textTransform' );
Expand Down Expand Up @@ -176,6 +180,12 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
: null;
}

if ( $has_text_align_support && ! $should_skip_text_align ) {
$typography_block_styles['textAlign'] = isset( $block_attributes['style']['typography']['textAlign'] )
? $block_attributes['style']['typography']['textAlign']
: null;
}

if ( $has_text_columns_support && ! $should_skip_text_columns && isset( $block_attributes['style']['typography']['textColumns'] ) ) {
$typography_block_styles['textColumns'] = isset( $block_attributes['style']['typography']['textColumns'] )
? $block_attributes['style']['typography']['textColumns']
Expand Down Expand Up @@ -225,13 +235,22 @@ function wp_apply_typography_support( $block_type, $block_attributes ) {
}

$attributes = array();
$classnames = array();
$styles = wp_style_engine_get_styles(
array( 'typography' => $typography_block_styles ),
array( 'convert_vars_to_classnames' => true )
);

if ( ! empty( $styles['classnames'] ) ) {
$attributes['class'] = $styles['classnames'];
$classnames[] = $styles['classnames'];
}

if ( $has_text_align_support && ! $should_skip_text_align && isset( $block_attributes['style']['typography']['textAlign'] ) ) {
$classnames[] = 'has-text-align-' . $block_attributes['style']['typography']['textAlign'];
}

if ( ! empty( $classnames ) ) {
$attributes['class'] = implode( ' ', $classnames );
}

if ( ! empty( $styles['css'] ) ) {
Expand Down
12 changes: 12 additions & 0 deletions src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ function _get_block_templates_files( $template_type, $query = array() ) {
return null;
}

$default_template_types = array();
if ( 'wp_template' === $template_type ) {
$default_template_types = get_default_block_template_types();
}

// Prepare metadata from $query.
$slugs_to_include = isset( $query['slug__in'] ) ? $query['slug__in'] : array();
$slugs_to_skip = isset( $query['slug__not_in'] ) ? $query['slug__not_in'] : array();
Expand Down Expand Up @@ -425,12 +430,19 @@ function _get_block_templates_files( $template_type, $query = array() ) {

if ( 'wp_template' === $template_type ) {
$candidate = _add_block_template_info( $new_template_item );
$is_custom = ! isset( $default_template_types[ $candidate['slug'] ] );

if (
! $post_type ||
( $post_type && isset( $candidate['postTypes'] ) && in_array( $post_type, $candidate['postTypes'], true ) )
) {
$template_files[ $template_slug ] = $candidate;
}

// The custom templates with no associated post types are available for all post types.
if ( $post_type && ! isset( $candidate['postTypes'] ) && $is_custom ) {
$template_files[ $template_slug ] = $candidate;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/class-wp-duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -1160,8 +1160,8 @@ public static function render_duotone_support( $block_content, $block, $wp_block
*
* @since 6.6.0
*
* @param string $block_content Rendered block content.
* @return string Filtered block content.
* @param string $block_content Rendered block content.
* @return string Filtered block content.
*/
public static function restore_image_outer_container( $block_content ) {
if ( wp_theme_has_theme_json() ) {
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/class-wp-theme-json-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class WP_Theme_JSON_Data {
* @param array $data Array following the theme.json specification.
* @param string $origin The origin of the data: default, theme, user.
*/
public function __construct( $data = array(), $origin = 'theme' ) {
public function __construct( $data = array( 'version' => WP_Theme_JSON::LATEST_SCHEMA ), $origin = 'theme' ) {
$this->origin = $origin;
$this->theme_json = new WP_Theme_JSON( $data, $this->origin );
}
Expand Down
Loading

0 comments on commit 1cf6ece

Please sign in to comment.