Skip to content

Commit

Permalink
Merge branch 'trunk' into try/package-update
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Sep 13, 2024
2 parents 5a5052c + 8f90a7e commit d4ce80c
Show file tree
Hide file tree
Showing 28 changed files with 749 additions and 164 deletions.
6 changes: 3 additions & 3 deletions src/js/_enqueues/admin/inline-edit-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ window.wp = window.wp || {};
if ( ! $( this ).parent().find( 'input[name="indeterminate_post_category[]"]' ).length ) {
// Get the term label text.
var label = $( this ).parent().text();
// Set indeterminate states for the backend. Add accessible text for indeterminate inputs.
// Set indeterminate states for the backend. Add accessible text for indeterminate inputs.
$( this ).after( '<input type="hidden" name="indeterminate_post_category[]" value="' + $( this ).val() + '">' ).attr( 'aria-label', label.trim() + ': ' + wp.i18n.__( 'Some selected posts have this category' ) );
}
}
Expand Down Expand Up @@ -603,9 +603,9 @@ $( function() { inlineEditPost.init(); } );
// Show/hide locks on posts.
$( function() {

// Set the heartbeat interval to 15 seconds.
// Set the heartbeat interval to 10 seconds.
if ( typeof wp !== 'undefined' && wp.heartbeat ) {
wp.heartbeat.interval( 15 );
wp.heartbeat.interval( 10 );
}
}).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
var locked = data['wp-check-locked-posts'] || {};
Expand Down
4 changes: 2 additions & 2 deletions src/js/_enqueues/admin/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ jQuery( function($) {
}
}).filter(':visible').find('.wp-tab-first').trigger( 'focus' );

// Set the heartbeat interval to 15 seconds if post lock dialogs are enabled.
// Set the heartbeat interval to 10 seconds if post lock dialogs are enabled.
if ( wp.heartbeat && $('#post-lock-dialog').length ) {
wp.heartbeat.interval( 15 );
wp.heartbeat.interval( 10 );
}

// The form is being submitted by the user.
Expand Down
56 changes: 25 additions & 31 deletions src/js/_enqueues/wp/heartbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@
}

/*
* The interval can be from 15 to 120 seconds and can be set temporarily to 5 seconds.
* It can be set in the initial options or changed later through JS and/or through PHP.
* Logic check: the interval can be from 1 to 3600 seconds and can be set temporarily
* to 5 seconds. It can be set in the initial options or changed later from JS
* or from PHP through the AJAX responses.
*/
if ( options.interval ) {
settings.mainInterval = options.interval;

if ( settings.mainInterval < 15 ) {
settings.mainInterval = 15;
} else if ( settings.mainInterval > 120 ) {
settings.mainInterval = 120;
if ( settings.mainInterval < 1 ) {
settings.mainInterval = 1;
} else if ( settings.mainInterval > 3600 ) {
settings.mainInterval = 3600;
}
}

Expand Down Expand Up @@ -721,10 +722,10 @@
*
* @memberOf wp.heartbeat.prototype
*
* @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120.
* @param {string|number} speed Interval: 'fast' or integer between 1 and 3600 (seconds).
* Fast equals 5.
* @param {string} ticks Tells how many ticks before the interval reverts
* back. Used with speed = 'fast' or 5.
* @param {number} ticks Tells how many ticks before the interval reverts back.
* Value must be between 1 and 30. Used with speed = 'fast' or 5.
*
* @return {number} Current interval in seconds.
*/
Expand All @@ -733,35 +734,28 @@
oldInterval = settings.tempInterval ? settings.tempInterval : settings.mainInterval;

if ( speed ) {
switch ( speed ) {
case 'fast':
case 5:
newInterval = 5000;
break;
case 15:
newInterval = 15000;
break;
case 30:
newInterval = 30000;
break;
case 60:
newInterval = 60000;
break;
case 120:
newInterval = 120000;
break;
case 'long-polling':
// Allow long polling (experimental).
settings.mainInterval = 0;
return 0;
default:
if ( 'fast' === speed ) {
// Special case, see below.
newInterval = 5000;
} else if ( 'long-polling' === speed ) {
// Allow long polling (experimental).
settings.mainInterval = 0;
return 0;
} else {
speed = parseInt( speed, 10 );

if ( speed >= 1 && speed <= 3600 ) {
newInterval = speed * 1000;
} else {
newInterval = settings.originalInterval;
}
}

if ( settings.minimalInterval && newInterval < settings.minimalInterval ) {
newInterval = settings.minimalInterval;
}

// Special case, runs for a number of ticks then reverts to the previous interval.
if ( 5000 === newInterval ) {
ticks = parseInt( ticks, 10 ) || 30;
ticks = ticks < 1 || ticks > 30 ? 30 : ticks;
Expand Down
8 changes: 8 additions & 0 deletions src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ static function ( $classes ) {
'before'
);

// 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 );
}'
);

/*
* Get all available templates for the post/page attributes meta-box.
* The "Default template" array element should only be added if the array is
Expand Down
94 changes: 52 additions & 42 deletions src/wp-admin/includes/class-wp-debug-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static function debug_data() {
'wp-active-theme' => array(),
'wp-parent-theme' => array(),
'wp-themes-inactive' => array(),
'wp-mu-plugins' => array(),
'wp-mu-plugins' => self::get_wp_mu_plugins(),
'wp-plugins-active' => array(),
'wp-plugins-inactive' => array(),
'wp-media' => array(),
Expand Down Expand Up @@ -199,12 +199,6 @@ public static function debug_data() {
'fields' => array(),
);

$info['wp-mu-plugins'] = array(
'label' => __( 'Must Use Plugins' ),
'show_count' => true,
'fields' => array(),
);

$info['wp-plugins-active'] = array(
'label' => __( 'Active Plugins' ),
'show_count' => true,
Expand Down Expand Up @@ -540,41 +534,6 @@ public static function debug_data() {
'debug' => $gs_debug,
);

// List must use plugins if there are any.
$mu_plugins = get_mu_plugins();

foreach ( $mu_plugins as $plugin_path => $plugin ) {
$plugin_version = $plugin['Version'];
$plugin_author = $plugin['Author'];

$plugin_version_string = __( 'No version or author information is available.' );
$plugin_version_string_debug = 'author: (undefined), version: (undefined)';

if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
/* translators: 1: Plugin version number. 2: Plugin author name. */
$plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
} else {
if ( ! empty( $plugin_author ) ) {
/* translators: %s: Plugin author name. */
$plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
}

if ( ! empty( $plugin_version ) ) {
/* translators: %s: Plugin version number. */
$plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
}
}

$info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
'label' => $plugin['Name'],
'value' => $plugin_version_string,
'debug' => $plugin_version_string_debug,
);
}

// List all available plugins.
$plugins = get_plugins();
$plugin_updates = get_plugin_updates();
Expand Down Expand Up @@ -1257,6 +1216,57 @@ public static function get_wp_server(): array {
);
}

/**
* Gets the WordPress plugins section of the debug data.
*
* @since 6.7.0
*
* @return array
*/
public static function get_wp_mu_plugins(): array {
// List must use plugins if there are any.
$mu_plugins = get_mu_plugins();
$fields = array();

foreach ( $mu_plugins as $plugin_path => $plugin ) {
$plugin_version = $plugin['Version'];
$plugin_author = $plugin['Author'];

$plugin_version_string = __( 'No version or author information is available.' );
$plugin_version_string_debug = 'author: (undefined), version: (undefined)';

if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
/* translators: 1: Plugin version number. 2: Plugin author name. */
$plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
$plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
} else {
if ( ! empty( $plugin_author ) ) {
/* translators: %s: Plugin author name. */
$plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
$plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
}

if ( ! empty( $plugin_version ) ) {
/* translators: %s: Plugin version number. */
$plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
$plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
}
}

$fields[ sanitize_text_field( $plugin['Name'] ) ] = array(
'label' => $plugin['Name'],
'value' => $plugin_version_string,
'debug' => $plugin_version_string_debug,
);
}

return array(
'label' => __( 'Must Use Plugins' ),
'show_count' => true,
'fields' => $fields,
);
}

/**
* Gets the WordPress constants section of the debug data.
*
Expand Down
57 changes: 52 additions & 5 deletions src/wp-admin/includes/translation-install.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@
*
* @param string $type Type of translations. Accepts 'plugins', 'themes', 'core'.
* @param array|object $args Translation API arguments. Optional.
* @return array|WP_Error On success an associative array of translations, WP_Error on failure.
* @return array|WP_Error {
* On success an associative array of translations, WP_Error on failure.
*
* @type array $translations {
* List of translations, each an array of data.
*
* @type array ...$0 {
* @type string $language Language code.
* @type string $version WordPress version.
* @type string $updated Date the translation was last updated, in MySQL datetime format.
* @type string $english_name English name of the language.
* @type string $native_name Native name of the language.
* @type string $package URL to download the translation package.
* @type string[] $iso Array of ISO language codes.
* @type array $strings Array of translated strings used in the installation process.
* }
* }
* }
*/
function translations_api( $type, $args = null ) {
if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) {
Expand Down Expand Up @@ -100,7 +117,24 @@ function translations_api( $type, $args = null ) {
*
* @since 4.0.0
*
* @param array|WP_Error $res Response as an associative array or WP_Error.
* @param array|WP_Error $res {
* On success an associative array of translations, WP_Error on failure.
*
* @type array $translations {
* List of translations, each an array of data.
*
* @type array ...$0 {
* @type string $language Language code.
* @type string $version WordPress version.
* @type string $updated Date the translation was last updated, in MySQL datetime format.
* @type string $english_name English name of the language.
* @type string $native_name Native name of the language.
* @type string $package URL to download the translation package.
* @type string[] $iso Array of ISO language codes.
* @type array $strings Array of translated strings used in the installation process.
* }
* }
* }
* @param string $type The type of translations being requested.
* @param object $args Translation API arguments.
*/
Expand All @@ -114,8 +148,21 @@ function translations_api( $type, $args = null ) {
*
* @see translations_api()
*
* @return array[] Array of translations, each an array of data, keyed by the language. If the API response results
* in an error, an empty array will be returned.
* @return array {
* Array of translations keyed by the language code, each an associative array of data.
* If the API response results in an error, an empty array will be returned.
*
* @type array ...$0 {
* @type string $language Language code.
* @type string $version WordPress version.
* @type string $updated Date the translation was last updated, in MySQL datetime format.
* @type string $english_name English name of the language.
* @type string $native_name Native name of the language.
* @type string $package URL to download the translation package.
* @type string[] $iso Array of ISO language codes.
* @type array $strings Array of translated strings used in the installation process.
* }
* }
*/
function wp_get_available_translations() {
if ( ! wp_installing() ) {
Expand All @@ -132,7 +179,7 @@ function wp_get_available_translations() {
}

$translations = array();
// Key the array with the language code for now.
// Key the array with the language code.
foreach ( $api['translations'] as $translation ) {
$translations[ $translation['language'] ] = $translation;
}
Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/block-template-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ function get_block_templates( $query = array(), $template_type = 'wp_template' )

if ( ! isset( $query['wp_id'] ) ) {
/*
* If the query has found some use templates, those have priority
* If the query has found some user templates, those have priority
* over the theme-provided ones, so we skip querying and building them.
*/
$query['slug__not_in'] = wp_list_pluck( $query_result, 'slug' );
Expand Down
Loading

0 comments on commit d4ce80c

Please sign in to comment.