rebase on oct-10-2023
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
//
|
||||
|
||||
/**
|
||||
* Ajax handler for the Heartbeat API in the no-privilege context.
|
||||
* Handles the Heartbeat API in the no-privilege context via AJAX .
|
||||
*
|
||||
* Runs when the user is not logged in.
|
||||
*
|
||||
@@ -76,7 +76,7 @@ function wp_ajax_nopriv_heartbeat() {
|
||||
//
|
||||
|
||||
/**
|
||||
* Ajax handler for fetching a list table.
|
||||
* Handles fetching a list table via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ function wp_ajax_fetch_list() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for tag search.
|
||||
* Handles tag search via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -126,7 +126,7 @@ function wp_ajax_ajax_tag_search() {
|
||||
$search = str_replace( $comma, ',', $search );
|
||||
}
|
||||
|
||||
if ( false !== strpos( $search, ',' ) ) {
|
||||
if ( str_contains( $search, ',' ) ) {
|
||||
$search = explode( ',', $search );
|
||||
$search = $search[ count( $search ) - 1 ];
|
||||
}
|
||||
@@ -178,7 +178,7 @@ function wp_ajax_ajax_tag_search() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for compression testing.
|
||||
* Handles compression testing via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -188,7 +188,12 @@ function wp_ajax_wp_compression_test() {
|
||||
}
|
||||
|
||||
if ( ini_get( 'zlib.output_compression' ) || 'ob_gzhandler' === ini_get( 'output_handler' ) ) {
|
||||
update_site_option( 'can_compress_scripts', 0 );
|
||||
// Use `update_option()` on single site to mark the option for autoloading.
|
||||
if ( is_multisite() ) {
|
||||
update_site_option( 'can_compress_scripts', 0 );
|
||||
} else {
|
||||
update_option( 'can_compress_scripts', 0, 'yes' );
|
||||
}
|
||||
wp_die( 0 );
|
||||
}
|
||||
|
||||
@@ -222,10 +227,20 @@ function wp_ajax_wp_compression_test() {
|
||||
wp_die();
|
||||
} elseif ( 'no' === $_GET['test'] ) {
|
||||
check_ajax_referer( 'update_can_compress_scripts' );
|
||||
update_site_option( 'can_compress_scripts', 0 );
|
||||
// Use `update_option()` on single site to mark the option for autoloading.
|
||||
if ( is_multisite() ) {
|
||||
update_site_option( 'can_compress_scripts', 0 );
|
||||
} else {
|
||||
update_option( 'can_compress_scripts', 0, 'yes' );
|
||||
}
|
||||
} elseif ( 'yes' === $_GET['test'] ) {
|
||||
check_ajax_referer( 'update_can_compress_scripts' );
|
||||
update_site_option( 'can_compress_scripts', 1 );
|
||||
// Use `update_option()` on single site to mark the option for autoloading.
|
||||
if ( is_multisite() ) {
|
||||
update_site_option( 'can_compress_scripts', 1 );
|
||||
} else {
|
||||
update_option( 'can_compress_scripts', 1, 'yes' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +248,7 @@ function wp_ajax_wp_compression_test() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for image editor previews.
|
||||
* Handles image editor previews via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -245,7 +260,7 @@ function wp_ajax_imgedit_preview() {
|
||||
|
||||
check_ajax_referer( "image_editor-$post_id" );
|
||||
|
||||
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||
|
||||
if ( ! stream_preview_image( $post_id ) ) {
|
||||
wp_die( -1 );
|
||||
@@ -255,7 +270,7 @@ function wp_ajax_imgedit_preview() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for oEmbed caching.
|
||||
* Handles oEmbed caching via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -267,7 +282,7 @@ function wp_ajax_oembed_cache() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for user autocomplete.
|
||||
* Handles user autocomplete via AJAX.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
@@ -283,16 +298,20 @@ function wp_ajax_autocomplete_user() {
|
||||
|
||||
$return = array();
|
||||
|
||||
// Check the type of request.
|
||||
// Current allowed values are `add` and `search`.
|
||||
/*
|
||||
* Check the type of request.
|
||||
* Current allowed values are `add` and `search`.
|
||||
*/
|
||||
if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) {
|
||||
$type = $_REQUEST['autocomplete_type'];
|
||||
} else {
|
||||
$type = 'add';
|
||||
}
|
||||
|
||||
// Check the desired field for value.
|
||||
// Current allowed values are `user_email` and `user_login`.
|
||||
/*
|
||||
* Check the desired field for value.
|
||||
* Current allowed values are `user_email` and `user_login`.
|
||||
*/
|
||||
if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) {
|
||||
$field = $_REQUEST['autocomplete_field'];
|
||||
} else {
|
||||
@@ -394,7 +413,7 @@ function wp_ajax_get_community_events() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for dashboard widgets.
|
||||
* Handles dashboard widgets via AJAX.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
@@ -415,7 +434,7 @@ function wp_ajax_dashboard_widgets() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for Customizer preview logged-in status.
|
||||
* Handles Customizer preview logged-in status via AJAX.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
@@ -563,7 +582,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
|
||||
//
|
||||
|
||||
/**
|
||||
* Ajax handler for adding a hierarchical term.
|
||||
* Handles adding a hierarchical term via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @access private
|
||||
@@ -693,7 +712,7 @@ function _wp_ajax_add_hierarchical_term() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for deleting a comment.
|
||||
* Handles deleting a comment via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -763,7 +782,7 @@ function wp_ajax_delete_comment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for deleting a tag.
|
||||
* Handles deleting a tag via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -790,7 +809,7 @@ function wp_ajax_delete_tag() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for deleting a link.
|
||||
* Handles deleting a link via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -816,7 +835,7 @@ function wp_ajax_delete_link() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for deleting meta.
|
||||
* Handles deleting meta via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -842,7 +861,7 @@ function wp_ajax_delete_meta() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for deleting a post.
|
||||
* Handles deleting a post via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -872,7 +891,7 @@ function wp_ajax_delete_post( $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for sending a post to the Trash.
|
||||
* Handles sending a post to the Trash via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -908,7 +927,7 @@ function wp_ajax_trash_post( $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler to restore a post from the Trash.
|
||||
* Handles restoring a post from the Trash via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -923,7 +942,7 @@ function wp_ajax_untrash_post( $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler to delete a page.
|
||||
* Handles deleting a page via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -953,7 +972,7 @@ function wp_ajax_delete_page( $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler to dim a comment.
|
||||
* Handles dimming a comment via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1009,7 +1028,7 @@ function wp_ajax_dim_comment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for adding a link category.
|
||||
* Handles adding a link category via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -1062,7 +1081,7 @@ function wp_ajax_add_link_category( $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler to add a tag.
|
||||
* Handles adding a tag via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1154,7 +1173,7 @@ function wp_ajax_add_tag() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for getting a tagcloud.
|
||||
* Handles getting a tagcloud via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1214,7 +1233,7 @@ function wp_ajax_get_tagcloud() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for getting comments.
|
||||
* Handles getting comments via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -1277,7 +1296,7 @@ function wp_ajax_get_comments( $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for replying to a comment.
|
||||
* Handles replying to a comment via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -1437,7 +1456,7 @@ function wp_ajax_replyto_comment( $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for editing a comment.
|
||||
* Handles editing a comment via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1492,7 +1511,7 @@ function wp_ajax_edit_comment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for adding a menu item.
|
||||
* Handles adding a menu item via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1505,8 +1524,10 @@ function wp_ajax_add_menu_item() {
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/nav-menu.php';
|
||||
|
||||
// For performance reasons, we omit some object properties from the checklist.
|
||||
// The following is a hacky way to restore them when adding non-custom items.
|
||||
/*
|
||||
* For performance reasons, we omit some object properties from the checklist.
|
||||
* The following is a hacky way to restore them when adding non-custom items.
|
||||
*/
|
||||
$menu_items_data = array();
|
||||
|
||||
foreach ( (array) $_POST['menu-item'] as $menu_item_data ) {
|
||||
@@ -1580,7 +1601,7 @@ function wp_ajax_add_menu_item() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for adding meta.
|
||||
* Handles adding meta via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1702,7 +1723,7 @@ function wp_ajax_add_meta() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for adding a user.
|
||||
* Handles adding a user via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -1757,7 +1778,7 @@ function wp_ajax_add_user( $action ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for closed post boxes.
|
||||
* Handles closed post boxes via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1794,7 +1815,7 @@ function wp_ajax_closed_postboxes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for hidden columns.
|
||||
* Handles hidden columns via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1818,7 +1839,7 @@ function wp_ajax_hidden_columns() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for updating whether to display the welcome panel.
|
||||
* Handles updating whether to display the welcome panel via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1835,7 +1856,7 @@ function wp_ajax_update_welcome_panel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for retrieving menu meta boxes.
|
||||
* Handles for retrieving menu meta boxes via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1886,7 +1907,7 @@ function wp_ajax_menu_get_metabox() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for internal linking.
|
||||
* Handles internal linking via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1922,7 +1943,7 @@ function wp_ajax_wp_link_ajax() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for menu locations save.
|
||||
* Handles saving menu locations via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1942,7 +1963,7 @@ function wp_ajax_menu_locations_save() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving the meta box order.
|
||||
* Handles saving the meta box order via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1978,7 +1999,7 @@ function wp_ajax_meta_box_order() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for menu quick searching.
|
||||
* Handles menu quick searching via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -1995,7 +2016,7 @@ function wp_ajax_menu_quick_search() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler to retrieve a permalink.
|
||||
* Handles retrieving a permalink via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2006,7 +2027,7 @@ function wp_ajax_get_permalink() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler to retrieve a sample permalink.
|
||||
* Handles retrieving a sample permalink via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2019,7 +2040,7 @@ function wp_ajax_sample_permalink() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for Quick Edit saving a post from a list table.
|
||||
* Handles Quick Edit saving a post from a list table via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -2138,7 +2159,7 @@ function wp_ajax_inline_save() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for quick edit saving for a term.
|
||||
* Handles Quick Edit saving for a term via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2198,7 +2219,7 @@ function wp_ajax_inline_save_tax() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for querying posts for the Find Posts modal.
|
||||
* Handles querying posts for the Find Posts modal via AJAX.
|
||||
*
|
||||
* @see window.findPosts
|
||||
*
|
||||
@@ -2267,7 +2288,7 @@ function wp_ajax_find_posts() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving the widgets order.
|
||||
* Handles saving the widgets order via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2291,7 +2312,7 @@ function wp_ajax_widgets_order() {
|
||||
$val = explode( ',', $val );
|
||||
|
||||
foreach ( $val as $k => $v ) {
|
||||
if ( strpos( $v, 'widget-' ) === false ) {
|
||||
if ( ! str_contains( $v, 'widget-' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2309,7 +2330,7 @@ function wp_ajax_widgets_order() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving a widget.
|
||||
* Handles saving a widget via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -2418,7 +2439,7 @@ function wp_ajax_save_widget() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for updating a widget.
|
||||
* Handles updating a widget via AJAX.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
@@ -2430,7 +2451,7 @@ function wp_ajax_update_widget() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for removing inactive widgets.
|
||||
* Handles removing inactive widgets via AJAX.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
@@ -2467,7 +2488,7 @@ function wp_ajax_delete_inactive_widgets() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for creating missing image sub-sizes for just uploaded images.
|
||||
* Handles creating missing image sub-sizes for just uploaded images via AJAX.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
@@ -2497,14 +2518,18 @@ function wp_ajax_media_create_image_subsizes() {
|
||||
}
|
||||
}
|
||||
|
||||
// Set a custom header with the attachment_id.
|
||||
// Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
|
||||
/*
|
||||
* Set a custom header with the attachment_id.
|
||||
* Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
|
||||
*/
|
||||
if ( ! headers_sent() ) {
|
||||
header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
|
||||
}
|
||||
|
||||
// This can still be pretty slow and cause timeout or out of memory errors.
|
||||
// The js that handles the response would need to also handle HTTP 500 errors.
|
||||
/*
|
||||
* This can still be pretty slow and cause timeout or out of memory errors.
|
||||
* The js that handles the response would need to also handle HTTP 500 errors.
|
||||
*/
|
||||
wp_update_image_subsizes( $attachment_id );
|
||||
|
||||
if ( ! empty( $_POST['_legacy_support'] ) ) {
|
||||
@@ -2524,7 +2549,7 @@ function wp_ajax_media_create_image_subsizes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for uploading attachments
|
||||
* Handles uploading attachments via AJAX.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*/
|
||||
@@ -2637,7 +2662,7 @@ function wp_ajax_upload_attachment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for image editing.
|
||||
* Handles image editing via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2649,7 +2674,7 @@ function wp_ajax_image_editor() {
|
||||
}
|
||||
|
||||
check_ajax_referer( "image_editor-$attachment_id" );
|
||||
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/image-edit.php';
|
||||
|
||||
$msg = false;
|
||||
|
||||
@@ -2692,7 +2717,7 @@ function wp_ajax_image_editor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for setting the featured image.
|
||||
* Handles setting the featured image via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2730,7 +2755,7 @@ function wp_ajax_set_post_thumbnail() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for retrieving HTML for the featured image.
|
||||
* Handles retrieving HTML for the featured image via AJAX.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*/
|
||||
@@ -2755,7 +2780,7 @@ function wp_ajax_get_post_thumbnail_html() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for setting the featured image for an attachment.
|
||||
* Handles setting the featured image for an attachment via AJAX.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
@@ -2810,7 +2835,7 @@ function wp_ajax_set_attachment_thumbnail() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for date formatting.
|
||||
* Handles formatting a date via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2819,7 +2844,7 @@ function wp_ajax_date_format() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for time formatting.
|
||||
* Handles formatting a time via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2828,7 +2853,7 @@ function wp_ajax_time_format() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving posts from the fullscreen editor.
|
||||
* Handles saving posts from the fullscreen editor via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @deprecated 4.3.0
|
||||
@@ -2872,7 +2897,7 @@ function wp_ajax_wp_fullscreen_save_post() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for removing a post lock.
|
||||
* Handles removing a post lock via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2914,7 +2939,7 @@ function wp_ajax_wp_remove_post_lock() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for dismissing a WordPress pointer.
|
||||
* Handles dismissing a WordPress pointer via AJAX.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -2941,7 +2966,7 @@ function wp_ajax_dismiss_wp_pointer() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for getting an attachment.
|
||||
* Handles getting an attachment via AJAX.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@@ -2977,7 +3002,7 @@ function wp_ajax_get_attachment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for querying attachments.
|
||||
* Handles querying attachments via AJAX.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@@ -3068,7 +3093,7 @@ function wp_ajax_query_attachments() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for updating attachment attributes.
|
||||
* Handles updating attachment attributes via AJAX.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@@ -3154,7 +3179,7 @@ function wp_ajax_save_attachment() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving backward compatible attachment attributes.
|
||||
* Handles saving backward compatible attachment attributes via AJAX.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@@ -3212,7 +3237,7 @@ function wp_ajax_save_attachment_compat() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving the attachment order.
|
||||
* Handles saving the attachment order via AJAX.
|
||||
*
|
||||
* @since 3.5.0
|
||||
*/
|
||||
@@ -3265,7 +3290,7 @@ function wp_ajax_save_attachment_order() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for sending an attachment to the editor.
|
||||
* Handles sending an attachment to the editor via AJAX.
|
||||
*
|
||||
* Generates the HTML to send an attachment to the editor.
|
||||
* Backward compatible with the {@see 'media_send_to_editor'} filter
|
||||
@@ -3304,11 +3329,11 @@ function wp_ajax_send_attachment_to_editor() {
|
||||
}
|
||||
|
||||
$url = empty( $attachment['url'] ) ? '' : $attachment['url'];
|
||||
$rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $id ) == $url );
|
||||
$rel = ( str_contains( $url, 'attachment_id' ) || get_attachment_link( $id ) === $url );
|
||||
|
||||
remove_filter( 'media_send_to_editor', 'image_media_send_to_editor' );
|
||||
|
||||
if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
|
||||
if ( str_starts_with( $post->post_mime_type, 'image' ) ) {
|
||||
$align = isset( $attachment['align'] ) ? $attachment['align'] : 'none';
|
||||
$size = isset( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
|
||||
$alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
|
||||
@@ -3339,7 +3364,7 @@ function wp_ajax_send_attachment_to_editor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for sending a link to the editor.
|
||||
* Handles sending a link to the editor via AJAX.
|
||||
*
|
||||
* Generates the HTML to send a non-image embed link to the editor.
|
||||
*
|
||||
@@ -3411,7 +3436,7 @@ function wp_ajax_send_link_to_editor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for the Heartbeat API.
|
||||
* Handles the Heartbeat API via AJAX.
|
||||
*
|
||||
* Runs when the user is logged in.
|
||||
*
|
||||
@@ -3498,7 +3523,7 @@ function wp_ajax_heartbeat() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for getting revision diffs.
|
||||
* Handles getting revision diffs via AJAX.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*/
|
||||
@@ -3538,8 +3563,8 @@ function wp_ajax_get_revision_diffs() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for auto-saving the selected color scheme for
|
||||
* a user's own profile.
|
||||
* Handles auto-saving the selected color scheme for
|
||||
* a user's own profile via AJAX.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*
|
||||
@@ -3568,7 +3593,7 @@ function wp_ajax_save_user_color_scheme() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for getting themes from themes_api().
|
||||
* Handles getting themes from themes_api() via AJAX.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
@@ -3699,7 +3724,7 @@ function wp_ajax_query_themes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply [embed] Ajax handlers to a string.
|
||||
* Applies [embed] Ajax handlers to a string.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
@@ -3753,9 +3778,11 @@ function wp_ajax_parse_embed() {
|
||||
$wp_embed->usecache = false;
|
||||
}
|
||||
|
||||
if ( is_ssl() && 0 === strpos( $url, 'http://' ) ) {
|
||||
// Admin is ssl and the user pasted non-ssl URL.
|
||||
// Check if the provider supports ssl embeds and use that for the preview.
|
||||
if ( is_ssl() && str_starts_with( $url, 'http://' ) ) {
|
||||
/*
|
||||
* Admin is ssl and the user pasted non-ssl URL.
|
||||
* Check if the provider supports ssl embeds and use that for the preview.
|
||||
*/
|
||||
$ssl_shortcode = preg_replace( '%^(\\[embed[^\\]]*\\])http://%i', '$1https://', $shortcode );
|
||||
$parsed = $wp_embed->run_shortcode( $ssl_shortcode );
|
||||
|
||||
@@ -3826,7 +3853,7 @@ function wp_ajax_parse_embed() {
|
||||
'attr' => $wp_embed->last_attr,
|
||||
);
|
||||
|
||||
if ( strpos( $parsed, 'class="wp-embedded-content' ) ) {
|
||||
if ( str_contains( $parsed, 'class="wp-embedded-content' ) ) {
|
||||
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
|
||||
$script_src = includes_url( 'js/wp-embed.js' );
|
||||
} else {
|
||||
@@ -3911,7 +3938,7 @@ function wp_ajax_parse_media_shortcode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for destroying multiple open sessions for a user.
|
||||
* Handles destroying multiple open sessions for a user via AJAX.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
@@ -3949,7 +3976,7 @@ function wp_ajax_destroy_sessions() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for cropping an image.
|
||||
* Handles cropping an image via AJAX.
|
||||
*
|
||||
* @since 4.3.0
|
||||
*/
|
||||
@@ -4088,7 +4115,7 @@ function wp_ajax_crop_image() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for generating a password.
|
||||
* Handles generating a password via AJAX.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
@@ -4097,7 +4124,7 @@ function wp_ajax_generate_password() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for generating a password in the no-privilege context.
|
||||
* Handles generating a password in the no-privilege context via AJAX.
|
||||
*
|
||||
* @since 5.7.0
|
||||
*/
|
||||
@@ -4106,7 +4133,7 @@ function wp_ajax_nopriv_generate_password() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for saving the user's WordPress.org username.
|
||||
* Handles saving the user's WordPress.org username via AJAX.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
@@ -4127,7 +4154,7 @@ function wp_ajax_save_wporg_username() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for installing a theme.
|
||||
* Handles installing a theme via AJAX.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
@@ -4161,7 +4188,7 @@ function wp_ajax_install_theme() {
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
include_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
|
||||
$api = themes_api(
|
||||
'theme_information',
|
||||
@@ -4253,7 +4280,7 @@ function wp_ajax_install_theme() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for updating a theme.
|
||||
* Handles updating a theme via AJAX.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
@@ -4348,7 +4375,7 @@ function wp_ajax_update_theme() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for deleting a theme.
|
||||
* Handles deleting a theme via AJAX.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
@@ -4406,7 +4433,7 @@ function wp_ajax_delete_theme() {
|
||||
wp_send_json_error( $status );
|
||||
}
|
||||
|
||||
include_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/theme.php';
|
||||
|
||||
$result = delete_theme( $stylesheet );
|
||||
|
||||
@@ -4422,7 +4449,7 @@ function wp_ajax_delete_theme() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for installing a plugin.
|
||||
* Handles installing a plugin via AJAX.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
@@ -4454,7 +4481,7 @@ function wp_ajax_install_plugin() {
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
|
||||
$api = plugins_api(
|
||||
'plugin_information',
|
||||
@@ -4531,7 +4558,7 @@ function wp_ajax_install_plugin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for updating a plugin.
|
||||
* Handles updating a plugin via AJAX.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
@@ -4639,7 +4666,7 @@ function wp_ajax_update_plugin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for deleting a plugin.
|
||||
* Handles deleting a plugin via AJAX.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
@@ -4716,7 +4743,7 @@ function wp_ajax_delete_plugin() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for searching plugins.
|
||||
* Handles searching plugins via AJAX.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
@@ -4773,7 +4800,7 @@ function wp_ajax_search_plugins() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for searching plugins to install.
|
||||
* Handles searching plugins to install via AJAX.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*/
|
||||
@@ -4823,7 +4850,7 @@ function wp_ajax_search_install_plugins() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for editing a theme or plugin file.
|
||||
* Handles editing a theme or plugin file via AJAX.
|
||||
*
|
||||
* @since 4.9.0
|
||||
*
|
||||
@@ -4852,7 +4879,7 @@ function wp_ajax_edit_theme_plugin_file() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for exporting a user's personal data.
|
||||
* Handles exporting a user's personal data via AJAX.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*/
|
||||
@@ -5042,7 +5069,7 @@ function wp_ajax_wp_privacy_export_personal_data() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for erasing personal data.
|
||||
* Handles erasing personal data via AJAX.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*/
|
||||
@@ -5271,7 +5298,7 @@ function wp_ajax_wp_privacy_erase_personal_data() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health checks on server communication.
|
||||
* Handles site health checks on server communication via AJAX.
|
||||
*
|
||||
* @since 5.2.0
|
||||
* @deprecated 5.6.0 Use WP_REST_Site_Health_Controller::test_dotorg_communication()
|
||||
@@ -5304,7 +5331,7 @@ function wp_ajax_health_check_dotorg_communication() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health checks on background updates.
|
||||
* Handles site health checks on background updates via AJAX.
|
||||
*
|
||||
* @since 5.2.0
|
||||
* @deprecated 5.6.0 Use WP_REST_Site_Health_Controller::test_background_updates()
|
||||
@@ -5337,7 +5364,7 @@ function wp_ajax_health_check_background_updates() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health checks on loopback requests.
|
||||
* Handles site health checks on loopback requests via AJAX.
|
||||
*
|
||||
* @since 5.2.0
|
||||
* @deprecated 5.6.0 Use WP_REST_Site_Health_Controller::test_loopback_requests()
|
||||
@@ -5370,7 +5397,7 @@ function wp_ajax_health_check_loopback_requests() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health check to update the result status.
|
||||
* Handles site health check to update the result status via AJAX.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*/
|
||||
@@ -5387,7 +5414,7 @@ function wp_ajax_health_check_site_status_result() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler for site health check to get directories and database sizes.
|
||||
* Handles site health check to get directories and database sizes via AJAX.
|
||||
*
|
||||
* @since 5.2.0
|
||||
* @deprecated 5.6.0 Use WP_REST_Site_Health_Controller::get_directory_sizes()
|
||||
@@ -5453,7 +5480,7 @@ function wp_ajax_health_check_get_sizes() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler to renew the REST API nonce.
|
||||
* Handles renewing the REST API nonce via AJAX.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*/
|
||||
@@ -5462,7 +5489,7 @@ function wp_ajax_rest_nonce() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler to enable or disable plugin and theme auto-updates.
|
||||
* Handles enabling or disable plugin and theme auto-updates via AJAX.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*/
|
||||
@@ -5532,7 +5559,7 @@ function wp_ajax_toggle_auto_updates() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax handler sends a password reset link.
|
||||
* Handles sending a password reset link via AJAX.
|
||||
*
|
||||
* @since 5.7.0
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Add a link to using values provided in $_POST.
|
||||
* Adds a link using values provided in $_POST.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
@@ -34,7 +34,6 @@ function edit_link( $link_id = 0 ) {
|
||||
);
|
||||
}
|
||||
|
||||
$_POST['link_url'] = esc_html( $_POST['link_url'] );
|
||||
$_POST['link_url'] = esc_url( $_POST['link_url'] );
|
||||
$_POST['link_name'] = esc_html( $_POST['link_name'] );
|
||||
$_POST['link_image'] = esc_html( $_POST['link_image'] );
|
||||
@@ -84,7 +83,7 @@ function get_default_link_to_edit() {
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param int $link_id ID of the link to delete
|
||||
* @param int $link_id ID of the link to delete.
|
||||
* @return true Always true.
|
||||
*/
|
||||
function wp_delete_link( $link_id ) {
|
||||
@@ -268,7 +267,7 @@ function wp_insert_link( $linkdata, $wp_error = false ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update link with the specified link categories.
|
||||
* Updates link with the specified link categories.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
|
||||
@@ -84,7 +84,7 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
$string = $this->upgrader->strings[ $string ];
|
||||
}
|
||||
|
||||
if ( strpos( $string, '%' ) !== false ) {
|
||||
if ( str_contains( $string, '%' ) ) {
|
||||
if ( ! empty( $args ) ) {
|
||||
$string = vsprintf( $string, $args );
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
$feedback = $this->upgrader->strings[ $feedback ];
|
||||
}
|
||||
|
||||
if ( strpos( $feedback, '%' ) !== false ) {
|
||||
if ( str_contains( $feedback, '%' ) ) {
|
||||
if ( $args ) {
|
||||
$args = array_map( 'strip_tags', $args );
|
||||
$args = array_map( 'esc_html', $args );
|
||||
@@ -79,13 +79,13 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
/**
|
||||
*/
|
||||
public function header() {
|
||||
// Nothing, This will be displayed within a iframe.
|
||||
// Nothing. This will be displayed within an iframe.
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function footer() {
|
||||
// Nothing, This will be displayed within a iframe.
|
||||
// Nothing. This will be displayed within an iframe.
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
$this->in_loop = true;
|
||||
printf( '<h2>' . $this->upgrader->strings['skin_before_update_header'] . ' <span class="spinner waiting-' . $this->upgrader->update_current . '"></span></h2>', $title, $this->upgrader->update_current, $this->upgrader->update_count );
|
||||
echo '<script type="text/javascript">jQuery(\'.waiting-' . esc_js( $this->upgrader->update_current ) . '\').css("display", "inline-block");</script>';
|
||||
// This progress messages div gets moved via JavaScript when clicking on "Show details.".
|
||||
// This progress messages div gets moved via JavaScript when clicking on "More details.".
|
||||
echo '<div class="update-messages hide-if-js" id="progress-' . esc_attr( $this->upgrader->update_current ) . '"><p>';
|
||||
$this->flush_output();
|
||||
}
|
||||
@@ -154,7 +154,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
if ( ! $this->error ) {
|
||||
echo '<div class="updated js-update-details" data-update-details="progress-' . esc_attr( $this->upgrader->update_current ) . '">' .
|
||||
'<p>' . sprintf( $this->upgrader->strings['skin_update_successful'], $title ) .
|
||||
' <button type="button" class="hide-if-no-js button-link js-update-details-toggle" aria-expanded="false">' . __( 'Show details.' ) . '</button>' .
|
||||
' <button type="button" class="hide-if-no-js button-link js-update-details-toggle" aria-expanded="false">' . __( 'More details.' ) . '<span class="dashicons dashicons-arrow-down" aria-hidden="true"></span></button>' .
|
||||
'</p></div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
class Core_Upgrader extends WP_Upgrader {
|
||||
|
||||
/**
|
||||
* Initialize the upgrade strings.
|
||||
* Initializes the upgrade strings.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -30,16 +30,16 @@ class Core_Upgrader extends WP_Upgrader {
|
||||
$this->strings['locked'] = __( 'Another update is currently in progress.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: Package URL. */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code pre">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['copy_failed'] = __( 'Could not copy files.' );
|
||||
$this->strings['copy_failed_space'] = __( 'Could not copy files. You may have run out of disk space.' );
|
||||
$this->strings['start_rollback'] = __( 'Attempting to roll back to previous version.' );
|
||||
$this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has rolled back to your previous version.' );
|
||||
$this->strings['start_rollback'] = __( 'Attempting to restore the previous version.' );
|
||||
$this->strings['rollback_was_required'] = __( 'Due to an error during updating, WordPress has been restored to your previous version.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade WordPress core.
|
||||
* Upgrades WordPress core.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
@@ -123,8 +123,10 @@ class Core_Upgrader extends WP_Upgrader {
|
||||
|
||||
$download = $this->download_package( $current->packages->$to_download, true );
|
||||
|
||||
// Allow for signature soft-fail.
|
||||
// WARNING: This may be removed in the future.
|
||||
/*
|
||||
* Allow for signature soft-fail.
|
||||
* WARNING: This may be removed in the future.
|
||||
*/
|
||||
if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
|
||||
// Output the failure error as a normal feedback, and not as an error:
|
||||
/** This filter is documented in wp-admin/includes/update-core.php */
|
||||
@@ -181,9 +183,9 @@ class Core_Upgrader extends WP_Upgrader {
|
||||
* mkdir_failed__copy_dir, copy_failed__copy_dir_retry, and disk_full.
|
||||
* do_rollback allows for update_core() to trigger a rollback if needed.
|
||||
*/
|
||||
if ( false !== strpos( $error_code, 'do_rollback' ) ) {
|
||||
if ( str_contains( $error_code, 'do_rollback' ) ) {
|
||||
$try_rollback = true;
|
||||
} elseif ( false !== strpos( $error_code, '__copy_dir' ) ) {
|
||||
} elseif ( str_contains( $error_code, '__copy_dir' ) ) {
|
||||
$try_rollback = true;
|
||||
} elseif ( 'disk_full' === $error_code ) {
|
||||
$try_rollback = true;
|
||||
@@ -323,7 +325,7 @@ class Core_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
// Don't claim we can update on update-core.php if we have a non-critical failure logged.
|
||||
if ( $wp_version === $failure_data['current'] && false !== strpos( $offered_ver, '.1.next.minor' ) ) {
|
||||
if ( $wp_version === $failure_data['current'] && str_contains( $offered_ver, '.1.next.minor' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -385,7 +387,7 @@ class Core_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the disk file checksums against the expected checksums.
|
||||
* Compares the disk file checksums against the expected checksums.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
@@ -405,7 +407,7 @@ class Core_Upgrader extends WP_Upgrader {
|
||||
|
||||
foreach ( $checksums as $file => $checksum ) {
|
||||
// Skip files which get updated.
|
||||
if ( 'wp-content' === substr( $file, 0, 10 ) ) {
|
||||
if ( str_starts_with( $file, 'wp-content' ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! file_exists( ABSPATH . $file ) || md5_file( ABSPATH . $file ) !== $checksum ) {
|
||||
|
||||
@@ -63,7 +63,14 @@ class Custom_Background {
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public function init() {
|
||||
$page = add_theme_page( __( 'Background' ), __( 'Background' ), 'edit_theme_options', 'custom-background', array( $this, 'admin_page' ) );
|
||||
$page = add_theme_page(
|
||||
_x( 'Background', 'custom background' ),
|
||||
_x( 'Background', 'custom background' ),
|
||||
'edit_theme_options',
|
||||
'custom-background',
|
||||
array( $this, 'admin_page' )
|
||||
);
|
||||
|
||||
if ( ! $page ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,12 +66,18 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the hooks for the Custom Header admin page.
|
||||
* Sets up the hooks for the Custom Header admin page.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function init() {
|
||||
$page = add_theme_page( __( 'Header' ), __( 'Header' ), 'edit_theme_options', 'custom-header', array( $this, 'admin_page' ) );
|
||||
$page = add_theme_page(
|
||||
_x( 'Header', 'custom image header' ),
|
||||
_x( 'Header', 'custom image header' ),
|
||||
'edit_theme_options',
|
||||
'custom-header',
|
||||
array( $this, 'admin_page' )
|
||||
);
|
||||
|
||||
if ( ! $page ) {
|
||||
return;
|
||||
@@ -140,7 +146,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current step.
|
||||
* Gets the current step.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*
|
||||
@@ -163,7 +169,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the enqueue for the JavaScript files.
|
||||
* Sets up the enqueue for the JavaScript files.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@@ -182,7 +188,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the enqueue for the CSS files
|
||||
* Sets up the enqueue for the CSS files.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*/
|
||||
@@ -197,7 +203,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute custom header modification.
|
||||
* Executes custom header modification.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
@@ -256,7 +262,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the default headers
|
||||
* Processes the default headers.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
@@ -293,9 +299,9 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display UI for selecting one of several default headers.
|
||||
* Displays UI for selecting one of several default headers.
|
||||
*
|
||||
* Show the random image option if this theme has multiple header images.
|
||||
* Shows the random image option if this theme has multiple header images.
|
||||
* Random image option is on by default if no header has been set.
|
||||
*
|
||||
* @since 3.0.0
|
||||
@@ -340,7 +346,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute JavaScript depending on step.
|
||||
* Executes JavaScript depending on step.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@@ -355,7 +361,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display JavaScript based on Step 1 and 3.
|
||||
* Displays JavaScript based on Step 1 and 3.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
@@ -363,7 +369,7 @@ class Custom_Image_Header {
|
||||
$default_color = '';
|
||||
if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) {
|
||||
$default_color = get_theme_support( 'custom-header', 'default-text-color' );
|
||||
if ( $default_color && false === strpos( $default_color, '#' ) ) {
|
||||
if ( $default_color && ! str_contains( $default_color, '#' ) ) {
|
||||
$default_color = '#' . $default_color;
|
||||
}
|
||||
}
|
||||
@@ -416,7 +422,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display JavaScript based on Step 2.
|
||||
* Displays JavaScript based on Step 2.
|
||||
*
|
||||
* @since 2.6.0
|
||||
*/
|
||||
@@ -492,7 +498,7 @@ class Custom_Image_Header {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display first step of custom header image page.
|
||||
* Displays first step of custom header image page.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@@ -697,7 +703,7 @@ class Custom_Image_Header {
|
||||
<th scope="row"><?php _e( 'Default Images' ); ?></th>
|
||||
<td>
|
||||
<?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?>
|
||||
<p><?php _e( 'If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.' ); ?></p>
|
||||
<p><?php _e( 'If you do not want to upload your own image, you can use one of these cool headers, or show a random one.' ); ?></p>
|
||||
<?php else : ?>
|
||||
<p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ); ?></p>
|
||||
<?php endif; ?>
|
||||
@@ -762,7 +768,7 @@ class Custom_Image_Header {
|
||||
$default_color = '';
|
||||
if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) {
|
||||
$default_color = get_theme_support( 'custom-header', 'default-text-color' );
|
||||
if ( $default_color && false === strpos( $default_color, '#' ) ) {
|
||||
if ( $default_color && ! str_contains( $default_color, '#' ) ) {
|
||||
$default_color = '#' . $default_color;
|
||||
}
|
||||
}
|
||||
@@ -770,7 +776,7 @@ class Custom_Image_Header {
|
||||
$default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : '';
|
||||
|
||||
$header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' );
|
||||
if ( $header_textcolor && false === strpos( $header_textcolor, '#' ) ) {
|
||||
if ( $header_textcolor && ! str_contains( $header_textcolor, '#' ) ) {
|
||||
$header_textcolor = '#' . $header_textcolor;
|
||||
}
|
||||
|
||||
@@ -806,7 +812,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display second step of custom header image page.
|
||||
* Displays second step of custom header image page.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@@ -949,7 +955,7 @@ endif;
|
||||
|
||||
|
||||
/**
|
||||
* Upload the file to be cropped in the second step.
|
||||
* Uploads the file to be cropped in the second step.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
@@ -990,7 +996,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display third step of custom header image page.
|
||||
* Displays third step of custom header image page.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @since 4.4.0 Switched to using wp_get_attachment_url() instead of the guid
|
||||
@@ -1086,7 +1092,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display last step of custom header image page.
|
||||
* Displays last step of custom header image page.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@@ -1096,7 +1102,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the page based on the current step.
|
||||
* Displays the page based on the current step.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
@@ -1141,16 +1147,17 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Choose a header image, selected from existing uploaded and default headers,
|
||||
* or provide an array of uploaded header data (either new, or from media library).
|
||||
* Chooses a header image, selected from existing uploaded and default headers,
|
||||
* or provides an array of uploaded header data (either new, or from media library).
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param mixed $choice Which header image to select. Allows for values of 'random-default-image',
|
||||
* for randomly cycling among the default images; 'random-uploaded-image', for randomly cycling
|
||||
* among the uploaded images; the key of a default image registered for that theme; and
|
||||
* the key of an image uploaded for that theme (the attachment ID of the image).
|
||||
* Or an array of arguments: attachment_id, url, width, height. All are required.
|
||||
* for randomly cycling among the default images; 'random-uploaded-image',
|
||||
* for randomly cycling among the uploaded images; the key of a default image
|
||||
* registered for that theme; and the key of an image uploaded for that theme
|
||||
* (the attachment ID of the image). Or an array of arguments: attachment_id,
|
||||
* url, width, height. All are required.
|
||||
*/
|
||||
final public function set_header_image( $choice ) {
|
||||
if ( is_array( $choice ) || is_object( $choice ) ) {
|
||||
@@ -1203,7 +1210,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a header image.
|
||||
* Removes a header image.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*/
|
||||
@@ -1212,7 +1219,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a header image to the default image for the theme.
|
||||
* Resets a header image to the default image for the theme.
|
||||
*
|
||||
* This method does not do anything if the theme does not have a default header image.
|
||||
*
|
||||
@@ -1242,7 +1249,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate width and height based on what the currently selected theme supports.
|
||||
* Calculates width and height based on what the currently selected theme supports.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
@@ -1293,7 +1300,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an attachment 'object'.
|
||||
* Creates an attachment 'object'.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
@@ -1322,7 +1329,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert an attachment and its metadata.
|
||||
* Inserts an attachment and its metadata.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
@@ -1572,7 +1579,7 @@ endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of a previous crop from the same base image.
|
||||
* Gets the ID of a previous crop from the same base image.
|
||||
*
|
||||
* @since 4.9.0
|
||||
*
|
||||
|
||||
@@ -108,14 +108,14 @@ class File_Upload_Upgrader {
|
||||
$this->filename = sanitize_file_name( $_GET[ $urlholder ] );
|
||||
$this->package = $uploads['basedir'] . '/' . $this->filename;
|
||||
|
||||
if ( 0 !== strpos( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) {
|
||||
if ( ! str_starts_with( realpath( $this->package ), realpath( $uploads['basedir'] ) ) ) {
|
||||
wp_die( __( 'Please select a file' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the attachment/uploaded file.
|
||||
* Deletes the attachment/uploaded file.
|
||||
*
|
||||
* @since 3.2.2
|
||||
*
|
||||
|
||||
@@ -797,7 +797,7 @@ class ftp_base {
|
||||
$chunks=explode(';',$pattern);
|
||||
foreach($chunks as $pattern) {
|
||||
$escape=array('$','^','.','{','}','(',')','[',']','|');
|
||||
while(strpos($pattern,'**')!==false)
|
||||
while(str_contains($pattern,'**'))
|
||||
$pattern=str_replace('**','*',$pattern);
|
||||
foreach($escape as $probe)
|
||||
$pattern=str_replace($probe,"\\$probe",$pattern);
|
||||
|
||||
@@ -105,7 +105,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the upgrade strings.
|
||||
* Initializes the upgrade strings.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*/
|
||||
@@ -114,7 +114,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
||||
$this->strings['up_to_date'] = __( 'Your translations are all up to date.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: Package URL. */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading translation from %s…' ), '<span class="code pre">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['process_failed'] = __( 'Translation update failed.' );
|
||||
$this->strings['process_success'] = __( 'Translation updated successfully.' );
|
||||
@@ -123,7 +123,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade a language pack.
|
||||
* Upgrades a language pack.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
@@ -147,7 +147,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk upgrade language packs.
|
||||
* Upgrades several language packs at once.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
@@ -336,9 +336,9 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
||||
$po = false;
|
||||
$mo = false;
|
||||
foreach ( (array) $files as $file => $filedata ) {
|
||||
if ( '.po' === substr( $file, -3 ) ) {
|
||||
if ( str_ends_with( $file, '.po' ) ) {
|
||||
$po = true;
|
||||
} elseif ( '.mo' === substr( $file, -3 ) ) {
|
||||
} elseif ( str_ends_with( $file, '.mo' ) ) {
|
||||
$mo = true;
|
||||
}
|
||||
}
|
||||
@@ -360,7 +360,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of an item being updated.
|
||||
* Gets the name of an item being updated.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
|
||||
@@ -632,9 +632,9 @@
|
||||
// newer_exist : the file was not extracted because a newer file exists
|
||||
// path_creation_fail : the file is not extracted because the folder
|
||||
// does not exist and can not be created
|
||||
// write_error : the file was not extracted because there was a
|
||||
// write_error : the file was not extracted because there was an
|
||||
// error while writing the file
|
||||
// read_error : the file was not extracted because there was a error
|
||||
// read_error : the file was not extracted because there was an error
|
||||
// while reading the file
|
||||
// invalid_header : the file was not extracted because of an archive
|
||||
// format error (bad file header)
|
||||
@@ -1170,8 +1170,8 @@
|
||||
// ----- Reset the error handler
|
||||
$this->privErrorReset();
|
||||
|
||||
// ----- Look if the $p_archive is a PclZip object
|
||||
if (is_object($p_archive) && $p_archive instanceof pclzip)
|
||||
// ----- Look if the $p_archive is an instantiated PclZip object
|
||||
if ($p_archive instanceof pclzip)
|
||||
{
|
||||
|
||||
// ----- Duplicate the archive
|
||||
@@ -1234,8 +1234,8 @@
|
||||
return(0);
|
||||
}
|
||||
|
||||
// ----- Look if the $p_archive_to_add is a PclZip object
|
||||
if (is_object($p_archive_to_add) && $p_archive_to_add instanceof pclzip)
|
||||
// ----- Look if the $p_archive_to_add is an instantiated PclZip object
|
||||
if ($p_archive_to_add instanceof pclzip)
|
||||
{
|
||||
|
||||
// ----- Merge the archive
|
||||
|
||||
@@ -46,7 +46,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to perform before installing a plugin.
|
||||
* Performs an action before installing a plugin.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param WP_Error $wp_error WP_Error object.
|
||||
* @return bool
|
||||
* @return bool True if the error should be hidden, false otherwise.
|
||||
*/
|
||||
public function hide_process_failed( $wp_error ) {
|
||||
if (
|
||||
@@ -81,7 +81,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to perform following a plugin install.
|
||||
* Performs an action following a plugin install.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -177,7 +177,7 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the plugin can be overwritten and output the HTML for overwriting a plugin on upload.
|
||||
* Checks if the plugin can be overwritten and outputs the HTML for overwriting a plugin on upload.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*
|
||||
|
||||
@@ -72,7 +72,7 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to perform following a single plugin update.
|
||||
* Performs an action following a single plugin update.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
||||
@@ -49,7 +49,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
public $new_plugin_data = array();
|
||||
|
||||
/**
|
||||
* Initialize the upgrade strings.
|
||||
* Initializes the upgrade strings.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
$this->strings['up_to_date'] = __( 'The plugin is at the latest version.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: Package URL. */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code pre">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['remove_old'] = __( 'Removing the old version of the plugin…' );
|
||||
$this->strings['remove_old_failed'] = __( 'Could not remove the old plugin.' );
|
||||
@@ -67,14 +67,14 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the installation strings.
|
||||
* Initializes the installation strings.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function install_strings() {
|
||||
$this->strings['no_package'] = __( 'Installation package not available.' );
|
||||
/* translators: %s: Package URL. */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code pre">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the package…' );
|
||||
$this->strings['installing_package'] = __( 'Installing the plugin…' );
|
||||
$this->strings['remove_old'] = __( 'Removing the current plugin…' );
|
||||
@@ -173,7 +173,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade a plugin.
|
||||
* Upgrades a plugin.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
|
||||
@@ -212,8 +212,10 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
add_filter( 'upgrader_pre_install', array( $this, 'active_before' ), 10, 2 );
|
||||
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
|
||||
add_filter( 'upgrader_post_install', array( $this, 'active_after' ), 10, 2 );
|
||||
// There's a Trac ticket to move up the directory for zips which are made a bit differently, useful for non-.org plugins.
|
||||
// 'source_selection' => array( $this, 'source_selection' ),
|
||||
/*
|
||||
* There's a Trac ticket to move up the directory for zips which are made a bit differently, useful for non-.org plugins.
|
||||
* 'source_selection' => array( $this, 'source_selection' ),
|
||||
*/
|
||||
if ( $parsed_args['clear_update_cache'] ) {
|
||||
// Clear cache so wp_update_plugins() knows about the new plugin.
|
||||
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
|
||||
@@ -226,14 +228,19 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
'clear_destination' => true,
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'plugin' => $plugin,
|
||||
'type' => 'plugin',
|
||||
'action' => 'update',
|
||||
'plugin' => $plugin,
|
||||
'type' => 'plugin',
|
||||
'action' => 'update',
|
||||
'temp_backup' => array(
|
||||
'slug' => dirname( $plugin ),
|
||||
'src' => WP_PLUGIN_DIR,
|
||||
'dir' => 'plugins',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||
// Cleanup our hooks, in case something else does an upgrade on this connection.
|
||||
remove_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9 );
|
||||
remove_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ) );
|
||||
remove_filter( 'upgrader_pre_install', array( $this, 'active_before' ) );
|
||||
@@ -247,8 +254,10 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
// Force refresh of plugin update information.
|
||||
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
|
||||
|
||||
// Ensure any future auto-update failures trigger a failure email by removing
|
||||
// the last failure notification from the list when plugins update successfully.
|
||||
/*
|
||||
* Ensure any future auto-update failures trigger a failure email by removing
|
||||
* the last failure notification from the list when plugins update successfully.
|
||||
*/
|
||||
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
|
||||
|
||||
if ( isset( $past_failure_emails[ $plugin ] ) ) {
|
||||
@@ -260,7 +269,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk upgrade several plugins at once.
|
||||
* Upgrades several plugins at once.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 3.7.0 The `$args` parameter was added, making clearing the plugin update cache optional.
|
||||
@@ -342,7 +351,12 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
'clear_working' => true,
|
||||
'is_multi' => true,
|
||||
'hook_extra' => array(
|
||||
'plugin' => $plugin,
|
||||
'plugin' => $plugin,
|
||||
'temp_backup' => array(
|
||||
'slug' => dirname( $plugin ),
|
||||
'src' => WP_PLUGIN_DIR,
|
||||
'dir' => 'plugins',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
@@ -376,11 +390,13 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
|
||||
$this->skin->footer();
|
||||
|
||||
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||
// Cleanup our hooks, in case something else does an upgrade on this connection.
|
||||
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ) );
|
||||
|
||||
// Ensure any future auto-update failures trigger a failure email by removing
|
||||
// the last failure notification from the list when plugins update successfully.
|
||||
/*
|
||||
* Ensure any future auto-update failures trigger a failure email by removing
|
||||
* the last failure notification from the list when plugins update successfully.
|
||||
*/
|
||||
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
|
||||
|
||||
foreach ( $results as $plugin => $result ) {
|
||||
@@ -469,7 +485,7 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the path to the file that contains the plugin info.
|
||||
* Retrieves the path to the file that contains the plugin info.
|
||||
*
|
||||
* This isn't used internally in the class, but is called by the skins.
|
||||
*
|
||||
@@ -641,8 +657,10 @@ class Plugin_Upgrader extends WP_Upgrader {
|
||||
return $removed;
|
||||
}
|
||||
|
||||
// If plugin is in its own directory, recursively delete the directory.
|
||||
// Base check on if plugin includes directory separator AND that it's not the root plugin folder.
|
||||
/*
|
||||
* If plugin is in its own directory, recursively delete the directory.
|
||||
* Base check on if plugin includes directory separator AND that it's not the root plugin folder.
|
||||
*/
|
||||
if ( strpos( $plugin, '/' ) && $this_plugin_dir !== $plugins_dir ) {
|
||||
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
|
||||
} else {
|
||||
|
||||
@@ -46,7 +46,7 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to perform before installing a theme.
|
||||
* Performs an action before installing a theme.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -66,7 +66,7 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param WP_Error $wp_error WP_Error object.
|
||||
* @return bool
|
||||
* @return bool True if the error should be hidden, false otherwise.
|
||||
*/
|
||||
public function hide_process_failed( $wp_error ) {
|
||||
if (
|
||||
@@ -81,7 +81,7 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to perform following a single theme install.
|
||||
* Performs an action following a single theme install.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -188,7 +188,7 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the theme can be overwritten and output the HTML for overwriting a theme on upload.
|
||||
* Checks if the theme can be overwritten and outputs the HTML for overwriting a theme on upload.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*
|
||||
|
||||
@@ -51,7 +51,7 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to perform following a single theme update.
|
||||
* Performs an action following a single theme update.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
|
||||
@@ -48,7 +48,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
public $new_theme_data = array();
|
||||
|
||||
/**
|
||||
* Initialize the upgrade strings.
|
||||
* Initializes the upgrade strings.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
$this->strings['up_to_date'] = __( 'The theme is at the latest version.' );
|
||||
$this->strings['no_package'] = __( 'Update package not available.' );
|
||||
/* translators: %s: Package URL. */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading update from %s…' ), '<span class="code pre">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the update…' );
|
||||
$this->strings['remove_old'] = __( 'Removing the old version of the theme…' );
|
||||
$this->strings['remove_old_failed'] = __( 'Could not remove the old theme.' );
|
||||
@@ -65,14 +65,14 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the installation strings.
|
||||
* Initializes the installation strings.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function install_strings() {
|
||||
$this->strings['no_package'] = __( 'Installation package not available.' );
|
||||
/* translators: %s: Package URL. */
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code">%s</span>' );
|
||||
$this->strings['downloading_package'] = sprintf( __( 'Downloading installation package from %s…' ), '<span class="code pre">%s</span>' );
|
||||
$this->strings['unpack_package'] = __( 'Unpacking the package…' );
|
||||
$this->strings['installing_package'] = __( 'Installing the theme…' );
|
||||
$this->strings['remove_old'] = __( 'Removing the old version of the theme…' );
|
||||
@@ -110,7 +110,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a child theme is being installed and we need to install its parent.
|
||||
* Checks if a child theme is being installed and its parent also needs to be installed.
|
||||
*
|
||||
* Hooked to the {@see 'upgrader_post_install'} filter by Theme_Upgrader::install().
|
||||
*
|
||||
@@ -278,7 +278,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade a theme.
|
||||
* Upgrades a theme.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional.
|
||||
@@ -328,9 +328,14 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
'clear_destination' => true,
|
||||
'clear_working' => true,
|
||||
'hook_extra' => array(
|
||||
'theme' => $theme,
|
||||
'type' => 'theme',
|
||||
'action' => 'update',
|
||||
'theme' => $theme,
|
||||
'type' => 'theme',
|
||||
'action' => 'update',
|
||||
'temp_backup' => array(
|
||||
'slug' => $theme,
|
||||
'src' => get_theme_root( $theme ),
|
||||
'dir' => 'themes',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
@@ -346,8 +351,10 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
|
||||
wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
|
||||
|
||||
// Ensure any future auto-update failures trigger a failure email by removing
|
||||
// the last failure notification from the list when themes update successfully.
|
||||
/*
|
||||
* Ensure any future auto-update failures trigger a failure email by removing
|
||||
* the last failure notification from the list when themes update successfully.
|
||||
*/
|
||||
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
|
||||
|
||||
if ( isset( $past_failure_emails[ $theme ] ) ) {
|
||||
@@ -359,7 +366,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade several themes at once.
|
||||
* Upgrades several themes at once.
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @since 3.7.0 The `$args` parameter was added, making clearing the update cache optional.
|
||||
@@ -443,7 +450,12 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
'clear_working' => true,
|
||||
'is_multi' => true,
|
||||
'hook_extra' => array(
|
||||
'theme' => $theme,
|
||||
'theme' => $theme,
|
||||
'temp_backup' => array(
|
||||
'slug' => $theme,
|
||||
'src' => get_theme_root( $theme ),
|
||||
'dir' => 'themes',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
@@ -477,13 +489,15 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
|
||||
$this->skin->footer();
|
||||
|
||||
// Cleanup our hooks, in case something else does a upgrade on this connection.
|
||||
// Cleanup our hooks, in case something else does an upgrade on this connection.
|
||||
remove_filter( 'upgrader_pre_install', array( $this, 'current_before' ) );
|
||||
remove_filter( 'upgrader_post_install', array( $this, 'current_after' ) );
|
||||
remove_filter( 'upgrader_clear_destination', array( $this, 'delete_old_theme' ) );
|
||||
|
||||
// Ensure any future auto-update failures trigger a failure email by removing
|
||||
// the last failure notification from the list when themes update successfully.
|
||||
/*
|
||||
* Ensure any future auto-update failures trigger a failure email by removing
|
||||
* the last failure notification from the list when themes update successfully.
|
||||
*/
|
||||
$past_failure_emails = get_option( 'auto_plugin_theme_update_emails', array() );
|
||||
|
||||
foreach ( $results as $theme => $result ) {
|
||||
@@ -622,7 +636,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn on maintenance mode before attempting to upgrade the active theme.
|
||||
* Turns on maintenance mode before attempting to upgrade the active theme.
|
||||
*
|
||||
* Hooked to the {@see 'upgrader_pre_install'} filter by Theme_Upgrader::upgrade() and
|
||||
* Theme_Upgrader::bulk_upgrade().
|
||||
@@ -654,7 +668,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn off maintenance mode after upgrading the active theme.
|
||||
* Turns off maintenance mode after upgrading the active theme.
|
||||
*
|
||||
* Hooked to the {@see 'upgrader_post_install'} filter by Theme_Upgrader::upgrade()
|
||||
* and Theme_Upgrader::bulk_upgrade().
|
||||
@@ -692,7 +706,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the old theme during an upgrade.
|
||||
* Deletes the old theme during an upgrade.
|
||||
*
|
||||
* Hooked to the {@see 'upgrader_clear_destination'} filter by Theme_Upgrader::upgrade()
|
||||
* and Theme_Upgrader::bulk_upgrade().
|
||||
@@ -730,7 +744,7 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WP_Theme object for a theme.
|
||||
* Gets the WP_Theme object for a theme.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 3.0.0 The `$theme` argument was added.
|
||||
|
||||
@@ -118,7 +118,7 @@ class WP_Ajax_Upgrader_Skin extends Automatic_Upgrader_Skin {
|
||||
$string = $this->upgrader->strings[ $string ];
|
||||
}
|
||||
|
||||
if ( false !== strpos( $string, '%' ) ) {
|
||||
if ( str_contains( $string, '%' ) ) {
|
||||
if ( ! empty( $args ) ) {
|
||||
$string = vsprintf( $string, $args );
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class WP_Application_Passwords_List_Table extends WP_List_Table {
|
||||
*
|
||||
* @since 5.6.0
|
||||
*
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
return array(
|
||||
|
||||
@@ -27,6 +27,8 @@ class WP_Automatic_Updater {
|
||||
* Determines whether the entire automatic updater is disabled.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
* @return bool True if the automatic updater is disabled, false otherwise.
|
||||
*/
|
||||
public function is_disabled() {
|
||||
// Background updates are disabled if you don't want file changes.
|
||||
@@ -146,6 +148,7 @@ class WP_Automatic_Updater {
|
||||
}
|
||||
|
||||
$check_dirs = array_unique( $check_dirs );
|
||||
$checkout = false;
|
||||
|
||||
// Search all directories we've found for evidence of version control.
|
||||
foreach ( $vcs_dirs as $vcs_dir ) {
|
||||
@@ -467,8 +470,10 @@ class WP_Automatic_Updater {
|
||||
&& ( 'up_to_date' === $upgrade_result->get_error_code()
|
||||
|| 'locked' === $upgrade_result->get_error_code() )
|
||||
) {
|
||||
// These aren't actual errors, treat it as a skipped-update instead
|
||||
// to avoid triggering the post-core update failure routines.
|
||||
/*
|
||||
* These aren't actual errors, treat it as a skipped-update instead
|
||||
* to avoid triggering the post-core update failure routines.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -545,8 +550,10 @@ class WP_Automatic_Updater {
|
||||
$this->update( 'core', $core_update );
|
||||
}
|
||||
|
||||
// Clean up, and check for any pending translations.
|
||||
// (Core_Upgrader checks for core updates.)
|
||||
/*
|
||||
* Clean up, and check for any pending translations.
|
||||
* (Core_Upgrader checks for core updates.)
|
||||
*/
|
||||
$theme_stats = array();
|
||||
if ( isset( $this->update_results['theme'] ) ) {
|
||||
foreach ( $this->update_results['theme'] as $upgrade ) {
|
||||
@@ -580,7 +587,7 @@ class WP_Automatic_Updater {
|
||||
|
||||
// Send debugging email to admin for all development installations.
|
||||
if ( ! empty( $this->update_results ) ) {
|
||||
$development_version = false !== strpos( get_bloginfo( 'version' ), '-' );
|
||||
$development_version = str_contains( get_bloginfo( 'version' ), '-' );
|
||||
|
||||
/**
|
||||
* Filters whether to send a debugging email for each automatic background update.
|
||||
@@ -615,8 +622,8 @@ class WP_Automatic_Updater {
|
||||
}
|
||||
|
||||
/**
|
||||
* If we tried to perform a core update, check if we should send an email,
|
||||
* and if we need to avoid processing future updates.
|
||||
* Checks whether to send an email and avoid processing future updates after
|
||||
* attempting a core update.
|
||||
*
|
||||
* @since 3.7.0
|
||||
*
|
||||
@@ -635,16 +642,18 @@ class WP_Automatic_Updater {
|
||||
|
||||
$error_code = $result->get_error_code();
|
||||
|
||||
// Any of these WP_Error codes are critical failures, as in they occurred after we started to copy core files.
|
||||
// We should not try to perform a background update again until there is a successful one-click update performed by the user.
|
||||
/*
|
||||
* Any of these WP_Error codes are critical failures, as in they occurred after we started to copy core files.
|
||||
* We should not try to perform a background update again until there is a successful one-click update performed by the user.
|
||||
*/
|
||||
$critical = false;
|
||||
if ( 'disk_full' === $error_code || false !== strpos( $error_code, '__copy_dir' ) ) {
|
||||
if ( 'disk_full' === $error_code || str_contains( $error_code, '__copy_dir' ) ) {
|
||||
$critical = true;
|
||||
} elseif ( 'rollback_was_required' === $error_code && is_wp_error( $result->get_error_data()->rollback ) ) {
|
||||
// A rollback is only critical if it failed too.
|
||||
$critical = true;
|
||||
$rollback_result = $result->get_error_data()->rollback;
|
||||
} elseif ( false !== strpos( $error_code, 'do_rollback' ) ) {
|
||||
} elseif ( str_contains( $error_code, 'do_rollback' ) ) {
|
||||
$critical = true;
|
||||
}
|
||||
|
||||
@@ -828,8 +837,10 @@ class WP_Automatic_Updater {
|
||||
|
||||
$body .= "\n\n";
|
||||
|
||||
// Don't show this message if there is a newer version available.
|
||||
// Potential for confusion, and also not useful for them to know at this point.
|
||||
/*
|
||||
* Don't show this message if there is a newer version available.
|
||||
* Potential for confusion, and also not useful for them to know at this point.
|
||||
*/
|
||||
if ( 'fail' === $type && ! $newer_version_available ) {
|
||||
$body .= __( 'An attempt was made, but your site could not be updated automatically.' ) . ' ';
|
||||
}
|
||||
@@ -900,8 +911,10 @@ class WP_Automatic_Updater {
|
||||
$body .= ' ' . __( 'Some data that describes the error your site encountered has been put together.' );
|
||||
$body .= ' ' . __( 'Your hosting company, support forum volunteers, or a friendly developer may be able to use this information to help you:' );
|
||||
|
||||
// If we had a rollback and we're still critical, then the rollback failed too.
|
||||
// Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
|
||||
/*
|
||||
* If we had a rollback and we're still critical, then the rollback failed too.
|
||||
* Loop through all errors (the main WP_Error, the update result, the rollback result) for code, data, etc.
|
||||
*/
|
||||
if ( 'rollback_was_required' === $result->get_error_code() ) {
|
||||
$errors = array( $result, $result->get_error_data()->update, $result->get_error_data()->rollback );
|
||||
} else {
|
||||
@@ -965,7 +978,7 @@ class WP_Automatic_Updater {
|
||||
|
||||
|
||||
/**
|
||||
* If we tried to perform plugin or theme updates, check if we should send an email.
|
||||
* Checks whether an email should be sent after attempting plugin or theme updates.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*
|
||||
|
||||
@@ -140,16 +140,17 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status,
|
||||
'search' => $search,
|
||||
'user_id' => $user_id,
|
||||
'offset' => $start,
|
||||
'number' => $number,
|
||||
'post_id' => $post_id,
|
||||
'type' => $comment_type,
|
||||
'orderby' => $orderby,
|
||||
'order' => $order,
|
||||
'post_type' => $post_type,
|
||||
'status' => isset( $status_map[ $comment_status ] ) ? $status_map[ $comment_status ] : $comment_status,
|
||||
'search' => $search,
|
||||
'user_id' => $user_id,
|
||||
'offset' => $start,
|
||||
'number' => $number,
|
||||
'post_id' => $post_id,
|
||||
'type' => $comment_type,
|
||||
'orderby' => $orderby,
|
||||
'order' => $order,
|
||||
'post_type' => $post_type,
|
||||
'update_comment_post_cache' => true,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -164,8 +165,6 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
$_comments = get_comments( $args );
|
||||
|
||||
if ( is_array( $_comments ) ) {
|
||||
update_comment_cache( $_comments );
|
||||
|
||||
$this->items = array_slice( $_comments, 0, $comments_per_page );
|
||||
$this->extra_items = array_slice( $_comments, $comments_per_page );
|
||||
|
||||
@@ -457,7 +456,7 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
/**
|
||||
* @global int $post_id
|
||||
*
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
global $post_id;
|
||||
@@ -541,8 +540,8 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
return array(
|
||||
'author' => 'comment_author',
|
||||
'response' => 'comment_post_ID',
|
||||
'author' => array( 'comment_author', false, __( 'Author' ), __( 'Table ordered by Comment Author.' ) ),
|
||||
'response' => array( 'comment_post_ID', false, _x( 'In Response To', 'column name' ), __( 'Table ordered by Post Replied To.' ) ),
|
||||
'date' => 'comment_date',
|
||||
);
|
||||
}
|
||||
@@ -581,6 +580,17 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
?>
|
||||
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
|
||||
<?php
|
||||
if ( ! isset( $_GET['orderby'] ) ) {
|
||||
// In the initial view, Comments are ordered by comment's date but there's no column for that.
|
||||
echo '<caption class="screen-reader-text">' .
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'Ordered by Comment Date, descending.' ) .
|
||||
'</caption>';
|
||||
} else {
|
||||
$this->print_table_description();
|
||||
}
|
||||
?>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php $this->print_column_headers(); ?>
|
||||
@@ -885,11 +895,13 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
|
||||
if ( $this->user_can ) {
|
||||
?>
|
||||
<label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>">
|
||||
<label class="label-covers-full-cell" for="cb-select-<?php echo $comment->comment_ID; ?>">
|
||||
<span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'Select comment' );
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<input id="cb-select-<?php echo $comment->comment_ID; ?>" type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" />
|
||||
<?php
|
||||
|
||||
@@ -323,6 +323,11 @@ class WP_Debug_Data {
|
||||
'value' => $wp_environment_type,
|
||||
'debug' => $wp_environment_type,
|
||||
),
|
||||
'WP_DEVELOPMENT_MODE' => array(
|
||||
'label' => 'WP_DEVELOPMENT_MODE',
|
||||
'value' => WP_DEVELOPMENT_MODE ? WP_DEVELOPMENT_MODE : __( 'Disabled' ),
|
||||
'debug' => WP_DEVELOPMENT_MODE,
|
||||
),
|
||||
'DB_CHARSET' => array(
|
||||
'label' => 'DB_CHARSET',
|
||||
'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
|
||||
@@ -839,6 +844,21 @@ class WP_Debug_Data {
|
||||
);
|
||||
}
|
||||
|
||||
// Server time.
|
||||
$date = new DateTime( 'now', new DateTimeZone( 'UTC' ) );
|
||||
$info['wp-server']['fields']['current'] = array(
|
||||
'label' => __( 'Current time' ),
|
||||
'value' => $date->format( DateTime::ATOM ),
|
||||
);
|
||||
$info['wp-server']['fields']['utc-time'] = array(
|
||||
'label' => __( 'Current UTC time' ),
|
||||
'value' => $date->format( DateTime::RFC850 ),
|
||||
);
|
||||
$info['wp-server']['fields']['server-time'] = array(
|
||||
'label' => __( 'Current Server time' ),
|
||||
'value' => wp_date( 'c', $_SERVER['REQUEST_TIME'] ),
|
||||
);
|
||||
|
||||
// Populate the database debug fields.
|
||||
if ( is_resource( $wpdb->dbh ) ) {
|
||||
// Old mysql extension.
|
||||
@@ -1599,20 +1619,26 @@ class WP_Debug_Data {
|
||||
$max_execution_time = ini_get( 'max_execution_time' );
|
||||
}
|
||||
|
||||
// The max_execution_time defaults to 0 when PHP runs from cli.
|
||||
// We still want to limit it below.
|
||||
/*
|
||||
* The max_execution_time defaults to 0 when PHP runs from cli.
|
||||
* We still want to limit it below.
|
||||
*/
|
||||
if ( empty( $max_execution_time ) ) {
|
||||
$max_execution_time = 30; // 30 seconds.
|
||||
}
|
||||
|
||||
if ( $max_execution_time > 20 ) {
|
||||
// If the max_execution_time is set to lower than 20 seconds, reduce it a bit to prevent
|
||||
// edge-case timeouts that may happen after the size loop has finished running.
|
||||
/*
|
||||
* If the max_execution_time is set to lower than 20 seconds, reduce it a bit to prevent
|
||||
* edge-case timeouts that may happen after the size loop has finished running.
|
||||
*/
|
||||
$max_execution_time -= 2;
|
||||
}
|
||||
|
||||
// Go through the various installation directories and calculate their sizes.
|
||||
// No trailing slashes.
|
||||
/*
|
||||
* Go through the various installation directories and calculate their sizes.
|
||||
* No trailing slashes.
|
||||
*/
|
||||
$paths = array(
|
||||
'wordpress_size' => untrailingslashit( ABSPATH ),
|
||||
'themes_size' => get_theme_root(),
|
||||
|
||||
@@ -57,8 +57,10 @@ class WP_Filesystem_Base {
|
||||
public function abspath() {
|
||||
$folder = $this->find_folder( ABSPATH );
|
||||
|
||||
// Perhaps the FTP folder is rooted at the WordPress install.
|
||||
// Check for wp-includes folder in root. Could have some false positives, but rare.
|
||||
/*
|
||||
* Perhaps the FTP folder is rooted at the WordPress install.
|
||||
* Check for wp-includes folder in root. Could have some false positives, but rare.
|
||||
*/
|
||||
if ( ! $folder && $this->is_dir( '/' . WPINC ) ) {
|
||||
$folder = '/';
|
||||
}
|
||||
@@ -305,8 +307,10 @@ class WP_Filesystem_Base {
|
||||
}
|
||||
}
|
||||
|
||||
// Only check this as a last resort, to prevent locating the incorrect install.
|
||||
// All above procedures will fail quickly if this is the right branch to take.
|
||||
/*
|
||||
* Only check this as a last resort, to prevent locating the incorrect install.
|
||||
* All above procedures will fail quickly if this is the right branch to take.
|
||||
*/
|
||||
if ( isset( $files[ $last_path ] ) ) {
|
||||
if ( $this->verbose ) {
|
||||
/* translators: %s: Directory name. */
|
||||
@@ -316,14 +320,18 @@ class WP_Filesystem_Base {
|
||||
return trailingslashit( $base . $last_path );
|
||||
}
|
||||
|
||||
// Prevent this function from looping again.
|
||||
// No need to proceed if we've just searched in `/`.
|
||||
/*
|
||||
* Prevent this function from looping again.
|
||||
* No need to proceed if we've just searched in `/`.
|
||||
*/
|
||||
if ( $loop || '/' === $base ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// As an extra last resort, Change back to / if the folder wasn't found.
|
||||
// This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
|
||||
/*
|
||||
* As an extra last resort, Change back to / if the folder wasn't found.
|
||||
* This comes into effect when the CWD is /home/user/ but WP is at /var/www/....
|
||||
*/
|
||||
return $this->search_for_folder( $folder, '/', true );
|
||||
|
||||
}
|
||||
@@ -398,7 +406,7 @@ class WP_Filesystem_Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts *nix-style file permissions to a octal number.
|
||||
* Converts *nix-style file permissions to an octal number.
|
||||
*
|
||||
* Converts '-rw-r--r--' to 0644
|
||||
* From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
|
||||
@@ -827,18 +835,28 @@ class WP_Filesystem_Base {
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
* Array of arrays containing file information. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type string $owner Owner name or ID.
|
||||
* @type int $size Size of file in bytes.
|
||||
* @type int $lastmodunix Last modified unix timestamp.
|
||||
* @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
|
||||
* @type int $time Last modified time.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* @type mixed $files If a directory and `$recursive` is true, contains another array of files.
|
||||
* @type array $0... {
|
||||
* Array of file information. Note that some elements may not be available on all filesystems.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type int|string|false $number File number. May be a numeric string. False if not available.
|
||||
* @type string|false $owner Owner name or ID, or false if not available.
|
||||
* @type string|false $group File permissions group, or false if not available.
|
||||
* @type int|string|false $size Size of file in bytes. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type int|string|false $lastmodunix Last modified unix timestamp. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type string|false $lastmod Last modified month (3 letters) and day (without leading 0), or
|
||||
* false if not available.
|
||||
* @type string|false $time Last modified time, or false if not available.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory, 'l' for link.
|
||||
* @type array|false $files If a directory and `$recursive` is true, contains another array of
|
||||
* files. False if unable to list directory contents.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
|
||||
|
||||
@@ -597,18 +597,28 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
* Array of arrays containing file information. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type string $owner Owner name or ID.
|
||||
* @type int $size Size of file in bytes.
|
||||
* @type int $lastmodunix Last modified unix timestamp.
|
||||
* @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
|
||||
* @type int $time Last modified time.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* @type mixed $files If a directory and `$recursive` is true, contains another array of files.
|
||||
* @type array $0... {
|
||||
* Array of file information. Note that some elements may not be available on all filesystems.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type false $number File number. Always false in this context.
|
||||
* @type string|false $owner Owner name or ID, or false if not available.
|
||||
* @type string|false $group File permissions group, or false if not available.
|
||||
* @type int|string|false $size Size of file in bytes. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type int|string|false $lastmodunix Last modified unix timestamp. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type string|false $lastmod Last modified month (3 letters) and day (without leading 0), or
|
||||
* false if not available.
|
||||
* @type string|false $time Last modified time, or false if not available.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory, 'l' for link.
|
||||
* @type array|false $files If a directory and `$recursive` is true, contains another array of
|
||||
* files. False if unable to list directory contents.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
|
||||
|
||||
@@ -419,11 +419,22 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 6.3.0 Returns false for an empty path.
|
||||
*
|
||||
* @param string $path Path to file or directory.
|
||||
* @return bool Whether $path exists or not.
|
||||
*/
|
||||
public function exists( $path ) {
|
||||
/*
|
||||
* Check for empty path. If ftp_nlist() receives an empty path,
|
||||
* it checks the current working directory and may return true.
|
||||
*
|
||||
* See https://core.trac.wordpress.org/ticket/33058.
|
||||
*/
|
||||
if ( '' === $path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$list = ftp_nlist( $this->link, $path );
|
||||
|
||||
if ( empty( $list ) && $this->is_dir( $path ) ) {
|
||||
@@ -591,7 +602,24 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
|
||||
/**
|
||||
* @param string $line
|
||||
* @return array
|
||||
* @return array {
|
||||
* Array of file information.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type string|false $number File number as a string, or false if not available.
|
||||
* @type string|false $owner Owner name or ID, or false if not available.
|
||||
* @type string|false $group File permissions group, or false if not available.
|
||||
* @type string|false $size Size of file in bytes as a string, or false if not available.
|
||||
* @type string|false $lastmodunix Last modified unix timestamp as a string, or false if not available.
|
||||
* @type string|false $lastmod Last modified month (3 letters) and day (without leading 0), or
|
||||
* false if not available.
|
||||
* @type string|false $time Last modified time, or false if not available.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory, 'l' for link.
|
||||
* @type array|false $files If a directory and `$recursive` is true, contains another array of files.
|
||||
* False if unable to list directory contents.
|
||||
* }
|
||||
*/
|
||||
public function parselisting( $line ) {
|
||||
static $is_windows = null;
|
||||
@@ -701,18 +729,28 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
* Array of arrays containing file information. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type string $owner Owner name or ID.
|
||||
* @type int $size Size of file in bytes.
|
||||
* @type int $lastmodunix Last modified unix timestamp.
|
||||
* @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
|
||||
* @type int $time Last modified time.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* @type mixed $files If a directory and `$recursive` is true, contains another array of files.
|
||||
* @type array $0... {
|
||||
* Array of file information. Note that some elements may not be available on all filesystems.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type int|string|false $number File number. May be a numeric string. False if not available.
|
||||
* @type string|false $owner Owner name or ID, or false if not available.
|
||||
* @type string|false $group File permissions group, or false if not available.
|
||||
* @type int|string|false $size Size of file in bytes. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type int|string|false $lastmodunix Last modified unix timestamp. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type string|false $lastmod Last modified month (3 letters) and day (without leading 0), or
|
||||
* false if not available.
|
||||
* @type string|false $time Last modified time, or false if not available.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory, 'l' for link.
|
||||
* @type array|false $files If a directory and `$recursive` is true, contains another array of
|
||||
* files. False if unable to list directory contents.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
|
||||
|
||||
@@ -33,7 +33,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
$this->errors = new WP_Error();
|
||||
|
||||
// Check if possible to use ftp functions.
|
||||
if ( ! include_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) {
|
||||
if ( ! require_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -421,11 +421,22 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
* Checks if a file or directory exists.
|
||||
*
|
||||
* @since 2.5.0
|
||||
* @since 6.3.0 Returns false for an empty path.
|
||||
*
|
||||
* @param string $path Path to file or directory.
|
||||
* @return bool Whether $path exists or not.
|
||||
*/
|
||||
public function exists( $path ) {
|
||||
/*
|
||||
* Check for empty path. If ftp::nlist() receives an empty path,
|
||||
* it checks the current working directory and may return true.
|
||||
*
|
||||
* See https://core.trac.wordpress.org/ticket/33058.
|
||||
*/
|
||||
if ( '' === $path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$list = $this->ftp->nlist( $path );
|
||||
|
||||
if ( empty( $list ) && $this->is_dir( $path ) ) {
|
||||
@@ -612,18 +623,28 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
* Array of arrays containing file information. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type string $owner Owner name or ID.
|
||||
* @type int $size Size of file in bytes.
|
||||
* @type int $lastmodunix Last modified unix timestamp.
|
||||
* @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
|
||||
* @type int $time Last modified time.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* @type mixed $files If a directory and `$recursive` is true, contains another array of files.
|
||||
* @type array $0... {
|
||||
* Array of file information. Note that some elements may not be available on all filesystems.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type int|string|false $number File number. May be a numeric string. False if not available.
|
||||
* @type string|false $owner Owner name or ID, or false if not available.
|
||||
* @type string|false $group File permissions group, or false if not available.
|
||||
* @type int|string|false $size Size of file in bytes. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type int|string|false $lastmodunix Last modified unix timestamp. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type string|false $lastmod Last modified month (3 letters) and day (without leading 0), or
|
||||
* false if not available.
|
||||
* @type string|false $time Last modified time, or false if not available.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory, 'l' for link.
|
||||
* @type array|false $files If a directory and `$recursive` is true, contains another array of
|
||||
* files. False if unable to list directory contents.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
|
||||
|
||||
@@ -103,6 +103,8 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
// Password can be blank if we are using keys.
|
||||
if ( ! $this->keys ) {
|
||||
$this->errors->add( 'empty_password', __( 'SSH2 password is required' ) );
|
||||
} else {
|
||||
$this->options['password'] = null;
|
||||
}
|
||||
} else {
|
||||
$this->options['password'] = $opt['password'];
|
||||
@@ -741,18 +743,28 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
|
||||
* @param bool $recursive Optional. Whether to recursively include file details in nested directories.
|
||||
* Default false.
|
||||
* @return array|false {
|
||||
* Array of files. False if unable to list directory contents.
|
||||
* Array of arrays containing file information. False if unable to list directory contents.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type string $owner Owner name or ID.
|
||||
* @type int $size Size of file in bytes.
|
||||
* @type int $lastmodunix Last modified unix timestamp.
|
||||
* @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
|
||||
* @type int $time Last modified time.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory.
|
||||
* @type mixed $files If a directory and `$recursive` is true, contains another array of files.
|
||||
* @type array $0... {
|
||||
* Array of file information. Note that some elements may not be available on all filesystems.
|
||||
*
|
||||
* @type string $name Name of the file or directory.
|
||||
* @type string $perms *nix representation of permissions.
|
||||
* @type string $permsn Octal representation of permissions.
|
||||
* @type false $number File number. Always false in this context.
|
||||
* @type string|false $owner Owner name or ID, or false if not available.
|
||||
* @type string|false $group File permissions group, or false if not available.
|
||||
* @type int|string|false $size Size of file in bytes. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type int|string|false $lastmodunix Last modified unix timestamp. May be a numeric string.
|
||||
* False if not available.
|
||||
* @type string|false $lastmod Last modified month (3 letters) and day (without leading 0), or
|
||||
* false if not available.
|
||||
* @type string|false $time Last modified time, or false if not available.
|
||||
* @type string $type Type of resource. 'f' for file, 'd' for directory, 'l' for link.
|
||||
* @type array|false $files If a directory and `$recursive` is true, contains another array of
|
||||
* files. False if unable to list directory contents.
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
|
||||
|
||||
@@ -41,7 +41,7 @@ class WP_Importer {
|
||||
$hashtable[ $r->meta_value ] = (int) $r->post_id;
|
||||
}
|
||||
}
|
||||
} while ( count( $results ) == $limit );
|
||||
} while ( count( $results ) === $limit );
|
||||
|
||||
return $hashtable;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class WP_Importer {
|
||||
}
|
||||
}
|
||||
}
|
||||
} while ( count( $results ) == $limit );
|
||||
} while ( count( $results ) === $limit );
|
||||
|
||||
return $hashtable;
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class WP_Importer {
|
||||
}
|
||||
|
||||
/**
|
||||
* GET URL
|
||||
* Gets URL.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $username
|
||||
|
||||
@@ -104,7 +104,7 @@ final class WP_Internal_Pointers {
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the pointer JavaScript data.
|
||||
* Prints the pointer JavaScript data.
|
||||
*
|
||||
* @since 3.3.0
|
||||
*
|
||||
|
||||
@@ -124,7 +124,7 @@ class WP_Links_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
return array(
|
||||
@@ -143,15 +143,15 @@ class WP_Links_List_Table extends WP_List_Table {
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
return array(
|
||||
'name' => 'name',
|
||||
'url' => 'url',
|
||||
'visible' => 'visible',
|
||||
'rating' => 'rating',
|
||||
'name' => array( 'name', false, _x( 'Name', 'link name' ), __( 'Table ordered by Name.' ), 'asc' ),
|
||||
'url' => array( 'url', false, __( 'URL' ), __( 'Table ordered by URL.' ) ),
|
||||
'visible' => array( 'visible', false, __( 'Visible' ), __( 'Table ordered by Visibility.' ) ),
|
||||
'rating' => array( 'rating', false, __( 'Rating' ), __( 'Table ordered by Rating.' ) ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the default primary column.
|
||||
* Gets the name of the default primary column.
|
||||
*
|
||||
* @since 4.3.0
|
||||
*
|
||||
@@ -174,11 +174,13 @@ class WP_Links_List_Table extends WP_List_Table {
|
||||
$link = $item;
|
||||
|
||||
?>
|
||||
<label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>">
|
||||
<label class="label-covers-full-cell" for="cb-select-<?php echo $link->link_id; ?>">
|
||||
<span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. %s: Link name. */
|
||||
printf( __( 'Select %s' ), $link->link_name );
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" />
|
||||
<?php
|
||||
|
||||
@@ -173,7 +173,7 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Make private properties readable for backward compatibility.
|
||||
* Makes private properties readable for backward compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
@@ -187,7 +187,7 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Make private properties settable for backward compatibility.
|
||||
* Makes private properties settable for backward compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
@@ -202,7 +202,7 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Make private properties checkable for backward compatibility.
|
||||
* Makes private properties checkable for backward compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
@@ -218,7 +218,7 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Make private properties un-settable for backward compatibility.
|
||||
* Makes private properties un-settable for backward compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
@@ -231,7 +231,7 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Make private/protected methods readable for backward compatibility.
|
||||
* Makes private/protected methods readable for backward compatibility.
|
||||
*
|
||||
* @since 4.0.0
|
||||
*
|
||||
@@ -269,7 +269,7 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* An internal method that sets all the necessary pagination arguments
|
||||
* Sets all the necessary pagination arguments.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -320,7 +320,7 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the table has items to display or not
|
||||
* Determines whether the table has items to display or not
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -698,13 +698,11 @@ class WP_List_Table {
|
||||
|
||||
$months = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"
|
||||
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
$extra_checks
|
||||
ORDER BY post_date DESC
|
||||
",
|
||||
"SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
|
||||
FROM $wpdb->posts
|
||||
WHERE post_type = %s
|
||||
$extra_checks
|
||||
ORDER BY post_date DESC",
|
||||
$post_type
|
||||
)
|
||||
);
|
||||
@@ -775,7 +773,9 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
printf(
|
||||
"<a href='%s' class='%s' id='view-switch-$mode'$aria_current><span class='screen-reader-text'>%s</span></a>\n",
|
||||
"<a href='%s' class='%s' id='view-switch-$mode'$aria_current>" .
|
||||
"<span class='screen-reader-text'>%s</span>" .
|
||||
"</a>\n",
|
||||
esc_url( remove_query_arg( 'attachment-filter', add_query_arg( 'mode', $mode ) ) ),
|
||||
implode( ' ', $classes ),
|
||||
$title
|
||||
@@ -821,20 +821,27 @@ class WP_List_Table {
|
||||
if ( ! $approved_comments && ! $pending_comments ) {
|
||||
// No comments at all.
|
||||
printf(
|
||||
'<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
|
||||
'<span aria-hidden="true">—</span>' .
|
||||
'<span class="screen-reader-text">%s</span>',
|
||||
__( 'No comments' )
|
||||
);
|
||||
} elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) {
|
||||
// Don't link the comment bubble for a trashed post.
|
||||
printf(
|
||||
'<span class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
|
||||
'<span class="post-com-count post-com-count-approved">' .
|
||||
'<span class="comment-count-approved" aria-hidden="true">%s</span>' .
|
||||
'<span class="screen-reader-text">%s</span>' .
|
||||
'</span>',
|
||||
$approved_comments_number,
|
||||
$pending_comments ? $approved_phrase : $approved_only_phrase
|
||||
);
|
||||
} elseif ( $approved_comments ) {
|
||||
// Link the comment bubble to approved comments.
|
||||
printf(
|
||||
'<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
|
||||
'<a href="%s" class="post-com-count post-com-count-approved">' .
|
||||
'<span class="comment-count-approved" aria-hidden="true">%s</span>' .
|
||||
'<span class="screen-reader-text">%s</span>' .
|
||||
'</a>',
|
||||
esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
@@ -850,7 +857,10 @@ class WP_List_Table {
|
||||
} else {
|
||||
// Don't link the comment bubble when there are no approved comments.
|
||||
printf(
|
||||
'<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
|
||||
'<span class="post-com-count post-com-count-no-comments">' .
|
||||
'<span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span>' .
|
||||
'<span class="screen-reader-text">%s</span>' .
|
||||
'</span>',
|
||||
$approved_comments_number,
|
||||
$pending_comments ?
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -862,7 +872,10 @@ class WP_List_Table {
|
||||
|
||||
if ( $pending_comments ) {
|
||||
printf(
|
||||
'<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>',
|
||||
'<a href="%s" class="post-com-count post-com-count-pending">' .
|
||||
'<span class="comment-count-pending" aria-hidden="true">%s</span>' .
|
||||
'<span class="screen-reader-text">%s</span>' .
|
||||
'</a>',
|
||||
esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
@@ -877,7 +890,10 @@ class WP_List_Table {
|
||||
);
|
||||
} else {
|
||||
printf(
|
||||
'<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>',
|
||||
'<span class="post-com-count post-com-count-pending post-com-count-no-pending">' .
|
||||
'<span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span>' .
|
||||
'<span class="screen-reader-text">%s</span>' .
|
||||
'</span>',
|
||||
$pending_comments_number,
|
||||
$approved_comments ?
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -1006,7 +1022,10 @@ class WP_List_Table {
|
||||
$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">«</span>';
|
||||
} else {
|
||||
$page_links[] = sprintf(
|
||||
"<a class='first-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
|
||||
"<a class='first-page button' href='%s'>" .
|
||||
"<span class='screen-reader-text'>%s</span>" .
|
||||
"<span aria-hidden='true'>%s</span>" .
|
||||
'</a>',
|
||||
esc_url( remove_query_arg( 'paged', $current_url ) ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'First page' ),
|
||||
@@ -1018,7 +1037,10 @@ class WP_List_Table {
|
||||
$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">‹</span>';
|
||||
} else {
|
||||
$page_links[] = sprintf(
|
||||
"<a class='prev-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
|
||||
"<a class='prev-page button' href='%s'>" .
|
||||
"<span class='screen-reader-text'>%s</span>" .
|
||||
"<span aria-hidden='true'>%s</span>" .
|
||||
'</a>',
|
||||
esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'Previous page' ),
|
||||
@@ -1028,23 +1050,29 @@ class WP_List_Table {
|
||||
|
||||
if ( 'bottom' === $which ) {
|
||||
$html_current_page = $current;
|
||||
$total_pages_before = '<span class="screen-reader-text">' .
|
||||
$total_pages_before = sprintf(
|
||||
'<span class="screen-reader-text">%s</span>' .
|
||||
'<span id="table-paging" class="paging-input">' .
|
||||
'<span class="tablenav-paging-text">',
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'Current Page' ) .
|
||||
'</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">';
|
||||
__( 'Current Page' )
|
||||
);
|
||||
} else {
|
||||
$html_current_page = sprintf(
|
||||
"%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>",
|
||||
'<label for="current-page-selector" class="screen-reader-text">' .
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'Current Page' ) .
|
||||
'</label>',
|
||||
'<label for="current-page-selector" class="screen-reader-text">%s</label>' .
|
||||
"<input class='current-page' id='current-page-selector' type='text'
|
||||
name='paged' value='%s' size='%d' aria-describedby='table-paging' />" .
|
||||
"<span class='tablenav-paging-text'>",
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'Current Page' ),
|
||||
$current,
|
||||
strlen( $total_pages )
|
||||
);
|
||||
}
|
||||
|
||||
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
||||
$page_links[] = $total_pages_before . sprintf(
|
||||
|
||||
$page_links[] = $total_pages_before . sprintf(
|
||||
/* translators: 1: Current page, 2: Total pages. */
|
||||
_x( '%1$s of %2$s', 'paging' ),
|
||||
$html_current_page,
|
||||
@@ -1055,7 +1083,10 @@ class WP_List_Table {
|
||||
$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">›</span>';
|
||||
} else {
|
||||
$page_links[] = sprintf(
|
||||
"<a class='next-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
|
||||
"<a class='next-page button' href='%s'>" .
|
||||
"<span class='screen-reader-text'>%s</span>" .
|
||||
"<span aria-hidden='true'>%s</span>" .
|
||||
'</a>',
|
||||
esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'Next page' ),
|
||||
@@ -1067,7 +1098,10 @@ class WP_List_Table {
|
||||
$page_links[] = '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">»</span>';
|
||||
} else {
|
||||
$page_links[] = sprintf(
|
||||
"<a class='last-page button' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>",
|
||||
"<a class='last-page button' href='%s'>" .
|
||||
"<span class='screen-reader-text'>%s</span>" .
|
||||
"<span aria-hidden='true'>%s</span>" .
|
||||
'</a>',
|
||||
esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'Last page' ),
|
||||
@@ -1111,10 +1145,17 @@ class WP_List_Table {
|
||||
*
|
||||
* The format is:
|
||||
* - `'internal-name' => 'orderby'`
|
||||
* - `'internal-name' => array( 'orderby', bool, 'abbr', 'orderby-text', 'initially-sorted-column-order' )` -
|
||||
* - `'internal-name' => array( 'orderby', 'asc' )` - The second element sets the initial sorting order.
|
||||
* - `'internal-name' => array( 'orderby', true )` - The second element makes the initial order descending.
|
||||
*
|
||||
* In the second format, passing true as second parameter will make the initial
|
||||
* sorting order be descending. Following parameters add a short column name to
|
||||
* be used as 'abbr' attribute, a translatable string for the current sorting,
|
||||
* and the initial order for the initial sorted column, 'asc' or 'desc' (default: false).
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @since 6.3.0 Added 'abbr', 'orderby-text' and 'initially-sorted-column-order'.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -1137,8 +1178,10 @@ class WP_List_Table {
|
||||
return $column;
|
||||
}
|
||||
|
||||
// We need a primary defined so responsive views show something,
|
||||
// so let's fall back to the first non-checkbox column.
|
||||
/*
|
||||
* We need a primary defined so responsive views show something,
|
||||
* so let's fall back to the first non-checkbox column.
|
||||
*/
|
||||
foreach ( $columns as $col => $column_name ) {
|
||||
if ( 'cb' === $col ) {
|
||||
continue;
|
||||
@@ -1152,6 +1195,8 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the primary column.
|
||||
*
|
||||
* Public wrapper for WP_List_Table::get_default_primary_column_name().
|
||||
*
|
||||
* @since 4.4.0
|
||||
@@ -1173,8 +1218,10 @@ class WP_List_Table {
|
||||
$columns = get_column_headers( $this->screen );
|
||||
$default = $this->get_default_primary_column_name();
|
||||
|
||||
// If the primary column doesn't exist,
|
||||
// fall back to the first non-checkbox column.
|
||||
/*
|
||||
* If the primary column doesn't exist,
|
||||
* fall back to the first non-checkbox column.
|
||||
*/
|
||||
if ( ! isset( $columns[ $default ] ) ) {
|
||||
$default = self::get_default_primary_column_name();
|
||||
}
|
||||
@@ -1253,9 +1300,22 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
$data = (array) $data;
|
||||
// Descending initial sorting.
|
||||
if ( ! isset( $data[1] ) ) {
|
||||
$data[1] = false;
|
||||
}
|
||||
// Current sorting translatable string.
|
||||
if ( ! isset( $data[2] ) ) {
|
||||
$data[2] = '';
|
||||
}
|
||||
// Initial view sorted column and asc/desc order, default: false.
|
||||
if ( ! isset( $data[3] ) ) {
|
||||
$data[3] = false;
|
||||
}
|
||||
// Initial order for the initial sorted column, default: false.
|
||||
if ( ! isset( $data[4] ) ) {
|
||||
$data[4] = false;
|
||||
}
|
||||
|
||||
$sortable[ $id ] = $data;
|
||||
}
|
||||
@@ -1292,30 +1352,39 @@ class WP_List_Table {
|
||||
$current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
|
||||
$current_url = remove_query_arg( 'paged', $current_url );
|
||||
|
||||
// When users click on a column header to sort by other columns.
|
||||
if ( isset( $_GET['orderby'] ) ) {
|
||||
$current_orderby = $_GET['orderby'];
|
||||
// In the initial view there's no orderby parameter.
|
||||
} else {
|
||||
$current_orderby = '';
|
||||
}
|
||||
|
||||
// Not in the initial view and descending order.
|
||||
if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
|
||||
$current_order = 'desc';
|
||||
} else {
|
||||
// The initial view is not always 'asc', we'll take care of this below.
|
||||
$current_order = 'asc';
|
||||
}
|
||||
|
||||
if ( ! empty( $columns['cb'] ) ) {
|
||||
static $cb_counter = 1;
|
||||
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' .
|
||||
$columns['cb'] = '<label class="label-covers-full-cell" 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++;
|
||||
}
|
||||
|
||||
foreach ( $columns as $column_key => $column_display_name ) {
|
||||
$class = array( 'manage-column', "column-$column_key" );
|
||||
$class = array( 'manage-column', "column-$column_key" );
|
||||
$aria_sort_attr = '';
|
||||
$abbr_attr = '';
|
||||
$order_text = '';
|
||||
|
||||
if ( in_array( $column_key, $hidden, true ) ) {
|
||||
$class[] = 'hidden';
|
||||
@@ -1332,14 +1401,41 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
if ( isset( $sortable[ $column_key ] ) ) {
|
||||
list( $orderby, $desc_first ) = $sortable[ $column_key ];
|
||||
$orderby = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : '';
|
||||
$desc_first = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false;
|
||||
$abbr = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : '';
|
||||
$orderby_text = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : '';
|
||||
$initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : '';
|
||||
|
||||
/*
|
||||
* We're in the initial view and there's no $_GET['orderby'] then check if the
|
||||
* initial sorting information is set in the sortable columns and use that.
|
||||
*/
|
||||
if ( '' === $current_orderby && $initial_order ) {
|
||||
// Use the initially sorted column $orderby as current orderby.
|
||||
$current_orderby = $orderby;
|
||||
// Use the initially sorted column asc/desc order as initial order.
|
||||
$current_order = $initial_order;
|
||||
}
|
||||
|
||||
/*
|
||||
* True in the initial view when an initial orderby is set via get_sortable_columns()
|
||||
* and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby.
|
||||
*/
|
||||
if ( $current_orderby === $orderby ) {
|
||||
$order = 'asc' === $current_order ? 'desc' : 'asc';
|
||||
// The sorted column. The `aria-sort` attribute must be set only on the sorted column.
|
||||
if ( 'asc' === $current_order ) {
|
||||
$order = 'desc';
|
||||
$aria_sort_attr = ' aria-sort="ascending"';
|
||||
} else {
|
||||
$order = 'asc';
|
||||
$aria_sort_attr = ' aria-sort="descending"';
|
||||
}
|
||||
|
||||
$class[] = 'sorted';
|
||||
$class[] = $current_order;
|
||||
} else {
|
||||
// The other sortable columns.
|
||||
$order = strtolower( $desc_first );
|
||||
|
||||
if ( ! in_array( $order, array( 'desc', 'asc' ), true ) ) {
|
||||
@@ -1348,12 +1444,33 @@ class WP_List_Table {
|
||||
|
||||
$class[] = 'sortable';
|
||||
$class[] = 'desc' === $order ? 'asc' : 'desc';
|
||||
|
||||
/* translators: Hidden accessibility text. */
|
||||
$asc_text = __( 'Sort ascending.' );
|
||||
/* translators: Hidden accessibility text. */
|
||||
$desc_text = __( 'Sort descending.' );
|
||||
$order_text = 'asc' === $order ? $asc_text : $desc_text;
|
||||
}
|
||||
|
||||
if ( '' !== $order_text ) {
|
||||
$order_text = ' <span class="screen-reader-text">' . $order_text . '</span>';
|
||||
}
|
||||
|
||||
// Print an 'abbr' attribute if a value is provided via get_sortable_columns().
|
||||
$abbr_attr = $abbr ? ' abbr="' . esc_attr( $abbr ) . '"' : '';
|
||||
|
||||
$column_display_name = sprintf(
|
||||
'<a href="%s"><span>%s</span><span class="sorting-indicator"></span></a>',
|
||||
'<a href="%1$s">' .
|
||||
'<span>%2$s</span>' .
|
||||
'<span class="sorting-indicators">' .
|
||||
'<span class="sorting-indicator asc" aria-hidden="true"></span>' .
|
||||
'<span class="sorting-indicator desc" aria-hidden="true"></span>' .
|
||||
'</span>' .
|
||||
'%3$s' .
|
||||
'</a>',
|
||||
esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ),
|
||||
$column_display_name
|
||||
$column_display_name,
|
||||
$order_text
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1365,7 +1482,80 @@ class WP_List_Table {
|
||||
$class = "class='" . implode( ' ', $class ) . "'";
|
||||
}
|
||||
|
||||
echo "<$tag $scope $id $class>$column_display_name</$tag>";
|
||||
echo "<$tag $scope $id $class $aria_sort_attr $abbr_attr>$column_display_name</$tag>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a table description with information about current sorting and order.
|
||||
*
|
||||
* For the table initial view, information about initial orderby and order
|
||||
* should be provided via get_sortable_columns().
|
||||
*
|
||||
* @since 6.3.0
|
||||
* @access public
|
||||
*/
|
||||
public function print_table_description() {
|
||||
list( $columns, $hidden, $sortable ) = $this->get_column_info();
|
||||
|
||||
if ( empty( $sortable ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// When users click on a column header to sort by other columns.
|
||||
if ( isset( $_GET['orderby'] ) ) {
|
||||
$current_orderby = $_GET['orderby'];
|
||||
// In the initial view there's no orderby parameter.
|
||||
} else {
|
||||
$current_orderby = '';
|
||||
}
|
||||
|
||||
// Not in the initial view and descending order.
|
||||
if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) {
|
||||
$current_order = 'desc';
|
||||
} else {
|
||||
// The initial view is not always 'asc', we'll take care of this below.
|
||||
$current_order = 'asc';
|
||||
}
|
||||
|
||||
foreach ( array_keys( $columns ) as $column_key ) {
|
||||
|
||||
if ( isset( $sortable[ $column_key ] ) ) {
|
||||
$orderby = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : '';
|
||||
$desc_first = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false;
|
||||
$abbr = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : '';
|
||||
$orderby_text = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : '';
|
||||
$initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : '';
|
||||
|
||||
if ( ! is_string( $orderby_text ) || '' === $orderby_text ) {
|
||||
return;
|
||||
}
|
||||
/*
|
||||
* We're in the initial view and there's no $_GET['orderby'] then check if the
|
||||
* initial sorting information is set in the sortable columns and use that.
|
||||
*/
|
||||
if ( '' === $current_orderby && $initial_order ) {
|
||||
// Use the initially sorted column $orderby as current orderby.
|
||||
$current_orderby = $orderby;
|
||||
// Use the initially sorted column asc/desc order as initial order.
|
||||
$current_order = $initial_order;
|
||||
}
|
||||
|
||||
/*
|
||||
* True in the initial view when an initial orderby is set via get_sortable_columns()
|
||||
* and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby.
|
||||
*/
|
||||
if ( $current_orderby === $orderby ) {
|
||||
/* translators: Hidden accessibility text. */
|
||||
$asc_text = __( 'Ascending.' );
|
||||
/* translators: Hidden accessibility text. */
|
||||
$desc_text = __( 'Descending.' );
|
||||
$order_text = 'asc' === $current_order ? $asc_text : $desc_text;
|
||||
echo '<caption class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</caption>';
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1382,6 +1572,7 @@ class WP_List_Table {
|
||||
$this->screen->render_screen_reader_content( 'heading_list' );
|
||||
?>
|
||||
<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
|
||||
<?php $this->print_table_description(); ?>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php $this->print_column_headers(); ?>
|
||||
@@ -1453,7 +1644,7 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra controls to be displayed between bulk actions and pagination.
|
||||
* Displays extra controls between bulk actions and pagination.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -1531,8 +1722,10 @@ class WP_List_Table {
|
||||
$classes .= ' hidden';
|
||||
}
|
||||
|
||||
// Comments column uses HTML in the display name with screen reader text.
|
||||
// Strip tags to get closer to a user-friendly string.
|
||||
/*
|
||||
* Comments column uses HTML in the display name with screen reader text.
|
||||
* Strip tags to get closer to a user-friendly string.
|
||||
*/
|
||||
$data = 'data-colname="' . esc_attr( wp_strip_all_tags( $column_display_name ) ) . '"';
|
||||
|
||||
$attributes = "class='$classes' $data";
|
||||
|
||||
@@ -140,7 +140,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
$selected = selected(
|
||||
$filter && 0 === strpos( $filter, 'post_mime_type:' ) &&
|
||||
$filter && str_starts_with( $filter, 'post_mime_type:' ) &&
|
||||
wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $filter ) ),
|
||||
true,
|
||||
false
|
||||
@@ -263,7 +263,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Override parent views so we can use the filter bar display.
|
||||
* Overrides parent views to use the filter bar display.
|
||||
*
|
||||
* @global string $mode List table view mode.
|
||||
*/
|
||||
@@ -312,15 +312,23 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
</div>
|
||||
|
||||
<div class="search-form">
|
||||
<label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label>
|
||||
<input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>">
|
||||
<p class="search-box">
|
||||
<label class="screen-reader-text" for="media-search-input">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
esc_html_e( 'Search Media' );
|
||||
?>
|
||||
</label>
|
||||
<input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>">
|
||||
<input id="search-submit" type="submit" class="button" value="<?php esc_attr_e( 'Search Media' ); ?>">
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
$posts_columns = array();
|
||||
@@ -389,11 +397,11 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
return array(
|
||||
'title' => 'title',
|
||||
'author' => 'author',
|
||||
'parent' => 'parent',
|
||||
'comments' => 'comment_count',
|
||||
'date' => array( 'date', true ),
|
||||
'title' => array( 'title', false, _x( 'File', 'column name' ), __( 'Table ordered by File Name.' ) ),
|
||||
'author' => array( 'author', false, __( 'Author' ), __( 'Table ordered by Author.' ) ),
|
||||
'parent' => array( 'parent', false, _x( 'Uploaded to', 'column name' ), __( 'Table ordered by Uploaded To.' ) ),
|
||||
'comments' => array( 'comment_count', __( 'Comments' ), false, __( 'Table ordered by Comments.' ) ),
|
||||
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -411,11 +419,13 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
|
||||
if ( current_user_can( 'edit_post', $post->ID ) ) {
|
||||
?>
|
||||
<label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>">
|
||||
<label class="label-covers-full-cell" for="cb-select-<?php echo $post->ID; ?>">
|
||||
<span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. %s: Attachment title. */
|
||||
printf( __( 'Select %s' ), _draft_or_post_title() );
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
|
||||
<?php
|
||||
@@ -652,7 +662,7 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
$taxonomy = 'category';
|
||||
} elseif ( 'tags' === $column_name ) {
|
||||
$taxonomy = 'post_tag';
|
||||
} elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
|
||||
} elseif ( str_starts_with( $column_name, 'taxonomy-' ) ) {
|
||||
$taxonomy = substr( $column_name, 9 );
|
||||
} else {
|
||||
$taxonomy = false;
|
||||
@@ -748,138 +758,104 @@ class WP_Media_List_Table extends WP_List_Table {
|
||||
private function _get_row_actions( $post, $att_title ) {
|
||||
$actions = array();
|
||||
|
||||
if ( $this->detached ) {
|
||||
if ( current_user_can( 'edit_post', $post->ID ) ) {
|
||||
$actions['edit'] = sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
get_edit_post_link( $post->ID ),
|
||||
if ( ! $this->is_trash && current_user_can( 'edit_post', $post->ID ) ) {
|
||||
$actions['edit'] = sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
esc_url( get_edit_post_link( $post->ID ) ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ),
|
||||
__( 'Edit' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( $this->is_trash ) {
|
||||
$actions['untrash'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
|
||||
esc_url( wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ) ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ),
|
||||
__( 'Edit' )
|
||||
esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ),
|
||||
__( 'Restore' )
|
||||
);
|
||||
} elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
|
||||
$actions['trash'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
|
||||
esc_url( wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ) ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ),
|
||||
_x( 'Trash', 'verb' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
|
||||
$actions['trash'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
|
||||
wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ),
|
||||
_x( 'Trash', 'verb' )
|
||||
);
|
||||
} else {
|
||||
$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
|
||||
$actions['delete'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>',
|
||||
wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ),
|
||||
$delete_ays,
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ),
|
||||
__( 'Delete Permanently' )
|
||||
);
|
||||
}
|
||||
}
|
||||
if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) {
|
||||
$show_confirmation = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
|
||||
|
||||
if ( get_permalink( $post->ID ) ) {
|
||||
$actions['delete'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>',
|
||||
esc_url( wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ) ),
|
||||
$show_confirmation,
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ),
|
||||
__( 'Delete Permanently' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$attachment_url = wp_get_attachment_url( $post->ID );
|
||||
|
||||
if ( ! $this->is_trash ) {
|
||||
$permalink = get_permalink( $post->ID );
|
||||
|
||||
if ( $permalink ) {
|
||||
$actions['view'] = sprintf(
|
||||
'<a href="%s" aria-label="%s" rel="bookmark">%s</a>',
|
||||
get_permalink( $post->ID ),
|
||||
esc_url( $permalink ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
|
||||
__( 'View' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( current_user_can( 'edit_post', $post->ID ) ) {
|
||||
$actions['attach'] = sprintf(
|
||||
'<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>',
|
||||
$post->ID,
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ),
|
||||
__( 'Attach' )
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
|
||||
$actions['edit'] = sprintf(
|
||||
'<a href="%s" aria-label="%s">%s</a>',
|
||||
get_edit_post_link( $post->ID ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ),
|
||||
__( 'Edit' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( $this->is_trash ) {
|
||||
$actions['untrash'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
|
||||
wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ),
|
||||
__( 'Restore' )
|
||||
);
|
||||
} elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
|
||||
$actions['trash'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
|
||||
wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ),
|
||||
_x( 'Trash', 'verb' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) {
|
||||
$delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
|
||||
$actions['delete'] = sprintf(
|
||||
'<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>',
|
||||
wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ),
|
||||
$delete_ays,
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ),
|
||||
__( 'Delete Permanently' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $this->is_trash ) {
|
||||
if ( get_permalink( $post->ID ) ) {
|
||||
$actions['view'] = sprintf(
|
||||
'<a href="%s" aria-label="%s" rel="bookmark">%s</a>',
|
||||
get_permalink( $post->ID ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
|
||||
__( 'View' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $attachment_url ) {
|
||||
$actions['copy'] = sprintf(
|
||||
'<span class="copy-to-clipboard-container"><button type="button" class="button-link copy-attachment-url media-library" data-clipboard-text="%s" aria-label="%s">%s</button><span class="success hidden" aria-hidden="true">%s</span></span>',
|
||||
esc_url( wp_get_attachment_url( $post->ID ) ),
|
||||
esc_url( $attachment_url ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ),
|
||||
__( 'Copy URL' ),
|
||||
__( 'Copied!' )
|
||||
);
|
||||
|
||||
$actions['download'] = sprintf(
|
||||
'<a href="%s" aria-label="%s" download>%s</a>',
|
||||
esc_url( wp_get_attachment_url( $post->ID ) ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ),
|
||||
__( 'Download file' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $attachment_url ) {
|
||||
$actions['download'] = sprintf(
|
||||
'<a href="%s" aria-label="%s" download>%s</a>',
|
||||
esc_url( $attachment_url ),
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ),
|
||||
__( 'Download file' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( $this->detached && current_user_can( 'edit_post', $post->ID ) ) {
|
||||
$actions['attach'] = sprintf(
|
||||
'<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>',
|
||||
$post->ID,
|
||||
/* translators: %s: Attachment title. */
|
||||
esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ),
|
||||
__( 'Attach' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the action links for each attachment in the Media list table.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string[] $actions An array of action links for each attachment.
|
||||
* Default 'Edit', 'Delete Permanently', 'View'.
|
||||
* Includes 'Edit', 'Delete Permanently', 'View',
|
||||
* 'Copy URL' and 'Download file'.
|
||||
* @param WP_Post $post WP_Post object for the current attachment.
|
||||
* @param bool $detached Whether the list table contains media not attached
|
||||
* to any posts. Default true.
|
||||
|
||||
@@ -81,7 +81,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
|
||||
$s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
|
||||
$wild = '';
|
||||
if ( false !== strpos( $s, '*' ) ) {
|
||||
if ( str_contains( $s, '*' ) ) {
|
||||
$wild = '*';
|
||||
$s = trim( $s, '*' );
|
||||
}
|
||||
@@ -109,12 +109,17 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
|
||||
if ( empty( $s ) ) {
|
||||
// Nothing to do.
|
||||
} elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||
|
||||
preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
|
||||
preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
|
||||
preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
|
||||
} elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s )
|
||||
|| preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s )
|
||||
|| preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s )
|
||||
|| preg_match( '/^[0-9]{1,3}\.$/', $s )
|
||||
) {
|
||||
// IPv4 address.
|
||||
$sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
|
||||
$sql = $wpdb->prepare(
|
||||
"SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s",
|
||||
$wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' )
|
||||
);
|
||||
|
||||
$reg_blog_ids = $wpdb->get_col( $sql );
|
||||
|
||||
if ( $reg_blog_ids ) {
|
||||
@@ -262,7 +267,11 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
|
||||
foreach ( $statuses as $status => $label_count ) {
|
||||
if ( (int) $counts[ $status ] > 0 ) {
|
||||
$label = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) );
|
||||
$label = sprintf(
|
||||
translate_nooped_plural( $label_count, $counts[ $status ] ),
|
||||
number_format_i18n( $counts[ $status ] )
|
||||
);
|
||||
|
||||
$full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
|
||||
|
||||
$view_links[ $status ] = array(
|
||||
@@ -306,7 +315,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extra controls to be displayed between bulk actions and pagination.
|
||||
* Displays extra controls between bulk actions and pagination.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*
|
||||
@@ -350,7 +359,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
$sites_columns = array(
|
||||
@@ -380,10 +389,19 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
|
||||
if ( is_subdomain_install() ) {
|
||||
$abbr = __( 'Domain' );
|
||||
$blogname_orderby_text = __( 'Table ordered by Site Domain Name.' );
|
||||
} else {
|
||||
$abbr = __( 'Path' );
|
||||
$blogname_orderby_text = __( 'Table ordered by Site Path.' );
|
||||
}
|
||||
|
||||
return array(
|
||||
'blogname' => 'blogname',
|
||||
'lastupdated' => 'lastupdated',
|
||||
'registered' => 'blog_id',
|
||||
'blogname' => array( 'blogname', false, $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' ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -402,13 +420,16 @@ 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="screen-reader-text" for="blog_<?php echo $blog['blog_id']; ?>">
|
||||
<label class="label-covers-full-cell" for="blog_<?php echo $blog['blog_id']; ?>">
|
||||
<span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: %s: Site URL. */
|
||||
printf( __( 'Select %s' ), $blogname );
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]" value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
|
||||
<input type="checkbox" id="blog_<?php echo $blog['blog_id']; ?>" name="allblogs[]"
|
||||
value="<?php echo esc_attr( $blog['blog_id'] ); ?>" />
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
@@ -440,8 +461,15 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
|
||||
?>
|
||||
<strong>
|
||||
<a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname; ?></a>
|
||||
<?php $this->site_states( $blog ); ?>
|
||||
<?php
|
||||
printf(
|
||||
'<a href="%1$s" class="edit">%2$s</a>',
|
||||
esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ),
|
||||
$blogname
|
||||
);
|
||||
|
||||
$this->site_states( $blog );
|
||||
?>
|
||||
</strong>
|
||||
<?php
|
||||
if ( 'list' !== $mode ) {
|
||||
@@ -476,7 +504,11 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
$date = __( 'Y/m/d g:i:s a' );
|
||||
}
|
||||
|
||||
echo ( '0000-00-00 00:00:00' === $blog['last_updated'] ) ? __( 'Never' ) : mysql2date( $date, $blog['last_updated'] );
|
||||
if ( '0000-00-00 00:00:00' === $blog['last_updated'] ) {
|
||||
_e( 'Never' );
|
||||
} else {
|
||||
echo mysql2date( $date, $blog['last_updated'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,7 +559,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
printf(
|
||||
'<a href="%s">%s</a>',
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url( network_admin_url( 'site-users.php?id=' . $blog['blog_id'] ) ),
|
||||
number_format_i18n( $user_count )
|
||||
);
|
||||
@@ -586,7 +618,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
reset( $this->status_list );
|
||||
|
||||
foreach ( $this->status_list as $status => $col ) {
|
||||
if ( 1 == $blog[ $status ] ) {
|
||||
if ( '1' === $blog[ $status ] ) {
|
||||
$class = " class='{$col[0]}'";
|
||||
}
|
||||
}
|
||||
@@ -600,7 +632,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe output comma-separated site states.
|
||||
* Determines whether to output comma-separated site states.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*
|
||||
@@ -620,7 +652,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
|
||||
$site_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
|
||||
foreach ( $this->status_list as $status => $col ) {
|
||||
if ( ( 1 === (int) $_site->{$status} ) && ( $site_status !== $status ) ) {
|
||||
if ( '1' === $_site->{$status} && $site_status !== $status ) {
|
||||
$site_states[ $col[0] ] = $col[1];
|
||||
}
|
||||
}
|
||||
@@ -699,33 +731,110 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
'visit' => '',
|
||||
);
|
||||
|
||||
$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ) . '">' . __( 'Edit' ) . '</a>';
|
||||
$actions['backend'] = "<a href='" . esc_url( get_admin_url( $blog['blog_id'] ) ) . "' class='edit'>" . __( 'Dashboard' ) . '</a>';
|
||||
if ( get_network()->site_id != $blog['blog_id'] ) {
|
||||
if ( '1' == $blog['deleted'] ) {
|
||||
$actions['activate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ), 'activateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Activate' ) . '</a>';
|
||||
$actions['edit'] = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ),
|
||||
__( 'Edit' )
|
||||
);
|
||||
|
||||
$actions['backend'] = sprintf(
|
||||
'<a href="%1$s" class="edit">%2$s</a>',
|
||||
esc_url( get_admin_url( $blog['blog_id'] ) ),
|
||||
__( 'Dashboard' )
|
||||
);
|
||||
|
||||
if ( ! is_main_site( $blog['blog_id'] ) ) {
|
||||
if ( '1' === $blog['deleted'] ) {
|
||||
$actions['activate'] = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url(
|
||||
wp_nonce_url(
|
||||
network_admin_url( 'sites.php?action=confirm&action2=activateblog&id=' . $blog['blog_id'] ),
|
||||
'activateblog_' . $blog['blog_id']
|
||||
)
|
||||
),
|
||||
__( 'Activate' )
|
||||
);
|
||||
} else {
|
||||
$actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ), 'deactivateblog_' . $blog['blog_id'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
|
||||
$actions['deactivate'] = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url(
|
||||
wp_nonce_url(
|
||||
network_admin_url( 'sites.php?action=confirm&action2=deactivateblog&id=' . $blog['blog_id'] ),
|
||||
'deactivateblog_' . $blog['blog_id']
|
||||
)
|
||||
),
|
||||
__( 'Deactivate' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( '1' == $blog['archived'] ) {
|
||||
$actions['unarchive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ), 'unarchiveblog_' . $blog['blog_id'] ) ) . '">' . __( 'Unarchive' ) . '</a>';
|
||||
if ( '1' === $blog['archived'] ) {
|
||||
$actions['unarchive'] = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url(
|
||||
wp_nonce_url(
|
||||
network_admin_url( 'sites.php?action=confirm&action2=unarchiveblog&id=' . $blog['blog_id'] ),
|
||||
'unarchiveblog_' . $blog['blog_id']
|
||||
)
|
||||
),
|
||||
__( 'Unarchive' )
|
||||
);
|
||||
} else {
|
||||
$actions['archive'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ), 'archiveblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Archive', 'verb; site' ) . '</a>';
|
||||
$actions['archive'] = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url(
|
||||
wp_nonce_url(
|
||||
network_admin_url( 'sites.php?action=confirm&action2=archiveblog&id=' . $blog['blog_id'] ),
|
||||
'archiveblog_' . $blog['blog_id']
|
||||
)
|
||||
),
|
||||
_x( 'Archive', 'verb; site' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( '1' == $blog['spam'] ) {
|
||||
$actions['unspam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ), 'unspamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Not Spam', 'site' ) . '</a>';
|
||||
if ( '1' === $blog['spam'] ) {
|
||||
$actions['unspam'] = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url(
|
||||
wp_nonce_url(
|
||||
network_admin_url( 'sites.php?action=confirm&action2=unspamblog&id=' . $blog['blog_id'] ),
|
||||
'unspamblog_' . $blog['blog_id']
|
||||
)
|
||||
),
|
||||
_x( 'Not Spam', 'site' )
|
||||
);
|
||||
} else {
|
||||
$actions['spam'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ), 'spamblog_' . $blog['blog_id'] ) ) . '">' . _x( 'Spam', 'site' ) . '</a>';
|
||||
$actions['spam'] = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url(
|
||||
wp_nonce_url(
|
||||
network_admin_url( 'sites.php?action=confirm&action2=spamblog&id=' . $blog['blog_id'] ),
|
||||
'spamblog_' . $blog['blog_id']
|
||||
)
|
||||
),
|
||||
_x( 'Spam', 'site' )
|
||||
);
|
||||
}
|
||||
|
||||
if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
|
||||
$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ), 'deleteblog_' . $blog['blog_id'] ) ) . '">' . __( 'Delete' ) . '</a>';
|
||||
$actions['delete'] = sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
esc_url(
|
||||
wp_nonce_url(
|
||||
network_admin_url( 'sites.php?action=confirm&action2=deleteblog&id=' . $blog['blog_id'] ),
|
||||
'deleteblog_' . $blog['blog_id']
|
||||
)
|
||||
),
|
||||
__( 'Delete' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$actions['visit'] = "<a href='" . esc_url( get_home_url( $blog['blog_id'], '/' ) ) . "' rel='bookmark'>" . __( 'Visit' ) . '</a>';
|
||||
$actions['visit'] = sprintf(
|
||||
'<a href="%1$s" rel="bookmark">%2$s</a>',
|
||||
esc_url( get_home_url( $blog['blog_id'], '/' ) ),
|
||||
__( 'Visit' )
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters the action links displayed for each site in the Sites list table.
|
||||
|
||||
@@ -322,7 +322,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
$columns = array(
|
||||
@@ -343,7 +343,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
return array(
|
||||
'name' => 'name',
|
||||
'name' => array( 'name', false, __( 'Theme' ), __( 'Table ordered by Theme Name.' ), 'asc' ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -512,8 +512,8 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
$theme = $item;
|
||||
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
|
||||
?>
|
||||
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
|
||||
<label class="screen-reader-text" for="<?php echo $checkbox_id; ?>" >
|
||||
<label class="label-covers-full-cell" for="<?php echo $checkbox_id; ?>" >
|
||||
<span class="screen-reader-text">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: Hidden accessibility text. %s: Theme name */
|
||||
@@ -521,7 +521,9 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
||||
$theme->display( 'Name' )
|
||||
);
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
$users_columns = array(
|
||||
@@ -212,10 +212,10 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
return array(
|
||||
'username' => 'login',
|
||||
'name' => 'name',
|
||||
'email' => 'email',
|
||||
'registered' => 'id',
|
||||
'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ),
|
||||
'name' => array( 'name', false, __( 'Name' ), __( 'Table ordered by Name.' ) ),
|
||||
'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ),
|
||||
'registered' => array( 'id', false, _x( 'Registered', 'user' ), __( 'Table ordered by User Registered Date.' ) ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -235,11 +235,13 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>">
|
||||
<label class="label-covers-full-cell" for="blog_<?php echo $user->ID; ?>">
|
||||
<span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. %s: User login. */
|
||||
printf( __( 'Select %s' ), $user->user_login );
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
|
||||
<?php
|
||||
|
||||
@@ -30,7 +30,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of known plugins.
|
||||
* Returns the list of known plugins.
|
||||
*
|
||||
* Uses the transient data from the updates API to determine the known
|
||||
* installed plugins.
|
||||
@@ -88,7 +88,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
* @global string $term
|
||||
*/
|
||||
public function prepare_items() {
|
||||
include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
|
||||
|
||||
global $tabs, $tab, $paged, $type, $term;
|
||||
|
||||
@@ -105,7 +105,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
$tabs['search'] = __( 'Search Results' );
|
||||
}
|
||||
|
||||
if ( 'beta' === $tab || false !== strpos( get_bloginfo( 'version' ), '-' ) ) {
|
||||
if ( 'beta' === $tab || str_contains( get_bloginfo( 'version' ), '-' ) ) {
|
||||
$tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' );
|
||||
}
|
||||
|
||||
@@ -115,8 +115,10 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
$tabs['favorites'] = _x( 'Favorites', 'Plugin Installer' );
|
||||
|
||||
if ( current_user_can( 'upload_plugins' ) ) {
|
||||
// No longer a real tab. Here for filter compatibility.
|
||||
// Gets skipped in get_views().
|
||||
/*
|
||||
* No longer a real tab. Here for filter compatibility.
|
||||
* Gets skipped in get_views().
|
||||
*/
|
||||
$tabs['upload'] = __( 'Upload Plugin' );
|
||||
}
|
||||
|
||||
@@ -424,7 +426,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
return array();
|
||||
|
||||
@@ -61,8 +61,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
|
||||
$this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'plugin' )
|
||||
&& current_user_can( 'update_plugins' )
|
||||
&& ( ! is_multisite() || $this->screen->in_admin( 'network' ) )
|
||||
&& ! in_array( $status, array( 'mustuse', 'dropins' ), true );
|
||||
&& ( ! is_multisite() || $this->screen->in_admin( 'network' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -262,8 +261,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
}
|
||||
} elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) )
|
||||
|| ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) {
|
||||
// On the non-network screen, populate the active list with plugins that are individually activated.
|
||||
// On the network admin screen, populate the active list with plugins that are network-activated.
|
||||
/*
|
||||
* On the non-network screen, populate the active list with plugins that are individually activated.
|
||||
* On the network admin screen, populate the active list with plugins that are network-activated.
|
||||
*/
|
||||
$plugins['active'][ $plugin_file ] = $plugin_data;
|
||||
|
||||
if ( ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file ) ) {
|
||||
@@ -297,6 +298,15 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
$plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the array of plugins for the list table.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @param array[] $plugins An array of arrays of plugin data, keyed by context.
|
||||
*/
|
||||
$plugins = apply_filters( 'plugins_list', $plugins );
|
||||
|
||||
$totals = array();
|
||||
foreach ( $plugins as $type => $list ) {
|
||||
$totals[ $type ] = count( $list );
|
||||
@@ -451,7 +461,8 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
|
||||
/**
|
||||
* @global string $status
|
||||
* @return array
|
||||
*
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
global $status;
|
||||
@@ -462,7 +473,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
'description' => __( 'Description' ),
|
||||
);
|
||||
|
||||
if ( $this->show_autoupdates ) {
|
||||
if ( $this->show_autoupdates && ! in_array( $status, array( 'mustuse', 'dropins' ), true ) ) {
|
||||
$columns['auto-updates'] = __( 'Automatic Updates' );
|
||||
}
|
||||
|
||||
@@ -982,7 +993,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
$checkbox = '';
|
||||
} else {
|
||||
$checkbox = sprintf(
|
||||
'<label class="screen-reader-text" for="%1$s">%2$s</label>' .
|
||||
'<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" />',
|
||||
$checkbox_id,
|
||||
/* translators: Hidden accessibility text. %s: Plugin name. */
|
||||
@@ -1021,8 +1032,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
|
||||
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
|
||||
|
||||
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
|
||||
$available_updates = get_site_transient( 'update_plugins' );
|
||||
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
|
||||
|
||||
foreach ( $columns as $column_name => $column_display_name ) {
|
||||
$extra_classes = '';
|
||||
@@ -1154,7 +1164,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
echo '</td>';
|
||||
break;
|
||||
case 'auto-updates':
|
||||
if ( ! $this->show_autoupdates ) {
|
||||
if ( ! $this->show_autoupdates || in_array( $status, array( 'mustuse', 'dropins' ), true ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current view is the "All" view.
|
||||
* Determines if the current view is the "All" view.
|
||||
*
|
||||
* @since 4.2.0
|
||||
*
|
||||
@@ -246,7 +246,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to create links to edit.php with params.
|
||||
* Creates a link to edit.php with params.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
@@ -651,7 +651,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
$post_type = $this->screen->post_type;
|
||||
@@ -760,12 +760,28 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
return array(
|
||||
'title' => 'title',
|
||||
'parent' => 'parent',
|
||||
'comments' => 'comment_count',
|
||||
'date' => array( 'date', true ),
|
||||
);
|
||||
|
||||
$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.' );
|
||||
$sortables = array(
|
||||
'title' => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ),
|
||||
'parent' => array( 'parent', false ),
|
||||
'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
|
||||
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ),
|
||||
);
|
||||
} else {
|
||||
$sortables = array(
|
||||
'title' => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ),
|
||||
'parent' => array( 'parent', false ),
|
||||
'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ),
|
||||
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ),
|
||||
);
|
||||
}
|
||||
// Custom Post Types: there's a filter for that, see get_column_info().
|
||||
|
||||
return $sortables;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -917,8 +933,8 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a top level page ID, display the nested hierarchy of sub-pages
|
||||
* together with paging support
|
||||
* Displays the nested hierarchy of sub-pages together with paging
|
||||
* support, based on a top level page ID.
|
||||
*
|
||||
* @since 3.1.0 (Standalone function exists since 2.6.0)
|
||||
* @since 4.2.0 Added the `$to_display` parameter.
|
||||
@@ -1012,11 +1028,13 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
*/
|
||||
if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :
|
||||
?>
|
||||
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>">
|
||||
<label class="label-covers-full-cell" for="cb-select-<?php the_ID(); ?>">
|
||||
<span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: %s: Post title. */
|
||||
printf( __( 'Select %s' ), _draft_or_post_title() );
|
||||
?>
|
||||
</span>
|
||||
</label>
|
||||
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
|
||||
<div class="locked-indicator">
|
||||
@@ -1271,7 +1289,7 @@ class WP_Posts_List_Table extends WP_List_Table {
|
||||
$taxonomy = 'category';
|
||||
} elseif ( 'tags' === $column_name ) {
|
||||
$taxonomy = 'post_tag';
|
||||
} elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
|
||||
} elseif ( str_starts_with( $column_name, 'taxonomy-' ) ) {
|
||||
$taxonomy = substr( $column_name, 9 );
|
||||
} else {
|
||||
$taxonomy = false;
|
||||
|
||||
@@ -36,7 +36,7 @@ class WP_Privacy_Data_Removal_Requests_List_Table extends WP_Privacy_Requests_Ta
|
||||
protected $post_type = 'user_request';
|
||||
|
||||
/**
|
||||
* Actions column.
|
||||
* Outputs the Actions column.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -108,7 +108,7 @@ class WP_Privacy_Data_Removal_Requests_List_Table extends WP_Privacy_Requests_Ta
|
||||
}
|
||||
|
||||
/**
|
||||
* Next steps column.
|
||||
* Outputs the Next steps column.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
|
||||
@@ -20,7 +20,7 @@ final class WP_Privacy_Policy_Content {
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* Add content to the postbox shown when editing the privacy policy.
|
||||
* Adds content to the postbox shown when editing the privacy policy.
|
||||
*
|
||||
* Plugins and themes should suggest text for inclusion in the site's privacy policy.
|
||||
* The suggested text should contain information about any functionality that affects user privacy,
|
||||
@@ -49,7 +49,7 @@ final class WP_Privacy_Policy_Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Quick check if any privacy info has changed.
|
||||
* Performs a quick check to determine whether any privacy info has changed.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*/
|
||||
@@ -103,11 +103,15 @@ final class WP_Privacy_Policy_Content {
|
||||
sort( $old );
|
||||
sort( $new );
|
||||
|
||||
// The == operator (equal, not identical) was used intentionally.
|
||||
// See https://www.php.net/manual/en/language.operators.array.php
|
||||
/*
|
||||
* The == operator (equal, not identical) was used intentionally.
|
||||
* See https://www.php.net/manual/en/language.operators.array.php
|
||||
*/
|
||||
if ( $new != $old ) {
|
||||
// A plugin was activated or deactivated, or some policy text has changed.
|
||||
// Show a notice on the relevant screens to inform the admin.
|
||||
/*
|
||||
* A plugin was activated or deactivated, or some policy text has changed.
|
||||
* Show a notice on the relevant screens to inform the admin.
|
||||
*/
|
||||
add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'policy_text_changed_notice' ) );
|
||||
$state = 'changed';
|
||||
} else {
|
||||
@@ -123,7 +127,7 @@ final class WP_Privacy_Policy_Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a warning when some privacy info has changed.
|
||||
* Outputs a warning when some privacy info has changed.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -154,7 +158,7 @@ final class WP_Privacy_Policy_Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the cached policy info when the policy page is updated.
|
||||
* Updates the cached policy info when the policy page is updated.
|
||||
*
|
||||
* @since 4.9.6
|
||||
* @access private
|
||||
@@ -203,7 +207,7 @@ final class WP_Privacy_Policy_Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for updated, added or removed privacy policy information from plugins.
|
||||
* Checks for updated, added or removed privacy policy information from plugins.
|
||||
*
|
||||
* Caches the current info in post_meta of the policy page.
|
||||
*
|
||||
@@ -301,7 +305,7 @@ final class WP_Privacy_Policy_Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a notice with a link to the guide when editing the privacy policy page.
|
||||
* Adds a notice with a link to the guide when editing the privacy policy page.
|
||||
*
|
||||
* @since 4.9.6
|
||||
* @since 5.0.0 The `$post` parameter was made optional.
|
||||
@@ -372,7 +376,7 @@ final class WP_Privacy_Policy_Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the privacy policy guide together with content from the theme and plugins.
|
||||
* Outputs the privacy policy guide together with content from the theme and plugins.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*/
|
||||
@@ -441,7 +445,7 @@ final class WP_Privacy_Policy_Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the default suggested privacy policy content.
|
||||
* Returns the default suggested privacy policy content.
|
||||
*
|
||||
* @since 4.9.6
|
||||
* @since 5.0.0 Added the `$blocks` parameter.
|
||||
@@ -656,11 +660,11 @@ final class WP_Privacy_Policy_Content {
|
||||
|
||||
if ( $blocks ) {
|
||||
foreach ( $strings as $key => $string ) {
|
||||
if ( 0 === strpos( $string, '<p>' ) ) {
|
||||
if ( str_starts_with( $string, '<p>' ) ) {
|
||||
$strings[ $key ] = '<!-- wp:paragraph -->' . $string . '<!-- /wp:paragraph -->';
|
||||
}
|
||||
|
||||
if ( 0 === strpos( $string, '<h2>' ) ) {
|
||||
if ( str_starts_with( $string, '<h2>' ) ) {
|
||||
$strings[ $key ] = '<!-- wp:heading -->' . $string . '<!-- /wp:heading -->';
|
||||
}
|
||||
}
|
||||
@@ -690,7 +694,7 @@ final class WP_Privacy_Policy_Content {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the suggested privacy policy text to the policy postbox.
|
||||
* Adds the suggested privacy policy text to the policy postbox.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
protected $post_type = 'INVALID';
|
||||
|
||||
/**
|
||||
* Get columns to show in the list table.
|
||||
* Gets columns to show in the list table.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -49,7 +49,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize the admin URL to the current page (by request_type).
|
||||
* Normalizes the admin URL to the current page (by request_type).
|
||||
*
|
||||
* @since 5.3.0
|
||||
*
|
||||
@@ -66,7 +66,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of sortable columns.
|
||||
* Gets a list of sortable columns.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -87,7 +87,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default primary column.
|
||||
* Returns the default primary column.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -98,7 +98,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Count number of requests for each status.
|
||||
* Counts the number of requests for each status.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -137,7 +137,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an associative array ( id => link ) with the list of views available on this table.
|
||||
* Gets an associative array ( id => link ) with the list of views available on this table.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -200,7 +200,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bulk actions.
|
||||
* Gets bulk actions.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -354,7 +354,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare items to output.
|
||||
* Prepares items to output.
|
||||
*
|
||||
* @since 4.9.6
|
||||
* @since 5.1.0 Added support for column sorting.
|
||||
@@ -407,7 +407,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkbox column.
|
||||
* Returns the markup for the Checkbox column.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -415,7 +415,13 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
* @return string Checkbox column markup.
|
||||
*/
|
||||
public function column_cb( $item ) {
|
||||
return sprintf( '<input type="checkbox" name="request_id[]" value="%1$s" /><span class="spinner"></span>', esc_attr( $item->ID ) );
|
||||
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>',
|
||||
esc_attr( $item->ID ),
|
||||
/* translators: Hidden accessibility text. %s: Email address. */
|
||||
sprintf( __( 'Select %s' ), $item->email )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,7 +462,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert timestamp for display.
|
||||
* Converts a timestamp for display.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -479,7 +485,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default column handler.
|
||||
* Handles the default column.
|
||||
*
|
||||
* @since 4.9.6
|
||||
* @since 5.7.0 Added `manage_{$this->screen->id}_custom_column` action.
|
||||
@@ -503,7 +509,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Created timestamp column. Overridden by children.
|
||||
* Returns the markup for the Created timestamp column. Overridden by children.
|
||||
*
|
||||
* @since 5.7.0
|
||||
*
|
||||
@@ -527,7 +533,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Next steps column. Overridden by children.
|
||||
* Returns the markup for the next steps column. Overridden by children.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
@@ -551,7 +557,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Embed scripts used to perform actions. Overridden by children.
|
||||
* Embeds scripts used to perform actions. Overridden by children.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*/
|
||||
|
||||
@@ -89,7 +89,7 @@ final class WP_Screen {
|
||||
* have a `$parent_base` of 'edit'.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
public $parent_base;
|
||||
|
||||
@@ -99,7 +99,7 @@ final class WP_Screen {
|
||||
* Some `$parent_file` values are 'edit.php?post_type=page', 'edit.php', and 'options-general.php'.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
public $parent_file;
|
||||
|
||||
@@ -230,7 +230,7 @@ final class WP_Screen {
|
||||
$post_type = $id;
|
||||
$id = 'post'; // Changes later. Ends up being $base.
|
||||
} else {
|
||||
if ( '.php' === substr( $id, -4 ) ) {
|
||||
if ( str_ends_with( $id, '.php' ) ) {
|
||||
$id = substr( $id, 0, -4 );
|
||||
}
|
||||
|
||||
@@ -241,16 +241,16 @@ final class WP_Screen {
|
||||
}
|
||||
|
||||
if ( ! $post_type && $hook_name ) {
|
||||
if ( '-network' === substr( $id, -8 ) ) {
|
||||
if ( str_ends_with( $id, '-network' ) ) {
|
||||
$id = substr( $id, 0, -8 );
|
||||
$in_admin = 'network';
|
||||
} elseif ( '-user' === substr( $id, -5 ) ) {
|
||||
} elseif ( str_ends_with( $id, '-user' ) ) {
|
||||
$id = substr( $id, 0, -5 );
|
||||
$in_admin = 'user';
|
||||
}
|
||||
|
||||
$id = sanitize_key( $id );
|
||||
if ( 'edit-comments' !== $id && 'edit-tags' !== $id && 'edit-' === substr( $id, 0, 5 ) ) {
|
||||
if ( 'edit-comments' !== $id && 'edit-tags' !== $id && str_starts_with( $id, 'edit-' ) ) {
|
||||
$maybe = substr( $id, 5 );
|
||||
if ( taxonomy_exists( $maybe ) ) {
|
||||
$id = 'edit-tags';
|
||||
@@ -1118,6 +1118,7 @@ final class WP_Screen {
|
||||
<?php _e( 'Some screen elements can be shown or hidden by using the checkboxes.' ); ?>
|
||||
<?php _e( 'Expand or collapse the elements by clicking on their headings, and arrange them by dragging their headings or by clicking on the up and down arrows.' ); ?>
|
||||
</p>
|
||||
<div class="metabox-prefs-container">
|
||||
<?php
|
||||
|
||||
meta_box_prefs( $this );
|
||||
@@ -1137,6 +1138,7 @@ final class WP_Screen {
|
||||
echo _x( 'Welcome', 'Welcome panel' ) . "</label>\n";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ class WP_Site_Health_Auto_Updates {
|
||||
}
|
||||
|
||||
$checksums = get_core_checksums( $wp_version, 'en_US' );
|
||||
$dev = ( false !== strpos( $wp_version, '-' ) );
|
||||
$dev = ( str_contains( $wp_version, '-' ) );
|
||||
// Get the last stable version's files and test against that.
|
||||
if ( ! $checksums && $dev ) {
|
||||
$checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' );
|
||||
@@ -358,7 +358,7 @@ class WP_Site_Health_Auto_Updates {
|
||||
|
||||
$unwritable_files = array();
|
||||
foreach ( array_keys( $checksums ) as $file ) {
|
||||
if ( 'wp-content' === substr( $file, 0, 10 ) ) {
|
||||
if ( str_starts_with( $file, 'wp-content' ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( ! file_exists( ABSPATH . $file ) ) {
|
||||
@@ -396,7 +396,7 @@ class WP_Site_Health_Auto_Updates {
|
||||
public function test_accepts_dev_updates() {
|
||||
require ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
|
||||
// Only for dev versions.
|
||||
if ( false === strpos( $wp_version, '-' ) ) {
|
||||
if ( ! str_contains( $wp_version, '-' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class WP_Site_Health {
|
||||
private $mysql_server_version = '';
|
||||
private $mysql_required_version = '5.5';
|
||||
private $mysql_recommended_version = '5.7';
|
||||
private $mariadb_recommended_version = '10.3';
|
||||
private $mariadb_recommended_version = '10.4';
|
||||
|
||||
public $php_memory_limit;
|
||||
|
||||
@@ -746,7 +746,7 @@ class WP_Site_Health {
|
||||
)
|
||||
),
|
||||
'actions' => sprintf(
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
esc_url( wp_get_update_php_url() ),
|
||||
__( 'Learn more about updating PHP' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -772,8 +772,10 @@ class WP_Site_Health {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// The PHP version is still receiving security fixes, but is lower than
|
||||
// the expected minimum version that will be required by WordPress in the near future.
|
||||
/*
|
||||
* The PHP version is still receiving security fixes, but is lower than
|
||||
* the expected minimum version that will be required by WordPress in the near future.
|
||||
*/
|
||||
if ( $response['is_secure'] && $response['is_lower_than_future_minimum'] ) {
|
||||
// The `is_secure` array key name doesn't actually imply this is a secure version of PHP. It only means it receives security updates.
|
||||
|
||||
@@ -892,7 +894,7 @@ class WP_Site_Health {
|
||||
esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions' ) ),
|
||||
'target="_blank" rel="noopener"',
|
||||
sprintf(
|
||||
' <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',
|
||||
'<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( '(opens in a new tab)' )
|
||||
)
|
||||
@@ -1216,7 +1218,7 @@ class WP_Site_Health {
|
||||
__( 'The SQL server is a required piece of software for the database WordPress uses to store all your site’s content and settings.' )
|
||||
),
|
||||
'actions' => sprintf(
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
/* translators: Localized version of WordPress requirements if one exists. */
|
||||
esc_url( __( 'https://wordpress.org/about/requirements/' ) ),
|
||||
__( 'Learn more about what WordPress requires to run.' ),
|
||||
@@ -1366,7 +1368,7 @@ class WP_Site_Health {
|
||||
* libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server.
|
||||
* mysqlnd has supported utf8mb4 since 5.0.9.
|
||||
*/
|
||||
if ( false !== strpos( $mysql_client_version, 'mysqlnd' ) ) {
|
||||
if ( str_contains( $mysql_client_version, 'mysqlnd' ) ) {
|
||||
$mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version );
|
||||
if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) {
|
||||
$result['status'] = 'recommended';
|
||||
@@ -1456,9 +1458,9 @@ class WP_Site_Health {
|
||||
);
|
||||
|
||||
$result['actions'] = sprintf(
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
/* translators: Localized Support reference. */
|
||||
esc_url( __( 'https://wordpress.org/support' ) ),
|
||||
esc_url( __( 'https://wordpress.org/support/forums/' ) ),
|
||||
__( 'Get help resolving this issue.' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( '(opens in a new tab)' )
|
||||
@@ -1494,7 +1496,7 @@ class WP_Site_Health {
|
||||
__( 'Debug mode is often enabled to gather more details about an error or site failure, but may contain sensitive information which should not be available on a publicly available website.' )
|
||||
),
|
||||
'actions' => sprintf(
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
/* translators: Documentation explaining debugging in WordPress. */
|
||||
esc_url( __( 'https://wordpress.org/documentation/article/debugging-in-wordpress/' ) ),
|
||||
__( 'Learn more about debugging in WordPress.' ),
|
||||
@@ -1508,7 +1510,7 @@ class WP_Site_Health {
|
||||
if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
|
||||
$result['label'] = __( 'Your site is set to log errors to a potentially public file' );
|
||||
|
||||
$result['status'] = ( 0 === strpos( ini_get( 'error_log' ), ABSPATH ) ) ? 'critical' : 'recommended';
|
||||
$result['status'] = str_starts_with( ini_get( 'error_log' ), ABSPATH ) ? 'critical' : 'recommended';
|
||||
|
||||
$result['description'] .= sprintf(
|
||||
'<p>%s</p>',
|
||||
@@ -1557,8 +1559,10 @@ class WP_Site_Health {
|
||||
* @return array The test results.
|
||||
*/
|
||||
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.
|
||||
/*
|
||||
* Enforce fresh HTTPS detection results. This is normally invoked by using cron,
|
||||
* but for Site Health it should always rely on the latest results.
|
||||
*/
|
||||
wp_update_https_detection_errors();
|
||||
|
||||
$default_update_url = wp_get_default_update_https_url();
|
||||
@@ -1585,8 +1589,10 @@ class WP_Site_Health {
|
||||
);
|
||||
|
||||
if ( ! wp_is_using_https() ) {
|
||||
// If the website is not using HTTPS, provide more information
|
||||
// about whether it is supported and how it can be enabled.
|
||||
/*
|
||||
* If the website is not using HTTPS, provide more information
|
||||
* about whether it is supported and how it can be enabled.
|
||||
*/
|
||||
$result['status'] = 'recommended';
|
||||
$result['label'] = __( 'Your website does not use HTTPS' );
|
||||
|
||||
@@ -1840,8 +1846,10 @@ class WP_Site_Health {
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-site-health-auto-updates.php';
|
||||
}
|
||||
|
||||
// Run the auto-update tests in a separate class,
|
||||
// as there are many considerations to be made.
|
||||
/*
|
||||
* Run the auto-update tests in a separate class,
|
||||
* as there are many considerations to be made.
|
||||
*/
|
||||
$automatic_updates = new WP_Site_Health_Auto_Updates();
|
||||
$tests = $automatic_updates->run_tests();
|
||||
|
||||
@@ -1925,6 +1933,183 @@ class WP_Site_Health {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests available disk space for updates.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @return array The test results.
|
||||
*/
|
||||
public function get_test_available_updates_disk_space() {
|
||||
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false;
|
||||
|
||||
$result = array(
|
||||
'label' => __( 'Disk space available to safely perform updates' ),
|
||||
'status' => 'good',
|
||||
'badge' => array(
|
||||
'label' => __( 'Security' ),
|
||||
'color' => 'blue',
|
||||
),
|
||||
'description' => sprintf(
|
||||
/* translators: %s: Available disk space in MB or GB. */
|
||||
'<p>' . __( '%s available disk space was detected, update routines can be performed safely.' ) . '</p>',
|
||||
size_format( $available_space )
|
||||
),
|
||||
'actions' => '',
|
||||
'test' => 'available_updates_disk_space',
|
||||
);
|
||||
|
||||
if ( false === $available_space ) {
|
||||
$result['description'] = __( 'Could not determine available disk space for updates.' );
|
||||
$result['status'] = 'recommended';
|
||||
} 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';
|
||||
} elseif ( $available_space < 100 * MB_IN_BYTES ) {
|
||||
$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
|
||||
$result['status'] = 'recommended';
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if plugin and theme temporary backup directories are writable or can be created.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
|
||||
*
|
||||
* @return array The test results.
|
||||
*/
|
||||
public function get_test_update_temp_backup_writable() {
|
||||
global $wp_filesystem;
|
||||
|
||||
$result = array(
|
||||
'label' => __( 'Plugin and theme temporary backup directory is writable' ),
|
||||
'status' => 'good',
|
||||
'badge' => array(
|
||||
'label' => __( 'Security' ),
|
||||
'color' => 'blue',
|
||||
),
|
||||
'description' => sprintf(
|
||||
/* translators: %s: wp-content/upgrade-temp-backup */
|
||||
'<p>' . __( 'The %s directory used to improve the stability of plugin and theme updates is writable.' ) . '</p>',
|
||||
'<code>wp-content/upgrade-temp-backup</code>'
|
||||
),
|
||||
'actions' => '',
|
||||
'test' => 'update_temp_backup_writable',
|
||||
);
|
||||
|
||||
if ( ! function_exists( 'WP_Filesystem' ) ) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
}
|
||||
|
||||
ob_start();
|
||||
$credentials = request_filesystem_credentials( '' );
|
||||
ob_end_clean();
|
||||
|
||||
if ( false === $credentials || ! WP_Filesystem( $credentials ) ) {
|
||||
$result['status'] = 'recommended';
|
||||
$result['label'] = __( 'Could not access filesystem' );
|
||||
$result['description'] = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
||||
return $result;
|
||||
}
|
||||
|
||||
$wp_content = $wp_filesystem->wp_content_dir();
|
||||
|
||||
if ( ! $wp_content ) {
|
||||
$result['status'] = 'critical';
|
||||
$result['label'] = __( 'Unable to locate WordPress content directory' );
|
||||
$result['description'] = sprintf(
|
||||
/* translators: %s: wp-content */
|
||||
'<p>' . __( 'The %s directory cannot be located.' ) . '</p>',
|
||||
'<code>wp-content</code>'
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
$upgrade_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade" );
|
||||
$upgrade_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade" );
|
||||
$backup_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup" );
|
||||
$backup_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup" );
|
||||
|
||||
$plugins_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup/plugins" );
|
||||
$plugins_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup/plugins" );
|
||||
$themes_dir_exists = $wp_filesystem->is_dir( "$wp_content/upgrade-temp-backup/themes" );
|
||||
$themes_dir_is_writable = $wp_filesystem->is_writable( "$wp_content/upgrade-temp-backup/themes" );
|
||||
|
||||
if ( $plugins_dir_exists && ! $plugins_dir_is_writable && $themes_dir_exists && ! $themes_dir_is_writable ) {
|
||||
$result['status'] = 'critical';
|
||||
$result['label'] = __( 'Plugin and theme temporary backup directories exist but are not writable' );
|
||||
$result['description'] = sprintf(
|
||||
/* translators: 1: wp-content/upgrade-temp-backup/plugins, 2: wp-content/upgrade-temp-backup/themes. */
|
||||
'<p>' . __( 'The %1$s and %2$s directories exist but are not writable. These directories are used to improve the stability of plugin updates. Please make sure the server has write permissions to these directories.' ) . '</p>',
|
||||
'<code>wp-content/upgrade-temp-backup/plugins</code>',
|
||||
'<code>wp-content/upgrade-temp-backup/themes</code>'
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( $plugins_dir_exists && ! $plugins_dir_is_writable ) {
|
||||
$result['status'] = 'critical';
|
||||
$result['label'] = __( 'Plugin temporary backup directory exists but is not writable' );
|
||||
$result['description'] = sprintf(
|
||||
/* translators: %s: wp-content/upgrade-temp-backup/plugins */
|
||||
'<p>' . __( 'The %s directory exists but is not writable. This directory is used to improve the stability of plugin updates. Please make sure the server has write permissions to this directory.' ) . '</p>',
|
||||
'<code>wp-content/upgrade-temp-backup/plugins</code>'
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( $themes_dir_exists && ! $themes_dir_is_writable ) {
|
||||
$result['status'] = 'critical';
|
||||
$result['label'] = __( 'Theme temporary backup directory exists but is not writable' );
|
||||
$result['description'] = sprintf(
|
||||
/* translators: %s: wp-content/upgrade-temp-backup/themes */
|
||||
'<p>' . __( 'The %s directory exists but is not writable. This directory is used to improve the stability of theme updates. Please make sure the server has write permissions to this directory.' ) . '</p>',
|
||||
'<code>wp-content/upgrade-temp-backup/themes</code>'
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( ( ! $plugins_dir_exists || ! $themes_dir_exists ) && $backup_dir_exists && ! $backup_dir_is_writable ) {
|
||||
$result['status'] = 'critical';
|
||||
$result['label'] = __( 'The temporary backup directory exists but is not writable' );
|
||||
$result['description'] = sprintf(
|
||||
/* translators: %s: wp-content/upgrade-temp-backup */
|
||||
'<p>' . __( 'The %s directory exists but is not writable. This directory is used to improve the stability of plugin and theme updates. Please make sure the server has write permissions to this directory.' ) . '</p>',
|
||||
'<code>wp-content/upgrade-temp-backup</code>'
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( ! $backup_dir_exists && $upgrade_dir_exists && ! $upgrade_dir_is_writable ) {
|
||||
$result['status'] = 'critical';
|
||||
$result['label'] = __( 'The upgrade directory exists but is not writable' );
|
||||
$result['description'] = sprintf(
|
||||
/* translators: %s: wp-content/upgrade */
|
||||
'<p>' . __( 'The %s directory exists but is not writable. This directory is used for plugin and theme updates. Please make sure the server has write permissions to this directory.' ) . '</p>',
|
||||
'<code>wp-content/upgrade</code>'
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( ! $upgrade_dir_exists && ! $wp_filesystem->is_writable( $wp_content ) ) {
|
||||
$result['status'] = 'critical';
|
||||
$result['label'] = __( 'The upgrade directory cannot be created' );
|
||||
$result['description'] = sprintf(
|
||||
/* translators: 1: wp-content/upgrade, 2: wp-content. */
|
||||
'<p>' . __( 'The %1$s directory does not exist, and the server does not have write permissions in %2$s to create it. This directory is used for plugin and theme updates. Please make sure the server has write permissions in %2$s.' ) . '</p>',
|
||||
'<code>wp-content/upgrade</code>',
|
||||
'<code>wp-content</code>'
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if loopbacks work as expected.
|
||||
*
|
||||
@@ -2295,7 +2480,7 @@ class WP_Site_Health {
|
||||
);
|
||||
} else {
|
||||
$result['actions'] .= sprintf(
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
__( 'https://developer.wordpress.org/rest-api/frequently-asked-questions/#why-is-authentication-not-working' ),
|
||||
__( 'Learn how to configure the Authorization header.' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -2328,7 +2513,7 @@ class WP_Site_Health {
|
||||
'status' => 'good',
|
||||
'label' => '',
|
||||
'actions' => sprintf(
|
||||
'<p><a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
'<p><a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
__( 'https://wordpress.org/documentation/article/optimization/#Caching' ),
|
||||
__( 'Learn more about page cache' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -2454,7 +2639,7 @@ class WP_Site_Health {
|
||||
__( 'A persistent object cache makes your site’s database more efficient, resulting in faster load times because WordPress can retrieve your site’s content and settings much more quickly.' )
|
||||
),
|
||||
'actions' => sprintf(
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s <span class="screen-reader-text">%s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
|
||||
esc_url( $action_url ),
|
||||
__( 'Learn more about persistent object caching.' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -2532,71 +2717,79 @@ class WP_Site_Health {
|
||||
public static function get_tests() {
|
||||
$tests = array(
|
||||
'direct' => array(
|
||||
'wordpress_version' => array(
|
||||
'wordpress_version' => array(
|
||||
'label' => __( 'WordPress Version' ),
|
||||
'test' => 'wordpress_version',
|
||||
),
|
||||
'plugin_version' => array(
|
||||
'plugin_version' => array(
|
||||
'label' => __( 'Plugin Versions' ),
|
||||
'test' => 'plugin_version',
|
||||
),
|
||||
'theme_version' => array(
|
||||
'theme_version' => array(
|
||||
'label' => __( 'Theme Versions' ),
|
||||
'test' => 'theme_version',
|
||||
),
|
||||
'php_version' => array(
|
||||
'php_version' => array(
|
||||
'label' => __( 'PHP Version' ),
|
||||
'test' => 'php_version',
|
||||
),
|
||||
'php_extensions' => array(
|
||||
'php_extensions' => array(
|
||||
'label' => __( 'PHP Extensions' ),
|
||||
'test' => 'php_extensions',
|
||||
),
|
||||
'php_default_timezone' => array(
|
||||
'php_default_timezone' => array(
|
||||
'label' => __( 'PHP Default Timezone' ),
|
||||
'test' => 'php_default_timezone',
|
||||
),
|
||||
'php_sessions' => array(
|
||||
'php_sessions' => array(
|
||||
'label' => __( 'PHP Sessions' ),
|
||||
'test' => 'php_sessions',
|
||||
),
|
||||
'sql_server' => array(
|
||||
'sql_server' => array(
|
||||
'label' => __( 'Database Server version' ),
|
||||
'test' => 'sql_server',
|
||||
),
|
||||
'utf8mb4_support' => array(
|
||||
'utf8mb4_support' => array(
|
||||
'label' => __( 'MySQL utf8mb4 support' ),
|
||||
'test' => 'utf8mb4_support',
|
||||
),
|
||||
'ssl_support' => array(
|
||||
'ssl_support' => array(
|
||||
'label' => __( 'Secure communication' ),
|
||||
'test' => 'ssl_support',
|
||||
),
|
||||
'scheduled_events' => array(
|
||||
'scheduled_events' => array(
|
||||
'label' => __( 'Scheduled events' ),
|
||||
'test' => 'scheduled_events',
|
||||
),
|
||||
'http_requests' => array(
|
||||
'http_requests' => array(
|
||||
'label' => __( 'HTTP Requests' ),
|
||||
'test' => 'http_requests',
|
||||
),
|
||||
'rest_availability' => array(
|
||||
'rest_availability' => array(
|
||||
'label' => __( 'REST API availability' ),
|
||||
'test' => 'rest_availability',
|
||||
'skip_cron' => true,
|
||||
),
|
||||
'debug_enabled' => array(
|
||||
'debug_enabled' => array(
|
||||
'label' => __( 'Debugging enabled' ),
|
||||
'test' => 'is_in_debug_mode',
|
||||
),
|
||||
'file_uploads' => array(
|
||||
'file_uploads' => array(
|
||||
'label' => __( 'File uploads' ),
|
||||
'test' => 'file_uploads',
|
||||
),
|
||||
'plugin_theme_auto_updates' => array(
|
||||
'plugin_theme_auto_updates' => array(
|
||||
'label' => __( 'Plugin and theme auto-updates' ),
|
||||
'test' => 'plugin_theme_auto_updates',
|
||||
),
|
||||
'update_temp_backup_writable' => array(
|
||||
'label' => __( 'Plugin and theme temporary backup directory access' ),
|
||||
'test' => 'update_temp_backup_writable',
|
||||
),
|
||||
'available_updates_disk_space' => array(
|
||||
'label' => __( 'Available disk space' ),
|
||||
'test' => 'available_updates_disk_space',
|
||||
),
|
||||
),
|
||||
'async' => array(
|
||||
'dotorg_communication' => array(
|
||||
@@ -3140,7 +3333,7 @@ class WP_Site_Health {
|
||||
public function get_page_cache_headers() {
|
||||
|
||||
$cache_hit_callback = static function ( $header_value ) {
|
||||
return false !== strpos( strtolower( $header_value ), 'hit' );
|
||||
return str_contains( strtolower( $header_value ), 'hit' );
|
||||
};
|
||||
|
||||
$cache_headers = array(
|
||||
@@ -3195,9 +3388,11 @@ class WP_Site_Health {
|
||||
|
||||
$headers = array();
|
||||
|
||||
// Include basic auth in loopback requests. Note that this will only pass along basic auth when user is
|
||||
// initiating the test. If a site requires basic auth, the test will fail when it runs in WP Cron as part of
|
||||
// wp_site_health_scheduled_check. This logic is copied from WP_Site_Health::can_perform_loopback().
|
||||
/*
|
||||
* Include basic auth in loopback requests. Note that this will only pass along basic auth when user is
|
||||
* initiating the test. If a site requires basic auth, the test will fail when it runs in WP Cron as part of
|
||||
* wp_site_health_scheduled_check. This logic is copied from WP_Site_Health::can_perform_loopback().
|
||||
*/
|
||||
if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
|
||||
$headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
|
||||
}
|
||||
|
||||
@@ -201,9 +201,9 @@ class WP_Site_Icon {
|
||||
* @param int $post_id Attachment ID.
|
||||
*/
|
||||
public function delete_attachment_data( $post_id ) {
|
||||
$site_icon_id = get_option( 'site_icon' );
|
||||
$site_icon_id = (int) get_option( 'site_icon' );
|
||||
|
||||
if ( $site_icon_id && $post_id == $site_icon_id ) {
|
||||
if ( $site_icon_id && $post_id === $site_icon_id ) {
|
||||
delete_option( 'site_icon' );
|
||||
}
|
||||
}
|
||||
@@ -222,9 +222,9 @@ class WP_Site_Icon {
|
||||
*/
|
||||
public function get_post_metadata( $value, $post_id, $meta_key, $single ) {
|
||||
if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) {
|
||||
$site_icon_id = get_option( 'site_icon' );
|
||||
$site_icon_id = (int) get_option( 'site_icon' );
|
||||
|
||||
if ( $post_id == $site_icon_id ) {
|
||||
if ( $post_id === $site_icon_id ) {
|
||||
add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
$columns = array(
|
||||
@@ -208,12 +208,20 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
* @return array
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
$taxonomy = $this->screen->taxonomy;
|
||||
|
||||
if ( ! isset( $_GET['orderby'] ) && is_taxonomy_hierarchical( $taxonomy ) ) {
|
||||
$name_orderby_text = __( 'Table ordered hierarchically.' );
|
||||
} else {
|
||||
$name_orderby_text = __( 'Table ordered by Name.' );
|
||||
}
|
||||
|
||||
return array(
|
||||
'name' => 'name',
|
||||
'description' => 'description',
|
||||
'slug' => 'slug',
|
||||
'posts' => 'count',
|
||||
'links' => 'count',
|
||||
'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ),
|
||||
'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ),
|
||||
'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ),
|
||||
'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ),
|
||||
'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -357,7 +365,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
||||
|
||||
if ( current_user_can( 'delete_term', $tag->term_id ) ) {
|
||||
return sprintf(
|
||||
'<label class="screen-reader-text" for="cb-select-%1$s">%2$s</label>' .
|
||||
'<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" />',
|
||||
$tag->term_id,
|
||||
/* translators: Hidden accessibility text. %s: Taxonomy term name. */
|
||||
|
||||
@@ -544,7 +544,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if the theme is already installed.
|
||||
* Checks to see if the theme is already installed.
|
||||
*
|
||||
* @since 3.4.0
|
||||
*
|
||||
|
||||
@@ -170,7 +170,7 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return string[] Array of column titles keyed by their column name.
|
||||
*/
|
||||
public function get_columns() {
|
||||
return array();
|
||||
|
||||
@@ -197,7 +197,7 @@ class WP_Upgrader_Skin {
|
||||
$feedback = $this->upgrader->strings[ $feedback ];
|
||||
}
|
||||
|
||||
if ( strpos( $feedback, '%' ) !== false ) {
|
||||
if ( str_contains( $feedback, '%' ) ) {
|
||||
if ( $args ) {
|
||||
$args = array_map( 'strip_tags', $args );
|
||||
$args = array_map( 'esc_html', $args );
|
||||
@@ -211,21 +211,21 @@ class WP_Upgrader_Skin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to perform before an update.
|
||||
* Performs an action before an update.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function before() {}
|
||||
|
||||
/**
|
||||
* Action to perform following an update.
|
||||
* Performs and action following an update.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
public function after() {}
|
||||
|
||||
/**
|
||||
* Output JavaScript that calls function to decrement the update counts.
|
||||
* Outputs JavaScript that calls function to decrement the update counts.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
@@ -270,7 +270,7 @@ class WP_Upgrader_Skin {
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param WP_Error $wp_error WP_Error object.
|
||||
* @return bool
|
||||
* @return bool True if the error should be hidden, false otherwise.
|
||||
*/
|
||||
public function hide_process_failed( $wp_error ) {
|
||||
return false;
|
||||
|
||||
@@ -112,6 +112,26 @@ class WP_Upgrader {
|
||||
*/
|
||||
public $update_current = 0;
|
||||
|
||||
/**
|
||||
* Stores the list of plugins or themes added to temporary backup directory.
|
||||
*
|
||||
* Used by the rollback functions.
|
||||
*
|
||||
* @since 6.3.0
|
||||
* @var array
|
||||
*/
|
||||
private $temp_backups = array();
|
||||
|
||||
/**
|
||||
* Stores the list of plugins or themes to be restored from temporary backup directory.
|
||||
*
|
||||
* Used by the rollback functions.
|
||||
*
|
||||
* @since 6.3.0
|
||||
* @var array
|
||||
*/
|
||||
private $temp_restores = array();
|
||||
|
||||
/**
|
||||
* Construct the upgrader with a skin.
|
||||
*
|
||||
@@ -129,20 +149,38 @@ class WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the upgrader.
|
||||
* Initializes the upgrader.
|
||||
*
|
||||
* This will set the relationship between the skin being used and this upgrader,
|
||||
* and also add the generic strings to `WP_Upgrader::$strings`.
|
||||
*
|
||||
* Additionally, it will schedule a weekly task to clean up the temporary backup directory.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 6.3.0 Added the `schedule_temp_backup_cleanup()` task.
|
||||
*/
|
||||
public function init() {
|
||||
$this->skin->set_upgrader( $this );
|
||||
$this->generic_strings();
|
||||
|
||||
if ( ! wp_installing() ) {
|
||||
$this->schedule_temp_backup_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the generic strings to WP_Upgrader::$strings.
|
||||
* Schedules the cleanup of the temporary backup directory.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*/
|
||||
protected function schedule_temp_backup_cleanup() {
|
||||
if ( false === wp_next_scheduled( 'wp_delete_temp_updater_backups' ) ) {
|
||||
wp_schedule_event( time(), 'weekly', 'wp_delete_temp_updater_backups' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the generic strings to WP_Upgrader::$strings.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*/
|
||||
@@ -151,7 +189,7 @@ class WP_Upgrader {
|
||||
$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['fs_no_content_dir'] = __( 'Unable to locate WordPress content directory (wp-content).' );
|
||||
$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.' );
|
||||
/* translators: %s: Directory name. */
|
||||
@@ -167,10 +205,19 @@ class WP_Upgrader {
|
||||
|
||||
$this->strings['maintenance_start'] = __( 'Enabling Maintenance mode…' );
|
||||
$this->strings['maintenance_end'] = __( 'Disabling Maintenance mode…' );
|
||||
|
||||
/* translators: %s: upgrade-temp-backup */
|
||||
$this->strings['temp_backup_mkdir_failed'] = sprintf( __( 'Could not create the %s directory.' ), 'upgrade-temp-backup' );
|
||||
/* translators: %s: upgrade-temp-backup */
|
||||
$this->strings['temp_backup_move_failed'] = sprintf( __( 'Could not move the old version to the %s directory.' ), 'upgrade-temp-backup' );
|
||||
/* translators: %s: The plugin or theme slug. */
|
||||
$this->strings['temp_backup_restore_failed'] = __( 'Could not restore the original version of %s.' );
|
||||
/* translators: %s: The plugin or theme slug. */
|
||||
$this->strings['temp_backup_delete_failed'] = __( 'Could not delete the temporary backup directory for %s.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the filesystem.
|
||||
* Connects to the filesystem.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
@@ -242,7 +289,7 @@ class WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a package.
|
||||
* Downloads a package.
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @since 5.2.0 Added the `$check_signatures` parameter.
|
||||
@@ -292,7 +339,7 @@ class WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpack a compressed package file.
|
||||
* Unpacks a compressed package file.
|
||||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
@@ -308,6 +355,10 @@ class WP_Upgrader {
|
||||
|
||||
$this->skin->feedback( 'unpack_package' );
|
||||
|
||||
if ( ! $wp_filesystem->wp_content_dir() ) {
|
||||
return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
|
||||
}
|
||||
|
||||
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
|
||||
|
||||
// Clean up contents of upgrade directory beforehand.
|
||||
@@ -346,7 +397,7 @@ class WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Flatten the results of WP_Filesystem_Base::dirlist() for iterating over.
|
||||
* Flattens the results of WP_Filesystem_Base::dirlist() for iterating over.
|
||||
*
|
||||
* @since 4.9.0
|
||||
* @access protected
|
||||
@@ -512,8 +563,10 @@ class WP_Upgrader {
|
||||
// There are no files?
|
||||
return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] );
|
||||
} else {
|
||||
// It's only a single file, the upgrader will use the folder name of this file as the destination folder.
|
||||
// Folder name is based on zip filename.
|
||||
/*
|
||||
* It's only a single file, the upgrader will use the folder name of this file as the destination folder.
|
||||
* Folder name is based on zip filename.
|
||||
*/
|
||||
$source = trailingslashit( $args['source'] );
|
||||
}
|
||||
|
||||
@@ -534,6 +587,16 @@ class WP_Upgrader {
|
||||
return $source;
|
||||
}
|
||||
|
||||
if ( ! empty( $args['hook_extra']['temp_backup'] ) ) {
|
||||
$temp_backup = $this->move_to_temp_backup_dir( $args['hook_extra']['temp_backup'] );
|
||||
|
||||
if ( is_wp_error( $temp_backup ) ) {
|
||||
return $temp_backup;
|
||||
}
|
||||
|
||||
$this->temp_backups[] = $args['hook_extra']['temp_backup'];
|
||||
}
|
||||
|
||||
// Has the source location changed? If so, we need a new source_files list.
|
||||
if ( $source !== $remote_source ) {
|
||||
$source_files = array_keys( $wp_filesystem->dirlist( $source ) );
|
||||
@@ -580,8 +643,10 @@ class WP_Upgrader {
|
||||
return $removed;
|
||||
}
|
||||
} elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) {
|
||||
// If we're not clearing the destination folder and something exists there already, bail.
|
||||
// But first check to see if there are actually any files in the folder.
|
||||
/*
|
||||
* If we're not clearing the destination folder and something exists there already, bail.
|
||||
* But first check to see if there are actually any files in the folder.
|
||||
*/
|
||||
$_files = $wp_filesystem->dirlist( $remote_destination );
|
||||
if ( ! empty( $_files ) ) {
|
||||
$wp_filesystem->delete( $remote_source, true ); // Clear out the source files.
|
||||
@@ -614,7 +679,7 @@ class WP_Upgrader {
|
||||
$result = copy_dir( $source, $remote_destination );
|
||||
}
|
||||
|
||||
// Clear the working folder?
|
||||
// Clear the working directory?
|
||||
if ( $args['clear_working'] ) {
|
||||
$wp_filesystem->delete( $remote_source, true );
|
||||
}
|
||||
@@ -651,7 +716,7 @@ class WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Run an upgrade/installation.
|
||||
* Runs an upgrade/installation.
|
||||
*
|
||||
* Attempts to download the package (if it is not a local file), unpack it, and
|
||||
* install it in the destination folder.
|
||||
@@ -760,8 +825,10 @@ class WP_Upgrader {
|
||||
*/
|
||||
$download = $this->download_package( $options['package'], true, $options['hook_extra'] );
|
||||
|
||||
// Allow for signature soft-fail.
|
||||
// WARNING: This may be removed in the future.
|
||||
/*
|
||||
* Allow for signature soft-fail.
|
||||
* WARNING: This may be removed in the future.
|
||||
*/
|
||||
if ( is_wp_error( $download ) && $download->get_error_data( 'softfail-filename' ) ) {
|
||||
|
||||
// Don't output the 'no signature could be found' failure message for now.
|
||||
@@ -827,7 +894,19 @@ class WP_Upgrader {
|
||||
$result = apply_filters( 'upgrader_install_package_result', $result, $options['hook_extra'] );
|
||||
|
||||
$this->skin->set_result( $result );
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
if ( ! empty( $options['hook_extra']['temp_backup'] ) ) {
|
||||
$this->temp_restores[] = $options['hook_extra']['temp_backup'];
|
||||
|
||||
/*
|
||||
* Restore the backup on shutdown.
|
||||
* Actions running on `shutdown` are immune to PHP timeouts,
|
||||
* so in case the failure was due to a PHP timeout,
|
||||
* it will still be able to properly restore the previous version.
|
||||
*/
|
||||
add_action( 'shutdown', array( $this, 'restore_temp_backup' ) );
|
||||
}
|
||||
$this->skin->error( $result );
|
||||
|
||||
if ( ! method_exists( $this->skin, 'hide_process_failed' ) || ! $this->skin->hide_process_failed( $result ) ) {
|
||||
@@ -840,6 +919,12 @@ class WP_Upgrader {
|
||||
|
||||
$this->skin->after();
|
||||
|
||||
// Clean up the backup kept in the temporary backup directory.
|
||||
if ( ! empty( $options['hook_extra']['temp_backup'] ) ) {
|
||||
// Delete the backup on `shutdown` to avoid a PHP timeout.
|
||||
add_action( 'shutdown', array( $this, 'delete_temp_backup' ), 100, 0 );
|
||||
}
|
||||
|
||||
if ( ! $options['is_multi'] ) {
|
||||
|
||||
/**
|
||||
@@ -881,7 +966,7 @@ class WP_Upgrader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle maintenance mode for the site.
|
||||
* Toggles maintenance mode for the site.
|
||||
*
|
||||
* Creates/deletes the maintenance file to enable/disable maintenance mode.
|
||||
*
|
||||
@@ -966,6 +1051,170 @@ class WP_Upgrader {
|
||||
public static function release_lock( $lock_name ) {
|
||||
return delete_option( $lock_name . '.lock' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the plugin or theme being updated into a temporary backup directory.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
|
||||
*
|
||||
* @param string[] $args {
|
||||
* Array of data for the temporary backup.
|
||||
*
|
||||
* @type string $slug Plugin or theme slug.
|
||||
* @type string $src Path to the root directory for plugins or themes.
|
||||
* @type string $dir Destination subdirectory name. Accepts 'plugins' or 'themes'.
|
||||
* }
|
||||
*
|
||||
* @return bool|WP_Error True on success, false on early exit, otherwise WP_Error.
|
||||
*/
|
||||
public function move_to_temp_backup_dir( $args ) {
|
||||
global $wp_filesystem;
|
||||
|
||||
if ( empty( $args['slug'] ) || empty( $args['src'] ) || empty( $args['dir'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip any plugin that has "." as its slug.
|
||||
* A slug of "." will result in a `$src` value ending in a period.
|
||||
*
|
||||
* On Windows, this will cause the 'plugins' folder to be moved,
|
||||
* and will cause a failure when attempting to call `mkdir()`.
|
||||
*/
|
||||
if ( '.' === $args['slug'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $wp_filesystem->wp_content_dir() ) {
|
||||
return new WP_Error( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
|
||||
}
|
||||
|
||||
$dest_dir = $wp_filesystem->wp_content_dir() . 'upgrade-temp-backup/';
|
||||
$sub_dir = $dest_dir . $args['dir'] . '/';
|
||||
|
||||
// Create the temporary backup directory if it does not exist.
|
||||
if ( ! $wp_filesystem->is_dir( $sub_dir ) ) {
|
||||
if ( ! $wp_filesystem->is_dir( $dest_dir ) ) {
|
||||
$wp_filesystem->mkdir( $dest_dir, FS_CHMOD_DIR );
|
||||
}
|
||||
|
||||
if ( ! $wp_filesystem->mkdir( $sub_dir, FS_CHMOD_DIR ) ) {
|
||||
// Could not create the backup directory.
|
||||
return new WP_Error( 'fs_temp_backup_mkdir', $this->strings['temp_backup_mkdir_failed'] );
|
||||
}
|
||||
}
|
||||
|
||||
$src_dir = $wp_filesystem->find_folder( $args['src'] );
|
||||
$src = trailingslashit( $src_dir ) . $args['slug'];
|
||||
$dest = $dest_dir . trailingslashit( $args['dir'] ) . $args['slug'];
|
||||
|
||||
// Delete the temporary backup directory if it already exists.
|
||||
if ( $wp_filesystem->is_dir( $dest ) ) {
|
||||
$wp_filesystem->delete( $dest, true );
|
||||
}
|
||||
|
||||
// Move to the temporary backup directory.
|
||||
$result = move_dir( $src, $dest, true );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
return new WP_Error( 'fs_temp_backup_move', $this->strings['temp_backup_move_failed'] );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the plugin or theme from temporary backup.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
|
||||
*
|
||||
* @return bool|WP_Error True on success, false on early exit, otherwise WP_Error.
|
||||
*/
|
||||
public function restore_temp_backup() {
|
||||
global $wp_filesystem;
|
||||
|
||||
$errors = new WP_Error();
|
||||
|
||||
foreach ( $this->temp_restores as $args ) {
|
||||
if ( empty( $args['slug'] ) || empty( $args['src'] ) || empty( $args['dir'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $wp_filesystem->wp_content_dir() ) {
|
||||
$errors->add( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
|
||||
return $errors;
|
||||
}
|
||||
|
||||
$src = $wp_filesystem->wp_content_dir() . 'upgrade-temp-backup/' . $args['dir'] . '/' . $args['slug'];
|
||||
$dest_dir = $wp_filesystem->find_folder( $args['src'] );
|
||||
$dest = trailingslashit( $dest_dir ) . $args['slug'];
|
||||
|
||||
if ( $wp_filesystem->is_dir( $src ) ) {
|
||||
// Cleanup.
|
||||
if ( $wp_filesystem->is_dir( $dest ) && ! $wp_filesystem->delete( $dest, true ) ) {
|
||||
$errors->add(
|
||||
'fs_temp_backup_delete',
|
||||
sprintf( $this->strings['temp_backup_restore_failed'], $args['slug'] )
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Move it.
|
||||
$result = move_dir( $src, $dest, true );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
$errors->add(
|
||||
'fs_temp_backup_delete',
|
||||
sprintf( $this->strings['temp_backup_restore_failed'], $args['slug'] )
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $errors->has_errors() ? $errors : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a temporary backup.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
|
||||
*
|
||||
* @return bool|WP_Error True on success, false on early exit, otherwise WP_Error.
|
||||
*/
|
||||
public function delete_temp_backup() {
|
||||
global $wp_filesystem;
|
||||
|
||||
$errors = new WP_Error();
|
||||
|
||||
foreach ( $this->temp_backups as $args ) {
|
||||
if ( empty( $args['slug'] ) || empty( $args['dir'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! $wp_filesystem->wp_content_dir() ) {
|
||||
$errors->add( 'fs_no_content_dir', $this->strings['fs_no_content_dir'] );
|
||||
return $errors;
|
||||
}
|
||||
|
||||
$temp_backup_dir = $wp_filesystem->wp_content_dir() . "upgrade-temp-backup/{$args['dir']}/{$args['slug']}";
|
||||
|
||||
if ( ! $wp_filesystem->delete( $temp_backup_dir, true ) ) {
|
||||
$errors->add(
|
||||
'temp_backup_delete_failed',
|
||||
sprintf( $this->strings['temp_backup_delete_failed'] ),
|
||||
$args['slug']
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return $errors->has_errors() ? $errors : true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Plugin_Upgrader class */
|
||||
|
||||
@@ -58,7 +58,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the current user's permissions.
|
||||
* Checks the current user's permissions.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -73,7 +73,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the users list for display.
|
||||
* Prepares the users list for display.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -150,7 +150,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Output 'no users' message.
|
||||
* Outputs 'no users' message.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -159,7 +159,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an associative array listing all the views that can be used
|
||||
* Returns an associative array listing all the views that can be used
|
||||
* with this table.
|
||||
*
|
||||
* Provides a list of roles and user count for that role for easy
|
||||
@@ -262,7 +262,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve an associative array of bulk actions available on this table.
|
||||
* Retrieves an associative array of bulk actions available on this table.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -290,7 +290,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the controls to allow user roles to be changed in bulk.
|
||||
* Outputs the controls to allow user roles to be changed in bulk.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -343,7 +343,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture the bulk action required, and return it.
|
||||
* Captures the bulk action required, and return it.
|
||||
*
|
||||
* Overridden from the base class implementation to capture
|
||||
* the role change drop-down.
|
||||
@@ -353,7 +353,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
* @return string The bulk action required.
|
||||
*/
|
||||
public function current_action() {
|
||||
if ( isset( $_REQUEST['changeit'] ) && ! empty( $_REQUEST['new_role'] ) ) {
|
||||
if ( isset( $_REQUEST['changeit'] ) ) {
|
||||
return 'promote';
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of columns for the list table.
|
||||
* Gets a list of columns for the list table.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -385,7 +385,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of sortable columns for the list table.
|
||||
* Gets a list of sortable columns for the list table.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
@@ -393,15 +393,15 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
*/
|
||||
protected function get_sortable_columns() {
|
||||
$columns = array(
|
||||
'username' => 'login',
|
||||
'email' => 'email',
|
||||
'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ),
|
||||
'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ),
|
||||
);
|
||||
|
||||
return $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the list table rows.
|
||||
* Generates the list table rows.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -417,7 +417,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate HTML for a single row on the users.php admin panel.
|
||||
* Generates HTML for a single row on the users.php admin panel.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @since 4.2.0 The `$style` parameter was deprecated.
|
||||
@@ -502,6 +502,7 @@ class WP_Users_List_Table extends WP_List_Table {
|
||||
// Add a link to send the user a reset password link by email.
|
||||
if ( get_current_user_id() !== $user_object->ID
|
||||
&& current_user_can( 'edit_user', $user_object->ID )
|
||||
&& true === wp_is_password_reset_allowed_for_user( $user_object )
|
||||
) {
|
||||
$actions['resetpassword'] = "<a class='resetpassword' href='" . wp_nonce_url( "users.php?action=resetpassword&users=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Send password reset' ) . '</a>';
|
||||
}
|
||||
@@ -523,7 +524,7 @@ 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="screen-reader-text" for="user_%1$s">%2$s</label>' .
|
||||
'<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" />',
|
||||
$user_object->ID,
|
||||
/* translators: Hidden accessibility text. %s: User login. */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieve the contributor credits.
|
||||
* Retrieves the contributor credits.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @since 5.6.0 Added the `$version` and `$locale` parameters.
|
||||
@@ -32,8 +32,8 @@ function wp_credits( $version = '', $locale = '' ) {
|
||||
$results = get_site_transient( 'wordpress_credits_' . $locale );
|
||||
|
||||
if ( ! is_array( $results )
|
||||
|| false !== strpos( $version, '-' )
|
||||
|| ( isset( $results['data']['version'] ) && strpos( $version, $results['data']['version'] ) !== 0 )
|
||||
|| str_contains( $version, '-' )
|
||||
|| ( isset( $results['data']['version'] ) && ! str_starts_with( $version, $results['data']['version'] ) )
|
||||
) {
|
||||
$url = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
|
||||
$options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );
|
||||
@@ -61,7 +61,7 @@ function wp_credits( $version = '', $locale = '' ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the link to a contributor's WordPress.org profile page.
|
||||
* Retrieves the link to a contributor's WordPress.org profile page.
|
||||
*
|
||||
* @access private
|
||||
* @since 3.2.0
|
||||
@@ -75,7 +75,7 @@ function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the link to an external library used in WordPress.
|
||||
* Retrieves the link to an external library used in WordPress.
|
||||
*
|
||||
* @access private
|
||||
* @since 3.2.0
|
||||
|
||||
@@ -532,7 +532,7 @@ function wp_network_dashboard_right_now() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Quick Draft widget display and creation of drafts.
|
||||
* Displays the Quick Draft widget.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*
|
||||
@@ -920,7 +920,9 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for Activity widget.
|
||||
* Outputs the Activity widget.
|
||||
*
|
||||
* Callback function for {@see 'dashboard_activity'}.
|
||||
*
|
||||
* @since 3.8.0
|
||||
*/
|
||||
@@ -982,7 +984,7 @@ function wp_dashboard_recent_posts( $args ) {
|
||||
'order' => $args['order'],
|
||||
'posts_per_page' => (int) $args['max'],
|
||||
'no_found_rows' => true,
|
||||
'cache_results' => false,
|
||||
'cache_results' => true,
|
||||
'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
|
||||
);
|
||||
|
||||
@@ -1227,10 +1229,9 @@ function wp_dashboard_trigger_widget_control( $widget_control_id = false ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The RSS dashboard widget control.
|
||||
* Sets up the RSS dashboard widget control and $args to be used as input to wp_widget_rss_form().
|
||||
*
|
||||
* Sets up $args to be used as input to wp_widget_rss_form(). Handles POST data
|
||||
* from RSS-type widgets.
|
||||
* Handles POST data from RSS-type widgets.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
@@ -1297,7 +1298,7 @@ function wp_dashboard_events_news() {
|
||||
<p class="community-events-footer">
|
||||
<?php
|
||||
printf(
|
||||
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
|
||||
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
|
||||
'https://make.wordpress.org/community/meetups-landing-page',
|
||||
__( 'Meetups' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -1309,7 +1310,7 @@ function wp_dashboard_events_news() {
|
||||
|
||||
<?php
|
||||
printf(
|
||||
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
|
||||
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
|
||||
'https://central.wordcamp.org/schedule/',
|
||||
__( 'WordCamps' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -1321,7 +1322,7 @@ function wp_dashboard_events_news() {
|
||||
|
||||
<?php
|
||||
printf(
|
||||
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
|
||||
'<a href="%1$s" target="_blank">%2$s <span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
|
||||
/* translators: If a Rosetta site exists (e.g. https://es.wordpress.org/news/), then use that. Otherwise, leave untranslated. */
|
||||
esc_url( _x( 'https://wordpress.org/news/', 'Events and News dashboard widget' ) ),
|
||||
__( 'News' ),
|
||||
@@ -1647,7 +1648,7 @@ function wp_dashboard_quota() {
|
||||
number_format_i18n( $quota )
|
||||
);
|
||||
printf(
|
||||
'<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
|
||||
'<a href="%1$s">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
|
||||
esc_url( admin_url( 'upload.php' ) ),
|
||||
$text,
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -1663,7 +1664,7 @@ function wp_dashboard_quota() {
|
||||
$percentused
|
||||
);
|
||||
printf(
|
||||
'<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>',
|
||||
'<a href="%1$s" class="musublink">%2$s<span class="screen-reader-text"> (%3$s)</span></a>',
|
||||
esc_url( admin_url( 'upload.php' ) ),
|
||||
$text,
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -1894,7 +1895,7 @@ function wp_dashboard_php_nag() {
|
||||
<p class="button-container">
|
||||
<?php
|
||||
printf(
|
||||
'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s <span class="screen-reader-text">%3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
|
||||
'<a class="button button-primary" href="%1$s" target="_blank" rel="noopener">%2$s<span class="screen-reader-text"> %3$s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a>',
|
||||
esc_url( wp_get_update_php_url() ),
|
||||
__( 'Learn more about updating PHP' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
@@ -2023,7 +2024,9 @@ function wp_dashboard_site_health() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty function usable by plugins to output empty dashboard widget (to be populated later by JS).
|
||||
* Outputs empty dashboard widget to be populated by JS later.
|
||||
*
|
||||
* Usable by plugins.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
@@ -2095,6 +2098,7 @@ function wp_welcome_panel() {
|
||||
<?php if ( $is_block_theme ) : ?>
|
||||
<h3><?php _e( 'Switch up your site’s look & feel with Styles' ); ?></h3>
|
||||
<p><?php _e( 'Tweak your site, or give it a whole new look! Get creative — how about a new color palette or font?' ); ?></p>
|
||||
<a href="<?php echo esc_url( admin_url( '/site-editor.php?path=%2Fwp_global_styles' ) ); ?>"><?php _e( 'Edit styles' ); ?></a>
|
||||
<?php else : ?>
|
||||
<h3><?php _e( 'Discover a new way to build your site.' ); ?></h3>
|
||||
<p><?php _e( 'There is a new kind of WordPress theme, called a block theme, that lets you build the site you’ve always wanted — with blocks and styles.' ); ?></p>
|
||||
|
||||
@@ -197,7 +197,7 @@ function remove_option_update_handler( $option_group, $option_name, $sanitize_ca
|
||||
* @deprecated 3.0.0
|
||||
*
|
||||
* @param string $filename
|
||||
**/
|
||||
*/
|
||||
function codepress_get_lang( $filename ) {
|
||||
_deprecated_function( __FUNCTION__, '3.0.0' );
|
||||
}
|
||||
@@ -207,7 +207,7 @@ function codepress_get_lang( $filename ) {
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @deprecated 3.0.0
|
||||
**/
|
||||
*/
|
||||
function codepress_footer_js() {
|
||||
_deprecated_function( __FUNCTION__, '3.0.0' );
|
||||
}
|
||||
@@ -217,7 +217,7 @@ function codepress_footer_js() {
|
||||
*
|
||||
* @since 2.8.0
|
||||
* @deprecated 3.0.0
|
||||
**/
|
||||
*/
|
||||
function use_codepress() {
|
||||
_deprecated_function( __FUNCTION__, '3.0.0' );
|
||||
}
|
||||
@@ -1365,7 +1365,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) {
|
||||
// Is this random plugin's slug already installed? If so, try again.
|
||||
reset( $plugin_slugs );
|
||||
foreach ( $plugin_slugs as $plugin_slug ) {
|
||||
if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) {
|
||||
if ( str_starts_with( $plugin_slug, $slug ) ) {
|
||||
unset( $items[$item_key] );
|
||||
continue 2;
|
||||
}
|
||||
@@ -1376,7 +1376,7 @@ function wp_dashboard_plugins_output( $rss, $args = array() ) {
|
||||
}
|
||||
|
||||
// Eliminate some common badly formed plugin descriptions.
|
||||
while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) )
|
||||
while ( ( null !== $item_key = array_rand($items) ) && str_contains( $items[$item_key]->get_description(), 'Plugin Name:' ) )
|
||||
unset($items[$item_key]);
|
||||
|
||||
if ( !isset($items[$item_key]) )
|
||||
|
||||
@@ -218,7 +218,7 @@ function export_wp( $args = array() ) {
|
||||
// Multisite: the base URL.
|
||||
return network_home_url();
|
||||
} else {
|
||||
// WordPress (single site): the blog URL.
|
||||
// WordPress (single site): the site URL.
|
||||
return get_bloginfo_rss( 'url' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,13 +127,16 @@ function get_home_path() {
|
||||
*
|
||||
* @since 2.6.0
|
||||
* @since 4.9.0 Added the `$exclusions` parameter.
|
||||
* @since 6.3.0 Added the `$include_hidden` parameter.
|
||||
*
|
||||
* @param string $folder Optional. Full path to folder. Default empty.
|
||||
* @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit).
|
||||
* @param string[] $exclusions Optional. List of folders and files to skip.
|
||||
* @param string $folder Optional. Full path to folder. Default empty.
|
||||
* @param int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit).
|
||||
* @param string[] $exclusions Optional. List of folders and files to skip.
|
||||
* @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
|
||||
* Default false.
|
||||
* @return string[]|false Array of files on success, false on failure.
|
||||
*/
|
||||
function list_files( $folder = '', $levels = 100, $exclusions = array() ) {
|
||||
function list_files( $folder = '', $levels = 100, $exclusions = array(), $include_hidden = false ) {
|
||||
if ( empty( $folder ) ) {
|
||||
return false;
|
||||
}
|
||||
@@ -156,12 +159,12 @@ function list_files( $folder = '', $levels = 100, $exclusions = array() ) {
|
||||
}
|
||||
|
||||
// Skip hidden and excluded files.
|
||||
if ( '.' === $file[0] || in_array( $file, $exclusions, true ) ) {
|
||||
if ( ( ! $include_hidden && '.' === $file[0] ) || in_array( $file, $exclusions, true ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_dir( $folder . $file ) ) {
|
||||
$files2 = list_files( $folder . $file, $levels - 1 );
|
||||
$files2 = list_files( $folder . $file, $levels - 1, array(), $include_hidden );
|
||||
if ( $files2 ) {
|
||||
$files = array_merge( $files, $files2 );
|
||||
} else {
|
||||
@@ -310,7 +313,7 @@ function wp_print_file_editor_templates() {
|
||||
<?php
|
||||
printf(
|
||||
/* translators: 1: Line number, 2: File path. */
|
||||
__( 'Your PHP code changes were rolled back due to an error on line %1$s of file %2$s. Please fix and try saving again.' ),
|
||||
__( 'Your PHP code changes were not applied due to an error on line %1$s of file %2$s. Please fix and try saving again.' ),
|
||||
'{{ data.line }}',
|
||||
'{{ data.file }}'
|
||||
);
|
||||
@@ -571,8 +574,10 @@ function wp_edit_theme_plugin_file( $args ) {
|
||||
}
|
||||
|
||||
if ( function_exists( 'session_status' ) && PHP_SESSION_ACTIVE === session_status() ) {
|
||||
// Close any active session to prevent HTTP requests from timing out
|
||||
// when attempting to connect back to the site.
|
||||
/*
|
||||
* Close any active session to prevent HTTP requests from timing out
|
||||
* when attempting to connect back to the site.
|
||||
*/
|
||||
session_write_close();
|
||||
}
|
||||
|
||||
@@ -684,7 +689,25 @@ function wp_tempnam( $filename = '', $dir = '' ) {
|
||||
// Suffix some random data to avoid filename conflicts.
|
||||
$temp_filename .= '-' . wp_generate_password( 6, false );
|
||||
$temp_filename .= '.tmp';
|
||||
$temp_filename = $dir . wp_unique_filename( $dir, $temp_filename );
|
||||
$temp_filename = wp_unique_filename( $dir, $temp_filename );
|
||||
|
||||
/*
|
||||
* Filesystems typically have a limit of 255 characters for a filename.
|
||||
*
|
||||
* If the generated unique filename exceeds this, truncate the initial
|
||||
* filename and try again.
|
||||
*
|
||||
* As it's possible that the truncated filename may exist, producing a
|
||||
* suffix of "-1" or "-10" which could exceed the limit again, truncate
|
||||
* it to 252 instead.
|
||||
*/
|
||||
$characters_over_limit = strlen( $temp_filename ) - 252;
|
||||
if ( $characters_over_limit > 0 ) {
|
||||
$filename = substr( $filename, 0, -$characters_over_limit );
|
||||
return wp_tempnam( $filename, $dir );
|
||||
}
|
||||
|
||||
$temp_filename = $dir . $temp_filename;
|
||||
|
||||
$fp = @fopen( $temp_filename, 'x' );
|
||||
|
||||
@@ -890,7 +913,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||
|
||||
// If you override this, you must provide $ext and $type!!
|
||||
$test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true;
|
||||
$mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false;
|
||||
$mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : null;
|
||||
|
||||
// A correct form post will pass this test.
|
||||
if ( $test_form && ( ! isset( $_POST['action'] ) || $_POST['action'] !== $action ) ) {
|
||||
@@ -997,7 +1020,7 @@ function _wp_handle_upload( &$file, $overrides, $time, $action ) {
|
||||
}
|
||||
|
||||
if ( false === $move_new_file ) {
|
||||
if ( 0 === strpos( $uploads['basedir'], ABSPATH ) ) {
|
||||
if ( str_starts_with( $uploads['basedir'], ABSPATH ) ) {
|
||||
$error_path = str_replace( ABSPATH, '', $uploads['basedir'] ) . $uploads['subdir'];
|
||||
} else {
|
||||
$error_path = basename( $uploads['basedir'] ) . $uploads['subdir'];
|
||||
@@ -1196,7 +1219,7 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
|
||||
if ( $content_disposition ) {
|
||||
$content_disposition = strtolower( $content_disposition );
|
||||
|
||||
if ( 0 === strpos( $content_disposition, 'attachment; filename=' ) ) {
|
||||
if ( str_starts_with( $content_disposition, 'attachment; filename=' ) ) {
|
||||
$tmpfname_disposition = sanitize_file_name( substr( $content_disposition, 21 ) );
|
||||
} else {
|
||||
$tmpfname_disposition = '';
|
||||
@@ -1248,12 +1271,14 @@ function download_url( $url, $timeout = 300, $signature_verification = false ) {
|
||||
$signature = wp_remote_retrieve_header( $response, 'X-Content-Signature' );
|
||||
|
||||
if ( ! $signature ) {
|
||||
// Retrieve signatures from a file if the header wasn't included.
|
||||
// WordPress.org stores signatures at $package_url.sig.
|
||||
/*
|
||||
* Retrieve signatures from a file if the header wasn't included.
|
||||
* WordPress.org stores signatures at $package_url.sig.
|
||||
*/
|
||||
|
||||
$signature_url = false;
|
||||
|
||||
if ( is_string( $url_path ) && ( '.zip' === substr( $url_path, -4 ) || '.tar.gz' === substr( $url_path, -7 ) ) ) {
|
||||
if ( is_string( $url_path ) && ( str_ends_with( $url_path, '.zip' ) || str_ends_with( $url_path, '.tar.gz' ) ) ) {
|
||||
$signature_url = str_replace( $url_path, $url_path . '.sig', $url );
|
||||
}
|
||||
|
||||
@@ -1377,14 +1402,16 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
|
||||
);
|
||||
}
|
||||
|
||||
// Check for a edge-case affecting PHP Maths abilities.
|
||||
// Check for an edge-case affecting PHP Maths abilities.
|
||||
if (
|
||||
! extension_loaded( 'sodium' ) &&
|
||||
in_array( PHP_VERSION_ID, array( 70200, 70201, 70202 ), true ) &&
|
||||
extension_loaded( 'opcache' )
|
||||
) {
|
||||
// Sodium_Compat isn't compatible with PHP 7.2.0~7.2.2 due to a bug in the PHP Opcache extension, bail early as it'll fail.
|
||||
// https://bugs.php.net/bug.php?id=75938
|
||||
/*
|
||||
* Sodium_Compat isn't compatible with PHP 7.2.0~7.2.2 due to a bug in the PHP Opcache extension, bail early as it'll fail.
|
||||
* https://bugs.php.net/bug.php?id=75938
|
||||
*/
|
||||
return new WP_Error(
|
||||
'signature_verification_unsupported',
|
||||
sprintf(
|
||||
@@ -1417,8 +1444,10 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
|
||||
// phpcs:enable
|
||||
}
|
||||
|
||||
// This cannot be performed in a reasonable amount of time.
|
||||
// https://github.com/paragonie/sodium_compat#help-sodium_compat-is-slow-how-can-i-make-it-fast
|
||||
/*
|
||||
* This cannot be performed in a reasonable amount of time.
|
||||
* https://github.com/paragonie/sodium_compat#help-sodium_compat-is-slow-how-can-i-make-it-fast
|
||||
*/
|
||||
if ( ! $sodium_compat_is_fast ) {
|
||||
return new WP_Error(
|
||||
'signature_verification_unsupported',
|
||||
@@ -1646,7 +1675,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
|
||||
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
|
||||
}
|
||||
|
||||
if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory.
|
||||
if ( str_starts_with( $info['name'], '__MACOSX/' ) ) { // Skip the OS X-created __MACOSX directory.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1659,7 +1688,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
|
||||
|
||||
$dirname = dirname( $info['name'] );
|
||||
|
||||
if ( '/' === substr( $info['name'], -1 ) ) {
|
||||
if ( str_ends_with( $info['name'], '/' ) ) {
|
||||
// Directory.
|
||||
$needed_dirs[] = $to . untrailingslashit( $info['name'] );
|
||||
} elseif ( '.' !== $dirname ) {
|
||||
@@ -1693,7 +1722,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it.
|
||||
if ( ! str_contains( $dir, $to ) ) { // If the directory is not within the working directory, skip it.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1726,11 +1755,11 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
|
||||
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
|
||||
}
|
||||
|
||||
if ( '/' === substr( $info['name'], -1 ) ) { // Directory.
|
||||
if ( str_ends_with( $info['name'], '/' ) ) { // Directory.
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( '__MACOSX/' === substr( $info['name'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files.
|
||||
if ( str_starts_with( $info['name'], '__MACOSX/' ) ) { // Don't extract the OS X-created __MACOSX directory files.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1800,7 +1829,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
|
||||
|
||||
// Determine any children directories needed (From within the archive).
|
||||
foreach ( $archive_files as $file ) {
|
||||
if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Skip the OS X-created __MACOSX directory.
|
||||
if ( str_starts_with( $file['filename'], '__MACOSX/' ) ) { // Skip the OS X-created __MACOSX directory.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1834,7 +1863,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( strpos( $dir, $to ) === false ) { // If the directory is not within the working directory, skip it.
|
||||
if ( ! str_contains( $dir, $to ) ) { // If the directory is not within the working directory, skip it.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1866,7 +1895,7 @@ function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( '__MACOSX/' === substr( $file['filename'], 0, 9 ) ) { // Don't extract the OS X-created __MACOSX directory files.
|
||||
if ( str_starts_with( $file['filename'], '__MACOSX/' ) ) { // Don't extract the OS X-created __MACOSX directory files.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1904,12 +1933,20 @@ function copy_dir( $from, $to, $skip_list = array() ) {
|
||||
$dirlist = $wp_filesystem->dirlist( $from );
|
||||
|
||||
if ( false === $dirlist ) {
|
||||
return new WP_Error( 'dirlist_failed_copy_dir', __( 'Directory listing failed.' ), basename( $to ) );
|
||||
return new WP_Error( 'dirlist_failed_copy_dir', __( 'Directory listing failed.' ), basename( $from ) );
|
||||
}
|
||||
|
||||
$from = trailingslashit( $from );
|
||||
$to = trailingslashit( $to );
|
||||
|
||||
if ( ! $wp_filesystem->exists( $to ) && ! $wp_filesystem->mkdir( $to ) ) {
|
||||
return new WP_Error(
|
||||
'mkdir_destination_failed_copy_dir',
|
||||
__( 'Could not create the destination directory.' ),
|
||||
basename( $to )
|
||||
);
|
||||
}
|
||||
|
||||
foreach ( (array) $dirlist as $filename => $fileinfo ) {
|
||||
if ( in_array( $filename, $skip_list, true ) ) {
|
||||
continue;
|
||||
@@ -1937,7 +1974,7 @@ function copy_dir( $from, $to, $skip_list = array() ) {
|
||||
$sub_skip_list = array();
|
||||
|
||||
foreach ( $skip_list as $skip_item ) {
|
||||
if ( 0 === strpos( $skip_item, $filename . '/' ) ) {
|
||||
if ( str_starts_with( $skip_item, $filename . '/' ) ) {
|
||||
$sub_skip_list[] = preg_replace( '!^' . preg_quote( $filename, '!' ) . '/!i', '', $skip_item );
|
||||
}
|
||||
}
|
||||
@@ -2316,8 +2353,10 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
|
||||
'private_key' => 'FTP_PRIKEY',
|
||||
);
|
||||
|
||||
// If defined, set it to that. Else, if POST'd, set it to that. If not, set it to an empty string.
|
||||
// Otherwise, keep it as it previously was (saved details in option).
|
||||
/*
|
||||
* If defined, set it to that. Else, if POST'd, set it to that. If not, set it to an empty string.
|
||||
* Otherwise, keep it as it previously was (saved details in option).
|
||||
*/
|
||||
foreach ( $ftp_constants as $key => $constant ) {
|
||||
if ( defined( $constant ) ) {
|
||||
$credentials[ $key ] = constant( $constant );
|
||||
@@ -2520,8 +2559,10 @@ function request_filesystem_credentials( $form_post, $type = '', $error = false,
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure the `submit_button()` function is available during the REST API call
|
||||
// from WP_Site_Health_Auto_Updates::test_check_wp_filesystem_method().
|
||||
/*
|
||||
* Make sure the `submit_button()` function is available during the REST API call
|
||||
* from WP_Site_Health_Auto_Updates::test_check_wp_filesystem_method().
|
||||
*/
|
||||
if ( ! function_exists( 'submit_button' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/template.php';
|
||||
}
|
||||
@@ -2685,7 +2726,7 @@ function wp_opcache_invalidate_directory( $dir ) {
|
||||
* with sub-directories represented as nested arrays.
|
||||
* @param string $path Absolute path to the directory.
|
||||
*/
|
||||
$invalidate_directory = function( $dirlist, $path ) use ( &$invalidate_directory ) {
|
||||
$invalidate_directory = static function( $dirlist, $path ) use ( &$invalidate_directory ) {
|
||||
$path = trailingslashit( $path );
|
||||
|
||||
foreach ( $dirlist as $name => $details ) {
|
||||
|
||||
+263
-258
@@ -28,7 +28,7 @@ function wp_image_editor( $post_id, $msg = false ) {
|
||||
die( __( 'Image data does not exist. Please re-upload the image.' ) );
|
||||
}
|
||||
|
||||
$sizer = $big > 400 ? 400 / $big : 1;
|
||||
$sizer = $big > 600 ? 600 / $big : 1;
|
||||
|
||||
$backup_sizes = get_post_meta( $post_id, '_wp_attachment_backup_sizes', true );
|
||||
$can_restore = false;
|
||||
@@ -43,25 +43,28 @@ function wp_image_editor( $post_id, $msg = false ) {
|
||||
$note = "<div class='notice notice-success' tabindex='-1' role='alert'><p>$msg->msg</p></div>";
|
||||
}
|
||||
}
|
||||
$edit_custom_sizes = false;
|
||||
|
||||
/**
|
||||
* Filters whether custom sizes are available options for image editing.
|
||||
* Shows the settings in the Image Editor that allow selecting to edit only the thumbnail of an image.
|
||||
*
|
||||
* @since 6.0.0
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @param bool|string[] $edit_custom_sizes True if custom sizes can be edited or array of custom size names.
|
||||
* @param bool $show Whether to show the settings in the Image Editor. Default false.
|
||||
*/
|
||||
$edit_custom_sizes = apply_filters( 'edit_custom_thumbnail_sizes', $edit_custom_sizes );
|
||||
$edit_thumbnails_separately = (bool) apply_filters( 'image_edit_thumbnails_separately', false );
|
||||
|
||||
?>
|
||||
<div class="imgedit-wrap wp-clearfix">
|
||||
<div id="imgedit-panel-<?php echo $post_id; ?>">
|
||||
|
||||
<div class="imgedit-panel-content wp-clearfix">
|
||||
<?php echo $note; ?>
|
||||
<?php echo $note; ?>
|
||||
<div class="imgedit-panel-content imgedit-panel-tools wp-clearfix">
|
||||
<div class="imgedit-menu wp-clearfix">
|
||||
<button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this )" class="imgedit-crop button disabled" disabled><?php esc_html_e( 'Crop' ); ?></button>
|
||||
<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>
|
||||
<div id="imgedit-rotate-menu" class="imgedit-popup-menu">
|
||||
<?php
|
||||
|
||||
// On some setups GD library does not provide imagerotate() - Ticket #11536.
|
||||
if ( wp_image_editor_supports(
|
||||
array(
|
||||
@@ -71,256 +74,256 @@ function wp_image_editor( $post_id, $msg = false ) {
|
||||
) ) {
|
||||
$note_no_rotate = '';
|
||||
?>
|
||||
<button type="button" class="imgedit-rleft button" onclick="imageEdit.rotate( 90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate left' ); ?></button>
|
||||
<button type="button" class="imgedit-rright button" onclick="imageEdit.rotate(-90, <?php echo "$post_id, '$nonce'"; ?>, this)"><?php esc_html_e( 'Rotate right' ); ?></button>
|
||||
<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>
|
||||
<?php
|
||||
} else {
|
||||
$note_no_rotate = '<p class="note-no-rotate"><em>' . __( 'Image rotation is not supported by your web host.' ) . '</em></p>';
|
||||
?>
|
||||
<button type="button" class="imgedit-rleft button disabled" disabled></button>
|
||||
<button type="button" class="imgedit-rright button disabled" disabled></button>
|
||||
<?php } ?>
|
||||
|
||||
<button type="button" onclick="imageEdit.flip(1, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-flipv button"><?php esc_html_e( 'Flip vertical' ); ?></button>
|
||||
<button type="button" onclick="imageEdit.flip(2, <?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-fliph button"><?php esc_html_e( 'Flip horizontal' ); ?></button>
|
||||
|
||||
<br class="imgedit-undo-redo-separator" />
|
||||
<button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><?php esc_html_e( 'Undo' ); ?></button>
|
||||
<button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><?php esc_html_e( 'Redo' ); ?></button>
|
||||
<?php echo $note_no_rotate; ?>
|
||||
</div>
|
||||
|
||||
<input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" />
|
||||
<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
|
||||
<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
|
||||
<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
|
||||
<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
|
||||
<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
|
||||
|
||||
<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
|
||||
<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')"
|
||||
src="<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=imgedit-preview&_ajax_nonce=' . $nonce . '&postid=' . $post_id . '&rand=' . rand( 1, 99999 ); ?>" alt="" />
|
||||
</div>
|
||||
|
||||
<div class="imgedit-submit">
|
||||
<input type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn" value="<?php esc_attr_e( 'Cancel' ); ?>" />
|
||||
<input type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn" value="<?php esc_attr_e( 'Save' ); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="imgedit-settings">
|
||||
<div class="imgedit-group">
|
||||
<div class="imgedit-group-top">
|
||||
<h2><?php _e( 'Scale Image' ); ?></h2>
|
||||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
esc_html_e( 'Scale Image Help' );
|
||||
?>
|
||||
</span></button>
|
||||
<div class="imgedit-help">
|
||||
<p><?php _e( 'You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.' ); ?></p>
|
||||
</div>
|
||||
<?php if ( isset( $meta['width'], $meta['height'] ) ) : ?>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: Image width and height in pixels. */
|
||||
__( 'Original dimensions %s' ),
|
||||
'<span class="imgedit-original-dimensions">' . $meta['width'] . ' × ' . $meta['height'] . '</span>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<div class="imgedit-submit">
|
||||
|
||||
<fieldset class="imgedit-scale">
|
||||
<legend><?php _e( 'New dimensions:' ); ?></legend>
|
||||
<div class="nowrap">
|
||||
<label for="imgedit-scale-width-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'scale width' );
|
||||
?>
|
||||
</label>
|
||||
<input type="text" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
|
||||
<span class="imgedit-separator" aria-hidden="true">×</span>
|
||||
<label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'scale height' );
|
||||
?>
|
||||
</label>
|
||||
<input type="text" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
|
||||
<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>">!</span>
|
||||
<div class="imgedit-scale-button-wrapper"><input id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary" value="<?php esc_attr_e( 'Scale' ); ?>" /></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( $can_restore ) { ?>
|
||||
|
||||
<div class="imgedit-group">
|
||||
<div class="imgedit-group-top">
|
||||
<h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link" aria-expanded="false"><?php _e( 'Restore original image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2>
|
||||
<div class="imgedit-help imgedit-restore">
|
||||
<p>
|
||||
<?php
|
||||
_e( 'Discard any changes and restore the original image.' );
|
||||
|
||||
if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) {
|
||||
echo ' ' . __( 'Previously edited copies of the image will not be deleted.' );
|
||||
<button type="button" class="imgedit-rleft button disabled" disabled></button>
|
||||
<button type="button" class="imgedit-rright button disabled" disabled></button>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<div class="imgedit-submit">
|
||||
<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
|
||||
<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>
|
||||
<?php echo $note_no_rotate; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<div class="imgedit-group">
|
||||
<div class="imgedit-group-top">
|
||||
<h2><?php _e( 'Image Crop' ); ?></h2>
|
||||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
esc_html_e( 'Image Crop Help' );
|
||||
?>
|
||||
</span></button>
|
||||
|
||||
<div class="imgedit-help">
|
||||
<p><?php _e( 'To crop the image, click on it and drag to make your selection.' ); ?></p>
|
||||
|
||||
<p><strong><?php _e( 'Crop Aspect Ratio' ); ?></strong><br />
|
||||
<?php _e( 'The aspect ratio is the relationship between the width and height. You can preserve the aspect ratio by holding down the shift key while resizing your selection. Use the input box to specify the aspect ratio, e.g. 1:1 (square), 4:3, 16:9, etc.' ); ?></p>
|
||||
|
||||
<p><strong><?php _e( 'Crop Selection' ); ?></strong><br />
|
||||
<?php _e( 'Once you have made your selection, you can adjust it by entering the size in pixels. The minimum selection size is the thumbnail size as set in the Media settings.' ); ?></p>
|
||||
<div class="imgedit-submit imgedit-menu">
|
||||
<button type="button" id="image-undo-<?php echo $post_id; ?>" onclick="imageEdit.undo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-undo button disabled" disabled><?php esc_html_e( 'Undo' ); ?></button>
|
||||
<button type="button" id="image-redo-<?php echo $post_id; ?>" onclick="imageEdit.redo(<?php echo "$post_id, '$nonce'"; ?>, this)" class="imgedit-redo button disabled" disabled><?php esc_html_e( 'Redo' ); ?></button>
|
||||
<button type="button" onclick="imageEdit.close(<?php echo $post_id; ?>, 1)" class="button imgedit-cancel-btn"><?php esc_html_e( 'Cancel Editing' ); ?></button>
|
||||
<button type="button" onclick="imageEdit.save(<?php echo "$post_id, '$nonce'"; ?>)" disabled="disabled" class="button button-primary imgedit-submit-btn"><?php esc_html_e( 'Save Edits' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<fieldset class="imgedit-crop-ratio">
|
||||
<legend><?php _e( 'Aspect ratio:' ); ?></legend>
|
||||
<div class="nowrap">
|
||||
<label for="imgedit-crop-width-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'crop ratio width' );
|
||||
?>
|
||||
</label>
|
||||
<input type="text" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" />
|
||||
<span class="imgedit-separator" aria-hidden="true">:</span>
|
||||
<label for="imgedit-crop-height-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'crop ratio height' );
|
||||
?>
|
||||
</label>
|
||||
<input type="text" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="imgedit-panel-content wp-clearfix">
|
||||
<div class="imgedit-tools">
|
||||
<input type="hidden" id="imgedit-nonce-<?php echo $post_id; ?>" value="<?php echo $nonce; ?>" />
|
||||
<input type="hidden" id="imgedit-sizer-<?php echo $post_id; ?>" value="<?php echo $sizer; ?>" />
|
||||
<input type="hidden" id="imgedit-history-<?php echo $post_id; ?>" value="" />
|
||||
<input type="hidden" id="imgedit-undone-<?php echo $post_id; ?>" value="0" />
|
||||
<input type="hidden" id="imgedit-selection-<?php echo $post_id; ?>" value="" />
|
||||
<input type="hidden" id="imgedit-x-<?php echo $post_id; ?>" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
|
||||
<input type="hidden" id="imgedit-y-<?php echo $post_id; ?>" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
|
||||
|
||||
<fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel">
|
||||
<legend><?php _e( 'Selection:' ); ?></legend>
|
||||
<div class="nowrap">
|
||||
<label for="imgedit-sel-width-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'selection width' );
|
||||
?>
|
||||
</label>
|
||||
<input type="text" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" />
|
||||
<span class="imgedit-separator" aria-hidden="true">×</span>
|
||||
<label for="imgedit-sel-height-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'selection height' );
|
||||
?>
|
||||
</label>
|
||||
<input type="text" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" />
|
||||
<div id="imgedit-crop-<?php echo $post_id; ?>" class="imgedit-crop-wrap">
|
||||
<div class="imgedit-crop-grid"></div>
|
||||
<img id="image-preview-<?php echo $post_id; ?>" onload="imageEdit.imgLoaded('<?php echo $post_id; ?>')"
|
||||
src="<?php echo esc_url( admin_url( 'admin-ajax.php', 'relative' ) ) . '?action=imgedit-preview&_ajax_nonce=' . $nonce . '&postid=' . $post_id . '&rand=' . rand( 1, 99999 ); ?>" alt="" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="imgedit-settings">
|
||||
<div class="imgedit-tool-active">
|
||||
<div class="imgedit-group">
|
||||
<div id="imgedit-scale" tabindex="-1" class="imgedit-group-controls">
|
||||
<div class="imgedit-group-top">
|
||||
<h2><?php _e( 'Scale Image' ); ?></h2>
|
||||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
esc_html_e( 'Scale Image Help' );
|
||||
?>
|
||||
</span></button>
|
||||
<div class="imgedit-help">
|
||||
<p><?php _e( 'You can proportionally scale the original image. For best results, scaling should be done before you crop, flip, or rotate. Images can only be scaled down, not up.' ); ?></p>
|
||||
</div>
|
||||
<?php if ( isset( $meta['width'], $meta['height'] ) ) : ?>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %s: Image width and height in pixels. */
|
||||
__( 'Original dimensions %s' ),
|
||||
'<span class="imgedit-original-dimensions">' . $meta['width'] . ' × ' . $meta['height'] . '</span>'
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
<div class="imgedit-submit">
|
||||
<fieldset class="imgedit-scale-controls">
|
||||
<legend><?php _e( 'New dimensions:' ); ?></legend>
|
||||
<div class="nowrap">
|
||||
<label for="imgedit-scale-width-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'scale height' );
|
||||
?>
|
||||
</label>
|
||||
<input type="number" step="1" min="0" max="<?php echo isset( $meta['width'] ) ? $meta['width'] : ''; ?>" aria-describedby="imgedit-scale-warn-<?php echo $post_id; ?>" id="imgedit-scale-width-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 1, this)" value="<?php echo isset( $meta['width'] ) ? $meta['width'] : 0; ?>" />
|
||||
<span class="imgedit-separator" aria-hidden="true">×</span>
|
||||
<label for="imgedit-scale-height-<?php echo $post_id; ?>" class="screen-reader-text"><?php _e( 'scale height' ); ?></label>
|
||||
<input type="number" step="1" min="0" max="<?php echo isset( $meta['height'] ) ? $meta['height'] : ''; ?>" aria-describedby="imgedit-scale-warn-<?php echo $post_id; ?>" id="imgedit-scale-height-<?php echo $post_id; ?>" onkeyup="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.scaleChanged(<?php echo $post_id; ?>, 0, this)" value="<?php echo isset( $meta['height'] ) ? $meta['height'] : 0; ?>" />
|
||||
<button id="imgedit-scale-button" type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'scale')" class="button button-primary"><?php esc_html_e( 'Scale' ); ?></button>
|
||||
<span class="imgedit-scale-warn" id="imgedit-scale-warn-<?php echo $post_id; ?>"><span class="dashicons dashicons-warning" aria-hidden="true"></span><?php esc_html_e( 'Images cannot be scaled to a size larger than the original.' ); ?></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( $can_restore ) { ?>
|
||||
<div class="imgedit-group">
|
||||
<div class="imgedit-group-top">
|
||||
<h2><button type="button" onclick="imageEdit.toggleHelp(this);" class="button-link" aria-expanded="false"><?php _e( 'Restore original image' ); ?> <span class="dashicons dashicons-arrow-down imgedit-help-toggle"></span></button></h2>
|
||||
<div class="imgedit-help imgedit-restore">
|
||||
<p>
|
||||
<?php
|
||||
_e( 'Discard any changes and restore the original image.' );
|
||||
if ( ! defined( 'IMAGE_EDIT_OVERWRITE' ) || ! IMAGE_EDIT_OVERWRITE ) {
|
||||
echo ' ' . __( 'Previously edited copies of the image will not be deleted.' );
|
||||
}
|
||||
?>
|
||||
</p>
|
||||
<div class="imgedit-submit">
|
||||
<input type="button" onclick="imageEdit.action(<?php echo "$post_id, '$nonce'"; ?>, 'restore')" class="button button-primary" value="<?php esc_attr_e( 'Restore image' ); ?>" <?php echo $can_restore; ?> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="imgedit-group">
|
||||
<div id="imgedit-crop" tabindex="-1" class="imgedit-group-controls">
|
||||
<div class="imgedit-group-top">
|
||||
<h2><?php _e( 'Crop Image' ); ?></h2>
|
||||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'Image Crop Help' );
|
||||
?>
|
||||
</span></button>
|
||||
<div class="imgedit-help">
|
||||
<p><?php _e( 'To crop the image, click on it and drag to make your selection.' ); ?></p>
|
||||
<p><strong><?php _e( 'Crop Aspect Ratio' ); ?></strong><br />
|
||||
<?php _e( 'The aspect ratio is the relationship between the width and height. You can preserve the aspect ratio by holding down the shift key while resizing your selection. Use the input box to specify the aspect ratio, e.g. 1:1 (square), 4:3, 16:9, etc.' ); ?></p>
|
||||
|
||||
<p><strong><?php _e( 'Crop Selection' ); ?></strong><br />
|
||||
<?php _e( 'Once you have made your selection, you can adjust it by entering the size in pixels. The minimum selection size is the thumbnail size as set in the Media settings.' ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<fieldset class="imgedit-crop-ratio">
|
||||
<legend><?php _e( 'Aspect ratio:' ); ?></legend>
|
||||
<div class="nowrap">
|
||||
<label for="imgedit-crop-width-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'crop ratio width' );
|
||||
?>
|
||||
</label>
|
||||
<input type="number" step="1" min="1" id="imgedit-crop-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 0, this)" />
|
||||
<span class="imgedit-separator" aria-hidden="true">:</span>
|
||||
<label for="imgedit-crop-height-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'crop ratio height' );
|
||||
?>
|
||||
</label>
|
||||
<input type="number" step="1" min="0" id="imgedit-crop-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" onblur="imageEdit.setRatioSelection(<?php echo $post_id; ?>, 1, this)" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel">
|
||||
<legend><?php _e( 'Selection:' ); ?></legend>
|
||||
<div class="nowrap">
|
||||
<label for="imgedit-sel-width-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'selection width' );
|
||||
?>
|
||||
</label>
|
||||
<input type="number" step="1" min="0" id="imgedit-sel-width-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" />
|
||||
<span class="imgedit-separator" aria-hidden="true">×</span>
|
||||
<label for="imgedit-sel-height-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'selection height' );
|
||||
?>
|
||||
</label>
|
||||
<input type="number" step="1" min="0" id="imgedit-sel-height-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset id="imgedit-crop-sel-<?php echo $post_id; ?>" class="imgedit-crop-sel">
|
||||
<legend><?php _e( 'Starting Coordinates:' ); ?></legend>
|
||||
<div class="nowrap">
|
||||
<label for="imgedit-start-x-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'horizontal start position' );
|
||||
?>
|
||||
</label>
|
||||
<input type="number" step="1" min="0" id="imgedit-start-x-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" value="0" />
|
||||
<span class="imgedit-separator" aria-hidden="true">×</span>
|
||||
<label for="imgedit-start-y-<?php echo $post_id; ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'vertical start position' );
|
||||
?>
|
||||
</label>
|
||||
<input type="number" step="1" min="0" id="imgedit-start-y-<?php echo $post_id; ?>" onkeyup="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" onblur="imageEdit.setNumSelection(<?php echo $post_id; ?>, this)" value="0" />
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="imgedit-crop-apply imgedit-menu container">
|
||||
<button class="button-primary" type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this );" class="imgedit-crop-apply button"><?php esc_html_e( 'Apply Crop' ); ?></button> <button type="button" onclick="imageEdit.handleCropToolClick( <?php echo "$post_id, '$nonce'"; ?>, this );" class="imgedit-crop-clear button" disabled="disabled"><?php esc_html_e( 'Clear Crop' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if ( $thumb && $sub_sizes ) {
|
||||
if ( $edit_thumbnails_separately && $thumb && $sub_sizes ) {
|
||||
$thumb_img = wp_constrain_dimensions( $thumb['width'], $thumb['height'], 160, 120 );
|
||||
?>
|
||||
|
||||
<div class="imgedit-group imgedit-applyto">
|
||||
<div class="imgedit-group-top">
|
||||
<h2><?php _e( 'Thumbnail Settings' ); ?></h2>
|
||||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text">
|
||||
<div class="imgedit-group-top">
|
||||
<h2><?php _e( 'Thumbnail Settings' ); ?></h2>
|
||||
<button type="button" class="dashicons dashicons-editor-help imgedit-help-toggle" onclick="imageEdit.toggleHelp(this);" aria-expanded="false"><span class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
esc_html_e( 'Thumbnail Settings Help' );
|
||||
?>
|
||||
</span></button>
|
||||
<div class="imgedit-help">
|
||||
<p><?php _e( 'You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.' ); ?></p>
|
||||
</span></button>
|
||||
<div class="imgedit-help">
|
||||
<p><?php _e( 'You can edit the image while preserving the thumbnail. For example, you may wish to have a square thumbnail that displays just a section of the image.' ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="imgedit-thumbnail-preview-group">
|
||||
<figure class="imgedit-thumbnail-preview">
|
||||
<img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" />
|
||||
<figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption>
|
||||
</figure>
|
||||
<div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target">
|
||||
<fieldset>
|
||||
<legend><?php _e( 'Apply changes to:' ); ?></legend>
|
||||
|
||||
<span class="imgedit-label">
|
||||
<input type="radio" id="imgedit-target-all" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
|
||||
<label for="imgedit-target-all"><?php _e( 'All image sizes' ); ?></label>
|
||||
</span>
|
||||
|
||||
<span class="imgedit-label">
|
||||
<input type="radio" id="imgedit-target-thumbnail" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" />
|
||||
<label for="imgedit-target-thumbnail"><?php _e( 'Thumbnail' ); ?></label>
|
||||
</span>
|
||||
|
||||
<span class="imgedit-label">
|
||||
<input type="radio" id="imgedit-target-nothumb" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
|
||||
<label for="imgedit-target-nothumb"><?php _e( 'All sizes except thumbnail' ); ?></label>
|
||||
</span>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<figure class="imgedit-thumbnail-preview">
|
||||
<img src="<?php echo $thumb['url']; ?>" width="<?php echo $thumb_img[0]; ?>" height="<?php echo $thumb_img[1]; ?>" class="imgedit-size-preview" alt="" draggable="false" />
|
||||
<figcaption class="imgedit-thumbnail-preview-caption"><?php _e( 'Current thumbnail' ); ?></figcaption>
|
||||
</figure>
|
||||
|
||||
<div id="imgedit-save-target-<?php echo $post_id; ?>" class="imgedit-save-target">
|
||||
<fieldset>
|
||||
<legend><?php _e( 'Apply changes to:' ); ?></legend>
|
||||
|
||||
<span class="imgedit-label">
|
||||
<input type="radio" id="imgedit-target-all" name="imgedit-target-<?php echo $post_id; ?>" value="all" checked="checked" />
|
||||
<label for="imgedit-target-all"><?php _e( 'All image sizes' ); ?></label>
|
||||
</span>
|
||||
|
||||
<span class="imgedit-label">
|
||||
<input type="radio" id="imgedit-target-thumbnail" name="imgedit-target-<?php echo $post_id; ?>" value="thumbnail" />
|
||||
<label for="imgedit-target-thumbnail"><?php _e( 'Thumbnail' ); ?></label>
|
||||
</span>
|
||||
|
||||
<span class="imgedit-label">
|
||||
<input type="radio" id="imgedit-target-nothumb" name="imgedit-target-<?php echo $post_id; ?>" value="nothumb" />
|
||||
<label for="imgedit-target-nothumb"><?php _e( 'All sizes except thumbnail' ); ?></label>
|
||||
</span>
|
||||
<?php
|
||||
if ( $edit_custom_sizes ) {
|
||||
if ( ! is_array( $edit_custom_sizes ) ) {
|
||||
$edit_custom_sizes = get_intermediate_image_sizes();
|
||||
}
|
||||
foreach ( array_unique( $edit_custom_sizes ) as $key => $size ) {
|
||||
if ( array_key_exists( $size, $meta['sizes'] ) ) {
|
||||
if ( 'thumbnail' === $size ) {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<span class="imgedit-label">
|
||||
<input type="radio" id="imgedit-target-custom<?php echo esc_attr( $key ); ?>" name="imgedit-target-<?php echo $post_id; ?>" value="<?php echo esc_attr( $size ); ?>" />
|
||||
<label for="imgedit-target-custom<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $size ); ?></label>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="imgedit-wait" id="imgedit-wait-<?php echo $post_id; ?>"></div>
|
||||
<div class="hidden" id="imgedit-leaving-<?php echo $post_id; ?>"><?php _e( "There are unsaved changes that will be lost. 'OK' to continue, 'Cancel' to return to the Image Editor." ); ?></div>
|
||||
</div>
|
||||
@@ -508,7 +511,7 @@ function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
|
||||
*/
|
||||
function _image_get_preview_ratio( $w, $h ) {
|
||||
$max = max( $w, $h );
|
||||
return $max > 400 ? ( 400 / $max ) : 1;
|
||||
return $max > 600 ? ( 600 / $max ) : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -893,23 +896,33 @@ function wp_save_image( $post_id ) {
|
||||
$target = ! empty( $_REQUEST['target'] ) ? preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['target'] ) : '';
|
||||
$scale = ! empty( $_REQUEST['do'] ) && 'scale' === $_REQUEST['do'];
|
||||
|
||||
if ( $scale && $fwidth > 0 && $fheight > 0 ) {
|
||||
/** 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'];
|
||||
|
||||
// Check if it has roughly the same w / h ratio.
|
||||
$diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );
|
||||
if ( -0.1 < $diff && $diff < 0.1 ) {
|
||||
// Scale the full size image.
|
||||
if ( $img->resize( $fwidth, $fheight ) ) {
|
||||
$scaled = true;
|
||||
}
|
||||
if ( $sX < $fwidth || $sY < $fheight ) {
|
||||
$return->error = esc_js( __( 'Images cannot be scaled to a size larger than the original.' ) );
|
||||
return $return;
|
||||
}
|
||||
|
||||
if ( ! $scaled ) {
|
||||
$return->error = esc_js( __( 'Error while saving the scaled image. Please reload the page and try again.' ) );
|
||||
return $return;
|
||||
if ( $fwidth > 0 && $fheight > 0 ) {
|
||||
// Check if it has roughly the same w / h ratio.
|
||||
$diff = round( $sX / $sY, 2 ) - round( $fwidth / $fheight, 2 );
|
||||
if ( -0.1 < $diff && $diff < 0.1 ) {
|
||||
// Scale the full size image.
|
||||
if ( $img->resize( $fwidth, $fheight ) ) {
|
||||
$scaled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $scaled ) {
|
||||
$return->error = esc_js( __( 'Error while saving the scaled image. Please reload the page and try again.' ) );
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
} elseif ( ! empty( $_REQUEST['history'] ) ) {
|
||||
$changes = json_decode( wp_unslash( $_REQUEST['history'] ) );
|
||||
@@ -945,7 +958,7 @@ function wp_save_image( $post_id ) {
|
||||
if ( defined( 'IMAGE_EDIT_OVERWRITE' ) && IMAGE_EDIT_OVERWRITE &&
|
||||
isset( $backup_sizes['full-orig'] ) && $backup_sizes['full-orig']['file'] != $basename ) {
|
||||
|
||||
if ( 'thumbnail' === $target ) {
|
||||
if ( $edit_thumbnails_separately && 'thumbnail' === $target ) {
|
||||
$new_path = "{$dirname}/{$filename}-temp.{$ext}";
|
||||
} else {
|
||||
$new_path = $path;
|
||||
@@ -995,29 +1008,21 @@ function wp_save_image( $post_id ) {
|
||||
$meta['width'] = $size['width'];
|
||||
$meta['height'] = $size['height'];
|
||||
|
||||
if ( $success ) {
|
||||
if ( $success && ( 'nothumb' === $target || 'all' === $target ) ) {
|
||||
$sizes = get_intermediate_image_sizes();
|
||||
if ( 'nothumb' === $target || 'all' === $target ) {
|
||||
if ( 'nothumb' === $target ) {
|
||||
$sizes = array_diff( $sizes, array( 'thumbnail' ) );
|
||||
}
|
||||
} elseif ( 'thumbnail' !== $target ) {
|
||||
$sizes = array_diff( $sizes, array( $target ) );
|
||||
|
||||
if ( $edit_thumbnails_separately && 'nothumb' === $target ) {
|
||||
$sizes = array_diff( $sizes, array( 'thumbnail' ) );
|
||||
}
|
||||
}
|
||||
|
||||
$return->fw = $meta['width'];
|
||||
$return->fh = $meta['height'];
|
||||
} elseif ( 'thumbnail' === $target ) {
|
||||
} elseif ( $edit_thumbnails_separately && 'thumbnail' === $target ) {
|
||||
$sizes = array( 'thumbnail' );
|
||||
$success = true;
|
||||
$delete = true;
|
||||
$nocrop = true;
|
||||
} else {
|
||||
$sizes = array( $target );
|
||||
$success = true;
|
||||
$delete = true;
|
||||
$nocrop = $_wp_additional_image_sizes[ $size ]['crop'];
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -28,8 +28,10 @@ function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $s
|
||||
$src_file = get_attached_file( $src );
|
||||
|
||||
if ( ! file_exists( $src_file ) ) {
|
||||
// If the file doesn't exist, attempt a URL fopen on the src link.
|
||||
// This can occur with certain file replication plugins.
|
||||
/*
|
||||
* If the file doesn't exist, attempt a URL fopen on the src link.
|
||||
* This can occur with certain file replication plugins.
|
||||
*/
|
||||
$src = _load_image_to_edit_path( $src, 'full' );
|
||||
} else {
|
||||
$src = $src_file;
|
||||
@@ -159,8 +161,10 @@ function wp_update_image_subsizes( $attachment_id ) {
|
||||
$image_file = wp_get_original_image_path( $attachment_id );
|
||||
|
||||
if ( empty( $image_meta ) || ! is_array( $image_meta ) ) {
|
||||
// Previously failed upload?
|
||||
// If there is an uploaded file, make all sub-sizes and generate all of the attachment meta.
|
||||
/*
|
||||
* Previously failed upload?
|
||||
* If there is an uploaded file, make all sub-sizes and generate all of the attachment meta.
|
||||
*/
|
||||
if ( ! empty( $image_file ) ) {
|
||||
$image_meta = wp_create_image_subsizes( $image_file, $attachment_id );
|
||||
} else {
|
||||
@@ -283,8 +287,10 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||
*/
|
||||
$threshold = (int) apply_filters( 'big_image_size_threshold', 2560, $imagesize, $file, $attachment_id );
|
||||
|
||||
// If the original image's dimensions are over the threshold,
|
||||
// scale the image and use it as the "full" size.
|
||||
/*
|
||||
* If the original image's dimensions are over the threshold,
|
||||
* scale the image and use it as the "full" size.
|
||||
*/
|
||||
if ( $threshold && ( $image_meta['width'] > $threshold || $image_meta['height'] > $threshold ) ) {
|
||||
$editor = wp_get_image_editor( $file );
|
||||
|
||||
@@ -304,8 +310,10 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
|
||||
}
|
||||
|
||||
if ( ! is_wp_error( $resized ) ) {
|
||||
// Append "-scaled" to the image file name. It will look like "my_image-scaled.jpg".
|
||||
// This doesn't affect the sub-sizes names as they are generated from the original image (for best quality).
|
||||
/*
|
||||
* Append "-scaled" to the image file name. It will look like "my_image-scaled.jpg".
|
||||
* This doesn't affect the sub-sizes names as they are generated from the original image (for best quality).
|
||||
*/
|
||||
$saved = $editor->save( $editor->generate_filename( 'scaled' ) );
|
||||
|
||||
if ( ! is_wp_error( $saved ) ) {
|
||||
|
||||
@@ -254,6 +254,9 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $
|
||||
*
|
||||
* @access private
|
||||
* @since 3.4.0
|
||||
*
|
||||
* @param array $matches Single regex match.
|
||||
* @return string Cleaned up HTML for caption.
|
||||
*/
|
||||
function _cleanup_image_add_caption( $matches ) {
|
||||
// Remove any line breaks from inside the tags.
|
||||
@@ -385,7 +388,7 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid
|
||||
}
|
||||
|
||||
// Use image exif/iptc data for title and caption defaults if possible.
|
||||
} elseif ( 0 === strpos( $type, 'image/' ) ) {
|
||||
} elseif ( str_starts_with( $type, 'image/' ) ) {
|
||||
$image_meta = wp_read_image_metadata( $file );
|
||||
|
||||
if ( $image_meta ) {
|
||||
@@ -419,14 +422,18 @@ function media_handle_upload( $file_id, $post_id, $post_data = array(), $overrid
|
||||
$attachment_id = wp_insert_attachment( $attachment, $file, $post_id, true );
|
||||
|
||||
if ( ! is_wp_error( $attachment_id ) ) {
|
||||
// Set a custom header with the attachment_id.
|
||||
// Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
|
||||
/*
|
||||
* Set a custom header with the attachment_id.
|
||||
* Used by the browser/client to resume creating image sub-sizes after a PHP fatal error.
|
||||
*/
|
||||
if ( ! headers_sent() ) {
|
||||
header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id );
|
||||
}
|
||||
|
||||
// The image sub-sizes are created during wp_generate_attachment_metadata().
|
||||
// This is generally slow and may cause timeouts or out of memory errors.
|
||||
/*
|
||||
* The image sub-sizes are created during wp_generate_attachment_metadata().
|
||||
* This is generally slow and may cause timeouts or out of memory errors.
|
||||
*/
|
||||
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
|
||||
}
|
||||
|
||||
@@ -534,8 +541,8 @@ function wp_iframe( $content_func, ...$args ) {
|
||||
wp_enqueue_style( 'colors' );
|
||||
// Check callback name for 'media'.
|
||||
if (
|
||||
( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) ||
|
||||
( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) )
|
||||
( is_array( $content_func ) && ! empty( $content_func[1] ) && str_starts_with( (string) $content_func[1], 'media' ) ) ||
|
||||
( ! is_array( $content_func ) && str_starts_with( $content_func, 'media' ) )
|
||||
) {
|
||||
wp_enqueue_style( 'deprecated-media' );
|
||||
}
|
||||
@@ -828,7 +835,7 @@ function media_upload_form_handler() {
|
||||
if ( ! empty( $attachment['url'] ) ) {
|
||||
$rel = '';
|
||||
|
||||
if ( strpos( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) == $attachment['url'] ) {
|
||||
if ( str_contains( $attachment['url'], 'attachment_id' ) || get_attachment_link( $send_id ) === $attachment['url'] ) {
|
||||
$rel = " rel='attachment wp-att-" . esc_attr( $send_id ) . "'";
|
||||
}
|
||||
|
||||
@@ -1351,12 +1358,12 @@ function media_post_single_attachment_fields_to_edit( $form_fields, $post ) {
|
||||
function image_media_send_to_editor( $html, $attachment_id, $attachment ) {
|
||||
$post = get_post( $attachment_id );
|
||||
|
||||
if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
|
||||
if ( str_starts_with( $post->post_mime_type, 'image' ) ) {
|
||||
$url = $attachment['url'];
|
||||
$align = ! empty( $attachment['align'] ) ? $attachment['align'] : 'none';
|
||||
$size = ! empty( $attachment['image-size'] ) ? $attachment['image-size'] : 'medium';
|
||||
$alt = ! empty( $attachment['image_alt'] ) ? $attachment['image_alt'] : '';
|
||||
$rel = ( strpos( $url, 'attachment_id' ) || get_attachment_link( $attachment_id ) === $url );
|
||||
$rel = ( str_contains( $url, 'attachment_id' ) || get_attachment_link( $attachment_id ) === $url );
|
||||
|
||||
return get_image_send_to_editor( $attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt );
|
||||
}
|
||||
@@ -1462,7 +1469,7 @@ function get_attachment_fields_to_edit( $post, $errors = null ) {
|
||||
$form_fields = array_merge_recursive( $form_fields, (array) $errors );
|
||||
|
||||
// This was formerly in image_attachment_fields_to_edit().
|
||||
if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) {
|
||||
if ( str_starts_with( $post->post_mime_type, 'image' ) ) {
|
||||
$alt = get_post_meta( $post->ID, '_wp_attachment_image_alt', true );
|
||||
|
||||
if ( empty( $alt ) ) {
|
||||
@@ -2180,8 +2187,8 @@ function media_upload_form( $errors = null ) {
|
||||
*/
|
||||
if (
|
||||
wp_is_mobile() &&
|
||||
strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false &&
|
||||
strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false
|
||||
str_contains( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) &&
|
||||
str_contains( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' )
|
||||
) {
|
||||
$plupload_init['multi_selection'] = false;
|
||||
}
|
||||
@@ -2737,7 +2744,7 @@ function media_upload_library_form( $errors ) {
|
||||
<label class="screen-reader-text" for="media-search-input">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
echo __( 'Search Media' ) . ':';
|
||||
_e( 'Search Media:' );
|
||||
?>
|
||||
</label>
|
||||
<input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" />
|
||||
@@ -3217,7 +3224,7 @@ function edit_form_image_editor( $post ) {
|
||||
?>
|
||||
</div>
|
||||
<div class="wp_attachment_details edit-form-section">
|
||||
<?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?>
|
||||
<?php if ( str_starts_with( $post->post_mime_type, 'image' ) ) : ?>
|
||||
<p class="attachment-alt-text">
|
||||
<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br />
|
||||
<textarea class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" aria-describedby="alt-text-description"><?php echo esc_attr( $alt_text ); ?></textarea>
|
||||
@@ -3507,7 +3514,7 @@ function wp_add_id3_tag_data( &$metadata, $data ) {
|
||||
if ( 'length' !== $key && ! empty( $list ) ) {
|
||||
$metadata[ $key ] = wp_kses_post( reset( $list ) );
|
||||
// Fix bug in byte stream analysis.
|
||||
if ( 'terms_of_use' === $key && 0 === strpos( $metadata[ $key ], 'yright notice.' ) ) {
|
||||
if ( 'terms_of_use' === $key && str_starts_with( $metadata[ $key ], 'yright notice.' ) ) {
|
||||
$metadata[ $key ] = 'Cop' . $metadata[ $key ];
|
||||
}
|
||||
}
|
||||
@@ -3847,7 +3854,7 @@ function wp_media_attach_action( $parent_id, $action = 'attach' ) {
|
||||
$referer = wp_get_referer();
|
||||
|
||||
if ( $referer ) {
|
||||
if ( false !== strpos( $referer, 'upload.php' ) ) {
|
||||
if ( str_contains( $referer, 'upload.php' ) ) {
|
||||
$location = remove_query_arg( array( 'attached', 'detach' ), $referer );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,11 +44,13 @@ if ( is_network_admin() ) {
|
||||
// Create list of page plugin hook names.
|
||||
foreach ( $menu as $menu_page ) {
|
||||
$pos = strpos( $menu_page[2], '?' );
|
||||
|
||||
if ( false !== $pos ) {
|
||||
// Handle post_type=post|page|foo pages.
|
||||
$hook_name = substr( $menu_page[2], 0, $pos );
|
||||
$hook_args = substr( $menu_page[2], $pos + 1 );
|
||||
wp_parse_str( $hook_args, $hook_args );
|
||||
|
||||
// Set the hook name to be the post type.
|
||||
if ( isset( $hook_args['post_type'] ) ) {
|
||||
$hook_name = $hook_args['post_type'];
|
||||
@@ -59,6 +61,7 @@ foreach ( $menu as $menu_page ) {
|
||||
} else {
|
||||
$hook_name = basename( $menu_page[2], '.php' );
|
||||
}
|
||||
|
||||
$hook_name = sanitize_title( $hook_name );
|
||||
|
||||
if ( isset( $compat[ $hook_name ] ) ) {
|
||||
@@ -98,17 +101,20 @@ foreach ( $menu as $id => $data ) {
|
||||
if ( empty( $submenu[ $data[2] ] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$subs = $submenu[ $data[2] ];
|
||||
$first_sub = reset( $subs );
|
||||
$old_parent = $data[2];
|
||||
$new_parent = $first_sub[2];
|
||||
|
||||
/*
|
||||
* If the first submenu is not the same as the assigned parent,
|
||||
* make the first submenu the new parent.
|
||||
*/
|
||||
if ( $new_parent != $old_parent ) {
|
||||
if ( $new_parent !== $old_parent ) {
|
||||
$_wp_real_parent_file[ $old_parent ] = $new_parent;
|
||||
$menu[ $id ][2] = $new_parent;
|
||||
|
||||
$menu[ $id ][2] = $new_parent;
|
||||
|
||||
foreach ( $submenu[ $old_parent ] as $index => $data ) {
|
||||
$submenu[ $new_parent ][ $index ] = $submenu[ $old_parent ][ $index ];
|
||||
@@ -171,7 +177,8 @@ foreach ( $menu as $id => $data ) {
|
||||
if ( ! empty( $submenu[ $data[2] ] ) && 1 === count( $submenu[ $data[2] ] ) ) {
|
||||
$subs = $submenu[ $data[2] ];
|
||||
$first_sub = reset( $subs );
|
||||
if ( $data[2] == $first_sub[2] ) {
|
||||
|
||||
if ( $data[2] === $first_sub[2] ) {
|
||||
unset( $submenu[ $data[2] ] );
|
||||
}
|
||||
}
|
||||
@@ -217,32 +224,36 @@ function add_menu_classes( $menu ) {
|
||||
$first_item = false;
|
||||
$last_order = false;
|
||||
$items_count = count( $menu );
|
||||
$i = 0;
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach ( $menu as $order => $top ) {
|
||||
$i++;
|
||||
|
||||
if ( 0 == $order ) { // Dashboard is always shown/single.
|
||||
if ( 0 === $order ) { // Dashboard is always shown/single.
|
||||
$menu[0][4] = add_cssclass( 'menu-top-first', $top[4] );
|
||||
$last_order = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( 0 === strpos( $top[2], 'separator' ) && false !== $last_order ) { // If separator.
|
||||
$first_item = true;
|
||||
$classes = $menu[ $last_order ][4];
|
||||
if ( str_starts_with( $top[2], 'separator' ) && false !== $last_order ) { // If separator.
|
||||
$first_item = true;
|
||||
$classes = $menu[ $last_order ][4];
|
||||
|
||||
$menu[ $last_order ][4] = add_cssclass( 'menu-top-last', $classes );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $first_item ) {
|
||||
$classes = $menu[ $order ][4];
|
||||
$first_item = false;
|
||||
$classes = $menu[ $order ][4];
|
||||
|
||||
$menu[ $order ][4] = add_cssclass( 'menu-top-first', $classes );
|
||||
$first_item = false;
|
||||
}
|
||||
|
||||
if ( $i == $items_count ) { // Last item.
|
||||
$classes = $menu[ $order ][4];
|
||||
if ( $i === $items_count ) { // Last item.
|
||||
$classes = $menu[ $order ][4];
|
||||
|
||||
$menu[ $order ][4] = add_cssclass( 'menu-top-last', $classes );
|
||||
}
|
||||
|
||||
@@ -272,10 +283,12 @@ uksort( $menu, 'strnatcasecmp' ); // Make it all pretty.
|
||||
*/
|
||||
if ( apply_filters( 'custom_menu_order', false ) ) {
|
||||
$menu_order = array();
|
||||
|
||||
foreach ( $menu as $menu_item ) {
|
||||
$menu_order[] = $menu_item[2];
|
||||
}
|
||||
unset( $menu_item );
|
||||
|
||||
$default_menu_order = $menu_order;
|
||||
|
||||
/**
|
||||
@@ -290,8 +303,9 @@ if ( apply_filters( 'custom_menu_order', false ) ) {
|
||||
*
|
||||
* @param array $menu_order An ordered array of menu items.
|
||||
*/
|
||||
$menu_order = apply_filters( 'menu_order', $menu_order );
|
||||
$menu_order = array_flip( $menu_order );
|
||||
$menu_order = apply_filters( 'menu_order', $menu_order );
|
||||
$menu_order = array_flip( $menu_order );
|
||||
|
||||
$default_menu_order = array_flip( $default_menu_order );
|
||||
|
||||
/**
|
||||
@@ -304,14 +318,16 @@ if ( apply_filters( 'custom_menu_order', false ) ) {
|
||||
*/
|
||||
function sort_menu( $a, $b ) {
|
||||
global $menu_order, $default_menu_order;
|
||||
|
||||
$a = $a[2];
|
||||
$b = $b[2];
|
||||
|
||||
if ( isset( $menu_order[ $a ] ) && ! isset( $menu_order[ $b ] ) ) {
|
||||
return -1;
|
||||
} elseif ( ! isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
|
||||
return 1;
|
||||
} elseif ( isset( $menu_order[ $a ] ) && isset( $menu_order[ $b ] ) ) {
|
||||
if ( $menu_order[ $a ] == $menu_order[ $b ] ) {
|
||||
if ( $menu_order[ $a ] === $menu_order[ $b ] ) {
|
||||
return 0;
|
||||
}
|
||||
return ( $menu_order[ $a ] < $menu_order[ $b ] ) ? -1 : 1;
|
||||
|
||||
@@ -469,10 +469,20 @@ function attachment_submit_meta_box( $post ) {
|
||||
<?php
|
||||
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
||||
if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
|
||||
echo "<a class='submitdelete deletion' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Move to Trash' ) . '</a>';
|
||||
printf(
|
||||
'<a class="submitdelete deletion" href="%1$s">%2$s</a>',
|
||||
get_delete_post_link( $post->ID ),
|
||||
__( 'Move to Trash' )
|
||||
);
|
||||
} else {
|
||||
$delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
|
||||
echo "<a class='submitdelete deletion'$delete_ays href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete permanently' ) . '</a>';
|
||||
$show_confirmation = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
|
||||
|
||||
printf(
|
||||
'<a class="submitdelete deletion"%1$s href="%2$s">%3$s</a>',
|
||||
$show_confirmation,
|
||||
get_delete_post_link( $post->ID, '', true ),
|
||||
__( 'Delete permanently' )
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1662,8 +1672,10 @@ function register_and_do_post_meta_boxes( $post ) {
|
||||
*/
|
||||
do_action_deprecated( 'dbx_post_advanced', array( $post ), '3.7.0', 'add_meta_boxes' );
|
||||
|
||||
// Allow the Discussion meta box to show up if the post type supports comments,
|
||||
// or if comments or pings are open.
|
||||
/*
|
||||
* Allow the Discussion meta box to show up if the post type supports comments,
|
||||
* or if comments or pings are open.
|
||||
*/
|
||||
if ( comments_open( $post ) || pings_open( $post ) || post_type_supports( $post_type, 'comments' ) ) {
|
||||
add_meta_box( 'commentstatusdiv', __( 'Discussion' ), 'post_comment_status_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
|
||||
}
|
||||
@@ -1675,8 +1687,10 @@ function register_and_do_post_meta_boxes( $post ) {
|
||||
$stati[] = 'private';
|
||||
|
||||
if ( in_array( get_post_status( $post ), $stati, true ) ) {
|
||||
// If the post type support comments, or the post has comments,
|
||||
// allow the Comments meta box.
|
||||
/*
|
||||
* If the post type support comments, or the post has comments,
|
||||
* allow the Comments meta box.
|
||||
*/
|
||||
if ( comments_open( $post ) || pings_open( $post ) || $post->comment_count > 0 || post_type_supports( $post_type, 'comments' ) ) {
|
||||
add_meta_box( 'commentsdiv', __( 'Comments' ), 'post_comment_meta_box', null, 'normal', 'core', array( '__back_compat_meta_box' => true ) );
|
||||
}
|
||||
|
||||
@@ -76,19 +76,19 @@ function extract_from_markers( $filename, $marker ) {
|
||||
$state = false;
|
||||
|
||||
foreach ( $markerdata as $markerline ) {
|
||||
if ( false !== strpos( $markerline, '# END ' . $marker ) ) {
|
||||
if ( str_contains( $markerline, '# END ' . $marker ) ) {
|
||||
$state = false;
|
||||
}
|
||||
|
||||
if ( $state ) {
|
||||
if ( '#' === substr( $markerline, 0, 1 ) ) {
|
||||
if ( str_starts_with( $markerline, '#' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[] = $markerline;
|
||||
}
|
||||
|
||||
if ( false !== strpos( $markerline, '# BEGIN ' . $marker ) ) {
|
||||
if ( str_contains( $markerline, '# BEGIN ' . $marker ) ) {
|
||||
$state = true;
|
||||
}
|
||||
}
|
||||
@@ -194,10 +194,10 @@ Any changes to the directives between these markers will be overwritten.'
|
||||
$found_end_marker = false;
|
||||
|
||||
foreach ( $lines as $line ) {
|
||||
if ( ! $found_marker && false !== strpos( $line, $start_marker ) ) {
|
||||
if ( ! $found_marker && str_contains( $line, $start_marker ) ) {
|
||||
$found_marker = true;
|
||||
continue;
|
||||
} elseif ( ! $found_end_marker && false !== strpos( $line, $end_marker ) ) {
|
||||
} elseif ( ! $found_end_marker && str_contains( $line, $end_marker ) ) {
|
||||
$found_end_marker = true;
|
||||
continue;
|
||||
}
|
||||
@@ -750,7 +750,7 @@ function set_screen_options() {
|
||||
default:
|
||||
$screen_option = false;
|
||||
|
||||
if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
|
||||
if ( str_ends_with( $option, '_page' ) || 'layout_columns' === $option ) {
|
||||
/**
|
||||
* Filters a screen option value before it is set.
|
||||
*
|
||||
@@ -1572,7 +1572,16 @@ function _wp_privacy_settings_filter_draft_page_titles( $title, $page ) {
|
||||
* @since 5.1.0
|
||||
* @since 5.1.1 Added the {@see 'wp_is_php_version_acceptable'} filter.
|
||||
*
|
||||
* @return array|false Array of PHP version data. False on failure.
|
||||
* @return array|false {
|
||||
* Array of PHP version data. False on failure.
|
||||
*
|
||||
* @type string $recommended_version The PHP version recommended by WordPress.
|
||||
* @type string $minimum_version The minimum required PHP version.
|
||||
* @type bool $is_supported Whether the PHP version is actively supported.
|
||||
* @type bool $is_secure Whether the PHP version receives security updates.
|
||||
* @type bool $is_acceptable Whether the PHP version is still acceptable or warnings
|
||||
* should be shown and an update recommended.
|
||||
* }
|
||||
*/
|
||||
function wp_check_php_version() {
|
||||
$version = PHP_VERSION;
|
||||
@@ -1595,14 +1604,6 @@ function wp_check_php_version() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Response should be an array with:
|
||||
* 'recommended_version' - string - The PHP version recommended by WordPress.
|
||||
* 'is_supported' - boolean - Whether the PHP version is actively supported.
|
||||
* 'is_secure' - boolean - Whether the PHP version receives security updates.
|
||||
* 'is_acceptable' - boolean - Whether the PHP version is still acceptable or warnings
|
||||
* should be shown and an update recommended.
|
||||
*/
|
||||
$response = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
if ( ! is_array( $response ) ) {
|
||||
|
||||
@@ -130,12 +130,17 @@ function wpmu_delete_blog( $blog_id, $drop = false ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a user from the network and remove from all sites.
|
||||
* Deletes a user and all of their posts from the network.
|
||||
*
|
||||
* This function:
|
||||
*
|
||||
* - Deletes all posts (of all post types) authored by the user on all sites on the network
|
||||
* - Deletes all links owned by the user on all sites on the network
|
||||
* - Removes the user from all sites on the network
|
||||
* - Deletes the user from the database
|
||||
*
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @todo Merge with wp_delete_user()?
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param int $id The user ID.
|
||||
@@ -843,6 +848,7 @@ var tb_pathToImage = "<?php echo esc_js( includes_url( 'js/thickbox/loadingAnima
|
||||
|
||||
/**
|
||||
* @param array $users
|
||||
* @return bool
|
||||
*/
|
||||
function confirm_delete_users( $users ) {
|
||||
$current_user = wp_get_current_user();
|
||||
@@ -999,8 +1005,10 @@ function network_settings_add_js() {
|
||||
jQuery( function($) {
|
||||
var languageSelect = $( '#WPLANG' );
|
||||
$( 'form' ).on( 'submit', function() {
|
||||
// Don't show a spinner for English and installed languages,
|
||||
// as there is nothing to download.
|
||||
/*
|
||||
* Don't show a spinner for English and installed languages,
|
||||
* as there is nothing to download.
|
||||
*/
|
||||
if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
|
||||
$( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' );
|
||||
}
|
||||
|
||||
@@ -39,8 +39,13 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
if ( post_type_exists( $object_type ) ) {
|
||||
if ( isset( $request['ID'] ) ) {
|
||||
$object_id = (int) $request['ID'];
|
||||
|
||||
if ( 'markup' === $response_format ) {
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
} elseif ( 'json' === $response_format ) {
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
@@ -55,8 +60,13 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
} elseif ( taxonomy_exists( $object_type ) ) {
|
||||
if ( isset( $request['ID'] ) ) {
|
||||
$object_id = (int) $request['ID'];
|
||||
|
||||
if ( 'markup' === $response_format ) {
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
} elseif ( 'json' === $response_format ) {
|
||||
$post_obj = get_term( $object_id, $object_type );
|
||||
echo wp_json_encode(
|
||||
@@ -84,18 +94,26 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
's' => $query,
|
||||
)
|
||||
);
|
||||
|
||||
if ( isset( $post_type_obj->_default_query ) ) {
|
||||
$args = array_merge( $args, (array) $post_type_obj->_default_query );
|
||||
}
|
||||
|
||||
$search_results_query = new WP_Query( $args );
|
||||
if ( ! $search_results_query->have_posts() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
while ( $search_results_query->have_posts() ) {
|
||||
$post = $search_results_query->next_post();
|
||||
|
||||
if ( 'markup' === $response_format ) {
|
||||
$var_by_ref = $post->ID;
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
} elseif ( 'json' === $response_format ) {
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
@@ -116,12 +134,18 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
'hide_empty' => false,
|
||||
)
|
||||
);
|
||||
|
||||
if ( empty( $terms ) || is_wp_error( $terms ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( (array) $terms as $term ) {
|
||||
if ( 'markup' === $response_format ) {
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', array( $term ) ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
} elseif ( 'json' === $response_format ) {
|
||||
echo wp_json_encode(
|
||||
array(
|
||||
@@ -145,7 +169,14 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
|
||||
function wp_nav_menu_setup() {
|
||||
// Register meta boxes.
|
||||
wp_nav_menu_post_type_meta_boxes();
|
||||
add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' );
|
||||
add_meta_box(
|
||||
'add-custom-links',
|
||||
__( 'Custom Links' ),
|
||||
'wp_nav_menu_item_link_meta_box',
|
||||
'nav-menus',
|
||||
'side',
|
||||
'default'
|
||||
);
|
||||
wp_nav_menu_taxonomy_meta_boxes();
|
||||
|
||||
// Register advanced menu items (columns).
|
||||
@@ -227,11 +258,20 @@ function wp_nav_menu_post_type_meta_boxes() {
|
||||
* meta box for.
|
||||
*/
|
||||
$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
|
||||
|
||||
if ( $post_type ) {
|
||||
$id = $post_type->name;
|
||||
// Give pages a higher priority.
|
||||
$priority = ( 'page' === $post_type->name ? 'core' : 'default' );
|
||||
add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type );
|
||||
add_meta_box(
|
||||
"add-post-type-{$id}",
|
||||
$post_type->labels->name,
|
||||
'wp_nav_menu_item_post_type_meta_box',
|
||||
'nav-menus',
|
||||
'side',
|
||||
$priority,
|
||||
$post_type
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,9 +291,18 @@ function wp_nav_menu_taxonomy_meta_boxes() {
|
||||
foreach ( $taxonomies as $tax ) {
|
||||
/** This filter is documented in wp-admin/includes/nav-menu.php */
|
||||
$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
|
||||
|
||||
if ( $tax ) {
|
||||
$id = $tax->name;
|
||||
add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
|
||||
add_meta_box(
|
||||
"add-{$id}",
|
||||
$tax->labels->name,
|
||||
'wp_nav_menu_item_taxonomy_meta_box',
|
||||
'nav-menus',
|
||||
'side',
|
||||
'default',
|
||||
$tax
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -298,17 +347,26 @@ function wp_nav_menu_item_link_meta_box() {
|
||||
<input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" />
|
||||
<p id="menu-item-url-wrap" class="wp-clearfix">
|
||||
<label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label>
|
||||
<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="code menu-item-textbox form-required" placeholder="https://" />
|
||||
<input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]"
|
||||
type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
|
||||
class="code menu-item-textbox form-required" placeholder="https://"
|
||||
/>
|
||||
</p>
|
||||
|
||||
<p id="menu-item-name-wrap" class="wp-clearfix">
|
||||
<label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label>
|
||||
<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="regular-text menu-item-textbox" />
|
||||
<input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]"
|
||||
type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
|
||||
class="regular-text menu-item-textbox"
|
||||
/>
|
||||
</p>
|
||||
|
||||
<p class="button-controls wp-clearfix">
|
||||
<span class="add-to-menu">
|
||||
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" />
|
||||
<input id="submit-customlinkdiv" name="add-custom-menu-item"
|
||||
type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
|
||||
class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>"
|
||||
/>
|
||||
<span class="spinner"></span>
|
||||
</span>
|
||||
</p>
|
||||
@@ -374,8 +432,12 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
$front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0;
|
||||
|
||||
$front_page_obj = null;
|
||||
|
||||
if ( ! empty( $front_page ) ) {
|
||||
$front_page_obj = get_post( $front_page );
|
||||
$front_page_obj = get_post( $front_page );
|
||||
}
|
||||
|
||||
if ( $front_page_obj ) {
|
||||
$front_page_obj->front_or_home = true;
|
||||
|
||||
$important_pages[] = $front_page_obj;
|
||||
@@ -402,11 +464,14 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
$posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0;
|
||||
|
||||
if ( ! empty( $posts_page ) ) {
|
||||
$posts_page_obj = get_post( $posts_page );
|
||||
$posts_page_obj->posts_page = true;
|
||||
$posts_page_obj = get_post( $posts_page );
|
||||
|
||||
$important_pages[] = $posts_page_obj;
|
||||
$suppress_page_ids[] = $posts_page_obj->ID;
|
||||
if ( $posts_page_obj ) {
|
||||
$front_page_obj->posts_page = true;
|
||||
|
||||
$important_pages[] = $posts_page_obj;
|
||||
$suppress_page_ids[] = $posts_page_obj->ID;
|
||||
}
|
||||
}
|
||||
|
||||
// Insert Privacy Policy Page.
|
||||
@@ -414,6 +479,7 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
|
||||
if ( ! empty( $privacy_policy_page_id ) ) {
|
||||
$privacy_policy_page = get_post( $privacy_policy_page_id );
|
||||
|
||||
if ( $privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status ) {
|
||||
$privacy_policy_page->privacy_policy_page = true;
|
||||
|
||||
@@ -484,7 +550,7 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
$current_tab = $_REQUEST[ $tab_name ];
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) {
|
||||
if ( ! empty( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) {
|
||||
$current_tab = 'search';
|
||||
}
|
||||
|
||||
@@ -500,35 +566,50 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
$most_recent_url = '';
|
||||
$view_all_url = '';
|
||||
$search_url = '';
|
||||
|
||||
if ( $nav_menu_selected_id ) {
|
||||
$most_recent_url = esc_url( add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) ) );
|
||||
$view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) );
|
||||
$search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ) );
|
||||
$most_recent_url = add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) );
|
||||
$view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) );
|
||||
$search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) );
|
||||
}
|
||||
?>
|
||||
<div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv">
|
||||
<ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs">
|
||||
<div id="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>" class="posttypediv">
|
||||
<ul id="<?php echo esc_attr( "posttype-{$post_type_name}-tabs" ); ?>" class="posttype-tabs add-menu-item-tabs">
|
||||
<li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>>
|
||||
<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php echo $most_recent_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent">
|
||||
<a class="nav-tab-link"
|
||||
data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>"
|
||||
href="<?php echo esc_url( $most_recent_url . "#tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>"
|
||||
>
|
||||
<?php _e( 'Most Recent' ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>>
|
||||
<a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php echo $view_all_url; ?>#<?php echo $post_type_name; ?>-all">
|
||||
<a class="nav-tab-link"
|
||||
data-type="<?php echo esc_attr( "{$post_type_name}-all" ); ?>"
|
||||
href="<?php echo esc_url( $view_all_url . "#{$post_type_name}-all" ); ?>"
|
||||
>
|
||||
<?php _e( 'View All' ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>>
|
||||
<a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php echo $search_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search">
|
||||
<a class="nav-tab-link"
|
||||
data-type="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>"
|
||||
href="<?php echo esc_url( $search_url . "#tabs-panel-posttype-{$post_type_name}-search" ); ?>"
|
||||
>
|
||||
<?php _e( 'Search' ); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul><!-- .posttype-tabs -->
|
||||
|
||||
<div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php esc_attr_e( 'Most Recent' ); ?>" tabindex="0">
|
||||
<ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear">
|
||||
<div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-most-recent" ); ?>"
|
||||
class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
|
||||
role="region" aria-label="<?php esc_attr_e( 'Most Recent' ); ?>" tabindex="0"
|
||||
>
|
||||
<ul id="<?php echo esc_attr( "{$post_type_name}checklist-most-recent" ); ?>"
|
||||
class="categorychecklist form-no-clear"
|
||||
>
|
||||
<?php
|
||||
$recent_args = array_merge(
|
||||
$recent_args = array_merge(
|
||||
$args,
|
||||
array(
|
||||
'orderby' => 'post_date',
|
||||
@@ -536,7 +617,8 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
'posts_per_page' => 15,
|
||||
)
|
||||
);
|
||||
$most_recent = $get_posts->query( $recent_args );
|
||||
$most_recent = $get_posts->query( $recent_args );
|
||||
|
||||
$args['walker'] = $walker;
|
||||
|
||||
/**
|
||||
@@ -558,17 +640,30 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
* @param array $box Arguments passed to `wp_nav_menu_item_post_type_meta_box()`.
|
||||
* @param array $recent_args An array of `WP_Query` arguments for 'Most Recent' tab.
|
||||
*/
|
||||
$most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box, $recent_args );
|
||||
$most_recent = apply_filters(
|
||||
"nav_menu_items_{$post_type_name}_recent",
|
||||
$most_recent,
|
||||
$args,
|
||||
$box,
|
||||
$recent_args
|
||||
);
|
||||
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $most_recent ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', $most_recent ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
?>
|
||||
</ul>
|
||||
</div><!-- /.tabs-panel -->
|
||||
|
||||
<div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search" role="region" aria-label="<?php echo $post_type->labels->search_items; ?>" tabindex="0">
|
||||
<div id="<?php echo esc_attr( "tabs-panel-posttype-{$post_type_name}-search" ); ?>"
|
||||
class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
|
||||
role="region" aria-label="<?php echo esc_attr( $post_type->labels->search_items ); ?>" tabindex="0"
|
||||
>
|
||||
<?php
|
||||
if ( isset( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) {
|
||||
$searched = esc_attr( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] );
|
||||
if ( isset( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] ) ) {
|
||||
$searched = esc_attr( $_REQUEST[ "quick-search-posttype-{$post_type_name}" ] );
|
||||
$search_results = get_posts(
|
||||
array(
|
||||
's' => $searched,
|
||||
@@ -583,22 +678,41 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
}
|
||||
?>
|
||||
<p class="quick-search-wrap">
|
||||
<label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text">
|
||||
<label for="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'Search' );
|
||||
?>
|
||||
</label>
|
||||
<input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" />
|
||||
<input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
|
||||
class="quick-search" value="<?php echo $searched; ?>"
|
||||
name="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>"
|
||||
id="<?php echo esc_attr( "quick-search-posttype-{$post_type_name}" ); ?>"
|
||||
/>
|
||||
<span class="spinner"></span>
|
||||
<?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?>
|
||||
<?php
|
||||
submit_button(
|
||||
__( 'Search' ),
|
||||
'small quick-search-submit hide-if-js',
|
||||
'submit',
|
||||
false,
|
||||
array( 'id' => "submit-quick-search-posttype-{$post_type_name}" )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear">
|
||||
<ul id="<?php echo esc_attr( "{$post_type_name}-search-checklist" ); ?>"
|
||||
data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>"
|
||||
class="categorychecklist form-no-clear"
|
||||
>
|
||||
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
|
||||
<?php
|
||||
$args['walker'] = $walker;
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', $search_results ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
?>
|
||||
<?php elseif ( is_wp_error( $search_results ) ) : ?>
|
||||
<li><?php echo $search_results->get_error_message(); ?></li>
|
||||
@@ -608,13 +722,20 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
</ul>
|
||||
</div><!-- /.tabs-panel -->
|
||||
|
||||
<div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $post_type->labels->all_items; ?>" tabindex="0">
|
||||
<div id="<?php echo esc_attr( "{$post_type_name}-all" ); ?>"
|
||||
class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
|
||||
role="region" aria-label="<?php echo esc_attr( $post_type->labels->all_items ); ?>" tabindex="0"
|
||||
>
|
||||
<?php if ( ! empty( $page_links ) ) : ?>
|
||||
<div class="add-menu-item-pagelinks">
|
||||
<?php echo $page_links; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<ul id="<?php echo $post_type_name; ?>checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear">
|
||||
|
||||
<ul id="<?php echo esc_attr( "{$post_type_name}checklist" ); ?>"
|
||||
data-wp-lists="<?php echo esc_attr( "list:{$post_type_name}" ); ?>"
|
||||
class="categorychecklist form-no-clear"
|
||||
>
|
||||
<?php
|
||||
$args['walker'] = $walker;
|
||||
|
||||
@@ -658,13 +779,23 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
* @param array $args An array of `WP_Query` arguments.
|
||||
* @param WP_Post_Type $post_type The current post type object for this menu item meta box.
|
||||
*/
|
||||
$posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type );
|
||||
$posts = apply_filters(
|
||||
"nav_menu_items_{$post_type_name}",
|
||||
$posts,
|
||||
$args,
|
||||
$post_type
|
||||
);
|
||||
|
||||
$checkbox_items = walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $posts ), 0, (object) $args );
|
||||
$checkbox_items = walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', $posts ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
|
||||
echo $checkbox_items;
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php if ( ! empty( $page_links ) ) : ?>
|
||||
<div class="add-menu-item-pagelinks">
|
||||
<?php echo $page_links; ?>
|
||||
@@ -672,14 +803,19 @@ function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) {
|
||||
<?php endif; ?>
|
||||
</div><!-- /.tabs-panel -->
|
||||
|
||||
<p class="button-controls wp-clearfix" data-items-type="posttype-<?php echo esc_attr( $post_type_name ); ?>">
|
||||
<p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "posttype-{$post_type_name}" ); ?>">
|
||||
<span class="list-controls hide-if-no-js">
|
||||
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" />
|
||||
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
|
||||
id="<?php echo esc_attr( $tab_name ); ?>" class="select-all"
|
||||
/>
|
||||
<label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label>
|
||||
</span>
|
||||
|
||||
<span class="add-to-menu">
|
||||
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr( 'submit-posttype-' . $post_type_name ); ?>" />
|
||||
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
|
||||
class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>"
|
||||
name="add-post-type-menu-item" id="<?php echo esc_attr( "submit-posttype-{$post_type_name}" ); ?>"
|
||||
/>
|
||||
<span class="spinner"></span>
|
||||
</span>
|
||||
</p>
|
||||
@@ -786,7 +922,7 @@ function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
|
||||
$current_tab = $_REQUEST[ $tab_name ];
|
||||
}
|
||||
|
||||
if ( ! empty( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) {
|
||||
if ( ! empty( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ) ) {
|
||||
$current_tab = 'search';
|
||||
}
|
||||
|
||||
@@ -802,35 +938,50 @@ function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
|
||||
$most_used_url = '';
|
||||
$view_all_url = '';
|
||||
$search_url = '';
|
||||
|
||||
if ( $nav_menu_selected_id ) {
|
||||
$most_used_url = esc_url( add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) ) );
|
||||
$view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) );
|
||||
$search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ) );
|
||||
$most_used_url = add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) );
|
||||
$view_all_url = add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) );
|
||||
$search_url = add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) );
|
||||
}
|
||||
?>
|
||||
<div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv">
|
||||
<ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs">
|
||||
<div id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>" class="taxonomydiv">
|
||||
<ul id="<?php echo esc_attr( "taxonomy-{$taxonomy_name}-tabs" ); ?>" class="taxonomy-tabs add-menu-item-tabs">
|
||||
<li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>>
|
||||
<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php echo $most_used_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop">
|
||||
<a class="nav-tab-link"
|
||||
data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>"
|
||||
href="<?php echo esc_url( $most_used_url . "#tabs-panel-{$taxonomy_name}-pop" ); ?>"
|
||||
>
|
||||
<?php echo esc_html( $taxonomy->labels->most_used ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>>
|
||||
<a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php echo $view_all_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all">
|
||||
<a class="nav-tab-link"
|
||||
data-type="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>"
|
||||
href="<?php echo esc_url( $view_all_url . "#tabs-panel-{$taxonomy_name}-all" ); ?>"
|
||||
>
|
||||
<?php _e( 'View All' ); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>>
|
||||
<a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php echo $search_url; ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>">
|
||||
<a class="nav-tab-link"
|
||||
data-type="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>"
|
||||
href="<?php echo esc_url( $search_url . "#tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>"
|
||||
>
|
||||
<?php _e( 'Search' ); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul><!-- .taxonomy-tabs -->
|
||||
|
||||
<div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->most_used; ?>" tabindex="0">
|
||||
<ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" >
|
||||
<div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-pop" ); ?>"
|
||||
class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
|
||||
role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->most_used ); ?>" tabindex="0"
|
||||
>
|
||||
<ul id="<?php echo esc_attr( "{$taxonomy_name}checklist-pop" ); ?>"
|
||||
class="categorychecklist form-no-clear"
|
||||
>
|
||||
<?php
|
||||
$popular_terms = get_terms(
|
||||
$popular_terms = get_terms(
|
||||
array(
|
||||
'taxonomy' => $taxonomy_name,
|
||||
'orderby' => 'count',
|
||||
@@ -839,24 +990,41 @@ function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
|
||||
'hierarchical' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$args['walker'] = $walker;
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $popular_terms ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', $popular_terms ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
?>
|
||||
</ul>
|
||||
</div><!-- /.tabs-panel -->
|
||||
|
||||
<div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->all_items; ?>" tabindex="0">
|
||||
<div id="<?php echo esc_attr( "tabs-panel-{$taxonomy_name}-all" ); ?>"
|
||||
class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
|
||||
role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->all_items ); ?>" tabindex="0"
|
||||
>
|
||||
<?php if ( ! empty( $page_links ) ) : ?>
|
||||
<div class="add-menu-item-pagelinks">
|
||||
<?php echo $page_links; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear">
|
||||
|
||||
<ul id="<?php echo esc_attr( "{$taxonomy_name}checklist" ); ?>"
|
||||
data-wp-lists="<?php echo esc_attr( "list:{$taxonomy_name}" ); ?>"
|
||||
class="categorychecklist form-no-clear"
|
||||
>
|
||||
<?php
|
||||
$args['walker'] = $walker;
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $terms ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', $terms ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php if ( ! empty( $page_links ) ) : ?>
|
||||
<div class="add-menu-item-pagelinks">
|
||||
<?php echo $page_links; ?>
|
||||
@@ -864,10 +1032,12 @@ function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
|
||||
<?php endif; ?>
|
||||
</div><!-- /.tabs-panel -->
|
||||
|
||||
<div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>" role="region" aria-label="<?php echo $taxonomy->labels->search_items; ?>" tabindex="0">
|
||||
<div id="<?php echo esc_attr( "tabs-panel-search-taxonomy-{$taxonomy_name}" ); ?>"
|
||||
class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"
|
||||
role="region" aria-label="<?php echo esc_attr( $taxonomy->labels->search_items ); ?>" tabindex="0">
|
||||
<?php
|
||||
if ( isset( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) {
|
||||
$searched = esc_attr( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] );
|
||||
if ( isset( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] ) ) {
|
||||
$searched = esc_attr( $_REQUEST[ "quick-search-taxonomy-{$taxonomy_name}" ] );
|
||||
$search_results = get_terms(
|
||||
array(
|
||||
'taxonomy' => $taxonomy_name,
|
||||
@@ -884,22 +1054,41 @@ function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
|
||||
}
|
||||
?>
|
||||
<p class="quick-search-wrap">
|
||||
<label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text">
|
||||
<label for="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>" class="screen-reader-text">
|
||||
<?php
|
||||
/* translators: Hidden accessibility text. */
|
||||
_e( 'Search' );
|
||||
?>
|
||||
</label>
|
||||
<input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" id="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" />
|
||||
<input type="search"
|
||||
class="quick-search" value="<?php echo $searched; ?>"
|
||||
name="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>"
|
||||
id="<?php echo esc_attr( "quick-search-taxonomy-{$taxonomy_name}" ); ?>"
|
||||
/>
|
||||
<span class="spinner"></span>
|
||||
<?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?>
|
||||
<?php
|
||||
submit_button(
|
||||
__( 'Search' ),
|
||||
'small quick-search-submit hide-if-js',
|
||||
'submit',
|
||||
false,
|
||||
array( 'id' => "submit-quick-search-taxonomy-{$taxonomy_name}" )
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
|
||||
<ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear">
|
||||
<ul id="<?php echo esc_attr( "{$taxonomy_name}-search-checklist" ); ?>"
|
||||
data-wp-lists="<?php echo esc_attr( "list:{$taxonomy_name}" ); ?>"
|
||||
class="categorychecklist form-no-clear"
|
||||
>
|
||||
<?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?>
|
||||
<?php
|
||||
$args['walker'] = $walker;
|
||||
echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args );
|
||||
echo walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', $search_results ),
|
||||
0,
|
||||
(object) $args
|
||||
);
|
||||
?>
|
||||
<?php elseif ( is_wp_error( $search_results ) ) : ?>
|
||||
<li><?php echo $search_results->get_error_message(); ?></li>
|
||||
@@ -909,14 +1098,19 @@ function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) {
|
||||
</ul>
|
||||
</div><!-- /.tabs-panel -->
|
||||
|
||||
<p class="button-controls wp-clearfix" data-items-type="taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>">
|
||||
<p class="button-controls wp-clearfix" data-items-type="<?php echo esc_attr( "taxonomy-{$taxonomy_name}" ); ?>">
|
||||
<span class="list-controls hide-if-no-js">
|
||||
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" />
|
||||
<input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
|
||||
id="<?php echo esc_attr( $tab_name ); ?>" class="select-all"
|
||||
/>
|
||||
<label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label>
|
||||
</span>
|
||||
|
||||
<span class="add-to-menu">
|
||||
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr( 'submit-taxonomy-' . $taxonomy_name ); ?>" />
|
||||
<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?>
|
||||
class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>"
|
||||
name="add-taxonomy-menu-item" id="<?php echo esc_attr( "submit-taxonomy-{$taxonomy_name}" ); ?>"
|
||||
/>
|
||||
<span class="spinner"></span>
|
||||
</span>
|
||||
</p>
|
||||
@@ -938,7 +1132,7 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
|
||||
$menu_id = (int) $menu_id;
|
||||
$items_saved = array();
|
||||
|
||||
if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) {
|
||||
if ( 0 === $menu_id || is_nav_menu( $menu_id ) ) {
|
||||
|
||||
// Loop through all the menu items' POST values.
|
||||
foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) {
|
||||
@@ -964,7 +1158,7 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
|
||||
if (
|
||||
empty( $_item_object_data['menu-item-db-id'] ) ||
|
||||
( 0 > $_possible_db_id ) ||
|
||||
$_possible_db_id != $_item_object_data['menu-item-db-id']
|
||||
$_possible_db_id !== (int) $_item_object_data['menu-item-db-id']
|
||||
) {
|
||||
$_actual_db_id = 0;
|
||||
} else {
|
||||
@@ -991,6 +1185,7 @@ function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $items_saved;
|
||||
}
|
||||
|
||||
@@ -1085,6 +1280,7 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
|
||||
|
||||
$some_pending_menu_items = false;
|
||||
$some_invalid_menu_items = false;
|
||||
|
||||
foreach ( (array) $menu_items as $menu_item ) {
|
||||
if ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) {
|
||||
$some_pending_menu_items = true;
|
||||
@@ -1095,16 +1291,25 @@ 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>';
|
||||
$result .= '<div class="notice notice-info notice-alt inline"><p>'
|
||||
. __( 'Click Save Menu to make pending menu items public.' )
|
||||
. '</p></div>';
|
||||
}
|
||||
|
||||
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>';
|
||||
$result .= '<div class="notice notice-error notice-alt inline"><p>'
|
||||
. __( 'There are some invalid menu items. Please check or delete them.' )
|
||||
. '</p></div>';
|
||||
}
|
||||
|
||||
$result .= '<ul class="menu" id="menu-to-edit"> ';
|
||||
$result .= walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items ), 0, (object) array( 'walker' => $walker ) );
|
||||
$result .= walk_nav_menu_tree(
|
||||
array_map( 'wp_setup_nav_menu_item', $menu_items ),
|
||||
0,
|
||||
(object) array( 'walker' => $walker )
|
||||
);
|
||||
$result .= ' </ul> ';
|
||||
|
||||
return $result;
|
||||
} elseif ( is_wp_error( $menu ) ) {
|
||||
return $menu;
|
||||
@@ -1141,10 +1346,19 @@ function wp_nav_menu_manage_columns() {
|
||||
*/
|
||||
function _wp_delete_orphaned_draft_menu_items() {
|
||||
global $wpdb;
|
||||
|
||||
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
|
||||
|
||||
// Delete orphaned draft menu items.
|
||||
$menu_items_to_delete = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < %d", $delete_timestamp ) );
|
||||
$menu_items_to_delete = $wpdb->get_col(
|
||||
$wpdb->prepare(
|
||||
"SELECT ID FROM $wpdb->posts AS p
|
||||
LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id
|
||||
WHERE post_type = 'nav_menu_item' AND post_status = 'draft'
|
||||
AND meta_key = '_menu_item_orphaned' AND meta_value < %d",
|
||||
$delete_timestamp
|
||||
)
|
||||
);
|
||||
|
||||
foreach ( (array) $menu_items_to_delete as $menu_item_id ) {
|
||||
wp_delete_post( $menu_item_id, true );
|
||||
@@ -1211,7 +1425,11 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||
$args[ $field ] = isset( $_POST[ $field ][ $_key ] ) ? $_POST[ $field ][ $_key ] : '';
|
||||
}
|
||||
|
||||
$menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][ $_key ] != $_key ? 0 : $_key ), $args );
|
||||
$menu_item_db_id = wp_update_nav_menu_item(
|
||||
$nav_menu_selected_id,
|
||||
( (int) $_POST['menu-item-db-id'][ $_key ] !== $_key ? 0 : $_key ),
|
||||
$args
|
||||
);
|
||||
|
||||
if ( is_wp_error( $menu_item_db_id ) ) {
|
||||
$messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>';
|
||||
@@ -1250,7 +1468,11 @@ function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selecte
|
||||
}
|
||||
|
||||
// Remove non-existent/deleted menus.
|
||||
$nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) );
|
||||
$nav_menu_option['auto_add'] = array_intersect(
|
||||
$nav_menu_option['auto_add'],
|
||||
wp_get_nav_menus( array( 'fields' => 'ids' ) )
|
||||
);
|
||||
|
||||
update_option( 'nav_menu_options', $nav_menu_option );
|
||||
|
||||
wp_defer_term_counting( false );
|
||||
@@ -1287,8 +1509,10 @@ function _wp_expand_nav_menu_post_data() {
|
||||
|
||||
if ( ! is_null( $data ) && $data ) {
|
||||
foreach ( $data as $post_input_data ) {
|
||||
// For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`),
|
||||
// derive the array path keys via regex and set the value in $_POST.
|
||||
/*
|
||||
* For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`),
|
||||
* derive the array path keys via regex and set the value in $_POST.
|
||||
*/
|
||||
preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches );
|
||||
|
||||
$array_bits = array( $matches[1] );
|
||||
@@ -1301,7 +1525,7 @@ function _wp_expand_nav_menu_post_data() {
|
||||
|
||||
// Build the new array value from leaf to trunk.
|
||||
for ( $i = count( $array_bits ) - 1; $i >= 0; $i-- ) {
|
||||
if ( count( $array_bits ) - 1 == $i ) {
|
||||
if ( count( $array_bits ) - 1 === $i ) {
|
||||
$new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value );
|
||||
} else {
|
||||
$new_post_data = array( $array_bits[ $i ] => $new_post_data );
|
||||
|
||||
@@ -263,7 +263,7 @@ function network_step1( $errors = false ) {
|
||||
echo '<div class="error inline"><p><strong>' . __( 'Warning:' ) . '</strong> ' . __( 'Subdirectory networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
|
||||
}
|
||||
|
||||
$is_www = ( 0 === strpos( $hostname, 'www.' ) );
|
||||
$is_www = str_starts_with( $hostname, 'www.' );
|
||||
if ( $is_www ) :
|
||||
?>
|
||||
<h3><?php esc_html_e( 'Server Address' ); ?></h3>
|
||||
@@ -394,7 +394,7 @@ function network_step2( $errors = false ) {
|
||||
$base = parse_url( $slashed_home, PHP_URL_PATH );
|
||||
$document_root_fix = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
|
||||
$abspath_fix = str_replace( '\\', '/', ABSPATH );
|
||||
$home_path = 0 === strpos( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
|
||||
$home_path = str_starts_with( $abspath_fix, $document_root_fix ) ? $document_root_fix . $base : get_home_path();
|
||||
$wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', $abspath_fix );
|
||||
$rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
|
||||
|
||||
|
||||
@@ -90,8 +90,10 @@ function options_general_add_js() {
|
||||
|
||||
var languageSelect = $( '#WPLANG' );
|
||||
$( 'form' ).on( 'submit', function() {
|
||||
// Don't show a spinner for English and installed languages,
|
||||
// as there is nothing to download.
|
||||
/*
|
||||
* Don't show a spinner for English and installed languages,
|
||||
* as there is nothing to download.
|
||||
*/
|
||||
if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
|
||||
$( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' );
|
||||
}
|
||||
|
||||
@@ -486,8 +486,10 @@ function install_plugin_install_status( $api, $loop = false ) {
|
||||
}
|
||||
} else {
|
||||
$key = array_keys( $installed_plugin );
|
||||
// Use the first plugin regardless of the name.
|
||||
// Could have issues for multiple plugins in one directory if they share different version numbers.
|
||||
/*
|
||||
* Use the first plugin regardless of the name.
|
||||
* Could have issues for multiple plugins in one directory if they share different version numbers.
|
||||
*/
|
||||
$key = reset( $key );
|
||||
|
||||
$update_file = $api->slug . '/' . $key;
|
||||
|
||||
@@ -102,7 +102,7 @@ function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
|
||||
// If no text domain is defined fall back to the plugin slug.
|
||||
if ( ! $plugin_data['TextDomain'] ) {
|
||||
$plugin_slug = dirname( plugin_basename( $plugin_file ) );
|
||||
if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) {
|
||||
if ( '.' !== $plugin_slug && ! str_contains( $plugin_slug, '/' ) ) {
|
||||
$plugin_data['TextDomain'] = $plugin_slug;
|
||||
}
|
||||
}
|
||||
@@ -178,8 +178,10 @@ function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup
|
||||
'title' => true,
|
||||
);
|
||||
|
||||
// Name is marked up inside <a> tags. Don't allow these.
|
||||
// Author is too, but some plugins have used <a> here (omitting Author URI).
|
||||
/*
|
||||
* Name is marked up inside <a> tags. Don't allow these.
|
||||
* Author is too, but some plugins have used <a> here (omitting Author URI).
|
||||
*/
|
||||
$plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links );
|
||||
$plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags );
|
||||
|
||||
@@ -294,7 +296,7 @@ function get_plugins( $plugin_folder = '' ) {
|
||||
|
||||
if ( $plugins_dir ) {
|
||||
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
|
||||
if ( '.' === substr( $file, 0, 1 ) ) {
|
||||
if ( str_starts_with( $file, '.' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -303,11 +305,11 @@ function get_plugins( $plugin_folder = '' ) {
|
||||
|
||||
if ( $plugins_subdir ) {
|
||||
while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) {
|
||||
if ( '.' === substr( $subfile, 0, 1 ) ) {
|
||||
if ( str_starts_with( $subfile, '.' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( '.php' === substr( $subfile, -4 ) ) {
|
||||
if ( str_ends_with( $subfile, '.php' ) ) {
|
||||
$plugin_files[] = "$file/$subfile";
|
||||
}
|
||||
}
|
||||
@@ -315,7 +317,7 @@ function get_plugins( $plugin_folder = '' ) {
|
||||
closedir( $plugins_subdir );
|
||||
}
|
||||
} else {
|
||||
if ( '.php' === substr( $file, -4 ) ) {
|
||||
if ( str_ends_with( $file, '.php' ) ) {
|
||||
$plugin_files[] = $file;
|
||||
}
|
||||
}
|
||||
@@ -371,7 +373,7 @@ function get_mu_plugins() {
|
||||
$plugins_dir = @opendir( WPMU_PLUGIN_DIR );
|
||||
if ( $plugins_dir ) {
|
||||
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
|
||||
if ( '.php' === substr( $file, -4 ) ) {
|
||||
if ( str_ends_with( $file, '.php' ) ) {
|
||||
$plugin_files[] = $file;
|
||||
}
|
||||
}
|
||||
@@ -969,8 +971,10 @@ function delete_plugins( $plugins, $deprecated = '' ) {
|
||||
|
||||
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
|
||||
|
||||
// If plugin is in its own directory, recursively delete the directory.
|
||||
// Base check on if plugin includes directory separator AND that it's not the root plugin folder.
|
||||
/*
|
||||
* If plugin is in its own directory, recursively delete the directory.
|
||||
* Base check on if plugin includes directory separator AND that it's not the root plugin folder.
|
||||
*/
|
||||
if ( strpos( $plugin_file, '/' ) && $this_plugin_dir !== $plugins_dir ) {
|
||||
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
|
||||
} else {
|
||||
@@ -1935,7 +1939,7 @@ function get_admin_page_parent( $parent_page = '' ) {
|
||||
$parent_file = $parent_page;
|
||||
return $parent_page;
|
||||
} elseif ( empty( $typenow ) && $pagenow === $submenu_array[2]
|
||||
&& ( empty( $parent_file ) || false === strpos( $parent_file, '?' ) )
|
||||
&& ( empty( $parent_file ) || ! str_contains( $parent_file, '?' ) )
|
||||
) {
|
||||
$parent_file = $parent_page;
|
||||
return $parent_page;
|
||||
|
||||
@@ -135,8 +135,10 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
|
||||
|
||||
$published_statuses = array( 'publish', 'future' );
|
||||
|
||||
// Posts 'submitted for approval' are submitted to $_POST the same as if they were being published.
|
||||
// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
|
||||
/*
|
||||
* Posts 'submitted for approval' are submitted to $_POST the same as if they were being published.
|
||||
* Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
|
||||
*/
|
||||
if ( isset( $post_data['post_status'] )
|
||||
&& ( in_array( $post_data['post_status'], $published_statuses, true )
|
||||
&& ! current_user_can( $ptype->cap->publish_posts ) )
|
||||
@@ -169,6 +171,10 @@ 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'];
|
||||
@@ -664,6 +670,15 @@ function bulk_edit_posts( $post_data = null ) {
|
||||
// Prevent wp_insert_post() from overwriting post format with the old data.
|
||||
unset( $post_data['tax_input']['post_format'] );
|
||||
|
||||
// Reset post date of scheduled post to be published.
|
||||
if (
|
||||
in_array( $post->post_status, array( 'future', 'draft' ), true ) &&
|
||||
'publish' === $post_data['post_status']
|
||||
) {
|
||||
$post_data['post_date'] = current_time( 'mysql' );
|
||||
$post_data['post_date_gmt'] = '';
|
||||
}
|
||||
|
||||
$post_id = wp_update_post( $post_data );
|
||||
update_post_meta( $post_id, '_edit_last', get_current_user_id() );
|
||||
$updated[] = $post_id;
|
||||
@@ -677,6 +692,16 @@ function bulk_edit_posts( $post_data = null ) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires after processing the post data for bulk edit.
|
||||
*
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @param int[] $updated An array of updated post IDs.
|
||||
* @param array $shared_post_data Associative array containing the post data.
|
||||
*/
|
||||
do_action( 'bulk_edit_posts', $updated, $shared_post_data );
|
||||
|
||||
return array(
|
||||
'updated' => $updated,
|
||||
'skipped' => $skipped,
|
||||
@@ -1010,11 +1035,10 @@ function get_meta_keys() {
|
||||
global $wpdb;
|
||||
|
||||
$keys = $wpdb->get_col(
|
||||
"
|
||||
SELECT meta_key
|
||||
FROM $wpdb->postmeta
|
||||
GROUP BY meta_key
|
||||
ORDER BY meta_key"
|
||||
"SELECT meta_key
|
||||
FROM $wpdb->postmeta
|
||||
GROUP BY meta_key
|
||||
ORDER BY meta_key"
|
||||
);
|
||||
|
||||
return $keys;
|
||||
@@ -1126,7 +1150,7 @@ function _fix_attachment_links( $post ) {
|
||||
$url_id = (int) $url_match[2];
|
||||
$rel_id = (int) $rel_match[1];
|
||||
|
||||
if ( ! $url_id || ! $rel_id || $url_id != $rel_id || strpos( $url_match[0], $site_url ) === false ) {
|
||||
if ( ! $url_id || ! $rel_id || $url_id != $rel_id || ! str_contains( $url_match[0], $site_url ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1421,8 +1445,10 @@ function get_sample_permalink( $post, $title = null, $name = null ) {
|
||||
$post->post_name = sanitize_title( $post->post_name ? $post->post_name : $post->post_title, $post->ID );
|
||||
}
|
||||
|
||||
// If the user wants to set a new name -- override the current one.
|
||||
// Note: if empty name is supplied -- use the title instead, see #6072.
|
||||
/*
|
||||
* If the user wants to set a new name -- override the current one.
|
||||
* Note: if empty name is supplied -- use the title instead, see #6072.
|
||||
*/
|
||||
if ( ! is_null( $name ) ) {
|
||||
$post->post_name = sanitize_title( $name ? $name : $title, $post->ID );
|
||||
}
|
||||
@@ -1516,7 +1542,7 @@ function get_sample_permalink_html( $post, $new_title = null, $new_slug = null )
|
||||
}
|
||||
|
||||
// Permalinks without a post/page name placeholder don't have anything to edit.
|
||||
if ( false === strpos( $permalink, '%postname%' ) && false === strpos( $permalink, '%pagename%' ) ) {
|
||||
if ( ! str_contains( $permalink, '%postname%' ) && ! str_contains( $permalink, '%pagename%' ) ) {
|
||||
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
|
||||
|
||||
if ( false !== $view_link ) {
|
||||
@@ -1555,11 +1581,11 @@ function get_sample_permalink_html( $post, $new_title = null, $new_slug = null )
|
||||
* @since 2.9.0
|
||||
* @since 4.4.0 Added `$post` parameter.
|
||||
*
|
||||
* @param string $return Sample permalink HTML markup.
|
||||
* @param int $post_id Post ID.
|
||||
* @param string $new_title New sample permalink title.
|
||||
* @param string $new_slug New sample permalink slug.
|
||||
* @param WP_Post $post Post object.
|
||||
* @param string $return Sample permalink HTML markup.
|
||||
* @param int $post_id Post ID.
|
||||
* @param string|null $new_title New sample permalink title.
|
||||
* @param string|null $new_slug New sample permalink slug.
|
||||
* @param WP_Post $post Post object.
|
||||
*/
|
||||
$return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post );
|
||||
|
||||
@@ -1756,7 +1782,7 @@ function _admin_notice_post_locked() {
|
||||
}
|
||||
|
||||
$sendback = wp_get_referer();
|
||||
if ( $locked && $sendback && false === strpos( $sendback, 'post.php' ) && false === strpos( $sendback, 'post-new.php' ) ) {
|
||||
if ( $locked && $sendback && ! str_contains( $sendback, 'post.php' ) && ! str_contains( $sendback, 'post-new.php' ) ) {
|
||||
|
||||
$sendback_text = __( 'Go back' );
|
||||
} else {
|
||||
@@ -2051,8 +2077,10 @@ function wp_autosave( $post_data ) {
|
||||
// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked.
|
||||
return edit_post( wp_slash( $post_data ) );
|
||||
} else {
|
||||
// Non-drafts or other users' drafts are not overwritten.
|
||||
// The autosave is stored in a special post revision for each user.
|
||||
/*
|
||||
* Non-drafts or other users' drafts are not overwritten.
|
||||
* The autosave is stored in a special post revision for each user.
|
||||
*/
|
||||
return wp_create_post_autosave( wp_slash( $post_data ) );
|
||||
}
|
||||
}
|
||||
@@ -2178,6 +2206,7 @@ function taxonomy_meta_box_sanitize_cb_input( $taxonomy, $terms ) {
|
||||
* of a block relevant for client registration.
|
||||
*
|
||||
* @since 5.0.0
|
||||
* @since 6.3.0 Added `selectors` field.
|
||||
*
|
||||
* @return array An associative array of registered block data.
|
||||
*/
|
||||
@@ -2192,6 +2221,7 @@ function get_block_editor_server_block_settings() {
|
||||
'attributes' => 'attributes',
|
||||
'provides_context' => 'providesContext',
|
||||
'uses_context' => 'usesContext',
|
||||
'selectors' => 'selectors',
|
||||
'supports' => 'supports',
|
||||
'category' => 'category',
|
||||
'styles' => 'styles',
|
||||
@@ -2436,7 +2466,7 @@ function the_block_editor_meta_box_post_form_hidden_fields( $post ) {
|
||||
$classic_elements = wp_html_split( $classic_output );
|
||||
$hidden_inputs = '';
|
||||
foreach ( $classic_elements as $element ) {
|
||||
if ( 0 !== strpos( $element, '<input ' ) ) {
|
||||
if ( ! str_starts_with( $element, '<input ' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,7 @@ function wp_privacy_generate_personal_data_export_group_html( $group_data, $grou
|
||||
foreach ( (array) $group_item_data as $group_item_datum ) {
|
||||
$value = $group_item_datum['value'];
|
||||
// If it looks like a link, make it a link.
|
||||
if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) {
|
||||
if ( ! str_contains( $value, ' ' ) && ( str_starts_with( $value, 'http://' ) || str_starts_with( $value, 'https://' ) ) ) {
|
||||
$value = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,10 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If comparing revisions, make sure we're dealing with the right post parent.
|
||||
// The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves.
|
||||
/*
|
||||
* If comparing revisions, make sure we are dealing with the right post parent.
|
||||
* The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves.
|
||||
*/
|
||||
if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID ) {
|
||||
return false;
|
||||
}
|
||||
@@ -118,8 +120,10 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
|
||||
$diff = wp_text_diff( $content_from, $content_to, $args );
|
||||
|
||||
if ( ! $diff && 'post_title' === $field ) {
|
||||
// It's a better user experience to still show the Title, even if it didn't change.
|
||||
// No, you didn't see this.
|
||||
/*
|
||||
* It's a better user experience to still show the Title, even if it didn't change.
|
||||
* No, you didn't see this.
|
||||
*/
|
||||
$diff = '<table class="diff"><colgroup><col class="content diffsplit left"><col class="content diffsplit middle"><col class="content diffsplit right"></colgroup><tbody><tr>';
|
||||
|
||||
// In split screen mode, show the title before/after side by side.
|
||||
|
||||
@@ -38,7 +38,7 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
|
||||
|
||||
$charset_collate = $wpdb->get_charset_collate();
|
||||
|
||||
if ( $blog_id && $blog_id != $wpdb->blogid ) {
|
||||
if ( $blog_id && (int) $blog_id !== $wpdb->blogid ) {
|
||||
$old_blog_id = $wpdb->set_blog_id( $blog_id );
|
||||
}
|
||||
|
||||
@@ -548,8 +548,10 @@ function populate_options( array $options = array() ) {
|
||||
// 5.6.0
|
||||
'auto_update_core_dev' => 'enabled',
|
||||
'auto_update_core_minor' => 'enabled',
|
||||
// Default to enabled for new installs.
|
||||
// See https://core.trac.wordpress.org/ticket/51742.
|
||||
/*
|
||||
* Default to enabled for new installs.
|
||||
* See https://core.trac.wordpress.org/ticket/51742.
|
||||
*/
|
||||
'auto_update_core_major' => 'enabled',
|
||||
|
||||
// 5.8.0
|
||||
@@ -983,6 +985,8 @@ endif;
|
||||
function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) {
|
||||
global $wpdb, $current_site, $wp_rewrite;
|
||||
|
||||
$network_id = (int) $network_id;
|
||||
|
||||
$errors = new WP_Error();
|
||||
if ( '' === $domain ) {
|
||||
$errors->add( 'empty_domain', __( 'You must provide a domain name.' ) );
|
||||
@@ -994,11 +998,13 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
// Check for network collision.
|
||||
$network_exists = false;
|
||||
if ( is_multisite() ) {
|
||||
if ( get_network( (int) $network_id ) ) {
|
||||
if ( get_network( $network_id ) ) {
|
||||
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
|
||||
}
|
||||
} else {
|
||||
if ( $network_id == $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) ) ) {
|
||||
if ( $network_id === (int) $wpdb->get_var(
|
||||
$wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id )
|
||||
) ) {
|
||||
$errors->add( 'siteid_exists', __( 'The network already exists.' ) );
|
||||
}
|
||||
}
|
||||
@@ -1011,7 +1017,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
return $errors;
|
||||
}
|
||||
|
||||
if ( 1 == $network_id ) {
|
||||
if ( 1 === $network_id ) {
|
||||
$wpdb->insert(
|
||||
$wpdb->site,
|
||||
array(
|
||||
@@ -1040,8 +1046,6 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
)
|
||||
);
|
||||
|
||||
$site_user = get_userdata( (int) $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", 'admin_user_id', $network_id ) ) );
|
||||
|
||||
/*
|
||||
* When upgrading from single to multisite, assume the current site will
|
||||
* become the main site of the network. When using populate_network()
|
||||
@@ -1065,8 +1069,19 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
)
|
||||
);
|
||||
$current_site->blog_id = $wpdb->insert_id;
|
||||
update_user_meta( $site_user->ID, 'source_domain', $domain );
|
||||
update_user_meta( $site_user->ID, 'primary_blog', $current_site->blog_id );
|
||||
|
||||
$site_user_id = (int) $wpdb->get_var(
|
||||
$wpdb->prepare(
|
||||
"SELECT meta_value
|
||||
FROM $wpdb->sitemeta
|
||||
WHERE meta_key = %s AND site_id = %d",
|
||||
'admin_user_id',
|
||||
$network_id
|
||||
)
|
||||
);
|
||||
|
||||
update_user_meta( $site_user_id, 'source_domain', $domain );
|
||||
update_user_meta( $site_user_id, 'primary_blog', $current_site->blog_id );
|
||||
|
||||
// Unable to use update_network_option() while populating the network.
|
||||
$wpdb->insert(
|
||||
@@ -1102,7 +1117,7 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
|
||||
);
|
||||
if ( is_wp_error( $page ) ) {
|
||||
$errstr = $page->get_error_message();
|
||||
} elseif ( 200 == wp_remote_retrieve_response_code( $page ) ) {
|
||||
} elseif ( 200 === wp_remote_retrieve_response_code( $page ) ) {
|
||||
$vhost_ok = true;
|
||||
}
|
||||
|
||||
@@ -1168,11 +1183,11 @@ function populate_network_meta( $network_id, array $meta = array() ) {
|
||||
$stylesheet = get_option( 'stylesheet' );
|
||||
$allowed_themes = array( $stylesheet => true );
|
||||
|
||||
if ( $template != $stylesheet ) {
|
||||
if ( $template !== $stylesheet ) {
|
||||
$allowed_themes[ $template ] = true;
|
||||
}
|
||||
|
||||
if ( WP_DEFAULT_THEME != $stylesheet && WP_DEFAULT_THEME != $template ) {
|
||||
if ( WP_DEFAULT_THEME !== $stylesheet && WP_DEFAULT_THEME !== $template ) {
|
||||
$allowed_themes[ WP_DEFAULT_THEME ] = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ function wp_insert_category( $catarr, $wp_error = false ) {
|
||||
function wp_update_category( $catarr ) {
|
||||
$cat_id = (int) $catarr['cat_ID'];
|
||||
|
||||
if ( isset( $catarr['category_parent'] ) && ( $cat_id == $catarr['category_parent'] ) ) {
|
||||
if ( isset( $catarr['category_parent'] ) && ( $cat_id === (int) $catarr['category_parent'] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,10 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
|
||||
$output = '';
|
||||
|
||||
if ( $parsed_args['checked_ontop'] ) {
|
||||
// Post-process $categories rather than adding an exclude to the get_terms() query
|
||||
// to keep the query the same across all posts (for any query cache).
|
||||
/*
|
||||
* Post-process $categories rather than adding an exclude to the get_terms() query
|
||||
* to keep the query the same across all posts (for any query cache).
|
||||
*/
|
||||
$checked_categories = array();
|
||||
$keys = array_keys( $categories );
|
||||
|
||||
@@ -724,16 +726,13 @@ function meta_form( $post = null ) {
|
||||
|
||||
if ( $keys ) {
|
||||
natcasesort( $keys );
|
||||
$meta_key_input_id = 'metakeyselect';
|
||||
} else {
|
||||
$meta_key_input_id = 'metakeyinput';
|
||||
}
|
||||
?>
|
||||
<p><strong><?php _e( 'Add New Custom Field:' ); ?></strong></p>
|
||||
<table id="newmeta">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="left"><label for="<?php echo $meta_key_input_id; ?>"><?php _ex( 'Name', 'meta name' ); ?></label></th>
|
||||
<th class="left"><label for="metakeyselect"><?php _ex( 'Name', 'meta name' ); ?></label></th>
|
||||
<th><label for="metavalue"><?php _e( 'Value' ); ?></label></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -753,19 +752,21 @@ function meta_form( $post = null ) {
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input class="hide-if-js" type="text" id="metakeyinput" name="metakeyinput" value="" />
|
||||
<a href="#postcustomstuff" class="hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggle();return false;">
|
||||
<input class="hidden" type="text" id="metakeyinput" name="metakeyinput" value="" aria-label="<?php _e( 'New custom field name' ); ?>" />
|
||||
<button type="button" id="newmeta-button" class="button button-small hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew').toggleClass('hidden');jQuery('#metakeyinput, #metakeyselect').filter(':visible').trigger('focus');">
|
||||
<span id="enternew"><?php _e( 'Enter new' ); ?></span>
|
||||
<span id="cancelnew" class="hidden"><?php _e( 'Cancel' ); ?></span></a>
|
||||
<span id="cancelnew" class="hidden"><?php _e( 'Cancel' ); ?></span></button>
|
||||
<?php } else { ?>
|
||||
<input type="text" id="metakeyinput" name="metakeyinput" value="" />
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea></td>
|
||||
<td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea>
|
||||
<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td colspan="2">
|
||||
<div class="submit">
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="submit add-custom-field">
|
||||
<?php
|
||||
submit_button(
|
||||
__( 'Add Custom Field' ),
|
||||
@@ -779,12 +780,7 @@ function meta_form( $post = null ) {
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
<?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?>
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1240,7 +1236,7 @@ function _get_plugin_from_callback( $callback ) {
|
||||
try {
|
||||
if ( is_array( $callback ) ) {
|
||||
$reflection = new ReflectionMethod( $callback[0], $callback[1] );
|
||||
} elseif ( is_string( $callback ) && false !== strpos( $callback, '::' ) ) {
|
||||
} elseif ( is_string( $callback ) && str_contains( $callback, '::' ) ) {
|
||||
$reflection = new ReflectionMethod( $callback );
|
||||
} else {
|
||||
$reflection = new ReflectionFunction( $callback );
|
||||
@@ -1257,14 +1253,14 @@ function _get_plugin_from_callback( $callback ) {
|
||||
$filename = wp_normalize_path( $reflection->getFileName() );
|
||||
$plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
|
||||
|
||||
if ( strpos( $filename, $plugin_dir ) === 0 ) {
|
||||
if ( str_starts_with( $filename, $plugin_dir ) ) {
|
||||
$filename = str_replace( $plugin_dir, '', $filename );
|
||||
$filename = preg_replace( '|^/([^/]*/).*$|', '\\1', $filename );
|
||||
|
||||
$plugins = get_plugins();
|
||||
|
||||
foreach ( $plugins as $name => $plugin ) {
|
||||
if ( strpos( $name, $filename ) === 0 ) {
|
||||
if ( str_starts_with( $name, $filename ) ) {
|
||||
return $plugin;
|
||||
}
|
||||
}
|
||||
@@ -1307,8 +1303,10 @@ function do_meta_boxes( $screen, $context, $data_object ) {
|
||||
|
||||
printf( '<div id="%s-sortables" class="meta-box-sortables">', esc_attr( $context ) );
|
||||
|
||||
// Grab the ones the user has manually sorted.
|
||||
// Pull them out of their previous context/priority and into the one the user chose.
|
||||
/*
|
||||
* Grab the ones the user has manually sorted.
|
||||
* Pull them out of their previous context/priority and into the one the user chose.
|
||||
*/
|
||||
$sorted = get_user_option( "meta-box-order_$page" );
|
||||
|
||||
if ( ! $already_sorted && $sorted ) {
|
||||
@@ -2178,7 +2176,7 @@ var ajaxurl = '<?php echo esc_js( admin_url( 'admin-ajax.php', 'relative' ) ); ?
|
||||
$admin_body_classes = apply_filters( 'admin_body_class', '' );
|
||||
$admin_body_classes = ltrim( $admin_body_classes . ' ' . $admin_body_class );
|
||||
?>
|
||||
<body <?php echo $admin_body_id; ?>class="wp-admin wp-core-ui no-js iframe <?php echo $admin_body_classes; ?>">
|
||||
<body <?php echo $admin_body_id; ?>class="wp-admin wp-core-ui no-js iframe <?php echo esc_attr( $admin_body_classes ); ?>">
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
var c = document.body.className;
|
||||
|
||||
@@ -711,16 +711,21 @@ function wp_prepare_themes_for_js( $themes = null ) {
|
||||
$is_block_theme = $theme->is_block_theme();
|
||||
|
||||
if ( $is_block_theme && $can_edit_theme_options ) {
|
||||
$customize_action = esc_url( admin_url( 'site-editor.php' ) );
|
||||
$customize_action = admin_url( 'site-editor.php' );
|
||||
if ( $current_theme !== $slug ) {
|
||||
$customize_action = add_query_arg( 'wp_theme_preview', $slug, $customize_action );
|
||||
}
|
||||
} elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) {
|
||||
$customize_action = esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'return' => urlencode( sanitize_url( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
|
||||
),
|
||||
wp_customize_url( $slug )
|
||||
)
|
||||
$customize_action = wp_customize_url( $slug );
|
||||
}
|
||||
if ( null !== $customize_action ) {
|
||||
$customize_action = add_query_arg(
|
||||
array(
|
||||
'return' => urlencode( sanitize_url( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
|
||||
),
|
||||
$customize_action
|
||||
);
|
||||
$customize_action = esc_url( $customize_action );
|
||||
}
|
||||
|
||||
$update_requires_wp = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null;
|
||||
@@ -1162,9 +1167,9 @@ function resume_theme( $theme, $redirect = '' ) {
|
||||
*/
|
||||
if ( ! empty( $redirect ) ) {
|
||||
$functions_path = '';
|
||||
if ( strpos( STYLESHEETPATH, $extension ) ) {
|
||||
if ( str_contains( STYLESHEETPATH, $extension ) ) {
|
||||
$functions_path = STYLESHEETPATH . '/functions.php';
|
||||
} elseif ( strpos( TEMPLATEPATH, $extension ) ) {
|
||||
} elseif ( str_contains( TEMPLATEPATH, $extension ) ) {
|
||||
$functions_path = TEMPLATEPATH . '/functions.php';
|
||||
}
|
||||
|
||||
|
||||
@@ -863,6 +863,10 @@ $_old_files = array(
|
||||
'wp-includes/blocks/comments-query-loop/editor-rtl.css',
|
||||
'wp-includes/blocks/comments-query-loop/editor-rtl.min.css',
|
||||
'wp-includes/blocks/comments-query-loop',
|
||||
// 6.3
|
||||
'wp-includes/images/wlw',
|
||||
'wp-includes/wlwmanifest.xml',
|
||||
'wp-includes/random_compat',
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1134,9 +1138,14 @@ function update_core( $from, $to ) {
|
||||
require WP_CONTENT_DIR . '/upgrade/version-current.php';
|
||||
$wp_filesystem->delete( $versions_file );
|
||||
|
||||
$php_version = PHP_VERSION;
|
||||
$mysql_version = $wpdb->db_version();
|
||||
$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
|
||||
$php_version = PHP_VERSION;
|
||||
$mysql_version = $wpdb->db_version();
|
||||
$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
|
||||
/*
|
||||
* Note: str_contains() 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.
|
||||
*/
|
||||
$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // A dash in the version indicates a development release.
|
||||
$php_compat = version_compare( $php_version, $required_php_version, '>=' );
|
||||
|
||||
@@ -1221,8 +1230,10 @@ function update_core( $from, $to ) {
|
||||
/** This filter is documented in wp-admin/includes/update-core.php */
|
||||
apply_filters( 'update_feedback', __( 'Preparing to install the latest version…' ) );
|
||||
|
||||
// Don't copy wp-content, we'll deal with that below.
|
||||
// We also copy version.php last so failed updates report their old version.
|
||||
/*
|
||||
* Don't copy wp-content, we'll deal with that below.
|
||||
* We also copy version.php last so failed updates report their old version.
|
||||
*/
|
||||
$skip = array( 'wp-content', 'wp-includes/version.php' );
|
||||
$check_is_writable = array();
|
||||
|
||||
@@ -1239,6 +1250,11 @@ function update_core( $from, $to ) {
|
||||
|
||||
if ( is_array( $checksums ) ) {
|
||||
foreach ( $checksums as $file => $checksum ) {
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
if ( 'wp-content' === substr( $file, 0, 10 ) ) {
|
||||
continue;
|
||||
}
|
||||
@@ -1346,6 +1362,11 @@ function update_core( $from, $to ) {
|
||||
|
||||
if ( isset( $checksums ) && is_array( $checksums ) ) {
|
||||
foreach ( $checksums as $file => $checksum ) {
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
if ( 'wp-content' === substr( $file, 0, 10 ) ) {
|
||||
continue;
|
||||
}
|
||||
@@ -1379,8 +1400,10 @@ function update_core( $from, $to ) {
|
||||
}
|
||||
}
|
||||
|
||||
// If we don't have enough free space, it isn't worth trying again.
|
||||
// Unlikely to be hit due to the check in unzip_file().
|
||||
/*
|
||||
* If we don't have enough free space, it isn't worth trying again.
|
||||
* Unlikely to be hit due to the check in unzip_file().
|
||||
*/
|
||||
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( ABSPATH ) : false;
|
||||
|
||||
if ( $available_space && $total_size >= $available_space ) {
|
||||
@@ -1398,15 +1421,21 @@ function update_core( $from, $to ) {
|
||||
}
|
||||
}
|
||||
|
||||
// Custom content directory needs updating now.
|
||||
// Copy languages.
|
||||
/*
|
||||
* Custom content directory needs updating now.
|
||||
* Copy languages.
|
||||
*/
|
||||
if ( ! is_wp_error( $result ) && $wp_filesystem->is_dir( $from . $distro . 'wp-content/languages' ) ) {
|
||||
if ( WP_LANG_DIR !== ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) {
|
||||
$lang_dir = WP_LANG_DIR;
|
||||
} 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 ) && 0 === strpos( $lang_dir, ABSPATH ) ) {
|
||||
// If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
|
||||
@@ -1437,8 +1466,10 @@ function update_core( $from, $to ) {
|
||||
// Remove maintenance file, we're done with potential site-breaking changes.
|
||||
$wp_filesystem->delete( $maintenance_file );
|
||||
|
||||
// 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users,
|
||||
// preventing installation of Twenty Twelve.
|
||||
/*
|
||||
* 3.5 -> 3.5+ - an empty twentytwelve directory was created upon upgrade to 3.5 for some users,
|
||||
* preventing installation of Twenty Twelve.
|
||||
*/
|
||||
if ( '3.5' === $old_wp_version ) {
|
||||
if ( is_dir( WP_CONTENT_DIR . '/themes/twentytwelve' )
|
||||
&& ! file_exists( WP_CONTENT_DIR . '/themes/twentytwelve/style.css' )
|
||||
@@ -1493,7 +1524,10 @@ function update_core( $from, $to ) {
|
||||
$wp_filesystem->mkdir( $dest . $filename, FS_CHMOD_DIR );
|
||||
$_result = copy_dir( $from . $distro . 'wp-content/' . $file, $dest . $filename );
|
||||
|
||||
// If a error occurs partway through this final step, keep the error flowing through, but keep process going.
|
||||
/*
|
||||
* If an error occurs partway through this final step,
|
||||
* keep the error flowing through, but keep the process going.
|
||||
*/
|
||||
if ( is_wp_error( $_result ) ) {
|
||||
if ( ! is_wp_error( $result ) ) {
|
||||
$result = new WP_Error();
|
||||
@@ -1758,6 +1792,11 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) {
|
||||
$files = array();
|
||||
|
||||
if ( file_exists( "{$directory}example.html" )
|
||||
/*
|
||||
* Note: str_contains() 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.
|
||||
*/
|
||||
&& false !== strpos( file_get_contents( "{$directory}example.html" ), '<title>Genericons</title>' )
|
||||
) {
|
||||
$files[] = "{$directory}example.html";
|
||||
@@ -1767,7 +1806,13 @@ function _upgrade_422_find_genericons_files_in_folder( $directory ) {
|
||||
$dirs = array_filter(
|
||||
$dirs,
|
||||
static function( $dir ) {
|
||||
// Skip any node_modules directories.
|
||||
/*
|
||||
* Skip any node_modules directories.
|
||||
*
|
||||
* Note: str_contains() 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.
|
||||
*/
|
||||
return false === strpos( $dir, 'node_modules' );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -15,12 +15,15 @@
|
||||
*/
|
||||
function get_preferred_from_update_core() {
|
||||
$updates = get_core_updates();
|
||||
|
||||
if ( ! is_array( $updates ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( empty( $updates ) ) {
|
||||
return (object) array( 'response' => 'latest' );
|
||||
}
|
||||
|
||||
return $updates[0];
|
||||
}
|
||||
|
||||
@@ -34,13 +37,14 @@ function get_preferred_from_update_core() {
|
||||
* @return array|false Array of the update objects on success, false on failure.
|
||||
*/
|
||||
function get_core_updates( $options = array() ) {
|
||||
$options = array_merge(
|
||||
$options = array_merge(
|
||||
array(
|
||||
'available' => true,
|
||||
'dismissed' => false,
|
||||
),
|
||||
$options
|
||||
);
|
||||
|
||||
$dismissed = get_site_option( 'dismissed_update_core' );
|
||||
|
||||
if ( ! is_array( $dismissed ) ) {
|
||||
@@ -55,6 +59,7 @@ function get_core_updates( $options = array() ) {
|
||||
|
||||
$updates = $from_api->updates;
|
||||
$result = array();
|
||||
|
||||
foreach ( $updates as $update ) {
|
||||
if ( 'autoupdate' === $update->response ) {
|
||||
continue;
|
||||
@@ -72,6 +77,7 @@ function get_core_updates( $options = array() ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -86,6 +92,7 @@ function get_core_updates( $options = array() ) {
|
||||
*/
|
||||
function find_core_auto_update() {
|
||||
$updates = get_site_transient( 'update_core' );
|
||||
|
||||
if ( ! $updates || empty( $updates->updates ) ) {
|
||||
return false;
|
||||
}
|
||||
@@ -94,6 +101,7 @@ function find_core_auto_update() {
|
||||
|
||||
$auto_update = false;
|
||||
$upgrader = new WP_Automatic_Updater();
|
||||
|
||||
foreach ( $updates->updates as $update ) {
|
||||
if ( 'autoupdate' !== $update->response ) {
|
||||
continue;
|
||||
@@ -107,6 +115,7 @@ function find_core_auto_update() {
|
||||
$auto_update = $update;
|
||||
}
|
||||
}
|
||||
|
||||
return $auto_update;
|
||||
}
|
||||
|
||||
@@ -124,6 +133,7 @@ function get_core_checksums( $version, $locale ) {
|
||||
$url = $http_url;
|
||||
|
||||
$ssl = wp_http_supports( array( 'ssl' ) );
|
||||
|
||||
if ( $ssl ) {
|
||||
$url = set_url_scheme( $url, 'https' );
|
||||
}
|
||||
@@ -133,6 +143,7 @@ function get_core_checksums( $version, $locale ) {
|
||||
);
|
||||
|
||||
$response = wp_remote_get( $url, $options );
|
||||
|
||||
if ( $ssl && is_wp_error( $response ) ) {
|
||||
trigger_error(
|
||||
sprintf(
|
||||
@@ -142,10 +153,11 @@ function get_core_checksums( $version, $locale ) {
|
||||
) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
|
||||
headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
|
||||
);
|
||||
|
||||
$response = wp_remote_get( $http_url, $options );
|
||||
}
|
||||
|
||||
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
|
||||
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -170,6 +182,7 @@ function get_core_checksums( $version, $locale ) {
|
||||
function dismiss_core_update( $update ) {
|
||||
$dismissed = get_site_option( 'dismissed_update_core' );
|
||||
$dismissed[ $update->current . '|' . $update->locale ] = true;
|
||||
|
||||
return update_site_option( 'dismissed_update_core', $dismissed );
|
||||
}
|
||||
|
||||
@@ -191,6 +204,7 @@ function undismiss_core_update( $version, $locale ) {
|
||||
}
|
||||
|
||||
unset( $dismissed[ $key ] );
|
||||
|
||||
return update_site_option( 'dismissed_update_core', $dismissed );
|
||||
}
|
||||
|
||||
@@ -211,11 +225,13 @@ function find_core_update( $version, $locale ) {
|
||||
}
|
||||
|
||||
$updates = $from_api->updates;
|
||||
|
||||
foreach ( $updates as $update ) {
|
||||
if ( $update->current == $version && $update->locale == $locale ) {
|
||||
if ( $update->current === $version && $update->locale === $locale ) {
|
||||
return $update;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -234,6 +250,7 @@ function core_update_footer( $msg = '' ) {
|
||||
}
|
||||
|
||||
$cur = get_preferred_from_update_core();
|
||||
|
||||
if ( ! is_object( $cur ) ) {
|
||||
$cur = new stdClass();
|
||||
}
|
||||
@@ -303,7 +320,7 @@ function update_nag() {
|
||||
|
||||
$version_url = sprintf(
|
||||
/* translators: %s: WordPress version. */
|
||||
esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
|
||||
esc_url( __( 'https://wordpress.org/documentation/wordpress-version/version-%s/' ) ),
|
||||
sanitize_title( $cur->current )
|
||||
);
|
||||
|
||||
@@ -335,6 +352,7 @@ function update_nag() {
|
||||
*/
|
||||
function update_right_now_message() {
|
||||
$theme_name = wp_get_theme();
|
||||
|
||||
if ( current_user_can( 'switch_themes' ) ) {
|
||||
$theme_name = sprintf( '<a href="themes.php">%1$s</a>', $theme_name );
|
||||
}
|
||||
@@ -384,6 +402,7 @@ function get_plugin_updates() {
|
||||
$all_plugins = get_plugins();
|
||||
$upgrade_plugins = array();
|
||||
$current = get_site_transient( 'update_plugins' );
|
||||
|
||||
foreach ( (array) $all_plugins as $plugin_file => $plugin_data ) {
|
||||
if ( isset( $current->response[ $plugin_file ] ) ) {
|
||||
$upgrade_plugins[ $plugin_file ] = (object) $plugin_data;
|
||||
@@ -405,8 +424,10 @@ function wp_plugin_update_rows() {
|
||||
}
|
||||
|
||||
$plugins = get_site_transient( 'update_plugins' );
|
||||
|
||||
if ( isset( $plugins->response ) && is_array( $plugins->response ) ) {
|
||||
$plugins = array_keys( $plugins->response );
|
||||
|
||||
foreach ( $plugins as $plugin_file ) {
|
||||
add_action( "after_plugin_row_{$plugin_file}", 'wp_plugin_update_row', 10, 2 );
|
||||
}
|
||||
@@ -424,6 +445,7 @@ function wp_plugin_update_rows() {
|
||||
*/
|
||||
function wp_plugin_update_row( $file, $plugin_data ) {
|
||||
$current = get_site_transient( 'update_plugins' );
|
||||
|
||||
if ( ! isset( $current->response[ $file ] ) ) {
|
||||
return false;
|
||||
}
|
||||
@@ -607,6 +629,7 @@ function get_theme_updates() {
|
||||
}
|
||||
|
||||
$update_themes = array();
|
||||
|
||||
foreach ( $current->response as $stylesheet => $data ) {
|
||||
$update_themes[ $stylesheet ] = wp_get_theme( $stylesheet );
|
||||
$update_themes[ $stylesheet ]->update = $data;
|
||||
@@ -626,6 +649,7 @@ function wp_theme_update_rows() {
|
||||
}
|
||||
|
||||
$themes = get_site_transient( 'update_themes' );
|
||||
|
||||
if ( isset( $themes->response ) && is_array( $themes->response ) ) {
|
||||
$themes = array_keys( $themes->response );
|
||||
|
||||
@@ -818,13 +842,16 @@ function wp_theme_update_row( $theme_key, $theme ) {
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @global int $upgrading
|
||||
*
|
||||
* @return void|false
|
||||
*/
|
||||
function maintenance_nag() {
|
||||
// Include an unmodified $wp_version.
|
||||
require ABSPATH . WPINC . '/version.php';
|
||||
global $upgrading;
|
||||
|
||||
$nag = isset( $upgrading );
|
||||
|
||||
if ( ! $nag ) {
|
||||
$failed = get_site_option( 'auto_core_update_failed' );
|
||||
/*
|
||||
|
||||
@@ -351,7 +351,7 @@ Commenter avatars come from <a href="%s">Gravatar</a>.'
|
||||
$privacy_policy_content = get_site_option( 'default_privacy_policy_content' );
|
||||
} else {
|
||||
if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
|
||||
include_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
|
||||
}
|
||||
|
||||
$privacy_policy_content = WP_Privacy_Policy_Content::get_default_content();
|
||||
@@ -440,8 +440,10 @@ Commenter avatars come from <a href="%s">Gravatar</a>.'
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'user_level' ) );
|
||||
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities' ) );
|
||||
|
||||
// Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.)
|
||||
// TODO: Get previous_blog_id.
|
||||
/*
|
||||
* Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.)
|
||||
* TODO: Get previous_blog_id.
|
||||
*/
|
||||
if ( ! is_super_admin( $user_id ) && 1 != $user_id ) {
|
||||
$wpdb->delete(
|
||||
$wpdb->usermeta,
|
||||
@@ -654,6 +656,8 @@ if ( ! function_exists( 'wp_upgrade' ) ) :
|
||||
update_site_meta( get_current_blog_id(), 'db_last_updated', microtime() );
|
||||
}
|
||||
|
||||
delete_transient( 'wp_core_block_css_files' );
|
||||
|
||||
/**
|
||||
* Fires after a site is fully upgraded.
|
||||
*
|
||||
@@ -832,6 +836,10 @@ function upgrade_all() {
|
||||
upgrade_600();
|
||||
}
|
||||
|
||||
if ( $wp_current_db_version < 55853 ) {
|
||||
upgrade_630();
|
||||
}
|
||||
|
||||
maybe_disable_link_manager();
|
||||
|
||||
maybe_disable_automattic_widgets();
|
||||
@@ -1638,8 +1646,10 @@ function upgrade_290() {
|
||||
global $wp_current_db_version;
|
||||
|
||||
if ( $wp_current_db_version < 11958 ) {
|
||||
// Previously, setting depth to 1 would redundantly disable threading,
|
||||
// but now 2 is the minimum depth to avoid confusion.
|
||||
/*
|
||||
* Previously, setting depth to 1 would redundantly disable threading,
|
||||
* but now 2 is the minimum depth to avoid confusion.
|
||||
*/
|
||||
if ( get_option( 'thread_comments_depth' ) == '1' ) {
|
||||
update_option( 'thread_comments_depth', 2 );
|
||||
update_option( 'thread_comments', 0 );
|
||||
@@ -1739,6 +1749,7 @@ function upgrade_330() {
|
||||
$_sidebars_widgets[ $index ][ $i ] = $id;
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = sanitize_title( $name );
|
||||
if ( isset( $wp_registered_widgets[ $id ] ) ) {
|
||||
$_sidebars_widgets[ $index ][ $i ] = $id;
|
||||
@@ -1748,13 +1759,15 @@ function upgrade_330() {
|
||||
$found = false;
|
||||
|
||||
foreach ( $wp_registered_widgets as $widget_id => $widget ) {
|
||||
if ( strtolower( $widget['name'] ) == strtolower( $name ) ) {
|
||||
if ( strtolower( $widget['name'] ) === strtolower( $name ) ) {
|
||||
$_sidebars_widgets[ $index ][ $i ] = $widget['id'];
|
||||
$found = true;
|
||||
|
||||
$found = true;
|
||||
break;
|
||||
} elseif ( sanitize_title( $widget['name'] ) == sanitize_title( $name ) ) {
|
||||
} elseif ( sanitize_title( $widget['name'] ) === sanitize_title( $name ) ) {
|
||||
$_sidebars_widgets[ $index ][ $i ] = $widget['id'];
|
||||
$found = true;
|
||||
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1835,7 +1848,7 @@ function upgrade_350() {
|
||||
if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
|
||||
$meta_keys = array();
|
||||
foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
|
||||
if ( false !== strpos( $name, '-' ) ) {
|
||||
if ( str_contains( $name, '-' ) ) {
|
||||
$meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
|
||||
}
|
||||
}
|
||||
@@ -2290,6 +2303,29 @@ function upgrade_600() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes changes made in WordPress 6.3.0.
|
||||
*
|
||||
* @ignore
|
||||
* @since 6.3.0
|
||||
*
|
||||
* @global int $wp_current_db_version The old (current) database version.
|
||||
*/
|
||||
function upgrade_630() {
|
||||
global $wp_current_db_version;
|
||||
|
||||
if ( $wp_current_db_version < 55853 ) {
|
||||
if ( ! is_multisite() ) {
|
||||
// Replace non-autoload option can_compress_scripts with autoload option, see #55270
|
||||
$can_compress_scripts = get_option( 'can_compress_scripts', false );
|
||||
if ( false !== $can_compress_scripts ) {
|
||||
delete_option( 'can_compress_scripts' );
|
||||
add_option( 'can_compress_scripts', $can_compress_scripts, '', 'yes' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes network-level upgrade routines.
|
||||
*
|
||||
@@ -2739,19 +2775,27 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
|
||||
$iqueries = array(); // Insertion queries.
|
||||
$for_update = array();
|
||||
|
||||
// Create a tablename index for an array ($cqueries) of queries.
|
||||
// Create a tablename index for an array ($cqueries) of recognized query types.
|
||||
foreach ( $queries as $qry ) {
|
||||
if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) {
|
||||
$cqueries[ trim( $matches[1], '`' ) ] = $qry;
|
||||
$for_update[ $matches[1] ] = 'Created table ' . $matches[1];
|
||||
} elseif ( preg_match( '|CREATE DATABASE ([^ ]*)|', $qry, $matches ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( preg_match( '|CREATE DATABASE ([^ ]*)|', $qry, $matches ) ) {
|
||||
array_unshift( $cqueries, $qry );
|
||||
} elseif ( preg_match( '|INSERT INTO ([^ ]*)|', $qry, $matches ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( preg_match( '|INSERT INTO ([^ ]*)|', $qry, $matches ) ) {
|
||||
$iqueries[] = $qry;
|
||||
} elseif ( preg_match( '|UPDATE ([^ ]*)|', $qry, $matches ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( preg_match( '|UPDATE ([^ ]*)|', $qry, $matches ) ) {
|
||||
$iqueries[] = $qry;
|
||||
} else {
|
||||
// Unrecognized query type.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3070,16 +3114,20 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
|
||||
} elseif ( $index_data['unique'] ) {
|
||||
$index_string .= 'UNIQUE ';
|
||||
}
|
||||
|
||||
if ( 'FULLTEXT' === strtoupper( $index_data['index_type'] ) ) {
|
||||
$index_string .= 'FULLTEXT ';
|
||||
}
|
||||
|
||||
if ( 'SPATIAL' === strtoupper( $index_data['index_type'] ) ) {
|
||||
$index_string .= 'SPATIAL ';
|
||||
}
|
||||
|
||||
$index_string .= 'KEY ';
|
||||
if ( 'primary' !== $index_name ) {
|
||||
$index_string .= '`' . $index_name . '`';
|
||||
}
|
||||
|
||||
$index_columns = '';
|
||||
|
||||
// For each column in the index.
|
||||
@@ -3176,8 +3224,9 @@ function make_db_current_silent( $tables = 'all' ) {
|
||||
* @return bool
|
||||
*/
|
||||
function make_site_theme_from_oldschool( $theme_name, $template ) {
|
||||
$home_path = get_home_path();
|
||||
$site_dir = WP_CONTENT_DIR . "/themes/$template";
|
||||
$home_path = get_home_path();
|
||||
$site_dir = WP_CONTENT_DIR . "/themes/$template";
|
||||
$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
|
||||
|
||||
if ( ! file_exists( "$home_path/index.php" ) ) {
|
||||
return false;
|
||||
@@ -3204,8 +3253,8 @@ function make_site_theme_from_oldschool( $theme_name, $template ) {
|
||||
// Check to make sure it's not a new index.
|
||||
if ( 'index.php' === $oldfile ) {
|
||||
$index = implode( '', file( "$oldpath/$oldfile" ) );
|
||||
if ( strpos( $index, 'WP_USE_THEMES' ) !== false ) {
|
||||
if ( ! copy( WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME . '/index.php', "$site_dir/$newfile" ) ) {
|
||||
if ( str_contains( $index, 'WP_USE_THEMES' ) ) {
|
||||
if ( ! copy( "$default_dir/$oldfile", "$site_dir/$newfile" ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3231,10 +3280,18 @@ function make_site_theme_from_oldschool( $theme_name, $template ) {
|
||||
}
|
||||
|
||||
// Update stylesheet references.
|
||||
$line = str_replace( "<?php echo __get_option('siteurl'); ?>/wp-layout.css", "<?php bloginfo('stylesheet_url'); ?>", $line );
|
||||
$line = str_replace(
|
||||
"<?php echo __get_option('siteurl'); ?>/wp-layout.css",
|
||||
"<?php bloginfo('stylesheet_url'); ?>",
|
||||
$line
|
||||
);
|
||||
|
||||
// Update comments template inclusion.
|
||||
$line = str_replace( "<?php include(ABSPATH . 'wp-comments.php'); ?>", '<?php comments_template(); ?>', $line );
|
||||
$line = str_replace(
|
||||
"<?php include(ABSPATH . 'wp-comments.php'); ?>",
|
||||
'<?php comments_template(); ?>',
|
||||
$line
|
||||
);
|
||||
|
||||
fwrite( $f, "{$line}\n" );
|
||||
}
|
||||
@@ -3243,7 +3300,13 @@ function make_site_theme_from_oldschool( $theme_name, $template ) {
|
||||
}
|
||||
|
||||
// Add a theme header.
|
||||
$header = "/*\nTheme Name: $theme_name\nTheme URI: " . __get_option( 'siteurl' ) . "\nDescription: A theme automatically created by the update.\nVersion: 1.0\nAuthor: Moi\n*/\n";
|
||||
$header = "/*\n" .
|
||||
"Theme Name: $theme_name\n" .
|
||||
'Theme URI: ' . __get_option( 'siteurl' ) . "\n" .
|
||||
"Description: A theme automatically created by the update.\n" .
|
||||
"Version: 1.0\n" .
|
||||
"Author: Moi\n" .
|
||||
"*/\n";
|
||||
|
||||
$stylelines = file_get_contents( "$site_dir/style.css" );
|
||||
if ( $stylelines ) {
|
||||
@@ -3272,8 +3335,10 @@ function make_site_theme_from_default( $theme_name, $template ) {
|
||||
$site_dir = WP_CONTENT_DIR . "/themes/$template";
|
||||
$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
|
||||
|
||||
// Copy files from the default theme to the site theme.
|
||||
// $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' );
|
||||
/*
|
||||
* Copy files from the default theme to the site theme.
|
||||
* $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' );
|
||||
*/
|
||||
|
||||
$theme_dir = @opendir( $default_dir );
|
||||
if ( $theme_dir ) {
|
||||
@@ -3281,9 +3346,11 @@ function make_site_theme_from_default( $theme_name, $template ) {
|
||||
if ( is_dir( "$default_dir/$theme_file" ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! copy( "$default_dir/$theme_file", "$site_dir/$theme_file" ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
chmod( "$site_dir/$theme_file", 0777 );
|
||||
}
|
||||
|
||||
@@ -3295,20 +3362,25 @@ function make_site_theme_from_default( $theme_name, $template ) {
|
||||
if ( $stylelines ) {
|
||||
$f = fopen( "$site_dir/style.css", 'w' );
|
||||
|
||||
$headers = array(
|
||||
'Theme Name:' => $theme_name,
|
||||
'Theme URI:' => __get_option( 'url' ),
|
||||
'Description:' => 'Your theme.',
|
||||
'Version:' => '1',
|
||||
'Author:' => 'You',
|
||||
);
|
||||
|
||||
foreach ( $stylelines as $line ) {
|
||||
if ( strpos( $line, 'Theme Name:' ) !== false ) {
|
||||
$line = 'Theme Name: ' . $theme_name;
|
||||
} elseif ( strpos( $line, 'Theme URI:' ) !== false ) {
|
||||
$line = 'Theme URI: ' . __get_option( 'url' );
|
||||
} elseif ( strpos( $line, 'Description:' ) !== false ) {
|
||||
$line = 'Description: Your theme.';
|
||||
} elseif ( strpos( $line, 'Version:' ) !== false ) {
|
||||
$line = 'Version: 1';
|
||||
} elseif ( strpos( $line, 'Author:' ) !== false ) {
|
||||
$line = 'Author: You';
|
||||
foreach ( $headers as $header => $value ) {
|
||||
if ( str_contains( $line, $header ) ) {
|
||||
$line = $header . ' ' . $value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fwrite( $f, $line . "\n" );
|
||||
}
|
||||
|
||||
fclose( $f );
|
||||
}
|
||||
|
||||
@@ -3324,9 +3396,11 @@ function make_site_theme_from_default( $theme_name, $template ) {
|
||||
if ( is_dir( "$default_dir/images/$image" ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! copy( "$default_dir/images/$image", "$site_dir/images/$image" ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
chmod( "$site_dir/images/$image", 0777 );
|
||||
}
|
||||
|
||||
|
||||
@@ -174,12 +174,12 @@ function edit_user( $user_id = 0 ) {
|
||||
}
|
||||
|
||||
// Check for "\" in password.
|
||||
if ( false !== strpos( wp_unslash( $pass1 ), '\\' ) ) {
|
||||
if ( str_contains( wp_unslash( $pass1 ), '\\' ) ) {
|
||||
$errors->add( 'pass', __( '<strong>Error:</strong> Passwords may not contain the character "\\".' ), array( 'form-field' => 'pass1' ) );
|
||||
}
|
||||
|
||||
// Checking the password has been typed twice the same.
|
||||
if ( ( $update || ! empty( $pass1 ) ) && $pass1 != $pass2 ) {
|
||||
if ( ( $update || ! empty( $pass1 ) ) && $pass1 !== $pass2 ) {
|
||||
$errors->add( 'pass', __( '<strong>Error:</strong> Passwords do not match. Please enter the same password in both password fields.' ), array( 'form-field' => 'pass1' ) );
|
||||
}
|
||||
|
||||
@@ -202,14 +202,14 @@ function edit_user( $user_id = 0 ) {
|
||||
$errors->add( 'invalid_username', __( '<strong>Error:</strong> Sorry, that username is not allowed.' ) );
|
||||
}
|
||||
|
||||
/* checking email address */
|
||||
// Checking email address.
|
||||
if ( empty( $user->user_email ) ) {
|
||||
$errors->add( 'empty_email', __( '<strong>Error:</strong> Please enter an email address.' ), array( 'form-field' => 'email' ) );
|
||||
} elseif ( ! is_email( $user->user_email ) ) {
|
||||
$errors->add( 'invalid_email', __( '<strong>Error:</strong> The email address is not correct.' ), array( 'form-field' => 'email' ) );
|
||||
} else {
|
||||
$owner_id = email_exists( $user->user_email );
|
||||
if ( $owner_id && ( ! $update || ( $owner_id != $user->ID ) ) ) {
|
||||
if ( $owner_id && ( ! $update || ( $owner_id !== $user->ID ) ) ) {
|
||||
$errors->add( 'email_exists', __( '<strong>Error:</strong> This email is already registered. Please choose another one.' ), array( 'form-field' => 'email' ) );
|
||||
}
|
||||
}
|
||||
@@ -324,18 +324,21 @@ function get_users_drafts( $user_id ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove user and optionally reassign posts and links to another user.
|
||||
* Delete user and optionally reassign posts and links to another user.
|
||||
*
|
||||
* If the $reassign parameter is not assigned to a User ID, then all posts will
|
||||
* be deleted of that user. The action {@see 'delete_user'} that is passed the User ID
|
||||
* Note that on a Multisite installation the user only gets removed from the site
|
||||
* and does not get deleted from the database.
|
||||
*
|
||||
* If the `$reassign` parameter is not assigned to a user ID, then all posts will
|
||||
* be deleted of that user. The action {@see 'delete_user'} that is passed the user ID
|
||||
* being deleted will be run after the posts are either reassigned or deleted.
|
||||
* The user meta will also be deleted that are for that User ID.
|
||||
* The user meta will also be deleted that are for that user ID.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @global wpdb $wpdb WordPress database abstraction object.
|
||||
*
|
||||
* @param int $id User ID.
|
||||
* @param int $id User ID.
|
||||
* @param int $reassign Optional. Reassign posts and links to new User ID.
|
||||
* @return bool True when finished.
|
||||
*/
|
||||
@@ -361,7 +364,10 @@ function wp_delete_user( $id, $reassign = null ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires immediately before a user is deleted from the database.
|
||||
* Fires immediately before a user is deleted from the site.
|
||||
*
|
||||
* Note that on a Multisite installation the user only gets removed from the site
|
||||
* and does not get deleted from the database.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @since 5.5.0 Added the `$user` parameter.
|
||||
@@ -440,7 +446,11 @@ function wp_delete_user( $id, $reassign = null ) {
|
||||
clean_user_cache( $user );
|
||||
|
||||
/**
|
||||
* Fires immediately after a user is deleted from the database.
|
||||
* Fires immediately after a user is deleted from the site.
|
||||
*
|
||||
* Note that on a Multisite installation the user may not have been deleted from
|
||||
* the database depending on whether `wp_delete_user()` or `wpmu_delete_user()`
|
||||
* was called.
|
||||
*
|
||||
* @since 2.9.0
|
||||
* @since 5.5.0 Added the `$user` parameter.
|
||||
@@ -485,7 +495,7 @@ function default_password_nag_handler( $errors = false ) {
|
||||
|
||||
// get_user_setting() = JS-saved UI setting. Else no-js-fallback code.
|
||||
if ( 'hide' === get_user_setting( 'default_password_nag' )
|
||||
|| isset( $_GET['default_password_nag'] ) && '0' == $_GET['default_password_nag']
|
||||
|| isset( $_GET['default_password_nag'] ) && '0' === $_GET['default_password_nag']
|
||||
) {
|
||||
delete_user_setting( 'default_password_nag' );
|
||||
update_user_meta( $user_ID, 'default_password_nag', false );
|
||||
@@ -507,7 +517,7 @@ function default_password_nag_edit_user( $user_ID, $old_data ) {
|
||||
$new_data = get_userdata( $user_ID );
|
||||
|
||||
// Remove the nag if the password has been changed.
|
||||
if ( $new_data->user_pass != $old_data->user_pass ) {
|
||||
if ( $new_data->user_pass !== $old_data->user_pass ) {
|
||||
delete_user_setting( 'default_password_nag' );
|
||||
update_user_meta( $user_ID, 'default_password_nag', false );
|
||||
}
|
||||
@@ -525,15 +535,28 @@ function default_password_nag() {
|
||||
if ( 'profile.php' === $pagenow || ! get_user_option( 'default_password_nag' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<div class="error default-password-nag">';
|
||||
echo '<p>';
|
||||
echo '<strong>' . __( 'Notice:' ) . '</strong> ';
|
||||
_e( 'You’re using the auto-generated password for your account. Would you like to change it?' );
|
||||
echo '</p><p>';
|
||||
printf( '<a href="%s">' . __( 'Yes, take me to my profile page' ) . '</a> | ', get_edit_profile_url() . '#password' );
|
||||
printf( '<a href="%s" id="default-password-nag-no">' . __( 'No thanks, do not remind me again' ) . '</a>', '?default_password_nag=0' );
|
||||
echo '</p></div>';
|
||||
?>
|
||||
<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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,6 +67,8 @@ function wp_list_widgets() {
|
||||
* @since 3.1.0
|
||||
* @access private
|
||||
*
|
||||
* @param array $a First array.
|
||||
* @param array $b Second array.
|
||||
* @return int
|
||||
*/
|
||||
function _sort_name_callback( $a, $b ) {
|
||||
|
||||
Reference in New Issue
Block a user