Merged in feature/81-dev-dev01 (pull request #5)

auto-patch  81-dev-dev01-2023-12-05T22_45_26

* auto-patch  81-dev-dev01-2023-12-05T22_45_26
This commit is contained in:
Tony Volpe
2023-12-05 23:05:59 +00:00
parent ba16964e7a
commit 725d3043d5
1463 changed files with 142461 additions and 89421 deletions

View File

@@ -60,7 +60,8 @@ if ( ! is_customize_preview() ) {
add_action( 'admin_print_scripts', 'print_emoji_detection_script' );
add_action( 'admin_print_scripts', 'print_head_scripts', 20 );
add_action( 'admin_print_footer_scripts', '_wp_footer_scripts' );
add_action( 'admin_print_styles', 'print_emoji_styles' );
add_action( 'admin_enqueue_scripts', 'wp_enqueue_emoji_styles' );
add_action( 'admin_print_styles', 'print_emoji_styles' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_emoji_styles().
add_action( 'admin_print_styles', 'print_admin_styles', 20 );
add_action( 'admin_print_scripts-index.php', 'wp_localize_community_events' );
@@ -168,3 +169,6 @@ add_action( 'post_updated', array( 'WP_Privacy_Policy_Content', '_policy_page_up
// Append '(Draft)' to draft page titles in the privacy page dropdown.
add_filter( 'list_pages', '_wp_privacy_settings_filter_draft_page_titles', 10, 2 );
// Font management.
add_action( 'admin_print_styles', 'wp_print_font_faces', 50 );

View File

@@ -2149,7 +2149,7 @@ function wp_ajax_inline_save() {
while ( $parent > 0 ) {
$parent_post = get_post( $parent );
$parent = $parent_post->post_parent;
$level++;
++$level;
}
}
@@ -2211,7 +2211,7 @@ function wp_ajax_inline_save_tax() {
while ( $parent > 0 ) {
$parent_tag = get_term( $parent, $taxonomy );
$parent = $parent_tag->parent;
$level++;
++$level;
}
$wp_list_table->single_row( $tag, $level );
@@ -2821,7 +2821,7 @@ function wp_ajax_set_attachment_thumbnail() {
}
if ( set_post_thumbnail( $post_id, $thumbnail_id ) ) {
$success++;
++$success;
}
}
@@ -3882,13 +3882,29 @@ function wp_ajax_parse_media_shortcode() {
$shortcode = wp_unslash( $_POST['shortcode'] );
// Only process previews for media related shortcodes:
$found_shortcodes = get_shortcode_tags_in_content( $shortcode );
$media_shortcodes = array(
'audio',
'embed',
'playlist',
'video',
'gallery',
);
$other_shortcodes = array_diff( $found_shortcodes, $media_shortcodes );
if ( ! empty( $other_shortcodes ) ) {
wp_send_json_error();
}
if ( ! empty( $_POST['post_ID'] ) ) {
$post = get_post( (int) $_POST['post_ID'] );
}
// The embed shortcode requires a post.
if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
if ( 'embed' === $shortcode ) {
if ( in_array( 'embed', $found_shortcodes, true ) ) {
wp_send_json_error();
}
} else {
@@ -4939,8 +4955,8 @@ function wp_ajax_wp_privacy_export_personal_data() {
* Array of personal data exporters.
*
* @type callable $callback Callable exporter function that accepts an
* email address and a page and returns an array
* of name => value pairs of personal data.
* email address and a page number and returns an
* array of name => value pairs of personal data.
* @type string $exporter_friendly_name Translated user facing friendly name for the
* exporter.
* }
@@ -5051,10 +5067,10 @@ function wp_ajax_wp_privacy_export_personal_data() {
*
* @since 4.9.6
*
* @param array $response The personal data for the given exporter and page.
* @param array $response The personal data for the given exporter and page number.
* @param int $exporter_index The index of the exporter that provided this data.
* @param string $email_address The email address associated with this personal data.
* @param int $page The page for this response.
* @param int $page The page number for this response.
* @param int $request_id The privacy request post ID associated with this request.
* @param bool $send_as_email Whether the final results of the export should be emailed to the user.
* @param string $exporter_key The key (slug) of the exporter that provided this data.
@@ -5128,8 +5144,8 @@ function wp_ajax_wp_privacy_erase_personal_data() {
* @type array ...$0 {
* Array of personal data exporters.
*
* @type callable $callback Callable eraser that accepts an email address and
* a page and returns an array with boolean values for
* @type callable $callback Callable eraser that accepts an email address and a page
* number, and returns an array with boolean values for
* whether items were removed or retained and any messages
* from the eraser, as well as if additional pages are
* available.
@@ -5281,10 +5297,17 @@ function wp_ajax_wp_privacy_erase_personal_data() {
*
* @since 4.9.6
*
* @param array $response The personal data for the given exporter and page.
* @param array $response {
* The personal data for the given exporter and page number.
*
* @type bool $items_removed Whether items were actually removed or not.
* @type bool $items_retained Whether items were retained or not.
* @type string[] $messages An array of messages to add to the personal data export file.
* @type bool $done Whether the eraser is finished or not.
* }
* @param int $eraser_index The index of the eraser that provided this data.
* @param string $email_address The email address associated with this personal data.
* @param int $page The page for this response.
* @param int $page The page number for this response.
* @param int $request_id The privacy request post ID associated with this request.
* @param string $eraser_key The key (slug) of the eraser that provided this data.
*/

View File

@@ -143,10 +143,16 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
echo '</p></div>';
if ( $this->error || ! $this->result ) {
if ( $this->error ) {
echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' ) . '</p></div>';
$after_error_message = sprintf( $this->upgrader->strings['skin_update_failed_error'], $title, '<strong>' . $this->error . '</strong>' );
} else {
echo '<div class="error"><p>' . sprintf( $this->upgrader->strings['skin_update_failed'], $title ) . '</p></div>';
$after_error_message = sprintf( $this->upgrader->strings['skin_update_failed'], $title );
}
wp_admin_notice(
$after_error_message,
array(
'additional_classes' => array( 'error' ),
)
);
echo '<script type="text/javascript">jQuery(\'#progress-' . esc_js( $this->upgrader->update_current ) . '\').show();</script>';
}

View File

@@ -239,30 +239,37 @@ class Custom_Background {
<div class="wrap" id="custom-background">
<h1><?php _e( 'Custom Background' ); ?></h1>
<?php if ( current_user_can( 'customize' ) ) { ?>
<div class="notice notice-info hide-if-no-customize">
<p>
<?php
printf(
<?php
if ( current_user_can( 'customize' ) ) {
$message = sprintf(
/* translators: %s: URL to background image configuration in Customizer. */
__( 'You can now manage and live-preview Custom Backgrounds in the <a href="%s">Customizer</a>.' ),
admin_url( 'customize.php?autofocus[control]=background_image' )
);
?>
</p>
</div>
<?php } ?>
wp_admin_notice(
$message,
array(
'type' => 'info',
'additional_classes' => array( 'hide-if-no-customize' ),
)
);
}
<?php if ( ! empty( $this->updated ) ) { ?>
<div id="message" class="updated">
<p>
<?php
/* translators: %s: Home URL. */
printf( __( 'Background updated. <a href="%s">Visit your site</a> to see how it looks.' ), esc_url( home_url( '/' ) ) );
?>
</p>
</div>
<?php } ?>
if ( ! empty( $this->updated ) ) {
$updated_message = sprintf(
/* translators: %s: Home URL. */
__( 'Background updated. <a href="%s">Visit your site</a> to see how it looks.' ),
esc_url( home_url( '/' ) )
);
wp_admin_notice(
$updated_message,
array(
'id' => 'message',
'additional_classes' => array( 'updated' ),
)
);
}
?>
<h2><?php _e( 'Background Image' ); ?></h2>
@@ -564,8 +571,9 @@ class Custom_Background {
$thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' );
set_theme_mod( 'background_image_thumb', sanitize_url( $thumbnail[0] ) );
/** This action is documented in wp-admin/includes/class-custom-image-header.php */
do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication.
/** This filter is documented in wp-admin/includes/class-custom-image-header.php */
$file = apply_filters( 'wp_create_file_in_uploads', $file, $id ); // For replication.
$this->updated = true;
}

View File

@@ -509,30 +509,37 @@ class Custom_Image_Header {
<div class="wrap">
<h1><?php _e( 'Custom Header' ); ?></h1>
<?php if ( current_user_can( 'customize' ) ) { ?>
<div class="notice notice-info hide-if-no-customize">
<p>
<?php
printf(
<?php
if ( current_user_can( 'customize' ) ) {
$message = sprintf(
/* translators: %s: URL to header image configuration in Customizer. */
__( 'You can now manage and live-preview Custom Header in the <a href="%s">Customizer</a>.' ),
admin_url( 'customize.php?autofocus[control]=header_image' )
);
?>
</p>
</div>
<?php } ?>
wp_admin_notice(
$message,
array(
'type' => 'info',
'additional_classes' => array( 'hide-if-no-customize' ),
)
);
}
<?php if ( ! empty( $this->updated ) ) { ?>
<div id="message" class="updated">
<p>
<?php
/* translators: %s: Home URL. */
printf( __( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ), esc_url( home_url( '/' ) ) );
?>
</p>
</div>
<?php } ?>
if ( ! empty( $this->updated ) ) {
$updated_message = sprintf(
/* translators: %s: Home URL. */
__( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ),
esc_url( home_url( '/' ) )
);
wp_admin_notice(
$updated_message,
array(
'id' => 'message',
'additional_classes' => array( 'updated' ),
)
);
}
?>
<h2><?php _e( 'Header Image' ); ?></h2>
@@ -875,14 +882,16 @@ endif;
$this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) );
/**
* Fires after the header image is set or an error is returned.
* Filters the attachment file path after the custom header or background image is set.
*
* Used for file replication.
*
* @since 2.1.0
*
* @param string $file Path to the file.
* @param int $attachment_id Attachment ID.
*/
do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication.
$file = apply_filters( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication.
return $this->finished();
} elseif ( $width > $max_width ) {

View File

@@ -153,7 +153,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param object[] $language_updates Optional. Array of language packs to update. @see wp_get_translation_updates().
* @param object[] $language_updates Optional. Array of language packs to update. See {@see wp_get_translation_updates()}.
* Default empty array.
* @param array $args {
* Other arguments for upgrading multiple language packs. Default empty array.
@@ -238,7 +238,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$destination .= '/themes';
}
$this->update_current++;
++$this->update_current;
$options = array(
'package' => $language_update->package,

View File

@@ -274,6 +274,8 @@ class Plugin_Upgrader extends WP_Upgrader {
* @since 2.8.0
* @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
*
* @global string $wp_version The WordPress version string.
*
* @param string[] $plugins Array of paths to plugin files relative to the plugins directory.
* @param array $args {
* Optional. Other arguments for upgrading several plugins at once.
@@ -283,6 +285,8 @@ class Plugin_Upgrader extends WP_Upgrader {
* @return array|false An array of results indexed by plugin file, or false if unable to connect to the filesystem.
*/
public function bulk_upgrade( $plugins, $args = array() ) {
global $wp_version;
$defaults = array(
'clear_update_cache' => true,
);
@@ -326,7 +330,7 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->update_count = count( $plugins );
$this->update_current = 0;
foreach ( $plugins as $plugin ) {
$this->update_current++;
++$this->update_current;
$this->skin->plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin, false, true );
if ( ! isset( $current->response[ $plugin ] ) ) {
@@ -343,23 +347,55 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->skin->plugin_active = is_plugin_active( $plugin );
$result = $this->run(
array(
'package' => $r->package,
'destination' => WP_PLUGIN_DIR,
'clear_destination' => true,
'clear_working' => true,
'is_multi' => true,
'hook_extra' => array(
'plugin' => $plugin,
'temp_backup' => array(
'slug' => dirname( $plugin ),
'src' => WP_PLUGIN_DIR,
'dir' => 'plugins',
if ( isset( $r->requires ) && ! is_wp_version_compatible( $r->requires ) ) {
$result = new WP_Error(
'incompatible_wp_required_version',
sprintf(
/* translators: 1: Current WordPress version, 2: WordPress version required by the new plugin version. */
__( 'Your WordPress version is %1$s, however the new plugin version requires %2$s.' ),
$wp_version,
$r->requires
)
);
$this->skin->before( $result );
$this->skin->error( $result );
$this->skin->after();
} elseif ( isset( $r->requires_php ) && ! is_php_version_compatible( $r->requires_php ) ) {
$result = new WP_Error(
'incompatible_php_required_version',
sprintf(
/* translators: 1: Current PHP version, 2: PHP version required by the new plugin version. */
__( 'The PHP version on your server is %1$s, however the new plugin version requires %2$s.' ),
PHP_VERSION,
$r->requires_php
)
);
$this->skin->before( $result );
$this->skin->error( $result );
$this->skin->after();
} else {
add_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
$result = $this->run(
array(
'package' => $r->package,
'destination' => WP_PLUGIN_DIR,
'clear_destination' => true,
'clear_working' => true,
'is_multi' => true,
'hook_extra' => array(
'plugin' => $plugin,
'temp_backup' => array(
'slug' => dirname( $plugin ),
'src' => WP_PLUGIN_DIR,
'dir' => 'plugins',
),
),
),
)
);
)
);
remove_filter( 'upgrader_source_selection', array( $this, 'check_package' ) );
}
$results[ $plugin ] = $result;

View File

@@ -426,7 +426,7 @@ class Theme_Upgrader extends WP_Upgrader {
$this->update_count = count( $themes );
$this->update_current = 0;
foreach ( $themes as $theme ) {
$this->update_current++;
++$this->update_current;
$this->skin->theme_info = $this->theme_info( $theme );
@@ -768,5 +768,4 @@ class Theme_Upgrader extends WP_Upgrader {
return $theme;
}
}

View File

@@ -32,7 +32,7 @@ class Walker_Category_Checklist extends Walker {
*
* @param string $output Used to append additional content (passed by reference).
* @param int $depth Depth of category. Used for tab indentation.
* @param array $args An array of arguments. @see wp_terms_checklist()
* @param array $args An array of arguments. See {@see wp_terms_checklist()}.
*/
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
@@ -48,7 +48,7 @@ class Walker_Category_Checklist extends Walker {
*
* @param string $output Used to append additional content (passed by reference).
* @param int $depth Depth of category. Used for tab indentation.
* @param array $args An array of arguments. @see wp_terms_checklist()
* @param array $args An array of arguments. See {@see wp_terms_checklist()}.
*/
public function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
@@ -67,7 +67,7 @@ class Walker_Category_Checklist extends Walker {
* @param string $output Used to append additional content (passed by reference).
* @param WP_Term $data_object The current term object.
* @param int $depth Depth of the term in reference to parents. Default 0.
* @param array $args An array of arguments. @see wp_terms_checklist()
* @param array $args An array of arguments. See {@see wp_terms_checklist()}.
* @param int $current_object_id Optional. ID of the current term. Default 0.
*/
public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {
@@ -130,7 +130,7 @@ class Walker_Category_Checklist extends Walker {
* @param string $output Used to append additional content (passed by reference).
* @param WP_Term $data_object The current term object.
* @param int $depth Depth of the term in reference to parents. Default 0.
* @param array $args An array of arguments. @see wp_terms_checklist()
* @param array $args An array of arguments. See {@see wp_terms_checklist()}.
*/
public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
$output .= "</li>\n";

View File

@@ -123,5 +123,4 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
$output .= '<input type="hidden" class="menu-item-classes" name="menu-item[' . $possible_object_id . '][menu-item-classes]" value="' . esc_attr( implode( ' ', $menu_item->classes ) ) . '" />';
$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $menu_item->xfn ) . '" />';
}
}

View File

@@ -61,7 +61,8 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
global $_wp_nav_menu_max_depth;
// Restores the more descriptive, specific name for use within this method.
$menu_item = $data_object;
$menu_item = $data_object;
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
ob_start();
@@ -319,5 +320,4 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
<?php
$output .= ob_get_clean();
}
}

View File

@@ -1390,7 +1390,7 @@ class WP_Automatic_Updater {
} else {
/* translators: %s: WordPress version. */
$body[] = sprintf( __( 'FAILED: WordPress failed to update to %s' ), $result->name );
$failures++;
++$failures;
}
$body[] = '';
@@ -1432,7 +1432,7 @@ class WP_Automatic_Updater {
if ( ! $item->result || is_wp_error( $item->result ) ) {
/* translators: %s: Name of plugin / theme / translation. */
$body[] = ' * ' . sprintf( __( 'FAILED: %s' ), $item->name );
$failures++;
++$failures;
}
}
}

View File

@@ -177,9 +177,10 @@ class WP_Comments_List_Table extends WP_List_Table {
array_merge(
$args,
array(
'count' => true,
'offset' => 0,
'number' => 0,
'count' => true,
'offset' => 0,
'number' => 0,
'orderby' => 'none',
)
)
);
@@ -298,6 +299,7 @@ class WP_Comments_List_Table extends WP_List_Table {
'post_id' => $post_id ? $post_id : 0,
'user_id' => $current_user_id,
'count' => true,
'orderby' => 'none',
)
);
$link = add_query_arg( 'user_id', $current_user_id, $link );
@@ -518,8 +520,9 @@ class WP_Comments_List_Table extends WP_List_Table {
foreach ( $comment_types as $type => $label ) {
if ( get_comments(
array(
'number' => 1,
'type' => $type,
'count' => true,
'orderby' => 'none',
'type' => $type,
)
) ) {
printf(
@@ -651,6 +654,19 @@ class WP_Comments_List_Table extends WP_List_Table {
$this->user_can = current_user_can( 'edit_comment', $comment->comment_ID );
$edit_post_cap = $post ? 'edit_post' : 'edit_posts';
if (
current_user_can( $edit_post_cap, $comment->comment_post_ID ) ||
(
empty( $post->post_password ) &&
current_user_can( 'read_post', $comment->comment_post_ID )
)
) {
// The user has access to the post
} else {
return false;
}
echo "<tr id='comment-$comment->comment_ID' class='$the_comment_class'>";
$this->single_row_columns( $comment );
echo "</tr>\n";
@@ -685,7 +701,8 @@ class WP_Comments_List_Table extends WP_List_Table {
}
// Restores the more descriptive, specific name for use within this method.
$comment = $item;
$comment = $item;
$the_comment_status = wp_get_comment_status( $comment );
$output = '';
@@ -895,7 +912,8 @@ class WP_Comments_List_Table extends WP_List_Table {
if ( $this->user_can ) {
?>
<label class="label-covers-full-cell" for="cb-select-<?php echo $comment->comment_ID; ?>">
<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
<label for="cb-select-<?php echo $comment->comment_ID; ?>">
<span class="screen-reader-text">
<?php
/* translators: Hidden accessibility text. */
@@ -903,7 +921,6 @@ class WP_Comments_List_Table extends WP_List_Table {
?>
</span>
</label>
<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
<?php
}
}
@@ -1087,6 +1104,9 @@ class WP_Comments_List_Table extends WP_List_Table {
* @param string $column_name The custom column's name.
*/
public function column_default( $item, $column_name ) {
// Restores the more descriptive, specific name for use within this method.
$comment = $item;
/**
* Fires when the default column output is displayed for a single row.
*
@@ -1095,6 +1115,6 @@ class WP_Comments_List_Table extends WP_List_Table {
* @param string $column_name The custom column's name.
* @param string $comment_id The comment ID as a numeric string.
*/
do_action( 'manage_comments_custom_column', $column_name, $item->comment_ID );
do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
}
}

View File

@@ -483,7 +483,7 @@ class WP_Community_Events {
$future_wordcamps = array_filter(
$future_events,
static function( $wordcamp ) {
static function ( $wordcamp ) {
return 'wordcamp' === $wordcamp['type'];
}
);

View File

@@ -548,6 +548,7 @@ class WP_Debug_Data {
);
} else {
// Get the PHP ini directive values.
$file_uploads = ini_get( 'file_uploads' );
$post_max_size = ini_get( 'post_max_size' );
$upload_max_filesize = ini_get( 'upload_max_filesize' );
$max_file_uploads = ini_get( 'max_file_uploads' );
@@ -556,8 +557,8 @@ class WP_Debug_Data {
// Add info in Media section.
$info['wp-media']['fields']['file_uploads'] = array(
'label' => __( 'File uploads' ),
'value' => empty( ini_get( 'file_uploads' ) ) ? __( 'Disabled' ) : __( 'Enabled' ),
'debug' => 'File uploads is turned off',
'value' => $file_uploads ? __( 'Enabled' ) : __( 'Disabled' ),
'debug' => $file_uploads,
);
$info['wp-media']['fields']['post_max_size'] = array(
'label' => __( 'Max size of post data allowed' ),
@@ -700,12 +701,6 @@ class WP_Debug_Data {
$php_version_debug .= ' 64bit';
}
if ( function_exists( 'php_sapi_name' ) ) {
$php_sapi = php_sapi_name();
} else {
$php_sapi = 'unknown';
}
$info['wp-server']['fields']['server_architecture'] = array(
'label' => __( 'Server architecture' ),
'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ),
@@ -723,8 +718,8 @@ class WP_Debug_Data {
);
$info['wp-server']['fields']['php_sapi'] = array(
'label' => __( 'PHP SAPI' ),
'value' => ( 'unknown' !== $php_sapi ? $php_sapi : __( 'Unable to determine PHP SAPI' ) ),
'debug' => $php_sapi,
'value' => PHP_SAPI,
'debug' => PHP_SAPI,
);
// Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
@@ -846,11 +841,12 @@ class WP_Debug_Data {
// Server time.
$date = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
$info['wp-server']['fields']['current'] = array(
$info['wp-server']['fields']['current'] = array(
'label' => __( 'Current time' ),
'value' => $date->format( DateTime::ATOM ),
);
$info['wp-server']['fields']['utc-time'] = array(
$info['wp-server']['fields']['utc-time'] = array(
'label' => __( 'Current UTC time' ),
'value' => $date->format( DateTime::RFC850 ),
);
@@ -860,10 +856,7 @@ class WP_Debug_Data {
);
// Populate the database debug fields.
if ( is_resource( $wpdb->dbh ) ) {
// Old mysql extension.
$extension = 'mysql';
} elseif ( is_object( $wpdb->dbh ) ) {
if ( is_object( $wpdb->dbh ) ) {
// mysqli or PDO.
$extension = get_class( $wpdb->dbh );
} else {
@@ -873,16 +866,7 @@ class WP_Debug_Data {
$server = $wpdb->get_var( 'SELECT VERSION()' );
if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) {
$client_version = $wpdb->dbh->client_info;
} else {
// phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
$client_version = $matches[0];
} else {
$client_version = null;
}
}
$client_version = $wpdb->dbh->client_info;
$info['wp-database']['fields']['extension'] = array(
'label' => __( 'Extension' ),

View File

@@ -216,13 +216,13 @@ class WP_Filesystem_Base {
}
}
} elseif ( 'direct' === $this->method ) {
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation.
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitization.
return trailingslashit( $folder );
}
$folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out Windows drive letter if it's there.
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation.
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitization.
if ( isset( $this->cache[ $folder ] ) ) {
return $this->cache[ $folder ];
@@ -333,7 +333,6 @@ class WP_Filesystem_Base {
* This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
*/
return $this->search_for_folder( $folder, '/', true );
}
/**
@@ -862,5 +861,4 @@ class WP_Filesystem_Base {
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
return false;
}
}

View File

@@ -105,7 +105,7 @@ class WP_Importer {
$source_comment_id = (int) $source_comment_id;
// Check if this comment came from this blog.
if ( $blog_id == $comment_agent_blog_id ) {
if ( (int) $blog_id === (int) $comment_agent_blog_id ) {
$hashtable[ $source_comment_id ] = (int) $r->comment_ID;
}
}

View File

@@ -174,7 +174,8 @@ class WP_Links_List_Table extends WP_List_Table {
$link = $item;
?>
<label class="label-covers-full-cell" for="cb-select-<?php echo $link->link_id; ?>">
<input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
<label for="cb-select-<?php echo $link->link_id; ?>">
<span class="screen-reader-text">
<?php
/* translators: Hidden accessibility text. %s: Link name. */
@@ -182,7 +183,6 @@ class WP_Links_List_Table extends WP_List_Table {
?>
</span>
</label>
<input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
<?php
}
@@ -290,6 +290,9 @@ class WP_Links_List_Table extends WP_List_Table {
* @param string $column_name Current column name.
*/
public function column_default( $item, $column_name ) {
// Restores the more descriptive, specific name for use within this method.
$link = $item;
/**
* Fires for each registered custom link column.
*
@@ -298,7 +301,7 @@ class WP_Links_List_Table extends WP_List_Table {
* @param string $column_name Name of the custom column.
* @param int $link_id Link ID.
*/
do_action( 'manage_link_custom_column', $column_name, $item->link_id );
do_action( 'manage_link_custom_column', $column_name, $link->link_id );
}
public function display_rows() {
@@ -332,7 +335,8 @@ class WP_Links_List_Table extends WP_List_Table {
}
// Restores the more descriptive, specific name for use within this method.
$link = $item;
$link = $item;
$edit_link = get_edit_bookmark_link( $link );
$actions = array();

View File

@@ -176,6 +176,7 @@ class WP_List_Table {
* Makes private properties readable for backward compatibility.
*
* @since 4.0.0
* @since 6.4.0 Getting a dynamic property is deprecated.
*
* @param string $name Property to get.
* @return mixed Property.
@@ -184,27 +185,44 @@ class WP_List_Table {
if ( in_array( $name, $this->compat_fields, true ) ) {
return $this->$name;
}
wp_trigger_error(
__METHOD__,
"The property `{$name}` is not declared. Getting a dynamic property is " .
'deprecated since version 6.4.0! Instead, declare the property on the class.',
E_USER_DEPRECATED
);
return null;
}
/**
* Makes private properties settable for backward compatibility.
*
* @since 4.0.0
* @since 6.4.0 Setting a dynamic property is deprecated.
*
* @param string $name Property to check if set.
* @param mixed $value Property value.
* @return mixed Newly-set property.
*/
public function __set( $name, $value ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
return $this->$name = $value;
$this->$name = $value;
return;
}
wp_trigger_error(
__METHOD__,
"The property `{$name}` is not declared. Setting a dynamic property is " .
'deprecated since version 6.4.0! Instead, declare the property on the class.',
E_USER_DEPRECATED
);
}
/**
* Makes private properties checkable for backward compatibility.
*
* @since 4.0.0
* @since 6.4.0 Checking a dynamic property is deprecated.
*
* @param string $name Property to check if set.
* @return bool Whether the property is a back-compat property and it is set.
@@ -214,6 +232,12 @@ class WP_List_Table {
return isset( $this->$name );
}
wp_trigger_error(
__METHOD__,
"The property `{$name}` is not declared. Checking `isset()` on a dynamic property " .
'is deprecated since version 6.4.0! Instead, declare the property on the class.',
E_USER_DEPRECATED
);
return false;
}
@@ -221,13 +245,22 @@ class WP_List_Table {
* Makes private properties un-settable for backward compatibility.
*
* @since 4.0.0
* @since 6.4.0 Unsetting a dynamic property is deprecated.
*
* @param string $name Property to unset.
*/
public function __unset( $name ) {
if ( in_array( $name, $this->compat_fields, true ) ) {
unset( $this->$name );
return;
}
wp_trigger_error(
__METHOD__,
"A property `{$name}` is not declared. Unsetting a dynamic property is " .
'deprecated since version 6.4.0! Instead, declare the property on the class.',
E_USER_DEPRECATED
);
}
/**
@@ -818,6 +851,20 @@ class WP_List_Table {
$pending_comments_number
);
$post_object = get_post( $post_id );
$edit_post_cap = $post_object ? 'edit_post' : 'edit_posts';
if (
current_user_can( $edit_post_cap, $post_id ) ||
(
empty( $post_object->post_password ) &&
current_user_can( 'read_post', $post_id )
)
) {
// The user has access to the post and thus can see comments
} else {
return false;
}
if ( ! $approved_comments && ! $pending_comments ) {
// No comments at all.
printf(
@@ -1370,14 +1417,14 @@ class WP_List_Table {
if ( ! empty( $columns['cb'] ) ) {
static $cb_counter = 1;
$columns['cb'] = '<label class="label-covers-full-cell" for="cb-select-all-' . $cb_counter . '">' .
$columns['cb'] = '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />
<label for="cb-select-all-' . $cb_counter . '">' .
'<span class="screen-reader-text">' .
/* translators: Hidden accessibility text. */
__( 'Select All' ) .
'</span>' .
'</label>' .
'<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />';
$cb_counter++;
'</label>';
++$cb_counter;
}
foreach ( $columns as $column_key => $column_display_name ) {

View File

@@ -297,7 +297,7 @@ class WP_Media_List_Table extends WP_List_Table {
<?php
$this->extra_tablenav( 'bar' );
/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
$views = apply_filters( "views_{$this->screen->id}", array() );
// Back compat for pre-4.0 view links.
@@ -419,7 +419,8 @@ class WP_Media_List_Table extends WP_List_Table {
if ( current_user_can( 'edit_post', $post->ID ) ) {
?>
<label class="label-covers-full-cell" for="cb-select-<?php echo $post->ID; ?>">
<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
<label for="cb-select-<?php echo $post->ID; ?>">
<span class="screen-reader-text">
<?php
/* translators: Hidden accessibility text. %s: Attachment title. */
@@ -427,7 +428,6 @@ class WP_Media_List_Table extends WP_List_Table {
?>
</span>
</label>
<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
<?php
}
}
@@ -880,11 +880,11 @@ class WP_Media_List_Table extends WP_List_Table {
return '';
}
// Restores the more descriptive, specific name for use within this method.
$post = $item;
$att_title = _draft_or_post_title();
$actions = $this->_get_row_actions(
$item, // WP_Post object for an attachment.
$att_title
);
$actions = $this->_get_row_actions( $post, $att_title );
return $this->row_actions( $actions );
}

View File

@@ -391,15 +391,15 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
protected function get_sortable_columns() {
if ( is_subdomain_install() ) {
$abbr = __( 'Domain' );
$blogname_abbr = __( 'Domain' );
$blogname_orderby_text = __( 'Table ordered by Site Domain Name.' );
} else {
$abbr = __( 'Path' );
$blogname_abbr = __( 'Path' );
$blogname_orderby_text = __( 'Table ordered by Site Path.' );
}
return array(
'blogname' => array( 'blogname', false, $abbr, $blogname_orderby_text ),
'blogname' => array( 'blogname', false, $blogname_abbr, $blogname_orderby_text ),
'lastupdated' => array( 'lastupdated', true, __( 'Last Updated' ), __( 'Table ordered by Last Updated.' ) ),
'registered' => array( 'blog_id', true, _x( 'Registered', 'site' ), __( 'Table ordered by Site Registered Date.' ), 'desc' ),
);
@@ -420,7 +420,8 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
if ( ! is_main_site( $blog['blog_id'] ) ) :
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
?>
<label class="label-covers-full-cell" for="blog_<?php echo $blog['blog_id']; ?>">
<input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
<label for="blog_<?php echo $blog['blog_id']; ?>">
<span class="screen-reader-text">
<?php
/* translators: %s: Site URL. */
@@ -428,8 +429,6 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
?>
</span>
</label>
<input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]"
value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
<?php
endif;
}
@@ -597,6 +596,9 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
* @param string $column_name Current column name.
*/
public function column_default( $item, $column_name ) {
// Restores the more descriptive, specific name for use within this method.
$blog = $item;
/**
* Fires for each registered custom column in the Sites list table.
*
@@ -605,7 +607,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
* @param string $column_name The name of the column to display.
* @param int $blog_id The site ID.
*/
do_action( 'manage_sites_custom_column', $column_name, $item['blog_id'] );
do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
}
/**
@@ -714,7 +716,8 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
}
// Restores the more descriptive, specific name for use within this method.
$blog = $item;
$blog = $item;
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
// Preordered.

View File

@@ -509,10 +509,12 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
*/
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$theme = $item;
$theme = $item;
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
?>
<label class="label-covers-full-cell" for="<?php echo $checkbox_id; ?>" >
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
<label for="<?php echo $checkbox_id; ?>" >
<span class="screen-reader-text">
<?php
printf(
@@ -523,7 +525,6 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
?>
</span>
</label>
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
<?php
}
@@ -859,7 +860,13 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
*/
echo apply_filters( 'theme_auto_update_setting_html', $html, $stylesheet, $theme );
echo '<div class="notice notice-error notice-alt inline hidden"><p></p></div>';
wp_admin_notice(
'',
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
)
);
}
/**
@@ -872,6 +879,11 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
* @param string $column_name The current column name.
*/
public function column_default( $item, $column_name ) {
// Restores the more descriptive, specific name for use within this method.
$theme = $item;
$stylesheet = $theme->get_stylesheet();
/**
* Fires inside each custom column of the Multisite themes list table.
*
@@ -881,12 +893,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
* @param string $stylesheet Directory name of the theme.
* @param WP_Theme $theme Current WP_Theme object.
*/
do_action(
'manage_themes_custom_column',
$column_name,
$item->get_stylesheet(), // Directory name of the theme.
$item // Theme object.
);
do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
}
/**

View File

@@ -235,7 +235,8 @@ class WP_MS_Users_List_Table extends WP_List_Table {
return;
}
?>
<label class="label-covers-full-cell" for="blog_<?php echo $user->ID; ?>">
<input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
<label for="blog_<?php echo $user->ID; ?>">
<span class="screen-reader-text">
<?php
/* translators: Hidden accessibility text. %s: User login. */
@@ -243,7 +244,6 @@ class WP_MS_Users_List_Table extends WP_List_Table {
?>
</span>
</label>
<input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
<?php
}
@@ -458,13 +458,11 @@ class WP_MS_Users_List_Table extends WP_List_Table {
* @param string $column_name The current column name.
*/
public function column_default( $item, $column_name ) {
// Restores the more descriptive, specific name for use within this method.
$user = $item;
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
echo apply_filters(
'manage_users_custom_column',
'', // Custom column output. Default empty.
$column_name,
$item->ID // User ID.
);
echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
}
public function display_rows() {
@@ -519,10 +517,10 @@ class WP_MS_Users_List_Table extends WP_List_Table {
}
// Restores the more descriptive, specific name for use within this method.
$user = $item;
$super_admins = get_super_admins();
$user = $item;
$actions = array();
$super_admins = get_super_admins();
$actions = array();
if ( current_user_can( 'edit_user', $user->ID ) ) {
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );

View File

@@ -290,10 +290,17 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
/**
*/
public function no_items() {
if ( isset( $this->error ) ) { ?>
<div class="inline error"><p><?php echo $this->error->get_error_message(); ?></p>
<p class="hide-if-no-js"><button class="button try-again"><?php _e( 'Try Again' ); ?></button></p>
</div>
if ( isset( $this->error ) ) {
$error_message = '<p>' . $this->error->get_error_message() . '</p>';
$error_message .= '<p class="hide-if-no-js"><button class="button try-again">' . __( 'Try Again' ) . '</button></p>';
wp_admin_notice(
$error_message,
array(
'additional_classes' => array( 'inline', 'error' ),
'paragraph_wrap' => false,
)
);
?>
<?php } else { ?>
<div class="no-plugin-results"><?php _e( 'No plugins found. Try a different search.' ); ?></div>
<?php
@@ -329,7 +336,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
public function views() {
$views = $this->get_views();
/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
$views = apply_filters( "views_{$this->screen->id}", $views );
$this->screen->render_screen_reader_content( 'heading_views' );
@@ -686,52 +693,59 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
<div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>">
<?php
if ( ! $compatible_php || ! $compatible_wp ) {
echo '<div class="notice inline notice-error notice-alt"><p>';
$incompatible_notice_message = '';
if ( ! $compatible_php && ! $compatible_wp ) {
_e( 'This plugin does not work with your versions of WordPress and PHP.' );
$incompatible_notice_message .= __( 'This plugin does not work with your versions of WordPress and PHP.' );
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
printf(
$incompatible_notice_message .= sprintf(
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
self_admin_url( 'update-core.php' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$incompatible_notice_message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
} elseif ( current_user_can( 'update_core' ) ) {
printf(
$incompatible_notice_message .= sprintf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
} elseif ( current_user_can( 'update_php' ) ) {
printf(
$incompatible_notice_message .= sprintf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$incompatible_notice_message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
}
} elseif ( ! $compatible_wp ) {
_e( 'This plugin does not work with your version of WordPress.' );
$incompatible_notice_message .= __( 'This plugin does not work with your version of WordPress.' );
if ( current_user_can( 'update_core' ) ) {
printf(
$incompatible_notice_message .= printf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
}
} elseif ( ! $compatible_php ) {
_e( 'This plugin does not work with your version of PHP.' );
$incompatible_notice_message .= __( 'This plugin does not work with your version of PHP.' );
if ( current_user_can( 'update_php' ) ) {
printf(
$incompatible_notice_message .= sprintf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$incompatible_notice_message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
}
}
echo '</p></div>';
wp_admin_notice(
$incompatible_notice_message,
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline' ),
)
);
}
?>
<div class="plugin-card-top">

View File

@@ -728,7 +728,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$suffix = 2;
while ( in_array( $plugin_id_attr, $plugin_id_attrs, true ) ) {
$plugin_id_attr = "$plugin_slug-$suffix";
$suffix++;
++$suffix;
}
$plugin_id_attrs[] = $plugin_id_attr;
@@ -993,12 +993,12 @@ class WP_Plugins_List_Table extends WP_List_Table {
$checkbox = '';
} else {
$checkbox = sprintf(
'<label class="label-covers-full-cell" for="%1$s"><span class="screen-reader-text">%2$s</span></label>' .
'<input type="checkbox" name="checked[]" value="%3$s" id="%1$s" />',
'<input type="checkbox" name="checked[]" value="%1$s" id="%2$s" />' .
'<label for="%2$s"><span class="screen-reader-text">%3$s</span></label>',
esc_attr( $plugin_file ),
$checkbox_id,
/* translators: Hidden accessibility text. %s: Plugin name. */
sprintf( __( 'Select %s' ), $plugin_data['Name'] ),
esc_attr( $plugin_file )
sprintf( __( 'Select %s' ), $plugin_data['Name'] )
);
}
@@ -1243,7 +1243,14 @@ class WP_Plugins_List_Table extends WP_List_Table {
*/
echo apply_filters( 'plugin_auto_update_setting_html', $html, $plugin_file, $plugin_data );
echo '<div class="notice notice-error notice-alt inline hidden"><p></p></div>';
wp_admin_notice(
'',
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
)
);
echo '</td>';
break;
@@ -1273,58 +1280,65 @@ class WP_Plugins_List_Table extends WP_List_Table {
if ( ! $compatible_php || ! $compatible_wp ) {
printf(
'<tr class="plugin-update-tr">' .
'<td colspan="%s" class="plugin-update colspanchange">' .
'<div class="update-message notice inline notice-error notice-alt"><p>',
'<tr class="plugin-update-tr"><td colspan="%s" class="plugin-update colspanchange">',
esc_attr( $this->get_column_count() )
);
$incompatible_message = '';
if ( ! $compatible_php && ! $compatible_wp ) {
_e( 'This plugin does not work with your versions of WordPress and PHP.' );
$incompatible_message .= __( 'This plugin does not work with your versions of WordPress and PHP.' );
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
printf(
$incompatible_message .= sprintf(
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
self_admin_url( 'update-core.php' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$incompatible_message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
} elseif ( current_user_can( 'update_core' ) ) {
printf(
$incompatible_message .= sprintf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
} elseif ( current_user_can( 'update_php' ) ) {
printf(
$incompatible_message .= sprintf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$incompatible_message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
}
} elseif ( ! $compatible_wp ) {
_e( 'This plugin does not work with your version of WordPress.' );
$incompatible_message .= __( 'This plugin does not work with your version of WordPress.' );
if ( current_user_can( 'update_core' ) ) {
printf(
$incompatible_message .= sprintf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s">Please update WordPress</a>.' ),
self_admin_url( 'update-core.php' )
);
}
} elseif ( ! $compatible_php ) {
_e( 'This plugin does not work with your version of PHP.' );
$incompatible_message .= __( 'This plugin does not work with your version of PHP.' );
if ( current_user_can( 'update_php' ) ) {
printf(
$incompatible_message .= sprintf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
$incompatible_message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
}
}
echo '</p></div></td></tr>';
wp_admin_notice(
$incompatible_message,
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
)
);
echo '</td></tr>';
}
/**

View File

@@ -764,7 +764,12 @@ class WP_Posts_List_Table extends WP_List_Table {
$post_type = $this->screen->post_type;
if ( 'page' === $post_type ) {
$title_orderby_text = isset( $_GET['orderby'] ) ? __( 'Table ordered by Title.' ) : __( 'Table ordered by Hierarchical Menu Order and Title.' );
if ( isset( $_GET['orderby'] ) ) {
$title_orderby_text = __( 'Table ordered by Title.' );
} else {
$title_orderby_text = __( 'Table ordered by Hierarchical Menu Order and Title.' );
}
$sortables = array(
'title' => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ),
'parent' => array( 'parent', false ),
@@ -893,7 +898,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$to_display[ $page->ID ] = $level;
}
$count++;
++$count;
if ( isset( $children_pages ) ) {
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
@@ -912,7 +917,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$to_display[ $op->ID ] = 0;
}
$count++;
++$count;
}
}
}
@@ -987,7 +992,7 @@ class WP_Posts_List_Table extends WP_List_Table {
while ( $my_parent = array_pop( $my_parents ) ) {
$to_display[ $my_parent->ID ] = $level - $num_parents;
$num_parents--;
--$num_parents;
}
}
@@ -995,7 +1000,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$to_display[ $page->ID ] = $level;
}
$count++;
++$count;
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
}
@@ -1014,6 +1019,7 @@ class WP_Posts_List_Table extends WP_List_Table {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$post = $item;
$show = current_user_can( 'edit_post', $post->ID );
/**
@@ -1028,7 +1034,8 @@ class WP_Posts_List_Table extends WP_List_Table {
*/
if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :
?>
<label class="label-covers-full-cell" for="cb-select-<?php the_ID(); ?>">
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
<label for="cb-select-<?php the_ID(); ?>">
<span class="screen-reader-text">
<?php
/* translators: %s: Post title. */
@@ -1036,7 +1043,6 @@ class WP_Posts_List_Table extends WP_List_Table {
?>
</span>
</label>
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
<div class="locked-indicator">
<span class="locked-indicator-icon" aria-hidden="true"></span>
<span class="screen-reader-text">
@@ -1092,7 +1098,7 @@ class WP_Posts_List_Table extends WP_List_Table {
break;
}
$this->current_level++;
++$this->current_level;
$find_main_page = (int) $parent->post_parent;
if ( ! isset( $parent_name ) ) {
@@ -1162,7 +1168,12 @@ class WP_Posts_List_Table extends WP_List_Table {
}
}
get_inline_data( $post );
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type );
if ( $quick_edit_enabled ) {
get_inline_data( $post );
}
}
/**
@@ -1223,7 +1234,7 @@ class WP_Posts_List_Table extends WP_List_Table {
}
/**
* Filters the published time of the post.
* Filters the published, scheduled, or unpublished time of the post.
*
* @since 2.5.1
* @since 5.5.0 Removed the difference between 'excerpt' and 'list' modes.
@@ -1453,7 +1464,8 @@ class WP_Posts_List_Table extends WP_List_Table {
}
// Restores the more descriptive, specific name for use within this method.
$post = $item;
$post = $item;
$post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( 'edit_post', $post->ID );
$actions = array();
@@ -1468,7 +1480,17 @@ class WP_Posts_List_Table extends WP_List_Table {
__( 'Edit' )
);
if ( 'wp_block' !== $post->post_type ) {
/**
* Filters whether Quick Edit should be enabled for the given post type.
*
* @since 6.4.0
*
* @param bool $enable Whether to enable the Quick Edit functionality. Default true.
* @param string $post_type Post type name.
*/
$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_post_type', true, $post->post_type );
if ( $quick_edit_enabled && 'wp_block' !== $post->post_type ) {
$actions['inline hide-if-no-js'] = sprintf(
'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
/* translators: %s: Post title. */
@@ -2071,16 +2093,23 @@ class WP_Posts_List_Table extends WP_List_Table {
<input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
<?php endif; ?>
<div class="notice notice-error notice-alt inline hidden">
<p class="error"></p>
</div>
<?php
wp_admin_notice(
'<p class="error"></p>',
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
'paragraph_wrap' => false,
)
);
?>
</div>
</div> <!-- end of .inline-edit-wrapper -->
</td></tr>
<?php
$bulk++;
++$bulk;
endwhile;
?>
</tbody></table>

View File

@@ -164,5 +164,4 @@ class WP_Privacy_Data_Removal_Requests_List_Table extends WP_Privacy_Requests_Ta
break;
}
}
}

View File

@@ -130,31 +130,28 @@ final class WP_Privacy_Policy_Content {
* Outputs a warning when some privacy info has changed.
*
* @since 4.9.6
*
* @global WP_Post $post Global post object.
*/
public static function policy_text_changed_notice() {
global $post;
$screen = get_current_screen()->id;
if ( 'privacy' !== $screen ) {
return;
}
?>
<div class="policy-text-updated notice notice-warning is-dismissible">
<p>
<?php
printf(
/* translators: %s: Privacy Policy Guide URL. */
__( 'The suggested privacy policy text has changed. Please <a href="%s">review the guide</a> and update your privacy policy.' ),
esc_url( admin_url( 'privacy-policy-guide.php?tab=policyguide' ) )
);
?>
</p>
</div>
<?php
$privacy_message = sprintf(
/* translators: %s: Privacy Policy Guide URL. */
__( 'The suggested privacy policy text has changed. Please <a href="%s">review the guide</a> and update your privacy policy.' ),
esc_url( admin_url( 'privacy-policy-guide.php?tab=policyguide' ) )
);
wp_admin_notice(
$privacy_message,
array(
'type' => 'warning',
'additional_classes' => array( 'policy-text-updated' ),
'dismissible' => true,
)
);
}
/**
@@ -356,22 +353,20 @@ final class WP_Privacy_Policy_Content {
'after'
);
} else {
?>
<div class="notice notice-warning inline wp-pp-notice">
<p>
<?php
echo $message;
printf(
' <a href="%s" target="_blank">%s <span class="screen-reader-text">%s</span></a>',
$url,
$label,
/* translators: Hidden accessibility text. */
__( '(opens in a new tab)' )
);
?>
</p>
</div>
<?php
$message .= sprintf(
' <a href="%s" target="_blank">%s <span class="screen-reader-text">%s</span></a>',
$url,
$label,
/* translators: Hidden accessibility text. */
__( '(opens in a new tab)' )
);
wp_admin_notice(
$message,
array(
'type' => 'warning',
'additional_classes' => array( 'inline', 'wp-pp-notice' ),
)
);
}
}
@@ -398,8 +393,14 @@ final class WP_Privacy_Policy_Content {
$badge_title = sprintf( __( 'Removed %s.' ), $date );
/* translators: %s: Date of plugin deactivation. */
$removed = __( 'You deactivated this plugin on %s and may no longer need this policy.' );
$removed = '<div class="notice notice-info inline"><p>' . sprintf( $removed, $date ) . '</p></div>';
$removed = sprintf( __( 'You deactivated this plugin on %s and may no longer need this policy.' ), $date );
$removed = wp_get_admin_notice(
$removed,
array(
'type' => 'info',
'additional_classes' => array( 'inline' ),
)
);
} elseif ( ! empty( $section['updated'] ) ) {
$badge_class = ' blue';
$date = date_i18n( $date_format, $section['updated'] );

View File

@@ -239,9 +239,9 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$resend = _wp_privacy_resend_request( $request_id );
if ( $resend && ! is_wp_error( $resend ) ) {
$count++;
++$count;
} else {
$failures++;
++$failures;
}
}
@@ -286,7 +286,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$result = _wp_privacy_completed_request( $request_id );
if ( $result && ! is_wp_error( $result ) ) {
$count++;
++$count;
}
}
@@ -309,9 +309,9 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
case 'delete':
foreach ( $request_ids as $request_id ) {
if ( wp_delete_post( $request_id, true ) ) {
$count++;
++$count;
} else {
$failures++;
++$failures;
}
}
@@ -416,8 +416,8 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
*/
public function column_cb( $item ) {
return sprintf(
'<label class="label-covers-full-cell" for="requester_%1$s"><span class="screen-reader-text">%2$s</span></label>' .
'<input type="checkbox" name="request_id[]" id="requester_%1$s" value="%1$s" /><span class="spinner"></span>',
'<input type="checkbox" name="request_id[]" id="requester_%1$s" value="%1$s" />' .
'<label for="requester_%1$s"><span class="screen-reader-text">%2$s</span></label><span class="spinner"></span>',
esc_attr( $item->ID ),
/* translators: Hidden accessibility text. %s: Email address. */
sprintf( __( 'Select %s' ), $item->email )

View File

@@ -42,7 +42,7 @@ class WP_Site_Health_Auto_Updates {
$tests = array_filter( $tests );
$tests = array_map(
static function( $test ) {
static function ( $test ) {
$test = (object) $test;
if ( empty( $test->severity ) ) {
@@ -228,7 +228,7 @@ class WP_Site_Health_Auto_Updates {
// Search all directories we've found for evidence of version control.
foreach ( $vcs_dirs as $vcs_dir ) {
foreach ( $check_dirs as $check_dir ) {
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments
if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
break 2;
}

View File

@@ -381,14 +381,14 @@ class WP_Site_Health {
// Loop over the available plugins and check their versions and active state.
foreach ( $plugins as $plugin_path => $plugin ) {
$plugins_total++;
++$plugins_total;
if ( is_plugin_active( $plugin_path ) ) {
$plugins_active++;
++$plugins_active;
}
if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
$plugins_need_update++;
++$plugins_need_update;
}
}
@@ -543,21 +543,21 @@ class WP_Site_Health {
}
foreach ( $all_themes as $theme_slug => $theme ) {
$themes_total++;
++$themes_total;
if ( array_key_exists( $theme_slug, $theme_updates ) ) {
$themes_need_updates++;
++$themes_need_updates;
}
}
// If this is a child theme, increase the allowed theme count by one, to account for the parent.
if ( is_child_theme() ) {
$allowed_theme_count++;
++$allowed_theme_count;
}
// If there's a default theme installed and not in use, we count that as allowed as well.
if ( $has_default_theme && ! $using_default_theme ) {
$allowed_theme_count++;
++$allowed_theme_count;
}
if ( $themes_total > $allowed_theme_count ) {
@@ -1356,13 +1356,8 @@ class WP_Site_Health {
}
}
if ( $wpdb->use_mysqli ) {
// phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info
$mysql_client_version = mysqli_get_client_info();
} else {
// phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
$mysql_client_version = mysql_get_client_info();
}
// phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info
$mysql_client_version = mysqli_get_client_info();
/*
* libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
@@ -1560,10 +1555,9 @@ class WP_Site_Health {
*/
public function get_test_https_status() {
/*
* Enforce fresh HTTPS detection results. This is normally invoked by using cron,
* but for Site Health it should always rely on the latest results.
* Check HTTPS detection results.
*/
wp_update_https_detection_errors();
$errors = wp_get_https_detection_errors();
$default_update_url = wp_get_default_update_https_url();
@@ -1943,10 +1937,6 @@ class WP_Site_Health {
public function get_test_available_updates_disk_space() {
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false;
$available_space = false !== $available_space
? (int) $available_space
: 0;
$result = array(
'label' => __( 'Disk space available to safely perform updates' ),
'status' => 'good',
@@ -1963,18 +1953,14 @@ class WP_Site_Health {
'test' => 'available_updates_disk_space',
);
if ( $available_space < 100 * MB_IN_BYTES ) {
$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
if ( false === $available_space ) {
$result['description'] = __( 'Could not determine available disk space for updates.' );
$result['status'] = 'recommended';
}
if ( $available_space < 20 * MB_IN_BYTES ) {
} elseif ( $available_space < 20 * MB_IN_BYTES ) {
$result['description'] = __( 'Available disk space is critically low, less than 20 MB available. Proceed with caution, updates may fail.' );
$result['status'] = 'critical';
}
if ( ! $available_space ) {
$result['description'] = __( 'Could not determine available disk space for updates.' );
} elseif ( $available_space < 100 * MB_IN_BYTES ) {
$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
$result['status'] = 'recommended';
}
@@ -3306,11 +3292,11 @@ class WP_Site_Health {
foreach ( $results as $result ) {
if ( 'critical' === $result['status'] ) {
$site_status['critical']++;
++$site_status['critical'];
} elseif ( 'recommended' === $result['status'] ) {
$site_status['recommended']++;
++$site_status['recommended'];
} else {
$site_status['good']++;
++$site_status['good'];
}
}
@@ -3646,5 +3632,4 @@ class WP_Site_Health {
*/
return apply_filters( 'site_status_available_object_cache_services', $services );
}
}

View File

@@ -63,7 +63,6 @@ class WP_Terms_List_Table extends WP_List_Table {
if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ), true ) ) {
$post_type = 'post';
}
}
/**
@@ -311,7 +310,7 @@ class WP_Terms_List_Table extends WP_List_Table {
while ( $my_parent = array_pop( $my_parents ) ) {
echo "\t";
$this->single_row( $my_parent, $level - $num_parents );
$num_parents--;
--$num_parents;
}
}
@@ -365,8 +364,8 @@ class WP_Terms_List_Table extends WP_List_Table {
if ( current_user_can( 'delete_term', $tag->term_id ) ) {
return sprintf(
'<label class="label-covers-full-cell" for="cb-select-%1$s"><span class="screen-reader-text">%2$s</span></label>' .
'<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />',
'<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />' .
'<label for="cb-select-%1$s"><span class="screen-reader-text">%2$s</span></label>',
$tag->term_id,
/* translators: Hidden accessibility text. %s: Taxonomy term name. */
sprintf( __( 'Select %s' ), $tag->name )
@@ -426,12 +425,17 @@ class WP_Terms_List_Table extends WP_List_Table {
$name
);
$output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
$output .= '<div class="name">' . $qe_data->name . '</div>';
/** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy );
/** This filter is documented in wp-admin/edit-tag-form.php */
$output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
$output .= '<div class="parent">' . $qe_data->parent . '</div></div>';
if ( $quick_edit_enabled ) {
$output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
$output .= '<div class="name">' . $qe_data->name . '</div>';
/** This filter is documented in wp-admin/edit-tag-form.php */
$output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
$output .= '<div class="parent">' . $qe_data->parent . '</div></div>';
}
return $output;
}
@@ -465,32 +469,46 @@ class WP_Terms_List_Table extends WP_List_Table {
}
// Restores the more descriptive, specific name for use within this method.
$tag = $item;
$tag = $item;
$taxonomy = $this->screen->taxonomy;
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
$edit_link = add_query_arg(
'wp_http_referer',
urlencode( wp_unslash( $uri ) ),
get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
);
$actions = array();
if ( current_user_can( 'edit_term', $tag->term_id ) ) {
$actions['edit'] = sprintf(
'<a href="%s" aria-label="%s">%s</a>',
esc_url( $edit_link ),
esc_url(
add_query_arg(
'wp_http_referer',
urlencode( wp_unslash( $uri ) ),
get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
)
),
/* translators: %s: Taxonomy term name. */
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $tag->name ) ),
__( 'Edit' )
);
$actions['inline hide-if-no-js'] = sprintf(
'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
/* translators: %s: Taxonomy term name. */
esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $tag->name ) ),
__( 'Quick&nbsp;Edit' )
);
/**
* Filters whether Quick Edit should be enabled for the given taxonomy.
*
* @since 6.4.0
*
* @param bool $enable Whether to enable the Quick Edit functionality. Default true.
* @param string $taxonomy Taxonomy name.
*/
$quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy );
if ( $quick_edit_enabled ) {
$actions['inline hide-if-no-js'] = sprintf(
'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
/* translators: %s: Taxonomy term name. */
esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $tag->name ) ),
__( 'Quick&nbsp;Edit' )
);
}
}
if ( current_user_can( 'delete_term', $tag->term_id ) ) {
@@ -627,6 +645,9 @@ class WP_Terms_List_Table extends WP_List_Table {
* @return string
*/
public function column_default( $item, $column_name ) {
// Restores the more descriptive, specific name for use within this method.
$tag = $item;
/**
* Filters the displayed columns in the terms list table.
*
@@ -644,7 +665,7 @@ class WP_Terms_List_Table extends WP_List_Table {
* @param string $column_name Name of the column.
* @param int $term_id Term ID.
*/
return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $item->term_id );
return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
}
/**
@@ -712,9 +733,16 @@ class WP_Terms_List_Table extends WP_List_Table {
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
<div class="notice notice-error notice-alt inline hidden">
<p class="error"></p>
</div>
<?php
wp_admin_notice(
'<p class="error"></p>',
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
'paragraph_wrap' => false,
)
);
?>
</div>
</div>

View File

@@ -185,10 +185,11 @@ class WP_Upgrader {
* @since 2.8.0
*/
public function generic_strings() {
$this->strings['bad_request'] = __( 'Invalid data provided.' );
$this->strings['fs_unavailable'] = __( 'Could not access filesystem.' );
$this->strings['fs_error'] = __( 'Filesystem error.' );
$this->strings['fs_no_root_dir'] = __( 'Unable to locate WordPress root directory.' );
$this->strings['bad_request'] = __( 'Invalid data provided.' );
$this->strings['fs_unavailable'] = __( 'Could not access filesystem.' );
$this->strings['fs_error'] = __( 'Filesystem error.' );
$this->strings['fs_no_root_dir'] = __( 'Unable to locate WordPress root directory.' );
/* translators: %s: Directory name. */
$this->strings['fs_no_content_dir'] = sprintf( __( 'Unable to locate WordPress content directory (%s).' ), 'wp-content' );
$this->strings['fs_no_plugins_dir'] = __( 'Unable to locate WordPress plugin directory.' );
$this->strings['fs_no_themes_dir'] = __( 'Unable to locate WordPress theme directory.' );
@@ -1206,8 +1207,7 @@ class WP_Upgrader {
if ( ! $wp_filesystem->delete( $temp_backup_dir, true ) ) {
$errors->add(
'temp_backup_delete_failed',
sprintf( $this->strings['temp_backup_delete_failed'] ),
$args['slug']
sprintf( $this->strings['temp_backup_delete_failed'], $args['slug'] )
);
continue;
}

View File

@@ -524,12 +524,12 @@ class WP_Users_List_Table extends WP_List_Table {
// Set up the checkbox (because the user is editable, otherwise it's empty).
$checkbox = sprintf(
'<label class="label-covers-full-cell" for="user_%1$s"><span class="screen-reader-text">%2$s</span></label>' .
'<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />',
'<input type="checkbox" name="users[]" id="user_%1$s" class="%2$s" value="%1$s" />' .
'<label for="user_%1$s"><span class="screen-reader-text">%3$s</span></label>',
$user_object->ID,
$role_classes,
/* translators: Hidden accessibility text. %s: User login. */
sprintf( __( 'Select %s' ), $user_object->user_login ),
$role_classes
sprintf( __( 'Select %s' ), $user_object->user_login )
);
} else {
@@ -680,5 +680,4 @@ class WP_Users_List_Table extends WP_List_Table {
*/
return apply_filters( 'get_role_list', $role_list, $user_object );
}
}

View File

@@ -284,7 +284,6 @@ function wp_dashboard() {
<?php
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
}
//
@@ -574,9 +573,16 @@ function wp_dashboard_quick_press( $error_msg = false ) {
<form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
<?php if ( $error_msg ) : ?>
<div class="error"><?php echo $error_msg; ?></div>
<?php endif; ?>
<?php
if ( $error_msg ) {
wp_admin_notice(
$error_msg,
array(
'additional_classes' => array( 'error' ),
)
);
}
?>
<div class="input-text-wrap" id="title-wrap">
<label for="title">
@@ -1103,7 +1109,16 @@ function wp_dashboard_recent_comments( $total_items = 5 ) {
echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
foreach ( $comments as $comment ) {
_wp_dashboard_recent_comments_row( $comment );
$comment_post = get_post( $comment->comment_post_ID );
if (
current_user_can( 'edit_post', $comment->comment_post_ID ) ||
(
empty( $comment_post->post_password ) &&
current_user_can( 'read_post', $comment->comment_post_ID )
)
) {
_wp_dashboard_recent_comments_row( $comment );
}
}
echo '</ul>';
@@ -1158,8 +1173,15 @@ function wp_dashboard_rss_output( $widget_id ) {
* @return bool True on success, false on failure.
*/
function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array(), ...$args ) {
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&hellip;' ) . '</p><div class="hide-if-js notice notice-error inline"><p>' . __( 'This widget requires JavaScript.' ) . '</p></div>';
$doing_ajax = wp_doing_ajax();
$loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading&hellip;' ) . '</p>';
$loading .= wp_get_admin_notice(
__( 'This widget requires JavaScript.' ),
array(
'type' => 'error',
'additional_classes' => array( 'inline', 'hide-if-js' ),
)
);
if ( empty( $check_urls ) ) {
$widgets = get_option( 'dashboard_widget_options' );
@@ -1341,25 +1363,19 @@ function wp_dashboard_events_news() {
* @since 4.8.0
*/
function wp_print_community_events_markup() {
?>
$community_events_notice = '<p class="hide-if-js">' . ( 'This widget requires JavaScript.' ) . '</p>';
$community_events_notice .= '<p class="community-events-error-occurred" aria-hidden="true">' . __( 'An error occurred. Please try again.' ) . '</p>';
$community_events_notice .= '<p class="community-events-could-not-locate" aria-hidden="true"></p>';
<div class="community-events-errors notice notice-error inline hide-if-js">
<p class="hide-if-js">
<?php _e( 'This widget requires JavaScript.' ); ?>
</p>
wp_admin_notice(
$community_events_notice,
array(
'type' => 'error',
'additional_classes' => array( 'community-events-errors', 'inline', 'hide-if-js' ),
'paragraph_wrap' => false,
)
);
<p class="community-events-error-occurred" aria-hidden="true">
<?php _e( 'An error occurred. Please try again.' ); ?>
</p>
<p class="community-events-could-not-locate" aria-hidden="true"></p>
</div>
<div class="community-events-loading hide-if-no-js">
<?php _e( 'Loading&hellip;' ); ?>
</div>
<?php
/*
* Hide the main element when the page first loads, because the content
* won't be ready until wp.communityEvents.renderEventsTemplate() has run.
@@ -1447,6 +1463,15 @@ function wp_print_community_events_templates() {
<div class="dashicons event-icon" aria-hidden="true"></div>
<div class="event-info-inner">
<a class="event-title" href="{{ event.url }}">{{ event.title }}</a>
<# if ( event.type ) {
const titleCaseEventType = event.type.replace(
/\w\S*/g,
function ( type ) { return type.charAt(0).toUpperCase() + type.substr(1).toLowerCase(); }
);
#>
{{ 'wordcamp' === event.type ? 'WordCamp' : titleCaseEventType }}
<span class="ce-separator"></span>
<# } #>
<span class="event-city">{{ event.location.location }}</span>
</div>
</div>

View File

@@ -493,7 +493,7 @@ class WP_User_Search {
* @return WP_User_Search
*/
function __construct( $search_term = '', $page = '', $role = '' ) {
_deprecated_function( __FUNCTION__, '3.1.0', 'WP_User_Query' );
_deprecated_class( 'WP_User_Search', '3.1.0', 'WP_User_Query' );
$this->search_term = wp_unslash( $search_term );
$this->raw_page = ( '' == $page ) ? false : (int) $page;
@@ -516,6 +516,7 @@ class WP_User_Search {
* @return WP_User_Search
*/
public function WP_User_Search( $search_term = '', $page = '', $role = '' ) {
_deprecated_constructor( 'WP_User_Search', '3.1.0', get_class( $this ) );
self::__construct( $search_term, $page, $role );
}

View File

@@ -777,9 +777,9 @@ function validate_file_to_edit( $file, $allowed_files = array() ) {
* An array of override parameters for this file, or boolean false if none are provided.
*
* @type callable $upload_error_handler Function to call when there is an error during the upload process.
* @see wp_handle_upload_error().
* See {@see wp_handle_upload_error()}.
* @type callable $unique_filename_callback Function to call when determining a unique file name for the file.
* @see wp_unique_filename().
* See {@see wp_unique_filename()}.
* @type string[] $upload_error_strings The strings that describe the error indicated in
* `$_FILES[{form field}]['error']`.
* @type bool $test_form Whether to test that the `$_POST['action']` parameter is as expected.
@@ -845,7 +845,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
* @since 5.7.0
*
* @param array|false $overrides An array of override parameters for this file. Boolean false if none are
* provided. @see _wp_handle_upload().
* provided. See {@see _wp_handle_upload()}.
* @param array $file {
* Reference to a single element from `$_FILES`.
*
@@ -1266,7 +1266,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
$signature_verification = in_array( parse_url( $url, PHP_URL_HOST ), $signed_hostnames, true );
}
// Perform signature valiation if supported.
// Perform signature validation if supported.
if ( $signature_verification ) {
$signature = wp_remote_retrieve_header( $response, 'X-Content-Signature' );
@@ -1493,7 +1493,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
// Ensure only valid-length signatures are considered.
if ( SODIUM_CRYPTO_SIGN_BYTES !== strlen( $signature_raw ) ) {
$skipped_signature++;
++$skipped_signature;
continue;
}
@@ -1502,7 +1502,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
// Only pass valid public keys through.
if ( SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES !== strlen( $key_raw ) ) {
$skipped_key++;
++$skipped_key;
continue;
}
@@ -1672,6 +1672,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
$info = $z->statIndex( $i );
if ( ! $info ) {
$z->close();
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
}
@@ -1697,6 +1698,9 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
}
}
// Enough space to unzip the file and copy its contents, with a 10% buffer.
$required_space = $uncompressed_size * 2.1;
/*
* disk_free_space() could return false. Assume that any falsey value is an error.
* A disk that has zero free bytes has bigger problems.
@@ -1705,7 +1709,8 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
if ( wp_doing_cron() ) {
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false;
if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
if ( $available_space && ( $required_space > $available_space ) ) {
$z->close();
return new WP_Error(
'disk_full_unzip_file',
__( 'Could not copy files. You may have run out of disk space.' ),
@@ -1743,15 +1748,36 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
foreach ( $needed_dirs as $_dir ) {
// Only check to see if the Dir exists upon creation failure. Less I/O this way.
if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
$z->close();
return new WP_Error( 'mkdir_failed_ziparchive', __( 'Could not create directory.' ), $_dir );
}
}
unset( $needed_dirs );
/**
* Filters archive unzipping to override with a custom process.
*
* @since 6.4.0
*
* @param null|true|WP_Error $result The result of the override. True on success, otherwise WP Error. Default null.
* @param string $file Full path and filename of ZIP archive.
* @param string $to Full path on the filesystem to extract archive to.
* @param string[] $needed_dirs A full list of required folders that need to be created.
* @param float $required_space The space required to unzip the file and copy its contents, with a 10% buffer.
*/
$pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
if ( null !== $pre ) {
// Ensure the ZIP file archive has been closed.
$z->close();
return $pre;
}
for ( $i = 0; $i < $z->numFiles; $i++ ) {
$info = $z->statIndex( $i );
if ( ! $info ) {
$z->close();
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
}
@@ -1771,17 +1797,34 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
$contents = $z->getFromIndex( $i );
if ( false === $contents ) {
$z->close();
return new WP_Error( 'extract_failed_ziparchive', __( 'Could not extract file from archive.' ), $info['name'] );
}
if ( ! $wp_filesystem->put_contents( $to . $info['name'], $contents, FS_CHMOD_FILE ) ) {
$z->close();
return new WP_Error( 'copy_failed_ziparchive', __( 'Could not copy file.' ), $info['name'] );
}
}
$z->close();
return true;
/**
* Filters the result of unzipping an archive.
*
* @since 6.4.0
*
* @param true|WP_Error $result The result of unzipping the archive. True on success, otherwise WP_Error. Default true.
* @param string $file Full path and filename of ZIP archive.
* @param string $to Full path on the filesystem the archive was extracted to.
* @param string[] $needed_dirs A full list of required folders that were created.
* @param float $required_space The space required to unzip the file and copy its contents, with a 10% buffer.
*/
$result = apply_filters( 'unzip_file', true, $file, $to, $needed_dirs, $required_space );
unset( $needed_dirs );
return $result;
}
/**
@@ -1838,6 +1881,9 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
$needed_dirs[] = $to . untrailingslashit( $file['folder'] ? $file['filename'] : dirname( $file['filename'] ) );
}
// Enough space to unzip the file and copy its contents, with a 10% buffer.
$required_space = $uncompressed_size * 2.1;
/*
* disk_free_space() could return false. Assume that any falsey value is an error.
* A disk that has zero free bytes has bigger problems.
@@ -1846,7 +1892,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
if ( wp_doing_cron() ) {
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false;
if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) {
if ( $available_space && ( $required_space > $available_space ) ) {
return new WP_Error(
'disk_full_unzip_file',
__( 'Could not copy files. You may have run out of disk space.' ),
@@ -1887,7 +1933,13 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), $_dir );
}
}
unset( $needed_dirs );
/** This filter is documented in src/wp-admin/includes/file.php */
$pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
if ( null !== $pre ) {
return $pre;
}
// Extract the files from the zip.
foreach ( $archive_files as $file ) {
@@ -1909,7 +1961,12 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
}
}
return true;
/** This action is documented in src/wp-admin/includes/file.php */
$result = apply_filters( 'unzip_file', true, $file, $to, $needed_dirs, $required_space );
unset( $needed_dirs );
return $result;
}
/**
@@ -2426,7 +2483,13 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
if ( is_wp_error( $error ) ) {
$error_string = esc_html( $error->get_error_message() );
}
echo '<div id="message" class="error"><p>' . $error_string . '</p></div>';
wp_admin_notice(
$error_string,
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
)
);
}
$types = array();
@@ -2701,7 +2764,6 @@ function wp_opcache_invalidate_directory( $dir ) {
__( '%s expects a non-empty string.' ),
'<code>wp_opcache_invalidate_directory()</code>'
);
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
trigger_error( $error_message );
}
return;
@@ -2726,7 +2788,7 @@ function wp_opcache_invalidate_directory( $dir ) {
* with sub-directories represented as nested arrays.
* @param string $path Absolute path to the directory.
*/
$invalidate_directory = static function( $dirlist, $path ) use ( &$invalidate_directory ) {
$invalidate_directory = static function ( $dirlist, $path ) use ( &$invalidate_directory ) {
$path = trailingslashit( $path );
foreach ( $dirlist as $name => $details ) {

View File

@@ -32,15 +32,16 @@ function wp_image_editor( $post_id, $msg = false ) {
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
$can_restore = false;
if ( ! empty( $backup_sizes ) && isset( $backup_sizes['full-orig'], $meta['file'] ) ) {
$can_restore = wp_basename( $meta['file'] ) !== $backup_sizes['full-orig']['file'];
}
if ( $msg ) {
if ( isset( $msg->error ) ) {
$note = "<div class='notice notice-error' tabindex='-1' role='alert'><p>$msg->error</p></div>";
$note = "<div class='notice notice-error' role='alert'><p>$msg->error</p></div>";
} elseif ( isset( $msg->msg ) ) {
$note = "<div class='notice notice-success' tabindex='-1' role='alert'><p>$msg->msg</p></div>";
$note = "<div class='notice notice-success' role='alert'><p>$msg->msg</p></div>";
}
}
@@ -62,7 +63,7 @@ function wp_image_editor( $post_id, $msg = false ) {
<button type="button" onclick="imageEdit.toggleCropTool( <?php echo "$post_id, '$nonce'"; ?>, this );" aria-expanded="false" aria-controls="imgedit-crop" class="imgedit-crop button disabled" disabled><?php esc_html_e( 'Crop' ); ?></button>
<button type="button" class="imgedit-scale button" onclick="imageEdit.toggleControls(this);" aria-expanded="false" aria-controls="imgedit-scale"><?php esc_html_e( 'Scale' ); ?></button>
<div class="imgedit-rotate-menu-container">
<button type="button" aria-controls="imgedit-rotate-menu" class="imgedit-rotate button" aria-expanded="false" onclick="imageEdit.togglePopup(this)"><?php esc_html_e( 'Image Rotation' ); ?></button>
<button type="button" aria-controls="imgedit-rotate-menu" class="imgedit-rotate button" aria-expanded="false" onclick="imageEdit.togglePopup(this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Image Rotation' ); ?></button>
<div id="imgedit-rotate-menu" class="imgedit-popup-menu">
<?php
// On some setups GD library does not provide imagerotate() - Ticket #11536.
@@ -74,9 +75,9 @@ function wp_image_editor( $post_id, $msg = false ) {
) ) {
$note_no_rotate = '';
?>
<button type="button" class="imgedit-rleft button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate 90° left' ); ?></button>
<button type="button" class="imgedit-rright button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate 90° right' ); ?></button>
<button type="button" class="imgedit-rfull button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(180, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate 180°' ); ?></button>
<button type="button" class="imgedit-rleft button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 90&deg; left' ); ?></button>
<button type="button" class="imgedit-rright button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 90&deg; right' ); ?></button>
<button type="button" class="imgedit-rfull button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.rotate(180, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()"><?php esc_html_e( 'Rotate 180&deg;' ); ?></button>
<?php
} else {
$note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>';
@@ -87,8 +88,8 @@ function wp_image_editor( $post_id, $msg = false ) {
}
?>
<hr />
<button type="button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button>
<button type="button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button>
<button type="button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button>
<button type="button" onkeyup="imageEdit.browsePopup(this)" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" onblur="imageEdit.monitorPopup()" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button>
<?php echo $note_no_rotate; ?>
</div>
</div>
@@ -636,15 +637,18 @@ function image_edit_apply_changes( $image, $changes ) {
$obj->sel = $obj->c;
unset( $obj->c );
}
$changes[ $key ] = $obj;
}
// Combine operations.
if ( count( $changes ) > 1 ) {
$filtered = array( $changes[0] );
for ( $i = 0, $j = 1, $c = count( $changes ); $j < $c; $j++ ) {
$combined = false;
if ( $filtered[ $i ]->type == $changes[ $j ]->type ) {
if ( $filtered[ $i ]->type === $changes[ $j ]->type ) {
switch ( $filtered[ $i ]->type ) {
case 'rotate':
$filtered[ $i ]->angle += $changes[ $j ]->angle;
@@ -656,10 +660,12 @@ function image_edit_apply_changes( $image, $changes ) {
break;
}
}
if ( ! $combined ) {
$filtered[ ++$i ] = $changes[ $j ];
}
}
$changes = $filtered;
unset( $filtered );
}
@@ -693,7 +699,7 @@ function image_edit_apply_changes( $image, $changes ) {
foreach ( $changes as $operation ) {
switch ( $operation->type ) {
case 'rotate':
if ( 0 != $operation->angle ) {
if ( 0 !== $operation->angle ) {
if ( $image instanceof WP_Image_Editor ) {
$image->rotate( $operation->angle );
} else {
@@ -702,11 +708,11 @@ function image_edit_apply_changes( $image, $changes ) {
}
break;
case 'flip':
if ( 0 != $operation->axis ) {
if ( 0 !== $operation->axis ) {
if ( $image instanceof WP_Image_Editor ) {
$image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
$image->flip( ( $operation->axis & 1 ) !== 0, ( $operation->axis & 2 ) !== 0 );
} else {
$image = _flip_image_resource( $image, ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 );
$image = _flip_image_resource( $image, ( $operation->axis & 1 ) !== 0, ( $operation->axis & 2 ) !== 0 );
}
}
break;
@@ -801,9 +807,8 @@ function wp_restore_image( $post_id ) {
if ( isset( $backup_sizes['full-orig'] ) && is_array( $backup_sizes['full-orig'] ) ) {
$data = $backup_sizes['full-orig'];
if ( $parts['basename'] != $data['file'] ) {
if ( $parts['basename'] !== $data['file'] ) {
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
// Delete only if it's an edited image.
if ( preg_match( '/-e[0-9]{13}\./', $parts['basename'] ) ) {
wp_delete_file( $file );
@@ -828,9 +833,9 @@ function wp_restore_image( $post_id ) {
foreach ( $default_sizes as $default_size ) {
if ( isset( $backup_sizes[ "$default_size-orig" ] ) ) {
$data = $backup_sizes[ "$default_size-orig" ];
if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] != $data['file'] ) {
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
if ( isset( $meta['sizes'][ $default_size ] ) && $meta['sizes'][ $default_size ]['file'] !== $data['file'] ) {
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
// Delete only if it's an edited image.
if ( preg_match( '/-e[0-9]{13}-/', $meta['sizes'][ $default_size ]['file'] ) ) {
$delete_file = path_join( $parts['dirname'], $meta['sizes'][ $default_size ]['file'] );
@@ -847,9 +852,9 @@ function wp_restore_image( $post_id ) {
}
}
if ( ! wp_update_attachment_metadata( $post_id, $meta ) ||
( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) ) ) {
if ( ! wp_update_attachment_metadata( $post_id, $meta )
|| ( $old_backup_sizes !== $backup_sizes && ! update_post_meta( $post_id, '_wp_attachment_backup_sizes', $backup_sizes ) )
) {
$msg->error = __( 'Cannot save image metadata.' );
return $msg;
}
@@ -858,6 +863,7 @@ function wp_restore_image( $post_id ) {
$msg->error = __( 'Image metadata is inconsistent.' );
} else {
$msg->msg = __( 'Image restored successfully.' );
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE ) {
delete_post_meta( $post_id, '_wp_attachment_backup_sizes' );
}
@@ -886,35 +892,36 @@ function wp_save_image( $post_id ) {
$post = get_post( $post_id );
$img = wp_get_image_editor( _load_image_to_edit_path( $post_id, 'full' ) );
if ( is_wp_error( $img ) ) {
$return->error = esc_js( __( 'Unable to create new image.' ) );
return $return;
}
$fwidth = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
$fheight = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
$full_width = ! empty( $_REQUEST['fwidth'] ) ? (int) $_REQUEST['fwidth'] : 0;
$full_height = ! empty( $_REQUEST['fheight'] ) ? (int) $_REQUEST['fheight'] : 0;
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
/** This filter is documented in wp-admin/includes/image-edit.php */
$edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false );
if ( $scale ) {
$size = $img->get_size();
$sX = $size['width'];
$sY = $size['height'];
$size = $img->get_size();
$original_width = $size['width'];
$original_height = $size['height'];
if ( $sX < $fwidth || $sY < $fheight ) {
if ( $full_width > $original_width || $full_height > $original_height ) {
$return->error = esc_js( __( 'Images cannot be scaled to a size larger than the original.' ) );
return $return;
}
if ( $fwidth > 0 && $fheight > 0 ) {
if ( $full_width > 0 && $full_height > 0 ) {
// Check if it has roughly the same w / h ratio.
$diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );
$diff = round( $original_width / $original_height, 2 ) - round( $full_width / $full_height, 2 );
if ( -0.1 < $diff && $diff < 0.1 ) {
// Scale the full size image.
if ( $img->resize( $fwidth, $fheight ) ) {
if ( $img->resize( $full_width, $full_height ) ) {
$scaled = true;
}
}
@@ -955,8 +962,9 @@ function wp_save_image( $post_id ) {
$filename = pathinfo( $path, PATHINFO_FILENAME );
$suffix = time() . rand( 100, 999 );
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE &&
isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) {
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE
&& isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] !== $basename
) {
if ( $edit_thumbnails_separately && 'thumbnail' === $target ) {
$new_path = "{$dirname}/{$filename}-temp.{$ext}";
@@ -969,8 +977,9 @@ function wp_save_image( $post_id ) {
$filename .= "-e{$suffix}";
$new_filename = "{$filename}.{$ext}";
$new_path = "{$dirname}/$new_filename";
if ( file_exists( $new_path ) ) {
$suffix++;
++$suffix;
} else {
break;
}
@@ -985,8 +994,11 @@ function wp_save_image( $post_id ) {
if ( 'nothumb' === $target || 'all' === $target || 'full' === $target || $scaled ) {
$tag = false;
if ( isset( $backup_sizes['full-orig'] ) ) {
if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes['full-orig']['file'] !== $basename ) {
if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE )
&& $backup_sizes['full-orig']['file'] !== $basename
) {
$tag = "full-$suffix";
}
} else {
@@ -1000,6 +1012,7 @@ function wp_save_image( $post_id ) {
'file' => $basename,
);
}
$success = ( $path === $new_path ) || update_attached_file( $post_id, $new_path );
$meta['file'] = _wp_relative_upload_path( $new_path );
@@ -1045,9 +1058,12 @@ function wp_save_image( $post_id ) {
foreach ( $sizes as $size ) {
$tag = false;
if ( isset( $meta['sizes'][ $size ] ) ) {
if ( isset( $backup_sizes[ "$size-orig" ] ) ) {
if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) && $backup_sizes[ "$size-orig" ]['file'] != $meta['sizes'][ $size ]['file'] ) {
if ( ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE )
&& $backup_sizes[ "$size-orig" ]['file'] !== $meta['sizes'][ $size ]['file']
) {
$tag = "$size-$suffix";
}
} else {
@@ -1088,10 +1104,12 @@ function wp_save_image( $post_id ) {
if ( 'thumbnail' === $target || 'all' === $target || 'full' === $target ) {
// Check if it's an image edit from attachment edit screen.
if ( ! empty( $_REQUEST['context'] ) && 'edit-attachment' === $_REQUEST['context'] ) {
$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
$thumb_url = wp_get_attachment_image_src( $post_id, array( 900, 600 ), true );
$return->thumbnail = $thumb_url[0];
} else {
$file_url = wp_get_attachment_url( $post_id );
if ( ! empty( $meta['sizes']['thumbnail'] ) ) {
$thumb = $meta['sizes']['thumbnail'];
$return->thumbnail = path_join( dirname( $file_url ), $thumb['file'] );
@@ -1109,5 +1127,6 @@ function wp_save_image( $post_id ) {
}
$return->msg = esc_js( __( 'Image saved' ) );
return $return;
}

View File

@@ -700,7 +700,7 @@ function wp_exif_frac2dec( $str ) {
}
// The denominator must not be zero.
if ( 0 == $denominator ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Deliberate loose comparison.
if ( 0 == $denominator ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual -- Deliberate loose comparison.
return 0;
}
@@ -782,7 +782,7 @@ function wp_read_image_metadata( $file ) {
) {
$iptc = iptcparse( $info['APP13'] );
} else {
// phpcs:ignore WordPress.PHP.NoSilencedErrors -- Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
// Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
$iptc = @iptcparse( $info['APP13'] );
}
@@ -855,7 +855,7 @@ function wp_read_image_metadata( $file ) {
) {
$exif = exif_read_data( $file );
} else {
// phpcs:ignore WordPress.PHP.NoSilencedErrors -- Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
// Silencing notice and warning is intentional. See https://core.trac.wordpress.org/ticket/42480
$exif = @exif_read_data( $file );
}
@@ -953,7 +953,6 @@ function wp_read_image_metadata( $file ) {
* @param array $exif EXIF data.
*/
return apply_filters( 'wp_read_image_metadata', $meta, $file, $image_type, $iptc, $exif );
}
/**

View File

@@ -638,7 +638,7 @@ function wp_iframe( $content_func, ...$args ) {
*/
function media_buttons( $editor_id = 'content' ) {
static $instance = 0;
$instance++;
++$instance;
$post = get_post();
@@ -2083,13 +2083,11 @@ function media_upload_header() {
*
* @global string $type
* @global string $tab
* @global bool $is_IE
* @global bool $is_opera
*
* @param array $errors
*/
function media_upload_form( $errors = null ) {
global $type, $tab, $is_IE, $is_opera;
global $type, $tab;
if ( ! _device_can_upload() ) {
echo '<p>' . sprintf(

View File

@@ -228,7 +228,7 @@ function add_menu_classes( $menu ) {
$i = 0;
foreach ( $menu as $order => $top ) {
$i++;
++$i;
if ( 0 === $order ) { // Dashboard is always shown/single.
$menu[0][4] = add_cssclass( 'menu-top-first', $top[4] );

View File

@@ -311,25 +311,24 @@ function post_submit_meta_box( $post, $args = array() ) {
endif;
if ( 'draft' === $post->post_status && get_post_meta( $post_id, '_customize_changeset_uuid', true ) ) :
?>
<div class="notice notice-info notice-alt inline">
<p>
<?php
printf(
/* translators: %s: URL to the Customizer. */
__( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ),
esc_url(
add_query_arg(
'changeset_uuid',
rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
admin_url( 'customize.php' )
)
)
);
?>
</p>
</div>
<?php
$message = sprintf(
/* translators: %s: URL to the Customizer. */
__( 'This draft comes from your <a href="%s">unpublished customization changes</a>. You can edit, but there is no need to publish now. It will be published automatically with those changes.' ),
esc_url(
add_query_arg(
'changeset_uuid',
rawurlencode( get_post_meta( $post_id, '_customize_changeset_uuid', true ) ),
admin_url( 'customize.php' )
)
)
);
wp_admin_notice(
$message,
array(
'type' => 'info',
'additional_classes' => array( 'notice-alt', 'inline' ),
)
);
endif;
/**
@@ -902,8 +901,8 @@ function post_comment_meta_box( $post ) {
$total = get_comments(
array(
'post_id' => $post->ID,
'number' => 1,
'count' => true,
'orderby' => 'none',
)
);
$wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
@@ -1033,7 +1032,7 @@ function page_attributes_meta_box( $post ) {
endif; // End empty pages check.
endif; // End hierarchical check.
if ( count( get_page_templates( $post ) ) > 0 && get_option( 'page_for_posts' ) != $post->ID ) :
if ( count( get_page_templates( $post ) ) > 0 && (int) get_option( 'page_for_posts' ) !== $post->ID ) :
$template = ! empty( $post->page_template ) ? $post->page_template : false;
?>
<p class="post-attributes-label-wrapper page-template-label-wrapper"><label class="post-attributes-label" for="page_template"><?php _e( 'Template' ); ?></label>
@@ -1496,7 +1495,7 @@ function link_advanced_meta_box( $link ) {
<?php
for ( $rating = 0; $rating <= 10; $rating++ ) {
echo '<option value="' . $rating . '"';
if ( isset( $link->link_rating ) && $link->link_rating == $rating ) {
if ( isset( $link->link_rating ) && $link->link_rating === $rating ) {
echo ' selected="selected"';
}
echo '>' . $rating . '</option>';

View File

@@ -403,7 +403,7 @@ function wp_print_theme_file_tree( $tree, $level = 2, $size = 1, $index = 1 ) {
$size = count( $tree );
foreach ( $tree as $label => $theme_file ) :
$index++;
++$index;
if ( ! is_array( $theme_file ) ) {
wp_print_theme_file_tree( $theme_file, $level, $index, $size );
@@ -505,7 +505,7 @@ function wp_print_plugin_file_tree( $tree, $label = '', $level = 2, $size = 1, $
$size = count( $tree );
foreach ( $tree as $label => $plugin_file ) :
$index++;
++$index;
if ( ! is_array( $plugin_file ) ) {
wp_print_plugin_file_tree( $plugin_file, $label, $level, $index, $size );

View File

@@ -58,14 +58,10 @@ function check_upload_size( $file ) {
* @since 3.0.0
* @since 5.1.0 Use wp_delete_site() internally to delete the site row from the database.
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $blog_id Site ID.
* @param bool $drop True if site's database tables should be dropped. Default false.
*/
function wpmu_delete_blog( $blog_id, $drop = false ) {
global $wpdb;
$blog_id = (int) $blog_id;
$switch = false;
@@ -696,11 +692,20 @@ function site_admin_notice() {
}
if ( (int) get_site_option( 'wpmu_upgrade_site' ) !== $wp_db_version ) {
echo "<div class='update-nag notice notice-warning inline'>" . sprintf(
$upgrade_network_message = sprintf(
/* translators: %s: URL to Upgrade Network screen. */
__( 'Thank you for Updating! Please visit the <a href="%s">Upgrade Network</a> page to update all your sites.' ),
esc_url( network_admin_url( 'upgrade.php' ) )
) . '</div>';
);
wp_admin_notice(
$upgrade_network_message,
array(
'type' => 'warning',
'additional_classes' => array( 'update-nag', 'inline' ),
'paragraph_wrap' => false,
)
);
}
}
@@ -738,7 +743,7 @@ function avoid_blog_page_permalink_collision( $data, $postarr ) {
while ( $c < 10 && get_id_from_blogname( $post_name ) ) {
$post_name .= mt_rand( 1, 10 );
$c++;
++$c;
}
if ( $post_name !== $data['post_name'] ) {

View File

@@ -1291,15 +1291,21 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
}
if ( $some_pending_menu_items ) {
$result .= '<div class="notice notice-info notice-alt inline"><p>'
. __( 'Click Save Menu to make pending menu items public.' )
. '</p></div>';
$message = __( 'Click Save Menu to make pending menu items public.' );
$notice_args = array(
'type' => 'info',
'additional_classes' => array( 'notice-alt', 'inline' ),
);
$result .= wp_get_admin_notice( $message, $notice_args );
}
if ( $some_invalid_menu_items ) {
$result .= '<div class="notice notice-error notice-alt inline"><p>'
. __( 'There are some invalid menu items. Please check or delete them.' )
. '</p></div>';
$message = __( 'There are some invalid menu items. Please check or delete them.' );
$notice_args = array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline' ),
);
$result .= wp_get_admin_notice( $message, $notice_args );
}
$result .= '<ul class="menu" id="menu-to-edit"> ';
@@ -1314,7 +1320,6 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
} elseif ( is_wp_error( $menu ) ) {
return $menu;
}
}
/**
@@ -1432,7 +1437,13 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
);
if ( is_wp_error( $menu_item_db_id ) ) {
$messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
$messages[] = wp_get_admin_notice(
$menu_item_db_id->get_error_message(),
array(
'id' => 'message',
'additional_classes' => array( 'error' ),
)
);
} else {
unset( $menu_items[ $menu_item_db_id ] );
}
@@ -1480,12 +1491,15 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
/** This action is documented in wp-includes/nav-menu.php */
do_action( 'wp_update_nav_menu', $nav_menu_selected_id );
$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' .
sprintf(
/* translators: %s: Nav menu title. */
__( '%s has been updated.' ),
'<strong>' . $nav_menu_selected_title . '</strong>'
) . '</p></div>';
/* translators: %s: Nav menu title. */
$message = sprintf( __( '%s has been updated.' ), '<strong>' . $nav_menu_selected_title . '</strong>' );
$notice_args = array(
'id' => 'message',
'dismissible' => true,
'additional_classes' => array( 'updated' ),
);
$messages[] = wp_get_admin_notice( $message, $notice_args );
unset( $menu_items, $unsorted_menu_items );

View File

@@ -113,11 +113,20 @@ function network_step1( $errors = false ) {
global $is_apache;
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . sprintf(
$cannot_define_constant_message = '<strong>' . __( 'Error:' ) . '</strong> ';
$cannot_define_constant_message .= sprintf(
/* translators: %s: DO_NOT_UPGRADE_GLOBAL_TABLES */
__( 'The constant %s cannot be defined when creating a network.' ),
'<code>DO_NOT_UPGRADE_GLOBAL_TABLES</code>'
) . '</p></div>';
);
wp_admin_notice(
$cannot_define_constant_message,
array(
'additional_classes' => array( 'error' ),
)
);
echo '</div>';
require_once ABSPATH . 'wp-admin/admin-footer.php';
die();
@@ -125,11 +134,14 @@ function network_step1( $errors = false ) {
$active_plugins = get_option( 'active_plugins' );
if ( ! empty( $active_plugins ) ) {
echo '<div class="notice notice-warning"><p><strong>' . __( 'Warning:' ) . '</strong> ' . sprintf(
/* translators: %s: URL to Plugins screen. */
__( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ),
admin_url( 'plugins.php?plugin_status=active' )
) . '</p></div>';
wp_admin_notice(
'<strong>' . __( 'Warning:' ) . '</strong> ' . sprintf(
/* translators: %s: URL to Plugins screen. */
__( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ),
admin_url( 'plugins.php?plugin_status=active' )
),
array( 'type' => 'warning' )
);
echo '<p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
echo '</div>';
require_once ABSPATH . 'wp-admin/admin-footer.php';
@@ -139,7 +151,13 @@ function network_step1( $errors = false ) {
$hostname = get_clean_basedomain();
$has_ports = strstr( $hostname, ':' );
if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) {
echo '<div class="error"><p><strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
wp_admin_notice(
'<strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ),
array(
'additional_classes' => array( 'error' ),
)
);
echo '<p>' . sprintf(
/* translators: %s: Port number. */
__( 'You cannot use port numbers such as %s.' ),
@@ -157,11 +175,17 @@ function network_step1( $errors = false ) {
$error_codes = array();
if ( is_wp_error( $errors ) ) {
echo '<div class="error"><p><strong>' . __( 'Error: The network could not be created.' ) . '</strong></p>';
$network_created_error_message = '<p><strong>' . __( 'Error: The network could not be created.' ) . '</strong></p>';
foreach ( $errors->get_error_messages() as $error ) {
echo "<p>$error</p>";
$network_created_error_message .= "<p>$error</p>";
}
echo '</div>';
wp_admin_notice(
$network_created_error_message,
array(
'additional_classes' => array( 'error' ),
'paragraph_wrap' => false,
)
);
$error_codes = $errors->get_error_codes();
}
@@ -192,33 +216,39 @@ function network_step1( $errors = false ) {
$subdomain_install = false;
$got_mod_rewrite = got_mod_rewrite();
if ( $got_mod_rewrite ) { // Dangerous assumptions.
echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ';
printf(
$message_class = 'updated';
$message = '<p><strong>' . __( 'Warning:' ) . '</strong> ';
$message .= '<p>' . sprintf(
/* translators: %s: mod_rewrite */
__( 'Please make sure the Apache %s module is installed as it will be used at the end of this installation.' ),
'<code>mod_rewrite</code>'
);
echo '</p>';
) . '</p>';
} elseif ( $is_apache ) {
echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ';
printf(
$message_class = 'error';
$message = '<p><strong>' . __( 'Warning:' ) . '</strong> ';
$message .= sprintf(
/* translators: %s: mod_rewrite */
__( 'It looks like the Apache %s module is not installed.' ),
'<code>mod_rewrite</code>'
);
echo '</p>';
) . '</p>';
}
if ( $got_mod_rewrite || $is_apache ) { // Protect against mod_rewrite mimicry (but ! Apache).
echo '<p>';
printf(
$message .= '<p>' . sprintf(
/* translators: 1: mod_rewrite, 2: mod_rewrite documentation URL, 3: Google search for mod_rewrite. */
__( 'If %1$s is disabled, ask your administrator to enable that module, or look at the <a href="%2$s">Apache documentation</a> or <a href="%3$s">elsewhere</a> for help setting it up.' ),
'<code>mod_rewrite</code>',
'https://httpd.apache.org/docs/mod/mod_rewrite.html',
'https://www.google.com/search?q=apache+mod_rewrite'
) . '</p>';
wp_admin_notice(
$message,
array(
'additional_classes' => array( $message_class, 'inline' ),
'paragraph_wrap' => false,
)
);
echo '</p></div>';
}
}
@@ -260,7 +290,14 @@ function network_step1( $errors = false ) {
endif;
if ( WP_CONTENT_DIR !== ABSPATH . 'wp-content' && ( allow_subdirectory_install() || ! allow_subdomain_install() ) ) {
echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
$subdirectory_warning_message = '<strong>' . __( 'Warning:' ) . '</strong> ';
$subdirectory_warning_message .= __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' );
wp_admin_notice(
$subdirectory_warning_message,
array(
'additional_classes' => array( 'error', 'inline' ),
)
);
}
$is_www = str_starts_with( $hostname, 'www.' );
@@ -406,7 +443,12 @@ function network_step2( $errors = false ) {
// Wildcard DNS message.
if ( is_wp_error( $errors ) ) {
echo '<div class="error">' . $errors->get_error_message() . '</div>';
wp_admin_notice(
$errors->get_error_message(),
array(
'additional_classes' => array( 'error' ),
)
);
}
if ( $_POST ) {
@@ -423,8 +465,14 @@ function network_step2( $errors = false ) {
<?php
} else {
$subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
wp_admin_notice(
'<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'An existing WordPress network was detected.' ),
array(
'additional_classes' => array( 'error' ),
)
);
?>
<div class="error"><p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
<p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
<?php
}
@@ -438,35 +486,36 @@ function network_step2( $errors = false ) {
?>
<h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
<p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
<div class="notice notice-warning inline"><p>
<?php
$notice_message = '<strong>' . __( 'Caution:' ) . '</strong> ';
$notice_args = array(
'type' => 'warning',
'additional_classes' => array( 'inline' ),
);
if ( file_exists( $home_path . '.htaccess' ) ) {
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
printf(
$notice_message .= sprintf(
/* translators: 1: wp-config.php, 2: .htaccess */
__( 'You should back up your existing %1$s and %2$s files.' ),
'<code>wp-config.php</code>',
'<code>.htaccess</code>'
);
} elseif ( file_exists( $home_path . 'web.config' ) ) {
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
printf(
$notice_message .= sprintf(
/* translators: 1: wp-config.php, 2: web.config */
__( 'You should back up your existing %1$s and %2$s files.' ),
'<code>wp-config.php</code>',
'<code>web.config</code>'
);
} else {
echo '<strong>' . __( 'Caution:' ) . '</strong> ';
printf(
$notice_message .= sprintf(
/* translators: %s: wp-config.php */
__( 'You should back up your existing %s file.' ),
'<code>wp-config.php</code>'
);
}
?>
</p></div>
<?php
wp_admin_notice( $notice_message, $notice_args );
}
?>
<ol>

View File

@@ -22,6 +22,13 @@ function _x() {}
*/
function add_filter() {}
/**
* @ignore
*/
function has_filter() {
return false;
}
/**
* @ignore
*/

View File

@@ -316,7 +316,7 @@ function install_dashboard() {
*/
function install_search_form( $deprecated = true ) {
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
$term = isset( $_REQUEST['s'] ) ? urldecode( wp_unslash( $_REQUEST['s'] ) ) : '';
?>
<form class="search-form search-plugins" method="get">
<input type="hidden" name="tab" value="search" />
@@ -817,37 +817,54 @@ function install_plugin_information() {
$tested_wp = ( empty( $api->tested ) || version_compare( get_bloginfo( 'version' ), $api->tested, '<=' ) );
if ( ! $compatible_php ) {
echo '<div class="notice notice-error notice-alt"><p>';
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
$compatible_php_notice_message = '<p>';
$compatible_php_notice_message .= __( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' );
if ( current_user_can( 'update_php' ) ) {
printf(
$compatible_php_notice_message .= sprintf(
/* translators: %s: URL to Update PHP page. */
' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ),
esc_url( wp_get_update_php_url() )
);
wp_update_php_annotation( '</p><p><em>', '</em>' );
) . wp_update_php_annotation( '</p><p><em>', '</em>', false );
} else {
echo '</p>';
$compatible_php_notice_message .= '</p>';
}
echo '</div>';
wp_admin_notice(
$compatible_php_notice_message,
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt' ),
'paragraph_wrap' => false,
)
);
}
if ( ! $tested_wp ) {
echo '<div class="notice notice-warning notice-alt"><p>';
_e( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' );
echo '</p></div>';
wp_admin_notice(
__( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' ),
array(
'type' => 'warning',
'additional_classes' => array( 'notice-alt' ),
)
);
} elseif ( ! $compatible_wp ) {
echo '<div class="notice notice-error notice-alt"><p>';
_e( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' );
$compatible_wp_notice_message = __( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' );
if ( current_user_can( 'update_core' ) ) {
printf(
$compatible_wp_notice_message .= sprintf(
/* translators: %s: URL to WordPress Updates screen. */
' ' . __( '<a href="%s" target="_parent">Click here to update WordPress</a>.' ),
esc_url( self_admin_url( 'update-core.php' ) )
);
}
echo '</p></div>';
wp_admin_notice(
$compatible_wp_notice_message,
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt' ),
)
);
}
foreach ( (array) $api->sections as $section_name => $content ) {

View File

@@ -854,7 +854,7 @@ function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
* @param bool $network_wide Whether to enable the plugin for all sites in the network.
* Default false.
* @param bool $silent Prevent calling activation hooks. Default false.
* @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
* @return true|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
*/
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
if ( ! is_array( $plugins ) ) {
@@ -2440,7 +2440,7 @@ function wp_get_plugin_error( $plugin ) {
*
* @param string $plugin Single plugin to resume.
* @param string $redirect Optional. URL to redirect to. Default empty string.
* @return bool|WP_Error True on success, false if `$plugin` was not paused,
* @return true|WP_Error True on success, false if `$plugin` was not paused,
* `WP_Error` on failure.
*/
function resume_plugin( $plugin, $redirect = '' ) {
@@ -2497,13 +2497,17 @@ function paused_plugins_notice() {
return;
}
printf(
'<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
$message = sprintf(
'<strong>%s</strong><br>%s</p><p><a href="%s">%s</a>',
__( 'One or more plugins failed to load properly.' ),
__( 'You can find more details and make changes on the Plugins screen.' ),
esc_url( admin_url( 'plugins.php?plugin_status=paused' ) ),
__( 'Go to the Plugins screen' )
);
wp_admin_notice(
$message,
array( 'type' => 'error' )
);
}
/**
@@ -2571,8 +2575,8 @@ function deactivated_plugins_notice() {
);
}
printf(
'<div class="notice notice-warning"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
$message = sprintf(
'<strong>%s</strong><br>%s</p><p><a href="%s">%s</a>',
sprintf(
/* translators: %s: Name of deactivated plugin. */
__( '%s plugin deactivated during WordPress upgrade.' ),
@@ -2582,6 +2586,7 @@ function deactivated_plugins_notice() {
esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ),
__( 'Go to the Plugins screen' )
);
wp_admin_notice( $message, array( 'type' => 'warning' ) );
}
// Empty the options.

View File

@@ -171,10 +171,6 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
}
}
if ( isset( $post_data['edit_date'] ) && 'false' === $post_data['edit_date'] ) {
$post_data['edit_date'] = false;
}
if ( ! empty( $post_data['edit_date'] ) ) {
$aa = $post_data['aa'];
$mm = $post_data['mm'];
@@ -197,7 +193,19 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
}
$post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
/*
* Only assign a post date if the user has explicitly set a new value.
* See #59125 and #19907.
*/
$previous_date = $post_id ? get_post_field( 'post_date', $post_id ) : false;
if ( $previous_date && $previous_date !== $post_data['post_date'] ) {
$post_data['edit_date'] = true;
$post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] );
} else {
$post_data['edit_date'] = false;
unset( $post_data['post_date'] );
unset( $post_data['post_date_gmt'] );
}
}
if ( isset( $post_data['post_category'] ) ) {
@@ -1957,11 +1965,12 @@ function wp_create_post_autosave( $post_data ) {
* Fires before an autosave is stored.
*
* @since 4.1.0
* @since 6.4.0 The `$is_update` parameter was added to indicate if the autosave is being updated or was newly created.
*
* @param array $new_autosave Post array - the autosave that is about to be saved.
* @param bool $is_update Whether this is an existing autosave.
*/
do_action( 'wp_creating_autosave', $new_autosave );
do_action( 'wp_creating_autosave', $new_autosave, true );
return wp_update_post( $new_autosave );
}
@@ -1969,7 +1978,68 @@ function wp_create_post_autosave( $post_data ) {
$post_data = wp_unslash( $post_data );
// Otherwise create the new autosave as a special post revision.
return _wp_put_post_revision( $post_data, true );
$revision = _wp_put_post_revision( $post_data, true );
if ( ! is_wp_error( $revision ) && 0 !== $revision ) {
/** This action is documented in wp-admin/includes/post.php */
do_action( 'wp_creating_autosave', get_post( $revision, ARRAY_A ), false );
}
return $revision;
}
/**
* Autosave the revisioned meta fields.
*
* Iterates through the revisioned meta fields and checks each to see if they are set,
* and have a changed value. If so, the meta value is saved and attached to the autosave.
*
* @since 6.4.0
*
* @param array $new_autosave The new post data being autosaved.
*/
function wp_autosave_post_revisioned_meta_fields( $new_autosave ) {
/*
* The post data arrives as either $_POST['data']['wp_autosave'] or the $_POST
* itself. This sets $posted_data to the correct variable.
*
* Ignoring sanitization to avoid altering meta. Ignoring the nonce check because
* this is hooked on inner core hooks where a valid nonce was already checked.
*/
$posted_data = isset( $_POST['data']['wp_autosave'] ) ? $_POST['data']['wp_autosave'] : $_POST;
$post_type = get_post_type( $new_autosave['post_parent'] );
/*
* Go thru the revisioned meta keys and save them as part of the autosave, if
* the meta key is part of the posted data, the meta value is not blank and
* the the meta value has changes from the last autosaved value.
*/
foreach ( wp_post_revision_meta_keys( $post_type ) as $meta_key ) {
if (
isset( $posted_data[ $meta_key ] ) &&
get_post_meta( $new_autosave['ID'], $meta_key, true ) !== wp_unslash( $posted_data[ $meta_key ] )
) {
/*
* Use the underlying delete_metadata() and add_metadata() functions
* vs delete_post_meta() and add_post_meta() to make sure we're working
* with the actual revision meta.
*/
delete_metadata( 'post', $new_autosave['ID'], $meta_key );
/*
* One last check to ensure meta value not empty().
*/
if ( ! empty( $posted_data[ $meta_key ] ) ) {
/*
* Add the revisions meta data to the autosave.
*/
add_metadata( 'post', $new_autosave['ID'], $meta_key, $posted_data[ $meta_key ] );
}
}
}
}
/**
@@ -2207,6 +2277,7 @@ function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) {
*
* @since 5.0.0
* @since 6.3.0 Added `selectors` field.
* @since 6.4.0 Added `block_hooks` field.
*
* @return array An associative array of registered block data.
*/
@@ -2221,6 +2292,7 @@ function get_block_editor_server_block_settings() {
'attributes' => 'attributes',
'provides_context' => 'providesContext',
'uses_context' => 'usesContext',
'block_hooks' => 'blockHooks',
'selectors' => 'selectors',
'supports' => 'supports',
'category' => 'category',

View File

@@ -161,7 +161,6 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
* @param WP_Post $compare_to The revision post to compare to.
*/
return apply_filters( 'wp_get_revision_ui_diff', $return, $compare_from, $compare_to );
}
/**

View File

@@ -556,6 +556,9 @@ function populate_options( array $options = array() ) {
// 5.8.0
'wp_force_deactivated_plugins' => array(),
// 6.4.0
'wp_attachment_pages_enabled' => 0,
);
// 3.3.0
@@ -979,7 +982,7 @@ endif;
* @param string $path Optional. The path to append to the network's domain name. Default '/'.
* @param bool $subdomain_install Optional. Whether the network is a subdomain installation or a subdirectory installation.
* Default false, meaning the network is a subdirectory installation.
* @return bool|WP_Error True on success, or WP_Error on warning (with the installation otherwise successful,
* @return true|WP_Error True on success, or WP_Error on warning (with the installation otherwise successful,
* so the error code must be checked) or failure.
*/
function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {

View File

@@ -461,7 +461,7 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
<legend>
<span class="hidden" id="editlegend"><?php _e( 'Edit Comment' ); ?></span>
<span class="hidden" id="replyhead"><?php _e( 'Reply to Comment' ); ?></span>
<span class="hidden" id="addhead"><?php _e( 'Add new Comment' ); ?></span>
<span class="hidden" id="addhead"><?php _e( 'Add New Comment' ); ?></span>
</legend>
<div id="replycontainer">
@@ -512,9 +512,16 @@ function wp_comment_reply( $position = 1, $checkbox = false, $mode = 'single', $
<button type="button" class="cancel button"><?php _e( 'Cancel' ); ?></button>
<span class="waiting spinner"></span>
</p>
<div class="notice notice-error notice-alt inline hidden">
<p class="error"></p>
</div>
<?php
wp_admin_notice(
'<p class="error"></p>',
array(
'type' => 'error',
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
'paragraph_wrap' => false,
)
);
?>
</div>
<input type="hidden" name="action" id="action" value="" />
@@ -900,7 +907,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
* @since 4.7.0 Added the `$post_type` parameter.
*
* @param string $default_template Optional. The template file name. Default empty.
* @param string $post_type Optional. Post type to get templates for. Default 'post'.
* @param string $post_type Optional. Post type to get templates for. Default 'page'.
*/
function page_template_dropdown( $default_template = '', $post_type = 'page' ) {
$templates = get_page_templates( null, $post_type );
@@ -1006,10 +1013,15 @@ function wp_import_upload_form( $action ) {
$size = size_format( $bytes );
$upload_dir = wp_upload_dir();
if ( ! empty( $upload_dir['error'] ) ) :
?>
<div class="error"><p><?php _e( 'Before you can upload your import file, you will need to fix the following error:' ); ?></p>
<p><strong><?php echo $upload_dir['error']; ?></strong></p></div>
<?php
$upload_directory_error = '<p>' . __( 'Before you can upload your import file, you will need to fix the following error:' ) . '</p>';
$upload_directory_error .= '<p><strong>' . $upload_dir['error'] . '</strong></p>';
wp_admin_notice(
$upload_directory_error,
array(
'additional_classes' => array( 'error' ),
'paragraph_wrap' => false,
)
);
else :
?>
<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>">
@@ -1355,7 +1367,7 @@ function do_meta_boxes( $screen, $context, $data_object ) {
}
}
$i++;
++$i;
// get_hidden_meta_boxes() doesn't apply in the block editor.
$hidden_class = ( ! $screen->is_block_editor() && in_array( $box['id'], $hidden, true ) ) ? ' hide-if-js' : '';
echo '<div id="' . $box['id'] . '" class="postbox ' . postbox_classes( $box['id'], $page ) . $hidden_class . '" ' . '>' . "\n";
@@ -1427,16 +1439,17 @@ function do_meta_boxes( $screen, $context, $data_object ) {
if ( WP_DEBUG && ! $block_compatible && 'edit' === $screen->parent_base && ! $screen->is_block_editor() && ! isset( $_GET['meta-box-loader'] ) ) {
$plugin = _get_plugin_from_callback( $box['callback'] );
if ( $plugin ) {
?>
<div class="error inline">
<p>
<?php
/* translators: %s: The name of the plugin that generated this meta box. */
printf( __( 'This meta box, from the %s plugin, is not compatible with the block editor.' ), "<strong>{$plugin['Name']}</strong>" );
?>
</p>
</div>
<?php
$meta_box_not_compatible_message = sprintf(
/* translators: %s: The name of the plugin that generated this meta box. */
__( 'This meta box, from the %s plugin, is not compatible with the block editor.' ),
"<strong>{$plugin['Name']}</strong>"
);
wp_admin_notice(
$meta_box_not_compatible_message,
array(
'additional_classes' => array( 'error', 'inline' ),
)
);
}
}
@@ -1451,7 +1464,6 @@ function do_meta_boxes( $screen, $context, $data_object ) {
echo '</div>';
return $i;
}
/**
@@ -1551,7 +1563,7 @@ function do_accordion_sections( $screen, $context, $data_object ) {
continue;
}
$i++;
++$i;
$hidden_class = in_array( $box['id'], $hidden, true ) ? 'hide-if-js' : '';
$open_class = '';
@@ -2689,17 +2701,22 @@ function convert_to_screen( $hook_name ) {
* @access private
*/
function _local_storage_notice() {
?>
<div id="local-storage-notice" class="hidden notice is-dismissible">
<p class="local-restore">
<?php _e( 'The backup of this post in your browser is different from the version below.' ); ?>
<button type="button" class="button restore-backup"><?php _e( 'Restore the backup' ); ?></button>
</p>
<p class="help">
<?php _e( 'This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.' ); ?>
</p>
</div>
<?php
$local_storage_message = '<p class="local-restore">';
$local_storage_message .= __( 'The backup of this post in your browser is different from the version below.' );
$local_storage_message .= '<button type="button" class="button restore-backup">' . __( 'Restore the backup' ) . '</button></p>';
$local_storage_message .= '<p class="help">';
$local_storage_message .= __( 'This will replace the current editor content with the last backup version. You can use undo and redo in the editor to get the old content back or to return to the restored version.' );
$local_storage_message .= '</p>';
wp_admin_notice(
$local_storage_message,
array(
'id' => 'local-storage-notice',
'additional_classes' => array( 'hidden' ),
'dismissible' => true,
'paragraph_wrap' => false,
)
);
}
/**
@@ -2777,9 +2794,12 @@ function wp_star_rating( $args = array() ) {
* @since 4.2.0
*/
function _wp_posts_page_notice() {
printf(
'<div class="notice notice-warning inline"><p>%s</p></div>',
__( 'You are currently editing the page that shows your latest posts.' )
wp_admin_notice(
__( 'You are currently editing the page that shows your latest posts.' ),
array(
'type' => 'warning',
'additional_classes' => array( 'inline' ),
)
);
}

View File

@@ -243,7 +243,6 @@ function display_themes() {
}
$wp_list_table->prepare_items();
$wp_list_table->display();
}
/**

View File

@@ -81,6 +81,8 @@ function delete_theme( $stylesheet, $redirect = '' ) {
*/
do_action( 'delete_theme', $stylesheet );
$theme = wp_get_theme( $stylesheet );
$themes_dir = trailingslashit( $themes_dir );
$theme_dir = trailingslashit( $themes_dir . $stylesheet );
$deleted = $wp_filesystem->delete( $theme_dir, true );
@@ -125,6 +127,9 @@ function delete_theme( $stylesheet, $redirect = '' ) {
WP_Theme::network_disable_theme( $stylesheet );
}
// Clear theme caches.
$theme->cache_delete();
// Force refresh of theme update information.
delete_site_transient( 'update_themes' );
@@ -156,7 +161,7 @@ function get_page_templates( $post = null, $post_type = 'page' ) {
* @return string
*/
function _get_template_edit_filename( $fullpath, $containingfolder ) {
return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath );
return str_replace( dirname( $containingfolder, 2 ), '', $fullpath );
}
/**
@@ -1058,12 +1063,7 @@ function customize_themes_print_templates() {
<# if ( data.active ) { #>
<button type="button" class="button button-primary customize-theme"><?php _e( 'Customize' ); ?></button>
<# } else if ( 'installed' === data.type ) { #>
<?php if ( current_user_can( 'delete_themes' ) ) { ?>
<# if ( data.actions && data.actions['delete'] ) { #>
<a href="{{{ data.actions['delete'] }}}" data-slug="{{ data.id }}" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a>
<# } #>
<?php } ?>
<div class="theme-inactive-actions">
<# if ( data.blockTheme ) { #>
<?php
/* translators: %s: Theme name. */
@@ -1079,6 +1079,12 @@ function customize_themes_print_templates() {
<button class="button button-primary disabled"><?php _e( 'Live Preview' ); ?></button>
<# } #>
<# } #>
</div>
<?php if ( current_user_can( 'delete_themes' ) ) { ?>
<# if ( data.actions && data.actions['delete'] ) { #>
<a href="{{{ data.actions['delete'] }}}" data-slug="{{ data.id }}" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a>
<# } #>
<?php } ?>
<# } else { #>
<# if ( data.compatibleWP && data.compatiblePHP ) { #>
<button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></button>
@@ -1166,11 +1172,14 @@ function resume_theme( $theme, $redirect = '' ) {
* creating a fatal error.
*/
if ( ! empty( $redirect ) ) {
$stylesheet_path = get_stylesheet_directory();
$template_path = get_template_directory();
$functions_path = '';
if ( str_contains( STYLESHEETPATH, $extension ) ) {
$functions_path = STYLESHEETPATH . '/functions.php';
} elseif ( str_contains( TEMPLATEPATH, $extension ) ) {
$functions_path = TEMPLATEPATH . '/functions.php';
if ( str_contains( $stylesheet_path, $extension ) ) {
$functions_path = $stylesheet_path . '/functions.php';
} elseif ( str_contains( $template_path, $extension ) ) {
$functions_path = $template_path . '/functions.php';
}
if ( ! empty( $functions_path ) ) {
@@ -1224,11 +1233,18 @@ function paused_themes_notice() {
return;
}
printf(
'<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
$message = sprintf(
'<p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p>',
__( 'One or more themes failed to load properly.' ),
__( 'You can find more details and make changes on the Themes screen.' ),
esc_url( admin_url( 'themes.php' ) ),
__( 'Go to the Themes screen' )
);
wp_admin_notice(
$message,
array(
'type' => 'error',
'paragraph_wrap' => false,
)
);
}

View File

@@ -867,6 +867,10 @@ $_old_files = array(
'wp-includes/images/wlw',
'wp-includes/wlwmanifest.xml',
'wp-includes/random_compat',
// 6.4
'wp-includes/navigation-fallback.php',
'wp-includes/blocks/navigation/view-modal.min.js',
'wp-includes/blocks/navigation/view-modal.js',
);
/**
@@ -997,6 +1001,7 @@ $_new_bundled_files = array(
'themes/twentytwentyone/' => '5.6',
'themes/twentytwentytwo/' => '5.9',
'themes/twentytwentythree/' => '6.1',
'themes/twentytwentyfour/' => '6.4',
);
/**
@@ -1431,9 +1436,13 @@ function update_core( $from, $to ) {
} else {
$lang_dir = WP_CONTENT_DIR . '/languages';
}
/*
* Note: str_starts_with() is not used here, as this file is included
* when updating from older WordPress versions, in which case
* the polyfills from wp-includes/compat.php may not be available.
*/
// Check if the language directory exists first.
if ( ! @is_dir( $lang_dir ) && str_starts_with( $lang_dir, ABSPATH ) ) {
if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) {
// If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
$wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR );
clearstatcache(); // For FTP, need to clear the stat cache.
@@ -1801,7 +1810,7 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) {
$dirs = glob( $directory . '*', GLOB_ONLYDIR );
$dirs = array_filter(
$dirs,
static function( $dir ) {
static function ( $dir ) {
/*
* Skip any node_modules directories.
*
@@ -1838,13 +1847,14 @@ function _upgrade_440_force_deactivate_incompatible_plugins() {
* @since 5.8.0
* @since 5.9.0 The minimum compatible version of Gutenberg is 11.9.
* @since 6.1.1 The minimum compatible version of Gutenberg is 14.1.
* @since 6.4.0 The minimum compatible version of Gutenberg is 16.5.
*/
function _upgrade_core_deactivate_incompatible_plugins() {
if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '14.1', '<' ) ) {
if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '16.5', '<' ) ) {
$deactivated_gutenberg['gutenberg'] = array(
'plugin_name' => 'Gutenberg',
'version_deactivated' => GUTENBERG_VERSION,
'version_compatible' => '14.1',
'version_compatible' => '16.5',
);
if ( is_plugin_active_for_network( 'gutenberg/gutenberg.php' ) ) {
$deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins', array() );

View File

@@ -342,7 +342,14 @@ function update_nag() {
);
}
echo "<div class='update-nag notice notice-warning inline'>$msg</div>";
wp_admin_notice(
$msg,
array(
'type' => 'warning',
'additional_classes' => array( 'update-nag', 'inline' ),
'paragraph_wrap' => false,
)
);
}
/**
@@ -884,7 +891,14 @@ function maintenance_nag() {
$msg = __( 'An automated WordPress update has failed to complete! Please notify the site administrator.' );
}
echo "<div class='update-nag notice notice-warning inline'>$msg</div>";
wp_admin_notice(
$msg,
array(
'type' => 'warning',
'additional_classes' => array( 'update-nag', 'inline' ),
'paragraph_wrap' => false,
)
);
}
/**
@@ -1049,19 +1063,12 @@ function wp_recovery_mode_nag() {
$url = add_query_arg( 'action', WP_Recovery_Mode::EXIT_ACTION, $url );
$url = wp_nonce_url( $url, WP_Recovery_Mode::EXIT_ACTION );
?>
<div class="notice notice-info">
<p>
<?php
printf(
/* translators: %s: Recovery Mode exit link. */
__( 'You are in recovery mode. This means there may be an error with a theme or plugin. To exit recovery mode, log out or use the Exit button. <a href="%s">Exit Recovery Mode</a>' ),
esc_url( $url )
);
?>
</p>
</div>
<?php
$message = sprintf(
/* translators: %s: Recovery Mode exit link. */
__( 'You are in recovery mode. This means there may be an error with a theme or plugin. To exit recovery mode, log out or use the Exit button. <a href="%s">Exit Recovery Mode</a>' ),
esc_url( $url )
);
wp_admin_notice( $message, array( 'type' => 'info' ) );
}
/**

View File

@@ -625,10 +625,9 @@ if ( ! function_exists( 'wp_upgrade' ) ) :
*
* @global int $wp_current_db_version The old (current) database version.
* @global int $wp_db_version The new database version.
* @global wpdb $wpdb WordPress database abstraction object.
*/
function wp_upgrade() {
global $wp_current_db_version, $wp_db_version, $wpdb;
global $wp_current_db_version, $wp_db_version;
$wp_current_db_version = __get_option( 'db_version' );
@@ -840,6 +839,10 @@ function upgrade_all() {
upgrade_630();
}
if ( $wp_current_db_version < 56657 ) {
upgrade_640();
}
maybe_disable_link_manager();
maybe_disable_automattic_widgets();
@@ -996,7 +999,6 @@ function upgrade_110() {
$wpdb->query( "UPDATE $wpdb->comments SET comment_date_gmt = DATE_ADD(comment_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" );
$wpdb->query( "UPDATE $wpdb->users SET user_registered = DATE_ADD(user_registered, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" );
}
}
/**
@@ -1294,7 +1296,7 @@ function upgrade_230() {
$num = 2;
do {
$alt_slug = $slug . "-$num";
$num++;
++$num;
$slug_check = $wpdb->get_var( $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $alt_slug ) );
} while ( $slug_check );
@@ -1546,7 +1548,6 @@ function upgrade_250() {
if ( $wp_current_db_version < 6689 ) {
populate_roles_250();
}
}
/**
@@ -1705,7 +1706,6 @@ function upgrade_300() {
)
);
}
}
/**
@@ -2326,6 +2326,29 @@ function upgrade_630() {
}
}
/**
* Executes changes made in WordPress 6.4.0.
*
* @ignore
* @since 6.4.0
*
* @global int $wp_current_db_version The old (current) database version.
*/
function upgrade_640() {
global $wp_current_db_version;
if ( $wp_current_db_version < 56657 ) {
// Enable attachment pages.
update_option( 'wp_attachment_pages_enabled', 1 );
// Remove the wp_https_detection cron. Https status is checked directly in an async Site Health check.
$scheduled = wp_get_scheduled_event( 'wp_https_detection' );
if ( $scheduled ) {
wp_clear_scheduled_hook( 'wp_https_detection' );
}
}
}
/**
* Executes network-level upgrade routines.
*
@@ -2485,7 +2508,7 @@ function upgrade_network() {
/**
* Creates a table in the database, if it doesn't already exist.
*
* This method checks for an existing database and creates a new one if it's not
* This method checks for an existing database table and creates a new one if it's not
* already present. It doesn't rely on MySQL's "IF NOT EXISTS" statement, but chooses
* to query all tables first and then run the SQL statement creating the table.
*

View File

@@ -535,28 +535,30 @@ function default_password_nag() {
if ( 'profile.php' === $pagenow || ! get_user_option( 'default_password_nag' ) ) {
return;
}
?>
<div class="error default-password-nag">
<p>
<strong><?php _e( 'Notice:' ); ?></strong>
<?php _e( 'You are using the auto-generated password for your account. Would you like to change it?' ); ?>
</p>
<p>
<?php
printf(
'<a href="%1$s">%2$s</a> | ',
esc_url( get_edit_profile_url() . '#password' ),
__( 'Yes, take me to my profile page' )
);
printf(
'<a href="%1$s" id="default-password-nag-no">%2$s</a>',
'?default_password_nag=0',
__( 'No thanks, do not remind me again' )
);
?>
</p>
</div>
<?php
$default_password_nag_message = sprintf(
'<p><strong>%1$s</strong> %2$s</p>',
__( 'Notice:' ),
__( 'You are using the auto-generated password for your account. Would you like to change it?' )
);
$default_password_nag_message .= sprintf(
'<p><a href="%1$s">%2$s</a> | ',
esc_url( get_edit_profile_url() . '#password' ),
__( 'Yes, take me to my profile page' )
);
$default_password_nag_message .= sprintf(
'<a href="%1$s" id="default-password-nag-no">%2$s</a></p>',
'?default_password_nag=0',
__( 'No thanks, do not remind me again' )
);
wp_admin_notice(
$default_password_nag_message,
array(
'additional_classes' => array( 'error', 'default-password-nag' ),
'paragraph_wrap' => false,
)
);
}
/**
@@ -636,6 +638,7 @@ Please click the following link to activate your user account:
*
* @since 5.6.0
* @since 6.2.0 Allow insecure HTTP connections for the local environment.
* @since 6.3.2 Validates the success and reject URLs to prevent javascript pseudo protocol being executed.
*
* @param array $request {
* The array of request data. All arguments are optional and may be empty.
@@ -649,27 +652,24 @@ Please click the following link to activate your user account:
* @return true|WP_Error True if the request is valid, a WP_Error object contains errors if not.
*/
function wp_is_authorize_application_password_request_valid( $request, $user ) {
$error = new WP_Error();
$is_local = 'local' === wp_get_environment_type();
$error = new WP_Error();
if ( ! empty( $request['success_url'] ) ) {
$scheme = wp_parse_url( $request['success_url'], PHP_URL_SCHEME );
if ( 'http' === $scheme && ! $is_local ) {
if ( isset( $request['success_url'] ) ) {
$validated_success_url = wp_is_authorize_application_redirect_url_valid( $request['success_url'] );
if ( is_wp_error( $validated_success_url ) ) {
$error->add(
'invalid_redirect_scheme',
__( 'The success URL must be served over a secure connection.' )
$validated_success_url->get_error_code(),
$validated_success_url->get_error_message()
);
}
}
if ( ! empty( $request['reject_url'] ) ) {
$scheme = wp_parse_url( $request['reject_url'], PHP_URL_SCHEME );
if ( 'http' === $scheme && ! $is_local ) {
if ( isset( $request['reject_url'] ) ) {
$validated_reject_url = wp_is_authorize_application_redirect_url_valid( $request['reject_url'] );
if ( is_wp_error( $validated_reject_url ) ) {
$error->add(
'invalid_redirect_scheme',
__( 'The rejection URL must be served over a secure connection.' )
$validated_reject_url->get_error_code(),
$validated_reject_url->get_error_message()
);
}
}
@@ -698,3 +698,59 @@ function wp_is_authorize_application_password_request_valid( $request, $user ) {
return true;
}
/**
* Validates the redirect URL protocol scheme. The protocol can be anything except http and javascript.
*
* @since 6.3.2
*
* @param string $url - The redirect URL to be validated.
*
* @return true|WP_Error True if the redirect URL is valid, a WP_Error object otherwise.
*/
function wp_is_authorize_application_redirect_url_valid( $url ) {
$bad_protocols = array( 'javascript', 'data' );
if ( empty( $url ) ) {
return true;
}
// Based on https://www.rfc-editor.org/rfc/rfc2396#section-3.1
$valid_scheme_regex = '/^[a-zA-Z][a-zA-Z0-9+.-]*:/';
if ( ! preg_match( $valid_scheme_regex, $url ) ) {
return new WP_Error(
'invalid_redirect_url_format',
__( 'Invalid URL format.' )
);
}
/**
* Filters the list of invalid protocols used in applications redirect URLs.
*
* @since 6.3.2
*
* @param string[] $bad_protocols Array of invalid protocols.
* @param string $url The redirect URL to be validated.
*/
$invalid_protocols = array_map( 'strtolower', apply_filters( 'wp_authorize_application_redirect_url_invalid_protocols', $bad_protocols, $url ) );
$scheme = wp_parse_url( $url, PHP_URL_SCHEME );
$host = wp_parse_url( $url, PHP_URL_HOST );
$is_local = 'local' === wp_get_environment_type();
// validates if the proper URI format is applied to the $url
if ( empty( $host ) || empty( $scheme ) || in_array( strtolower( $scheme ), $invalid_protocols, true ) ) {
return new WP_Error(
'invalid_redirect_url_format',
__( 'Invalid URL format.' )
);
}
if ( 'http' === $scheme && ! $is_local ) {
return new WP_Error(
'invalid_redirect_scheme',
__( 'The URL must be served over a secure connection.' )
);
}
return true;
}

View File

@@ -134,7 +134,7 @@ function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) {
function wp_list_widget_controls_dynamic_sidebar( $params ) {
global $wp_registered_widgets;
static $i = 0;
$i++;
++$i;
$widget_id = $params[0]['widget_id'];
$id = isset( $params[0]['_temp_id'] ) ? $params[0]['_temp_id'] : $widget_id;
@@ -168,7 +168,7 @@ function next_widget_id_number( $id_base ) {
$number = max( $number, $matches[1] );
}
}
$number++;
++$number;
return $number;
}