Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-01-29 00:45:18 +00:00
parent e336b24edd
commit 001ffe81fb
497 changed files with 6841 additions and 5486 deletions

View File

@ -68,7 +68,7 @@ if ( is_object( $wp_object_cache ) ) {
$wp_object_cache->cache_enabled = false; $wp_object_cache->cache_enabled = false;
} }
// Fix for page title // Fix for page title.
$wp_query->is_404 = false; $wp_query->is_404 = false;
/** /**

View File

@ -27,7 +27,7 @@ send_origin_headers();
header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
header( 'X-Robots-Tag: noindex' ); header( 'X-Robots-Tag: noindex' );
// Require an action parameter // Require an action parameter.
if ( empty( $_REQUEST['action'] ) ) { if ( empty( $_REQUEST['action'] ) ) {
wp_die( '0', 400 ); wp_die( '0', 400 );
} }
@ -141,7 +141,7 @@ $core_actions_post = array(
'health-check-get-sizes', 'health-check-get-sizes',
); );
// Deprecated // Deprecated.
$core_actions_post_deprecated = array( 'wp-fullscreen-save-post', 'press-this-save-post', 'press-this-add-category' ); $core_actions_post_deprecated = array( 'wp-fullscreen-save-post', 'press-this-save-post', 'press-this-add-category' );
$core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated ); $core_actions_post = array_merge( $core_actions_post, $core_actions_post_deprecated );
@ -189,5 +189,5 @@ if ( is_user_logged_in() ) {
*/ */
do_action( "wp_ajax_nopriv_{$action}" ); do_action( "wp_ajax_nopriv_{$action}" );
} }
// Default status // Default status.
wp_die( '0' ); wp_die( '0' );

View File

@ -6,7 +6,7 @@
* @subpackage Administration * @subpackage Administration
*/ */
// don't load directly // Don't load directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
die( '-1' ); die( '-1' );
} }
@ -104,7 +104,7 @@ do_action( 'admin_print_footer_scripts' );
*/ */
do_action( "admin_footer-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores do_action( "admin_footer-{$hook_suffix}" ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
// get_site_option() won't exist when auto upgrading from <= 2.7 // get_site_option() won't exist when auto upgrading from <= 2.7.
if ( function_exists( 'get_site_option' ) ) { if ( function_exists( 'get_site_option' ) ) {
if ( false === get_site_option( 'can_compress_scripts' ) ) { if ( false === get_site_option( 'can_compress_scripts' ) ) {
compression_test(); compression_test();

View File

@ -93,12 +93,12 @@ require_once( ABSPATH . 'wp-admin/includes/admin.php' );
auth_redirect(); auth_redirect();
// Schedule trash collection // Schedule trash collection.
if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) { if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) {
wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' ); wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' );
} }
// Schedule Transient cleanup. // Schedule transient cleanup.
if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) { if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) {
wp_schedule_event( time(), 'daily', 'delete_expired_transients' ); wp_schedule_event( time(), 'daily', 'delete_expired_transients' );
} }
@ -182,7 +182,7 @@ if ( isset( $plugin_page ) ) {
// Back-compat for plugins using add_management_page(). // Back-compat for plugins using add_management_page().
if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook( $plugin_page, 'tools.php' ) ) { if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' != get_plugin_page_hook( $plugin_page, 'tools.php' ) ) {
// There could be plugin specific params on the URL, so we need the whole query string // There could be plugin specific params on the URL, so we need the whole query string.
if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
$query_string = $_SERVER['QUERY_STRING']; $query_string = $_SERVER['QUERY_STRING'];
} else { } else {
@ -347,7 +347,7 @@ if ( isset( $plugin_page ) ) {
include( ABSPATH . 'wp-admin/admin-footer.php' ); include( ABSPATH . 'wp-admin/admin-footer.php' );
// Make sure rules are flushed // Make sure rules are flushed.
flush_rewrite_rules( false ); flush_rewrite_rules( false );
exit(); exit();

View File

@ -38,7 +38,7 @@ if ( ! current_user_can( 'upload_files' ) ) {
wp_die( __( 'Sorry, you are not allowed to upload files.' ) ); wp_die( __( 'Sorry, you are not allowed to upload files.' ) );
} }
// just fetch the detail form for that attachment // Just fetch the detail form for that attachment.
if ( isset( $_REQUEST['attachment_id'] ) && intval( $_REQUEST['attachment_id'] ) && $_REQUEST['fetch'] ) { if ( isset( $_REQUEST['attachment_id'] ) && intval( $_REQUEST['attachment_id'] ) && $_REQUEST['fetch'] ) {
$id = intval( $_REQUEST['attachment_id'] ); $id = intval( $_REQUEST['attachment_id'] );
$post = get_post( $id ); $post = get_post( $id );
@ -112,7 +112,7 @@ if ( $_REQUEST['short'] ) {
// Short form response - attachment ID only. // Short form response - attachment ID only.
echo $id; echo $id;
} else { } else {
// Long form response - big chunk of html. // Long form response - big chunk of HTML.
$type = $_REQUEST['type']; $type = $_REQUEST['type'];
/** /**

View File

@ -137,7 +137,7 @@ switch ( $action ) {
break; break;
} }
if ( $comment->comment_approved != '0' ) { // if not unapproved if ( $comment->comment_approved != '0' ) { // If not unapproved.
$message = ''; $message = '';
switch ( $comment->comment_approved ) { switch ( $comment->comment_approved ) {
case '1': case '1':
@ -355,6 +355,6 @@ switch ( $action ) {
default: default:
wp_die( __( 'Unknown action.' ) ); wp_die( __( 'Unknown action.' ) );
} // end switch } // End switch.
include( ABSPATH . 'wp-admin/admin-footer.php' ); include( ABSPATH . 'wp-admin/admin-footer.php' );

View File

@ -133,7 +133,7 @@ include( ABSPATH . 'wp-admin/admin-footer.php' );
return; return;
// These are strings returned by the API that we want to be translatable // These are strings returned by the API that we want to be translatable.
__( 'Project Leaders' ); __( 'Project Leaders' );
/* translators: %s: The current WordPress version number. */ /* translators: %s: The current WordPress version number. */
__( 'Core Contributors to WordPress %s' ); __( 'Core Contributors to WordPress %s' );

View File

@ -52,7 +52,7 @@ if ( $doaction ) {
wp_defer_comment_counting( true ); wp_defer_comment_counting( true );
foreach ( $comment_ids as $comment_id ) { // Check the permissions on each foreach ( $comment_ids as $comment_id ) { // Check the permissions on each.
if ( ! current_user_can( 'edit_comment', $comment_id ) ) { if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
continue; continue;
} }

View File

@ -6,7 +6,7 @@
* @subpackage Administration * @subpackage Administration
*/ */
// don't load directly // Don't load directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
die( '-1' ); die( '-1' );
} }
@ -95,7 +95,7 @@ if ( $thumbnail_support ) {
wp_enqueue_media( array( 'post' => $post_ID ) ); wp_enqueue_media( array( 'post' => $post_ID ) );
} }
// Add the local autosave notice HTML // Add the local autosave notice HTML.
add_action( 'admin_footer', '_local_storage_notice' ); add_action( 'admin_footer', '_local_storage_notice' );
/* /*
@ -242,7 +242,7 @@ $form_action = 'editpost';
$nonce_action = 'update-post_' . $post_ID; $nonce_action = 'update-post_' . $post_ID;
$form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />"; $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc_attr( $post_ID ) . "' />";
// Detect if there exists an autosave newer than the post and if that autosave is different than the post // Detect if there exists an autosave newer than the post and if that autosave is different than the post.
if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) { if ( $autosave && mysql2date( 'U', $autosave->post_modified_gmt, false ) > mysql2date( 'U', $post->post_modified_gmt, false ) ) {
foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) { foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) {
if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) {

View File

@ -8,7 +8,7 @@
* @subpackage Administration * @subpackage Administration
*/ */
// don't load directly // Don't load directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
die( '-1' ); die( '-1' );
} }
@ -148,10 +148,12 @@ $font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );
*/ */
$allowed_block_types = apply_filters( 'allowed_block_types', true, $post ); $allowed_block_types = apply_filters( 'allowed_block_types', true, $post );
// Get all available templates for the post/page attributes meta-box. /*
// The "Default template" array element should only be added if the array is * Get all available templates for the post/page attributes meta-box.
// not empty so we do not trigger the template select element without any options * The "Default template" array element should only be added if the array is
// besides the default value. * not empty so we do not trigger the template select element without any options
* besides the default value.
*/
$available_templates = wp_get_theme()->get_page_templates( get_post( $post->ID ) ); $available_templates = wp_get_theme()->get_page_templates( get_post( $post->ID ) );
$available_templates = ! empty( $available_templates ) ? array_merge( $available_templates = ! empty( $available_templates ) ? array_merge(
array( array(

View File

@ -6,7 +6,7 @@
* @subpackage Administration * @subpackage Administration
*/ */
// don't load directly // Don't load directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
die( '-1' ); die( '-1' );
} }

View File

@ -6,7 +6,7 @@
* @subpackage Administration * @subpackage Administration
*/ */
// don't load directly // Don't load directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
die( '-1' ); die( '-1' );
} }

View File

@ -6,12 +6,12 @@
* @subpackage Administration * @subpackage Administration
*/ */
// don't load directly // Don't load directly.
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
die( '-1' ); die( '-1' );
} }
// Back compat hooks // Back compat hooks.
if ( 'category' == $taxonomy ) { if ( 'category' == $taxonomy ) {
/** /**
* Fires before the Edit Category form. * Fires before the Edit Category form.
@ -191,7 +191,7 @@ if ( isset( $tag->name ) ) {
<p class="description"><?php _e( 'The description is not prominent by default; however, some themes may show it.' ); ?></p></td> <p class="description"><?php _e( 'The description is not prominent by default; however, some themes may show it.' ); ?></p></td>
</tr> </tr>
<?php <?php
// Back compat hooks // Back compat hooks.
if ( 'category' == $taxonomy ) { if ( 'category' == $taxonomy ) {
/** /**
* Fires after the Edit Category form fields are displayed. * Fires after the Edit Category form fields are displayed.
@ -238,7 +238,7 @@ if ( isset( $tag->name ) ) {
?> ?>
</table> </table>
<?php <?php
// Back compat hooks // Back compat hooks.
if ( 'category' == $taxonomy ) { if ( 'category' == $taxonomy ) {
/** This action is documented in wp-admin/edit-tags.php */ /** This action is documented in wp-admin/edit-tags.php */
do_action_deprecated( 'edit_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' ); do_action_deprecated( 'edit_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' );

View File

@ -204,7 +204,7 @@ switch ( $wp_list_table->current_action() ) {
$tags = (array) $_REQUEST['delete_tags']; $tags = (array) $_REQUEST['delete_tags'];
/** This action is documented in wp-admin/edit.php */ /** This action is documented in wp-admin/edit.php */
$location = apply_filters( "handle_bulk_actions-{$screen}", $location, $wp_list_table->current_action(), $tags ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores $location = apply_filters( "handle_bulk_actions-{$screen}", $location, $wp_list_table->current_action(), $tags ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
break; break;
} }

View File

@ -47,7 +47,7 @@ if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) {
$wp_list_table = _get_list_table( 'WP_Posts_List_Table' ); $wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
$pagenum = $wp_list_table->get_pagenum(); $pagenum = $wp_list_table->get_pagenum();
// Back-compat for viewing comments of an entry // Back-compat for viewing comments of an entry.
foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) { foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
if ( ! empty( $_REQUEST[ $_redirect ] ) ) { if ( ! empty( $_REQUEST[ $_redirect ] ) ) {
wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) ); wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) );

View File

@ -39,7 +39,7 @@ if ( current_user_can( 'install_plugins' ) ) {
$popular_importers = array(); $popular_importers = array();
} }
// Detect and redirect invalid importers like 'movabletype', which is registered as 'mt' // Detect and redirect invalid importers like 'movabletype', which is registered as 'mt'.
if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) { if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) {
$importer_id = $popular_importers[ $_GET['invalid'] ]['importer-id']; $importer_id = $popular_importers[ $_GET['invalid'] ]['importer-id'];
if ( $importer_id != $_GET['invalid'] ) { // Prevent redirect loops. if ( $importer_id != $_GET['invalid'] ) { // Prevent redirect loops.
@ -93,7 +93,7 @@ foreach ( $popular_importers as $pop_importer => $pop_data ) {
} }
if ( empty( $importers ) ) { if ( empty( $importers ) ) {
echo '<p>' . __( 'No importers are available.' ) . '</p>'; // TODO: make more helpful echo '<p>' . __( 'No importers are available.' ) . '</p>'; // TODO: Make more helpful.
} else { } else {
uasort( $importers, '_usort_by_first_member' ); uasort( $importers, '_usort_by_first_member' );
?> ?>

View File

@ -128,7 +128,7 @@ add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 );
add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 );
add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 );
// Privacy hooks // Privacy hooks.
add_filter( 'wp_privacy_personal_data_erasure_page', 'wp_privacy_process_personal_data_erasure_page', 10, 5 ); add_filter( 'wp_privacy_personal_data_erasure_page', 'wp_privacy_process_personal_data_erasure_page', 10, 5 );
add_filter( 'wp_privacy_personal_data_export_page', 'wp_privacy_process_personal_data_export_page', 10, 7 ); add_filter( 'wp_privacy_personal_data_export_page', 'wp_privacy_process_personal_data_export_page', 10, 7 );
add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 ); add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 );

View File

@ -74,7 +74,7 @@ require_once( ABSPATH . 'wp-admin/includes/theme.php' );
require_once( ABSPATH . 'wp-admin/includes/privacy-tools.php' ); require_once( ABSPATH . 'wp-admin/includes/privacy-tools.php' );
/** WordPress Privacy List Table classes. */ /** WordPress Privacy List Table classes. */
// Previously in wp-admin/includes/user.php. Need to be loaded for backwards compatibility. // Previously in wp-admin/includes/user.php. Need to be loaded for backward compatibility.
require_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-requests-table.php' ); require_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-requests-table.php' );
require_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php' ); require_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php' );
require_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php' ); require_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php' );

View File

@ -22,7 +22,7 @@
function wp_ajax_nopriv_heartbeat() { function wp_ajax_nopriv_heartbeat() {
$response = array(); $response = array();
// screen_id is the same as $current_screen->id and the JS global 'pagenow'. // 'screen_id' is the same as $current_screen->id and the JS global 'pagenow'.
if ( ! empty( $_POST['screen_id'] ) ) { if ( ! empty( $_POST['screen_id'] ) ) {
$screen_id = sanitize_key( $_POST['screen_id'] ); $screen_id = sanitize_key( $_POST['screen_id'] );
} else { } else {
@ -272,23 +272,23 @@ function wp_ajax_autocomplete_user() {
$return = array(); $return = array();
// Check the type of request // Check the type of request.
// Current allowed values are `add` and `search` // Current allowed values are `add` and `search`.
if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) { if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) {
$type = $_REQUEST['autocomplete_type']; $type = $_REQUEST['autocomplete_type'];
} else { } else {
$type = 'add'; $type = 'add';
} }
// Check the desired field for value // Check the desired field for value.
// Current allowed values are `user_email` and `user_login` // Current allowed values are `user_email` and `user_login`.
if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) { if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) {
$field = $_REQUEST['autocomplete_field']; $field = $_REQUEST['autocomplete_field'];
} else { } else {
$field = 'user_login'; $field = 'user_login';
} }
// Exclude current users of this blog // Exclude current users of this blog.
if ( isset( $_REQUEST['site_id'] ) ) { if ( isset( $_REQUEST['site_id'] ) ) {
$id = absint( $_REQUEST['site_id'] ); $id = absint( $_REQUEST['site_id'] );
} else { } else {
@ -433,7 +433,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
$page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0; $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0;
$url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : ''; $url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : '';
// JS didn't send us everything we need to know. Just die with success message // JS didn't send us everything we need to know. Just die with success message.
if ( ! $total || ! $per_page || ! $page || ! $url ) { if ( ! $total || ! $per_page || ! $page || ! $url ) {
$time = time(); $time = time();
$comment = get_comment( $comment_id ); $comment = get_comment( $comment_id );
@ -482,7 +482,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
$total = 0; $total = 0;
} }
// Only do the expensive stuff on a page-break, and about 1 other time per page // Only do the expensive stuff on a page-break, and about 1 other time per page.
if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) {
$post_id = 0; $post_id = 0;
// What type of comment count are we looking for? // What type of comment count are we looking for?
@ -600,7 +600,7 @@ function _wp_ajax_add_hierarchical_term() {
$checked_categories[] = $cat_id; $checked_categories[] = $cat_id;
if ( $parent ) { // Do these all at once in a second if ( $parent ) { // Do these all at once in a second.
continue; continue;
} }
@ -626,11 +626,11 @@ function _wp_ajax_add_hierarchical_term() {
); );
} }
if ( $parent ) { // Foncy - replace the parent and all its children if ( $parent ) { // Foncy - replace the parent and all its children.
$parent = get_term( $parent, $taxonomy->name ); $parent = get_term( $parent, $taxonomy->name );
$term_id = $parent->term_id; $term_id = $parent->term_id;
while ( $parent->parent ) { // get the top parent while ( $parent->parent ) { // Get the top parent.
$parent = get_term( $parent->parent, $taxonomy->name ); $parent = get_term( $parent->parent, $taxonomy->name );
if ( is_wp_error( $parent ) ) { if ( is_wp_error( $parent ) ) {
break; break;
@ -716,7 +716,8 @@ function wp_ajax_delete_comment() {
$r = wp_untrash_comment( $comment ); $r = wp_untrash_comment( $comment );
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) { // undo trash, not in trash // Undo trash, not in trash.
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'trash' ) {
$delta = 1; $delta = 1;
} }
} elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) { } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) {
@ -732,7 +733,8 @@ function wp_ajax_delete_comment() {
$r = wp_unspam_comment( $comment ); $r = wp_unspam_comment( $comment );
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) { // undo spam, not in spam // Undo spam, not in spam.
if ( ! isset( $_POST['comment_status'] ) || $_POST['comment_status'] != 'spam' ) {
$delta = 1; $delta = 1;
} }
} elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) { } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) {
@ -741,7 +743,8 @@ function wp_ajax_delete_comment() {
wp_die( -1 ); wp_die( -1 );
} }
if ( $r ) { // Decide if we need to send back '1' or a more complicated response including page links and comment counts if ( $r ) {
// Decide if we need to send back '1' or a more complicated response including page links and comment counts.
_wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); _wp_ajax_delete_comment_response( $comment->comment_ID, $delta );
} }
@ -989,7 +992,7 @@ function wp_ajax_dim_comment() {
$x->send(); $x->send();
} }
// Decide if we need to send back '1' or a more complicated response including page links and comment counts // Decide if we need to send back '1' or a more complicated response including page links and comment counts.
_wp_ajax_delete_comment_response( $comment->comment_ID ); _wp_ajax_delete_comment_response( $comment->comment_ID );
wp_die( 0 ); wp_die( 0 );
} }
@ -1161,7 +1164,7 @@ function wp_ajax_get_tagcloud() {
$tags[ $key ]->id = $tag->term_id; $tags[ $key ]->id = $tag->term_id;
} }
// We need raw tag names here, so don't filter the output // We need raw tag names here, so don't filter the output.
$return = wp_generate_tag_cloud( $return = wp_generate_tag_cloud(
$tags, $tags,
array( array(
@ -1288,8 +1291,8 @@ function wp_ajax_replyto_comment( $action ) {
} }
if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
kses_remove_filters(); // start with a clean slate kses_remove_filters(); // Start with a clean slate.
kses_init_filters(); // set up the filters kses_init_filters(); // Set up the filters.
remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); remove_filter( 'pre_comment_content', 'wp_filter_post_kses' );
add_filter( 'pre_comment_content', 'wp_filter_kses' ); add_filter( 'pre_comment_content', 'wp_filter_kses' );
} }
@ -1478,7 +1481,7 @@ function wp_ajax_add_menu_item() {
$_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) ); $_menu_items = array_map( 'wp_setup_nav_menu_item', array( $_object ) );
$_menu_item = reset( $_menu_items ); $_menu_item = reset( $_menu_items );
// Restore the missing menu item properties // Restore the missing menu item properties.
$menu_item_data['menu-item-description'] = $_menu_item->description; $menu_item_data['menu-item-description'] = $_menu_item->description;
} }
@ -1498,7 +1501,7 @@ function wp_ajax_add_menu_item() {
if ( ! empty( $menu_obj->ID ) ) { if ( ! empty( $menu_obj->ID ) ) {
$menu_obj = wp_setup_nav_menu_item( $menu_obj ); $menu_obj = wp_setup_nav_menu_item( $menu_obj );
$menu_obj->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title; $menu_obj->title = empty( $menu_obj->title ) ? __( 'Menu Item' ) : $menu_obj->title;
$menu_obj->label = $menu_obj->title; // don't show "(pending)" in ajax-added items $menu_obj->label = $menu_obj->title; // Don't show "(pending)" in ajax-added items.
$menu_items[] = $menu_obj; $menu_items[] = $menu_obj;
} }
} }
@ -1548,7 +1551,7 @@ function wp_ajax_add_meta() {
// If the post is an autodraft, save the post as a draft and then attempt to save the meta. // If the post is an autodraft, save the post as a draft and then attempt to save the meta.
if ( $post->post_status == 'auto-draft' ) { if ( $post->post_status == 'auto-draft' ) {
$post_data = array(); $post_data = array();
$post_data['action'] = 'draft'; // Warning fix $post_data['action'] = 'draft'; // Warning fix.
$post_data['post_ID'] = $pid; $post_data['post_ID'] = $pid;
$post_data['post_type'] = $post->post_type; $post_data['post_type'] = $post->post_type;
$post_data['post_status'] = 'draft'; $post_data['post_status'] = 'draft';
@ -1608,7 +1611,7 @@ function wp_ajax_add_meta() {
$meta = get_metadata_by_mid( 'post', $mid ); $meta = get_metadata_by_mid( 'post', $mid );
if ( ! $meta ) { if ( ! $meta ) {
wp_die( 0 ); // if meta doesn't exist wp_die( 0 ); // If meta doesn't exist.
} }
if ( if (
@ -1731,7 +1734,8 @@ function wp_ajax_closed_postboxes() {
} }
if ( is_array( $hidden ) ) { if ( is_array( $hidden ) ) {
$hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) ); // postboxes that are always shown // Postboxes that are always shown.
$hidden = array_diff( $hidden, array( 'submitdiv', 'linksubmitdiv', 'manage-menu', 'create-menu' ) );
update_user_option( $user->ID, "metaboxhidden_$page", $hidden, true ); update_user_option( $user->ID, "metaboxhidden_$page", $hidden, true );
} }
@ -2620,7 +2624,7 @@ function wp_ajax_image_editor() {
* @since 3.1.0 * @since 3.1.0
*/ */
function wp_ajax_set_post_thumbnail() { function wp_ajax_set_post_thumbnail() {
$json = ! empty( $_REQUEST['json'] ); // New-style request $json = ! empty( $_REQUEST['json'] ); // New-style request.
$post_ID = intval( $_POST['post_id'] ); $post_ID = intval( $_POST['post_id'] );
if ( ! current_user_can( 'edit_post', $post_ID ) ) { if ( ! current_user_can( 'edit_post', $post_ID ) ) {
@ -3226,7 +3230,7 @@ function wp_ajax_send_attachment_to_editor() {
$html = stripslashes_deep( $_POST['html'] ); $html = stripslashes_deep( $_POST['html'] );
} else { } else {
$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; $html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : '';
$rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized $rel = $rel ? ' rel="attachment wp-att-' . $id . '"' : ''; // Hard-coded string, $id is already sanitized.
if ( ! empty( $url ) ) { if ( ! empty( $url ) ) {
$html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>'; $html = '<a href="' . esc_url( $url ) . '"' . $rel . '>' . $html . '</a>';
@ -3287,7 +3291,7 @@ function wp_ajax_send_link_to_editor() {
$fallback = $wp_embed->maybe_make_link( $src ); $fallback = $wp_embed->maybe_make_link( $src );
if ( $check_embed !== $fallback ) { if ( $check_embed !== $fallback ) {
// TinyMCE view for [embed] will parse this // TinyMCE view for [embed] will parse this.
$html = '[embed]' . $src . '[/embed]'; $html = '[embed]' . $src . '[/embed]';
} elseif ( $link_text ) { } elseif ( $link_text ) {
$html = '<a href="' . esc_url( $src ) . '">' . $link_text . '</a>'; $html = '<a href="' . esc_url( $src ) . '">' . $link_text . '</a>';
@ -3327,7 +3331,7 @@ function wp_ajax_heartbeat() {
$data = array(); $data = array();
$nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' ); $nonce_state = wp_verify_nonce( $_POST['_nonce'], 'heartbeat-nonce' );
// screen_id is the same as $current_screen->id and the JS global 'pagenow'. // 'screen_id' is the same as $current_screen->id and the JS global 'pagenow'.
if ( ! empty( $_POST['screen_id'] ) ) { if ( ! empty( $_POST['screen_id'] ) ) {
$screen_id = sanitize_key( $_POST['screen_id'] ); $screen_id = sanitize_key( $_POST['screen_id'] );
} else { } else {
@ -3392,7 +3396,7 @@ function wp_ajax_heartbeat() {
*/ */
do_action( 'heartbeat_tick', $response, $screen_id ); do_action( 'heartbeat_tick', $response, $screen_id );
// Send the current time according to the server // Send the current time according to the server.
$response['server_time'] = time(); $response['server_time'] = time();
wp_send_json( $response ); wp_send_json( $response );
@ -3735,7 +3739,7 @@ function wp_ajax_parse_media_shortcode() {
$post = get_post( (int) $_POST['post_ID'] ); $post = get_post( (int) $_POST['post_ID'] );
} }
// the embed shortcode requires a post // The embed shortcode requires a post.
if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) { if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
if ( 'embed' === $shortcode ) { if ( 'embed' === $shortcode ) {
wp_send_json_error(); wp_send_json_error();

View File

@ -41,8 +41,10 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin {
if ( $context ) { if ( $context ) {
$this->options['context'] = $context; $this->options['context'] = $context;
} }
// TODO: fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version /*
// This will output a credentials form in event of failure, We don't want that, so just hide with a buffer * TODO: Fix up request_filesystem_credentials(), or split it, to allow us to request a no-output version.
* This will output a credentials form in event of failure. We don't want that, so just hide with a buffer.
*/
ob_start(); ob_start();
$result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership ); $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership );
ob_end_clean(); ob_end_clean();

View File

@ -115,7 +115,7 @@ class Core_Upgrader extends WP_Upgrader {
$to_download = 'full'; $to_download = 'full';
} }
// Lock to prevent multiple Core Updates occurring // Lock to prevent multiple Core Updates occurring.
$lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS ); $lock = WP_Upgrader::create_lock( 'core_updater', 15 * MINUTE_IN_SECONDS );
if ( ! $lock ) { if ( ! $lock ) {
return new WP_Error( 'locked', $this->strings['locked'] ); return new WP_Error( 'locked', $this->strings['locked'] );
@ -220,7 +220,7 @@ class Core_Upgrader extends WP_Upgrader {
) )
); );
// Clear the current updates // Clear the current updates.
delete_site_transient( 'update_core' ); delete_site_transient( 'update_core' );
if ( ! $parsed_args['do_rollback'] ) { if ( ! $parsed_args['do_rollback'] ) {
@ -272,8 +272,9 @@ class Core_Upgrader extends WP_Upgrader {
public static function should_update_to_version( $offered_ver ) { public static function should_update_to_version( $offered_ver ) {
include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z
$current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y $current_branch = implode( '.', array_slice( preg_split( '/[.-]/', $wp_version ), 0, 2 ) ); // x.y
$new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y $new_branch = implode( '.', array_slice( preg_split( '/[.-]/', $offered_ver ), 0, 2 ) ); // x.y
$current_is_development_version = (bool) strpos( $wp_version, '-' ); $current_is_development_version = (bool) strpos( $wp_version, '-' );
// Defaults: // Defaults:
@ -284,17 +285,17 @@ class Core_Upgrader extends WP_Upgrader {
// WP_AUTO_UPDATE_CORE = true (all), 'minor', false. // WP_AUTO_UPDATE_CORE = true (all), 'minor', false.
if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) {
if ( false === WP_AUTO_UPDATE_CORE ) { if ( false === WP_AUTO_UPDATE_CORE ) {
// Defaults to turned off, unless a filter allows it // Defaults to turned off, unless a filter allows it.
$upgrade_dev = false; $upgrade_dev = false;
$upgrade_minor = false; $upgrade_minor = false;
$upgrade_major = false; $upgrade_major = false;
} elseif ( true === WP_AUTO_UPDATE_CORE ) { } elseif ( true === WP_AUTO_UPDATE_CORE ) {
// ALL updates for core // ALL updates for core.
$upgrade_dev = true; $upgrade_dev = true;
$upgrade_minor = true; $upgrade_minor = true;
$upgrade_major = true; $upgrade_major = true;
} elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) {
// Only minor updates for core // Only minor updates for core.
$upgrade_dev = false; $upgrade_dev = false;
$upgrade_minor = true; $upgrade_minor = true;
$upgrade_major = false; $upgrade_major = false;
@ -306,7 +307,7 @@ class Core_Upgrader extends WP_Upgrader {
return false; return false;
} }
// 2: If we're running a newer version, that's a nope // 2: If we're running a newer version, that's a nope.
if ( version_compare( $wp_version, $offered_ver, '>' ) ) { if ( version_compare( $wp_version, $offered_ver, '>' ) ) {
return false; return false;
} }
@ -323,15 +324,17 @@ class Core_Upgrader extends WP_Upgrader {
return false; return false;
} }
// Cannot update if we're retrying the same A to B update that caused a non-critical failure. /*
// Some non-critical failures do allow retries, like download_failed. * Cannot update if we're retrying the same A to B update that caused a non-critical failure.
// 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2. * Some non-critical failures do allow retries, like download_failed.
* 3.7.1 => 3.7.2 resulted in files_not_writable, if we are still on 3.7.1 and still trying to update to 3.7.2.
*/
if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) { if ( empty( $failure_data['retry'] ) && $wp_version == $failure_data['current'] && $offered_ver == $failure_data['attempted'] ) {
return false; return false;
} }
} }
// 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2 // 3: 3.7-alpha-25000 -> 3.7-alpha-25678 -> 3.7-beta1 -> 3.7-beta2.
if ( $current_is_development_version ) { if ( $current_is_development_version ) {
/** /**
@ -348,7 +351,7 @@ class Core_Upgrader extends WP_Upgrader {
// Else fall through to minor + major branches below. // Else fall through to minor + major branches below.
} }
// 4: Minor In-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4) // 4: Minor in-branch updates (3.7.0 -> 3.7.1 -> 3.7.2 -> 3.7.4).
if ( $current_branch == $new_branch ) { if ( $current_branch == $new_branch ) {
/** /**
@ -361,7 +364,7 @@ class Core_Upgrader extends WP_Upgrader {
return apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor ); return apply_filters( 'allow_minor_auto_core_updates', $upgrade_minor );
} }
// 5: Major version updates (3.7.0 -> 3.8.0 -> 3.9.1) // 5: Major version updates (3.7.0 -> 3.8.0 -> 3.9.1).
if ( version_compare( $new_branch, $current_branch, '>' ) ) { if ( version_compare( $new_branch, $current_branch, '>' ) ) {
/** /**
@ -374,7 +377,7 @@ class Core_Upgrader extends WP_Upgrader {
return apply_filters( 'allow_major_auto_core_updates', $upgrade_major ); return apply_filters( 'allow_major_auto_core_updates', $upgrade_major );
} }
// If we're not sure, we don't want it // If we're not sure, we don't want it.
return false; return false;
} }
@ -398,7 +401,7 @@ class Core_Upgrader extends WP_Upgrader {
} }
foreach ( $checksums as $file => $checksum ) { foreach ( $checksums as $file => $checksum ) {
// Skip files which get updated // Skip files which get updated.
if ( 'wp-content' == substr( $file, 0, 10 ) ) { if ( 'wp-content' == substr( $file, 0, 10 ) ) {
continue; continue;
} }

View File

@ -124,7 +124,7 @@ class Custom_Background {
} }
if ( isset( $_POST['remove-background'] ) ) { if ( isset( $_POST['remove-background'] ) ) {
// @TODO: Uploaded files are not removed here. // @todo Uploaded files are not removed here.
check_admin_referer( 'custom-background-remove', '_wpnonce-custom-background-remove' ); check_admin_referer( 'custom-background-remove', '_wpnonce-custom-background-remove' );
set_theme_mod( 'background_image', '' ); set_theme_mod( 'background_image', '' );
set_theme_mod( 'background_image_thumb', '' ); set_theme_mod( 'background_image_thumb', '' );
@ -284,7 +284,7 @@ class Custom_Background {
. " background-attachment: $background_attachment;"; . " background-attachment: $background_attachment;";
} }
?> ?>
<div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // must be double quote, see above ?> <div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // Must be double quote, see above. ?>
<?php if ( $background_image_thumb ) { ?> <?php if ( $background_image_thumb ) { ?>
<img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /><br /> <img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /><br />
<img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /> <img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" />
@ -503,7 +503,7 @@ class Custom_Background {
$file = $file['file']; $file = $file['file'];
$filename = wp_basename( $file ); $filename = wp_basename( $file );
// Construct the object array // Construct the object array.
$object = array( $object = array(
'post_title' => $filename, 'post_title' => $filename,
'post_content' => $url, 'post_content' => $url,
@ -512,10 +512,10 @@ class Custom_Background {
'context' => 'custom-background', 'context' => 'custom-background',
); );
// Save the data // Save the data.
$id = wp_insert_attachment( $object, $file ); $id = wp_insert_attachment( $object, $file );
// Add the meta-data // Add the metadata.
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) );
update_post_meta( $id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) ); update_post_meta( $id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) );
@ -525,7 +525,7 @@ class Custom_Background {
set_theme_mod( 'background_image_thumb', esc_url_raw( $thumbnail[0] ) ); set_theme_mod( 'background_image_thumb', esc_url_raw( $thumbnail[0] ) );
/** This action is documented in wp-admin/includes/class-custom-image-header.php */ /** This action is documented in wp-admin/includes/class-custom-image-header.php */
do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication.
$this->updated = true; $this->updated = true;
} }

View File

@ -800,7 +800,7 @@ endif;
} }
$max_width = 0; $max_width = 0;
// For flex, limit size of image displayed to 1500px unless theme says otherwise // For flex, limit size of image displayed to 1500px unless theme says otherwise.
if ( current_theme_supports( 'custom-header', 'flex-width' ) ) { if ( current_theme_supports( 'custom-header', 'flex-width' ) ) {
$max_width = 1500; $max_width = 1500;
} }
@ -810,10 +810,10 @@ endif;
} }
$max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) ); $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) );
// If flexible height isn't supported and the image is the exact right size // If flexible height isn't supported and the image is the exact right size.
if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' ) if ( ! current_theme_supports( 'custom-header', 'flex-height' ) && ! current_theme_supports( 'custom-header', 'flex-width' )
&& $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) { && $width == get_theme_support( 'custom-header', 'width' ) && $height == get_theme_support( 'custom-header', 'height' ) ) {
// Add the meta-data // Add the metadata.
if ( file_exists( $file ) ) { if ( file_exists( $file ) ) {
wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) );
} }
@ -828,7 +828,7 @@ endif;
* @param string $file Path to the file. * @param string $file Path to the file.
* @param int $attachment_id Attachment ID. * @param int $attachment_id Attachment ID.
*/ */
do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication.
return $this->finished(); return $this->finished();
} elseif ( $width > $max_width ) { } elseif ( $width > $max_width ) {
@ -839,7 +839,7 @@ endif;
} }
/** This filter is documented in wp-admin/includes/class-custom-image-header.php */ /** This filter is documented in wp-admin/includes/class-custom-image-header.php */
$image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication.
$url = str_replace( wp_basename( $url ), wp_basename( $image ), $url ); $url = str_replace( wp_basename( $url ), wp_basename( $image ), $url );
$width = $width / $oitar; $width = $width / $oitar;
@ -910,7 +910,7 @@ endif;
$file = $file['file']; $file = $file['file'];
$filename = wp_basename( $file ); $filename = wp_basename( $file );
// Construct the object array // Construct the object array.
$object = array( $object = array(
'post_title' => $filename, 'post_title' => $filename,
'post_content' => $url, 'post_content' => $url,
@ -919,7 +919,7 @@ endif;
'context' => 'custom-header', 'context' => 'custom-header',
); );
// Save the data // Save the data.
$attachment_id = wp_insert_attachment( $object, $file ); $attachment_id = wp_insert_attachment( $object, $file );
return compact( 'attachment_id', 'file', 'filename', 'url', 'type' ); return compact( 'attachment_id', 'file', 'filename', 'url', 'type' );
} }
@ -982,7 +982,7 @@ endif;
} }
/** This filter is documented in wp-admin/includes/class-custom-image-header.php */ /** This filter is documented in wp-admin/includes/class-custom-image-header.php */
$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
$object = $this->create_attachment_object( $cropped, $attachment_id ); $object = $this->create_attachment_object( $cropped, $attachment_id );
@ -990,7 +990,7 @@ endif;
unset( $object['ID'] ); unset( $object['ID'] );
} }
// Update the attachment // Update the attachment.
$attachment_id = $this->insert_attachment( $object, $cropped ); $attachment_id = $this->insert_attachment( $object, $cropped );
$url = wp_get_attachment_url( $attachment_id ); $url = wp_get_attachment_url( $attachment_id );
@ -1180,7 +1180,7 @@ endif;
'dst_width' => null, 'dst_width' => null,
); );
// For flex, limit size of image displayed to 1500px unless theme says otherwise // For flex, limit size of image displayed to 1500px unless theme says otherwise.
if ( $has_flex_width ) { if ( $has_flex_width ) {
$max_width = 1500; $max_width = 1500;
} }
@ -1318,7 +1318,7 @@ endif;
} }
/** This filter is documented in wp-admin/includes/class-custom-image-header.php */ /** This filter is documented in wp-admin/includes/class-custom-image-header.php */
$cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication.
$object = $this->create_attachment_object( $cropped, $attachment_id ); $object = $this->create_attachment_object( $cropped, $attachment_id );
@ -1434,8 +1434,8 @@ endif;
// Get the default image if there is one. // Get the default image if there is one.
$default = get_theme_support( 'custom-header', 'default-image' ); $default = get_theme_support( 'custom-header', 'default-image' );
if ( ! $default ) { // If not, if ( ! $default ) { // If not, easy peasy.
return $this->default_headers; // easy peasy. return $this->default_headers;
} }
$default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() );

View File

@ -56,7 +56,7 @@ class File_Upload_Upgrader {
wp_die( __( 'Please select a file' ) ); wp_die( __( 'Please select a file' ) );
} }
//Handle a newly uploaded file, Else assume it's already been uploaded // Handle a newly uploaded file. Else, assume it's already been uploaded.
if ( ! empty( $_FILES ) ) { if ( ! empty( $_FILES ) ) {
$overrides = array( $overrides = array(
'test_form' => false, 'test_form' => false,
@ -71,7 +71,7 @@ class File_Upload_Upgrader {
$this->filename = $_FILES[ $form ]['name']; $this->filename = $_FILES[ $form ]['name'];
$this->package = $file['file']; $this->package = $file['file'];
// Construct the object array // Construct the object array.
$object = array( $object = array(
'post_title' => $this->filename, 'post_title' => $this->filename,
'post_content' => $file['url'], 'post_content' => $file['url'],

View File

@ -192,7 +192,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$this->skin->feedback( 'starting_upgrade' ); $this->skin->feedback( 'starting_upgrade' );
} }
// Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230 // Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230.
remove_all_filters( 'upgrader_pre_install' ); remove_all_filters( 'upgrader_pre_install' );
remove_all_filters( 'upgrader_clear_destination' ); remove_all_filters( 'upgrader_clear_destination' );
remove_all_filters( 'upgrader_post_install' ); remove_all_filters( 'upgrader_post_install' );
@ -202,7 +202,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
$this->skin->header(); $this->skin->header();
// Connect to the Filesystem first. // Connect to the filesystem first.
$res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) ); $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
if ( ! $res ) { if ( ! $res ) {
$this->skin->footer(); $this->skin->footer();
@ -369,7 +369,7 @@ class Language_Pack_Upgrader extends WP_Upgrader {
public function get_name_for_update( $update ) { public function get_name_for_update( $update ) {
switch ( $update->type ) { switch ( $update->type ) {
case 'core': case 'core':
return 'WordPress'; // Not translated return 'WordPress'; // Not translated.
case 'theme': case 'theme':
$theme = wp_get_theme( $update->slug ); $theme = wp_get_theme( $update->slug );

View File

@ -123,7 +123,7 @@ class Plugin_Upgrader extends WP_Upgrader {
return $this->result; return $this->result;
} }
// Force refresh of plugin update information // Force refresh of plugin update information.
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
return true; return true;
@ -163,12 +163,13 @@ class Plugin_Upgrader extends WP_Upgrader {
return false; return false;
} }
// Get the URL to the zip file // Get the URL to the zip file.
$r = $current->response[ $plugin ]; $r = $current->response[ $plugin ];
add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 ); add_filter( 'upgrader_pre_install', array( $this, 'deactivate_plugin_before_upgrade' ), 10, 2 );
add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 ); add_filter( 'upgrader_clear_destination', array( $this, 'delete_old_plugin' ), 10, 4 );
//'source_selection' => array($this, 'source_selection'), //there's a trac ticket to move up the directory for zip's which are made a bit differently, useful for non-.org plugins. // 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'] ) { if ( $parsed_args['clear_update_cache'] ) {
// Clear cache so wp_update_plugins() knows about the new plugin. // Clear cache so wp_update_plugins() knows about the new plugin.
add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 );
@ -197,7 +198,7 @@ class Plugin_Upgrader extends WP_Upgrader {
return $this->result; return $this->result;
} }
// Force refresh of plugin update information // Force refresh of plugin update information.
wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); wp_clean_plugins_cache( $parsed_args['clear_update_cache'] );
return true; return true;
@ -234,7 +235,7 @@ class Plugin_Upgrader extends WP_Upgrader {
$this->skin->header(); $this->skin->header();
// Connect to the Filesystem first. // Connect to the filesystem first.
$res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) );
if ( ! $res ) { if ( ! $res ) {
$this->skin->footer(); $this->skin->footer();
@ -247,7 +248,7 @@ class Plugin_Upgrader extends WP_Upgrader {
* Only start maintenance mode if: * Only start maintenance mode if:
* - running Multisite and there are one or more plugins specified, OR * - running Multisite and there are one or more plugins specified, OR
* - a plugin with an update available is currently active. * - a plugin with an update available is currently active.
* @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. * @todo For multisite, maintenance mode should only kick in for individual sites if at all possible.
*/ */
$maintenance = ( is_multisite() && ! empty( $plugins ) ); $maintenance = ( is_multisite() && ! empty( $plugins ) );
foreach ( $plugins as $plugin ) { foreach ( $plugins as $plugin ) {
@ -294,11 +295,11 @@ class Plugin_Upgrader extends WP_Upgrader {
$results[ $plugin ] = $this->result; $results[ $plugin ] = $this->result;
// Prevent credentials auth screen from displaying multiple times // Prevent credentials auth screen from displaying multiple times.
if ( false === $result ) { if ( false === $result ) {
break; break;
} }
} //end foreach $plugins } // End foreach $plugins.
$this->maintenance_mode( false ); $this->maintenance_mode( false );
@ -353,7 +354,7 @@ class Plugin_Upgrader extends WP_Upgrader {
return $source; return $source;
} }
// Check the folder contains at least 1 valid plugin. // Check that the folder contains at least 1 valid plugin.
$plugins_found = false; $plugins_found = false;
$files = glob( $working_directory . '*.php' ); $files = glob( $working_directory . '*.php' );
if ( $files ) { if ( $files ) {
@ -390,12 +391,14 @@ class Plugin_Upgrader extends WP_Upgrader {
return false; return false;
} }
$plugin = get_plugins( '/' . $this->result['destination_name'] ); //Ensure to pass with leading slash // Ensure to pass with leading slash.
$plugin = get_plugins( '/' . $this->result['destination_name'] );
if ( empty( $plugin ) ) { if ( empty( $plugin ) ) {
return false; return false;
} }
$pluginfiles = array_keys( $plugin ); //Assume the requested plugin is the first in the list // Assume the requested plugin is the first in the list.
$pluginfiles = array_keys( $plugin );
return $this->result['destination_name'] . '/' . $pluginfiles[0]; return $this->result['destination_name'] . '/' . $pluginfiles[0];
} }
@ -414,11 +417,11 @@ class Plugin_Upgrader extends WP_Upgrader {
*/ */
public function deactivate_plugin_before_upgrade( $return, $plugin ) { public function deactivate_plugin_before_upgrade( $return, $plugin ) {
if ( is_wp_error( $return ) ) { //Bypass. if ( is_wp_error( $return ) ) { // Bypass.
return $return; return $return;
} }
// When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it // When in cron (background updates) don't deactivate the plugin, as we require a browser to reactivate it.
if ( wp_doing_cron() ) { if ( wp_doing_cron() ) {
return $return; return $return;
} }
@ -429,7 +432,7 @@ class Plugin_Upgrader extends WP_Upgrader {
} }
if ( is_plugin_active( $plugin ) ) { if ( is_plugin_active( $plugin ) ) {
//Deactivate the plugin silently, Prevent deactivation hooks from running. // Deactivate the plugin silently, Prevent deactivation hooks from running.
deactivate_plugins( $plugin, true ); deactivate_plugins( $plugin, true );
} }
@ -456,7 +459,7 @@ class Plugin_Upgrader extends WP_Upgrader {
global $wp_filesystem; global $wp_filesystem;
if ( is_wp_error( $removed ) ) { if ( is_wp_error( $removed ) ) {
return $removed; //Pass errors through. return $removed; // Pass errors through.
} }
$plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : '';
@ -467,12 +470,13 @@ class Plugin_Upgrader extends WP_Upgrader {
$plugins_dir = $wp_filesystem->wp_plugins_dir(); $plugins_dir = $wp_filesystem->wp_plugins_dir();
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) ); $this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin ) );
if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { //If it's already vanished. if ( ! $wp_filesystem->exists( $this_plugin_dir ) ) { // If it's already vanished.
return $removed; return $removed;
} }
// If plugin is in its own directory, recursively delete the directory. // If plugin is in its own directory, recursively delete the directory.
if ( strpos( $plugin, '/' ) && $this_plugin_dir != $plugins_dir ) { //base check on if plugin includes directory separator AND that it's not the root plugin folder // 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 ); $deleted = $wp_filesystem->delete( $this_plugin_dir, true );
} else { } else {
$deleted = $wp_filesystem->delete( $plugins_dir . $plugin ); $deleted = $wp_filesystem->delete( $plugins_dir . $plugin );

View File

@ -94,7 +94,7 @@ class Theme_Upgrader extends WP_Upgrader {
* @return bool * @return bool
*/ */
public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) { public function check_parent_theme_filter( $install_result, $hook_extra, $child_result ) {
// Check to see if we need to install a parent theme // Check to see if we need to install a parent theme.
$theme_info = $this->theme_info(); $theme_info = $this->theme_info();
if ( ! $theme_info->parent() ) { if ( ! $theme_info->parent() ) {
@ -119,11 +119,11 @@ class Theme_Upgrader extends WP_Upgrader {
'tags' => false, 'tags' => false,
), ),
) )
); //Save on a bit of bandwidth. ); // Save on a bit of bandwidth.
if ( ! $api || is_wp_error( $api ) ) { if ( ! $api || is_wp_error( $api ) ) {
$this->skin->feedback( 'parent_theme_not_found', $theme_info->get( 'Template' ) ); $this->skin->feedback( 'parent_theme_not_found', $theme_info->get( 'Template' ) );
// Don't show activate or preview actions after installation // Don't show activate or preview actions after installation.
add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) ); add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) );
return $install_result; return $install_result;
} }
@ -132,20 +132,21 @@ class Theme_Upgrader extends WP_Upgrader {
$child_api = $this->skin->api; $child_api = $this->skin->api;
$child_success_message = $this->strings['process_success']; $child_success_message = $this->strings['process_success'];
// Override them // Override them.
$this->skin->api = $api; $this->skin->api = $api;
$this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];//, $api->name, $api->version);
$this->strings['process_success_specific'] = $this->strings['parent_theme_install_success']; //, $api->name, $api->version );
$this->skin->feedback( 'parent_theme_prepare_install', $api->name, $api->version ); $this->skin->feedback( 'parent_theme_prepare_install', $api->name, $api->version );
add_filter( 'install_theme_complete_actions', '__return_false', 999 ); // Don't show any actions after installing the theme. add_filter( 'install_theme_complete_actions', '__return_false', 999 ); // Don't show any actions after installing the theme.
// Install the parent theme // Install the parent theme.
$parent_result = $this->run( $parent_result = $this->run(
array( array(
'package' => $api->download_link, 'package' => $api->download_link,
'destination' => get_theme_root(), 'destination' => get_theme_root(),
'clear_destination' => false, //Do not overwrite files. 'clear_destination' => false, // Do not overwrite files.
'clear_working' => true, 'clear_working' => true,
) )
); );
@ -154,10 +155,10 @@ class Theme_Upgrader extends WP_Upgrader {
add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) ); add_filter( 'install_theme_complete_actions', array( $this, 'hide_activate_preview_actions' ) );
} }
// Start cleaning up after the parents installation // Start cleaning up after the parent's installation.
remove_filter( 'install_theme_complete_actions', '__return_false', 999 ); remove_filter( 'install_theme_complete_actions', '__return_false', 999 );
// Reset child's result and data // Reset child's result and data.
$this->result = $child_result; $this->result = $child_result;
$this->skin->api = $child_api; $this->skin->api = $child_api;
$this->strings['process_success'] = $child_success_message; $this->strings['process_success'] = $child_success_message;
@ -219,7 +220,7 @@ class Theme_Upgrader extends WP_Upgrader {
array( array(
'package' => $package, 'package' => $package,
'destination' => get_theme_root(), 'destination' => get_theme_root(),
'clear_destination' => false, //Do not overwrite files. 'clear_destination' => false, // Do not overwrite files.
'clear_working' => true, 'clear_working' => true,
'hook_extra' => array( 'hook_extra' => array(
'type' => 'theme', 'type' => 'theme',
@ -236,7 +237,7 @@ class Theme_Upgrader extends WP_Upgrader {
return $this->result; return $this->result;
} }
// Refresh the Theme Update information // Refresh the Theme Update information.
wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
return true; return true;
@ -349,7 +350,7 @@ class Theme_Upgrader extends WP_Upgrader {
$this->skin->header(); $this->skin->header();
// Connect to the Filesystem first. // Connect to the filesystem first.
$res = $this->fs_connect( array( WP_CONTENT_DIR ) ); $res = $this->fs_connect( array( WP_CONTENT_DIR ) );
if ( ! $res ) { if ( ! $res ) {
$this->skin->footer(); $this->skin->footer();
@ -358,10 +359,12 @@ class Theme_Upgrader extends WP_Upgrader {
$this->skin->bulk_header(); $this->skin->bulk_header();
// Only start maintenance mode if: /*
// - running Multisite and there are one or more themes specified, OR * Only start maintenance mode if:
// - a theme with an update available is currently in use. * - running Multisite and there are one or more themes specified, OR
// @TODO: For multisite, maintenance mode should only kick in for individual sites if at all possible. * - a theme with an update available is currently in use.
* @todo For multisite, maintenance mode should only kick in for individual sites if at all possible.
*/
$maintenance = ( is_multisite() && ! empty( $themes ) ); $maintenance = ( is_multisite() && ! empty( $themes ) );
foreach ( $themes as $theme ) { foreach ( $themes as $theme ) {
$maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template(); $maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template();
@ -388,7 +391,7 @@ class Theme_Upgrader extends WP_Upgrader {
continue; continue;
} }
// Get the URL to the zip file // Get the URL to the zip file.
$r = $current->response[ $theme ]; $r = $current->response[ $theme ];
$result = $this->run( $result = $this->run(
@ -406,15 +409,15 @@ class Theme_Upgrader extends WP_Upgrader {
$results[ $theme ] = $this->result; $results[ $theme ] = $this->result;
// Prevent credentials auth screen from displaying multiple times // Prevent credentials auth screen from displaying multiple times.
if ( false === $result ) { if ( false === $result ) {
break; break;
} }
} //end foreach $plugins } // End foreach $themes.
$this->maintenance_mode( false ); $this->maintenance_mode( false );
// Refresh the Theme Update information // Refresh the Theme Update information.
wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); wp_clean_themes_cache( $parsed_args['clear_update_cache'] );
/** This action is documented in wp-admin/includes/class-wp-upgrader.php */ /** This action is documented in wp-admin/includes/class-wp-upgrader.php */
@ -462,13 +465,13 @@ class Theme_Upgrader extends WP_Upgrader {
return $source; return $source;
} }
// Check the folder contains a valid theme // Check that the folder contains a valid theme.
$working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source ); $working_directory = str_replace( $wp_filesystem->wp_content_dir(), trailingslashit( WP_CONTENT_DIR ), $source );
if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation. if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation.
return $source; return $source;
} }
// A proper archive should have a style.css file in the single subdirectory // A proper archive should have a style.css file in the single subdirectory.
if ( ! file_exists( $working_directory . 'style.css' ) ) { if ( ! file_exists( $working_directory . 'style.css' ) ) {
return new WP_Error( return new WP_Error(
'incompatible_archive_theme_no_style', 'incompatible_archive_theme_no_style',
@ -536,10 +539,11 @@ class Theme_Upgrader extends WP_Upgrader {
$theme = isset( $theme['theme'] ) ? $theme['theme'] : ''; $theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
if ( $theme != get_stylesheet() ) { //If not current if ( $theme != get_stylesheet() ) { // If not current.
return $return; return $return;
} }
//Change to maintenance mode now.
// Change to maintenance mode now.
if ( ! $this->bulk ) { if ( ! $this->bulk ) {
$this->maintenance_mode( true ); $this->maintenance_mode( true );
} }
@ -566,7 +570,7 @@ class Theme_Upgrader extends WP_Upgrader {
$theme = isset( $theme['theme'] ) ? $theme['theme'] : ''; $theme = isset( $theme['theme'] ) ? $theme['theme'] : '';
if ( $theme != get_stylesheet() ) { // If not current if ( $theme != get_stylesheet() ) { // If not current.
return $return; return $return;
} }
@ -577,7 +581,7 @@ class Theme_Upgrader extends WP_Upgrader {
switch_theme( $stylesheet ); switch_theme( $stylesheet );
} }
//Time to remove maintenance mode // Time to remove maintenance mode.
if ( ! $this->bulk ) { if ( ! $this->bulk ) {
$this->maintenance_mode( false ); $this->maintenance_mode( false );
} }

View File

@ -21,7 +21,7 @@ class Walker_Category_Checklist extends Walker {
public $db_fields = array( public $db_fields = array(
'parent' => 'parent', 'parent' => 'parent',
'id' => 'term_id', 'id' => 'term_id',
); //TODO: decouple this ); // TODO: Decouple this.
/** /**
* Starts the list before the elements are added. * Starts the list before the elements are added.

View File

@ -106,7 +106,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
$output .= '</label>'; $output .= '</label>';
// Menu item hidden fields // Menu item hidden fields.
$output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />'; $output .= '<input type="hidden" class="menu-item-db-id" name="menu-item[' . $possible_object_id . '][menu-item-db-id]" value="' . $possible_db_id . '" />';
$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $item->object ) . '" />'; $output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="' . esc_attr( $item->object ) . '" />';
$output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="' . esc_attr( $item->menu_item_parent ) . '" />'; $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="' . esc_attr( $item->menu_item_parent ) . '" />';
@ -119,4 +119,4 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
$output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $item->xfn ) . '" />'; $output .= '<input type="hidden" class="menu-item-xfn" name="menu-item[' . $possible_object_id . '][menu-item-xfn]" value="' . esc_attr( $item->xfn ) . '" />';
} }
} // Walker_Nav_Menu_Checklist }

View File

@ -295,4 +295,4 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
$output .= ob_get_clean(); $output .= ob_get_clean();
} }
} // Walker_Nav_Menu_Edit }

View File

@ -141,7 +141,7 @@ class WP_Automatic_Updater {
return false; return false;
} }
// Only relax the filesystem checks when the update doesn't include new files // Only relax the filesystem checks when the update doesn't include new files.
$allow_relaxed_file_ownership = false; $allow_relaxed_file_ownership = false;
if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) { if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) {
$allow_relaxed_file_ownership = true; $allow_relaxed_file_ownership = true;
@ -283,7 +283,7 @@ class WP_Automatic_Updater {
break; break;
case 'plugin': case 'plugin':
$upgrader = new Plugin_Upgrader( $skin ); $upgrader = new Plugin_Upgrader( $skin );
$context = WP_PLUGIN_DIR; // We don't support custom Plugin directories, or updates for WPMU_PLUGIN_DIR $context = WP_PLUGIN_DIR; // We don't support custom Plugin directories, or updates for WPMU_PLUGIN_DIR.
break; break;
case 'theme': case 'theme':
$upgrader = new Theme_Upgrader( $skin ); $upgrader = new Theme_Upgrader( $skin );
@ -357,7 +357,7 @@ class WP_Automatic_Updater {
'pre_check_md5' => false, 'pre_check_md5' => false,
// Only available for core updates. // Only available for core updates.
'attempt_rollback' => true, 'attempt_rollback' => true,
// Allow relaxed file ownership in some scenarios // Allow relaxed file ownership in some scenarios.
'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership, 'allow_relaxed_file_ownership' => $allow_relaxed_file_ownership,
) )
); );
@ -409,51 +409,51 @@ class WP_Automatic_Updater {
return; return;
} }
// Don't automatically run these thins, as we'll handle it ourselves // Don't automatically run these things, as we'll handle it ourselves.
remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
remove_action( 'upgrader_process_complete', 'wp_version_check' ); remove_action( 'upgrader_process_complete', 'wp_version_check' );
remove_action( 'upgrader_process_complete', 'wp_update_plugins' ); remove_action( 'upgrader_process_complete', 'wp_update_plugins' );
remove_action( 'upgrader_process_complete', 'wp_update_themes' ); remove_action( 'upgrader_process_complete', 'wp_update_themes' );
// Next, Plugins // Next, plugins.
wp_update_plugins(); // Check for Plugin updates wp_update_plugins(); // Check for plugin updates.
$plugin_updates = get_site_transient( 'update_plugins' ); $plugin_updates = get_site_transient( 'update_plugins' );
if ( $plugin_updates && ! empty( $plugin_updates->response ) ) { if ( $plugin_updates && ! empty( $plugin_updates->response ) ) {
foreach ( $plugin_updates->response as $plugin ) { foreach ( $plugin_updates->response as $plugin ) {
$this->update( 'plugin', $plugin ); $this->update( 'plugin', $plugin );
} }
// Force refresh of plugin update information // Force refresh of plugin update information.
wp_clean_plugins_cache(); wp_clean_plugins_cache();
} }
// Next, those themes we all love // Next, those themes we all love.
wp_update_themes(); // Check for Theme updates wp_update_themes(); // Check for theme updates.
$theme_updates = get_site_transient( 'update_themes' ); $theme_updates = get_site_transient( 'update_themes' );
if ( $theme_updates && ! empty( $theme_updates->response ) ) { if ( $theme_updates && ! empty( $theme_updates->response ) ) {
foreach ( $theme_updates->response as $theme ) { foreach ( $theme_updates->response as $theme ) {
$this->update( 'theme', (object) $theme ); $this->update( 'theme', (object) $theme );
} }
// Force refresh of theme update information // Force refresh of theme update information.
wp_clean_themes_cache(); wp_clean_themes_cache();
} }
// Next, Process any core update // Next, process any core update.
wp_version_check(); // Check for Core updates wp_version_check(); // Check for core updates.
$core_update = find_core_auto_update(); $core_update = find_core_auto_update();
if ( $core_update ) { if ( $core_update ) {
$this->update( 'core', $core_update ); $this->update( 'core', $core_update );
} }
// Clean up, and check for any pending translations // Clean up, and check for any pending translations.
// (Core_Upgrader checks for core updates) // (Core_Upgrader checks for core updates.)
$theme_stats = array(); $theme_stats = array();
if ( isset( $this->update_results['theme'] ) ) { if ( isset( $this->update_results['theme'] ) ) {
foreach ( $this->update_results['theme'] as $upgrade ) { foreach ( $this->update_results['theme'] as $upgrade ) {
$theme_stats[ $upgrade->item->theme ] = ( true === $upgrade->result ); $theme_stats[ $upgrade->item->theme ] = ( true === $upgrade->result );
} }
} }
wp_update_themes( $theme_stats ); // Check for Theme updates wp_update_themes( $theme_stats ); // Check for theme updates.
$plugin_stats = array(); $plugin_stats = array();
if ( isset( $this->update_results['plugin'] ) ) { if ( isset( $this->update_results['plugin'] ) ) {
@ -461,21 +461,21 @@ class WP_Automatic_Updater {
$plugin_stats[ $upgrade->item->plugin ] = ( true === $upgrade->result ); $plugin_stats[ $upgrade->item->plugin ] = ( true === $upgrade->result );
} }
} }
wp_update_plugins( $plugin_stats ); // Check for Plugin updates wp_update_plugins( $plugin_stats ); // Check for plugin updates.
// Finally, Process any new translations // Finally, process any new translations.
$language_updates = wp_get_translation_updates(); $language_updates = wp_get_translation_updates();
if ( $language_updates ) { if ( $language_updates ) {
foreach ( $language_updates as $update ) { foreach ( $language_updates as $update ) {
$this->update( 'translation', $update ); $this->update( 'translation', $update );
} }
// Clear existing caches // Clear existing caches.
wp_clean_update_cache(); wp_clean_update_cache();
wp_version_check(); // check for Core updates wp_version_check(); // Check for core updates.
wp_update_themes(); // Check for Theme updates wp_update_themes(); // Check for theme updates.
wp_update_plugins(); // Check for Plugin updates wp_update_plugins(); // Check for plugin updates.
} }
// Send debugging email to admin for all development installations. // Send debugging email to admin for all development installations.
@ -626,7 +626,7 @@ class WP_Automatic_Updater {
); );
$next_user_core_update = get_preferred_from_update_core(); $next_user_core_update = get_preferred_from_update_core();
// If the update transient is empty, use the update we just performed // If the update transient is empty, use the update we just performed.
if ( ! $next_user_core_update ) { if ( ! $next_user_core_update ) {
$next_user_core_update = $core_update; $next_user_core_update = $core_update;
} }
@ -860,7 +860,7 @@ class WP_Automatic_Updater {
/* translators: %s: Network home URL. */ /* translators: %s: Network home URL. */
$body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) ); $body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) );
// Core // Core.
if ( isset( $this->update_results['core'] ) ) { if ( isset( $this->update_results['core'] ) ) {
$result = $this->update_results['core'][0]; $result = $this->update_results['core'][0];
if ( $result->result && ! is_wp_error( $result->result ) ) { if ( $result->result && ! is_wp_error( $result->result ) ) {
@ -874,7 +874,7 @@ class WP_Automatic_Updater {
$body[] = ''; $body[] = '';
} }
// Plugins, Themes, Translations // Plugins, Themes, Translations.
foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) { foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) {
if ( ! isset( $this->update_results[ $type ] ) ) { if ( ! isset( $this->update_results[ $type ] ) ) {
continue; continue;
@ -894,7 +894,7 @@ class WP_Automatic_Updater {
} }
} }
if ( $success_items != $this->update_results[ $type ] ) { if ( $success_items != $this->update_results[ $type ] ) {
// Failed updates // Failed updates.
$messages = array( $messages = array(
'plugin' => __( 'The following plugins failed to update:' ), 'plugin' => __( 'The following plugins failed to update:' ),
'theme' => __( 'The following themes failed to update:' ), 'theme' => __( 'The following themes failed to update:' ),

View File

@ -100,7 +100,7 @@ class WP_Comments_List_Table extends WP_List_Table {
if ( isset( $_REQUEST['number'] ) ) { if ( isset( $_REQUEST['number'] ) ) {
$number = (int) $_REQUEST['number']; $number = (int) $_REQUEST['number'];
} else { } else {
$number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra $number = $comments_per_page + min( 8, $comments_per_page ); // Grab a few extra.
} }
$page = $this->get_pagenum(); $page = $this->get_pagenum();
@ -222,7 +222,7 @@ class WP_Comments_List_Table extends WP_List_Table {
'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>',
'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>',
'comments' 'comments'
), // singular not used ), // Singular not used.
/* translators: %s: Number of comments. */ /* translators: %s: Number of comments. */
'mine' => _nx_noop( 'mine' => _nx_noop(
@ -746,7 +746,7 @@ class WP_Comments_List_Table extends WP_List_Table {
++$i; ++$i;
( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | ';
// Reply and quickedit need a hide-if-no-js span when not added with ajax // Reply and quickedit need a hide-if-no-js span when not added with ajax.
if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) { if ( ( 'reply' === $action || 'quickedit' === $action ) && ! wp_doing_ajax() ) {
$action .= ' hide-if-no-js'; $action .= ' hide-if-no-js';
} elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) { } elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) {

View File

@ -92,7 +92,7 @@ class WP_Community_Events {
return $cached_events; return $cached_events;
} }
// include an unmodified $wp_version // Include an unmodified $wp_version.
include( ABSPATH . WPINC . '/version.php' ); include( ABSPATH . WPINC . '/version.php' );
$api_url = 'http://api.wordpress.org/events/1.0/'; $api_url = 'http://api.wordpress.org/events/1.0/';

View File

@ -580,7 +580,7 @@ class WP_Debug_Data {
if ( function_exists( 'phpversion' ) ) { if ( function_exists( 'phpversion' ) ) {
$php_version_debug = phpversion(); $php_version_debug = phpversion();
// Whether PHP supports 64bit // Whether PHP supports 64-bit.
$php64bit = ( PHP_INT_SIZE * 8 === 64 ); $php64bit = ( PHP_INT_SIZE * 8 === 64 );
$php_version = sprintf( $php_version = sprintf(
@ -677,7 +677,7 @@ class WP_Debug_Data {
); );
} }
// SUHOSIN // SUHOSIN.
$suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ); $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
$info['wp-server']['fields']['suhosin'] = array( $info['wp-server']['fields']['suhosin'] = array(
@ -686,7 +686,7 @@ class WP_Debug_Data {
'debug' => $suhosin_loaded, 'debug' => $suhosin_loaded,
); );
// Imagick // Imagick.
$imagick_loaded = extension_loaded( 'imagick' ); $imagick_loaded = extension_loaded( 'imagick' );
$info['wp-server']['fields']['imagick_availability'] = array( $info['wp-server']['fields']['imagick_availability'] = array(
@ -1012,7 +1012,7 @@ class WP_Debug_Data {
$theme_version = $theme->version; $theme_version = $theme->version;
$theme_author = $theme->author; $theme_author = $theme->author;
// Sanitize // Sanitize.
$theme_author = wp_kses( $theme_author, array() ); $theme_author = wp_kses( $theme_author, array() );
$theme_version_string = __( 'No version or author information is available.' ); $theme_version_string = __( 'No version or author information is available.' );
@ -1054,7 +1054,7 @@ class WP_Debug_Data {
); );
} }
// Add more filesystem checks // Add more filesystem checks.
if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) { if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
$is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR ); $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );

View File

@ -55,7 +55,8 @@ class WP_Filesystem_Base {
*/ */
public function abspath() { public function abspath() {
$folder = $this->find_folder( 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 ) ) { if ( ! $folder && $this->is_dir( '/' . WPINC ) ) {
$folder = '/'; $folder = '/';
} }
@ -96,7 +97,7 @@ class WP_Filesystem_Base {
public function wp_themes_dir( $theme = false ) { public function wp_themes_dir( $theme = false ) {
$theme_root = get_theme_root( $theme ); $theme_root = get_theme_root( $theme );
// Account for relative theme roots // Account for relative theme roots.
if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) { if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) {
$theme_root = WP_CONTENT_DIR . $theme_root; $theme_root = WP_CONTENT_DIR . $theme_root;
} }
@ -182,7 +183,7 @@ class WP_Filesystem_Base {
'FTP_LANG_DIR' => WP_LANG_DIR, 'FTP_LANG_DIR' => WP_LANG_DIR,
); );
// Direct matches ( folder = CONSTANT/ ) // Direct matches ( folder = CONSTANT/ ).
foreach ( $constant_overrides as $constant => $dir ) { foreach ( $constant_overrides as $constant => $dir ) {
if ( ! defined( $constant ) ) { if ( ! defined( $constant ) ) {
continue; continue;
@ -192,12 +193,12 @@ class WP_Filesystem_Base {
} }
} }
// Prefix Matches ( folder = CONSTANT/subdir ) // Prefix matches ( folder = CONSTANT/subdir ),
foreach ( $constant_overrides as $constant => $dir ) { foreach ( $constant_overrides as $constant => $dir ) {
if ( ! defined( $constant ) ) { if ( ! defined( $constant ) ) {
continue; continue;
} }
if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir if ( 0 === stripos( $folder, $dir ) ) { // $folder starts with $dir.
$potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder ); $potential_folder = preg_replace( '#^' . preg_quote( $dir, '#' ) . '/#i', trailingslashit( constant( $constant ) ), $folder );
$potential_folder = trailingslashit( $potential_folder ); $potential_folder = trailingslashit( $potential_folder );
@ -208,12 +209,12 @@ class WP_Filesystem_Base {
} }
} }
} elseif ( 'direct' == $this->method ) { } elseif ( 'direct' == $this->method ) {
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation.
return trailingslashit( $folder ); return trailingslashit( $folder );
} }
$folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out windows drive letter if it's there. $folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out Windows drive letter if it's there.
$folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation.
if ( isset( $this->cache[ $folder ] ) ) { if ( isset( $this->cache[ $folder ] ) ) {
return $this->cache[ $folder ]; return $this->cache[ $folder ];
@ -240,7 +241,7 @@ class WP_Filesystem_Base {
* *
* @param string $folder The folder to locate. * @param string $folder The folder to locate.
* @param string $base The folder to start searching from. * @param string $base The folder to start searching from.
* @param bool $loop If the function has recursed, Internal use only. * @param bool $loop If the function has recursed. Internal use only.
* @return string|false The location of the remote path, false to cease looping. * @return string|false The location of the remote path, false to cease looping.
*/ */
public function search_for_folder( $folder, $base = '.', $loop = false ) { public function search_for_folder( $folder, $base = '.', $loop = false ) {
@ -303,7 +304,7 @@ class WP_Filesystem_Base {
} }
// Prevent this function from looping again. // Prevent this function from looping again.
// No need to proceed if we've just searched in / // No need to proceed if we've just searched in `/`.
if ( $loop || '/' == $base ) { if ( $loop || '/' == $base ) {
return false; return false;
} }
@ -328,39 +329,39 @@ class WP_Filesystem_Base {
*/ */
public function gethchmod( $file ) { public function gethchmod( $file ) {
$perms = intval( $this->getchmod( $file ), 8 ); $perms = intval( $this->getchmod( $file ), 8 );
if ( ( $perms & 0xC000 ) == 0xC000 ) { // Socket if ( ( $perms & 0xC000 ) == 0xC000 ) { // Socket.
$info = 's'; $info = 's';
} elseif ( ( $perms & 0xA000 ) == 0xA000 ) { // Symbolic Link } elseif ( ( $perms & 0xA000 ) == 0xA000 ) { // Symbolic Link.
$info = 'l'; $info = 'l';
} elseif ( ( $perms & 0x8000 ) == 0x8000 ) { // Regular } elseif ( ( $perms & 0x8000 ) == 0x8000 ) { // Regular.
$info = '-'; $info = '-';
} elseif ( ( $perms & 0x6000 ) == 0x6000 ) { // Block special } elseif ( ( $perms & 0x6000 ) == 0x6000 ) { // Block special.
$info = 'b'; $info = 'b';
} elseif ( ( $perms & 0x4000 ) == 0x4000 ) { // Directory } elseif ( ( $perms & 0x4000 ) == 0x4000 ) { // Directory.
$info = 'd'; $info = 'd';
} elseif ( ( $perms & 0x2000 ) == 0x2000 ) { // Character special } elseif ( ( $perms & 0x2000 ) == 0x2000 ) { // Character special.
$info = 'c'; $info = 'c';
} elseif ( ( $perms & 0x1000 ) == 0x1000 ) { // FIFO pipe } elseif ( ( $perms & 0x1000 ) == 0x1000 ) { // FIFO pipe.
$info = 'p'; $info = 'p';
} else { // Unknown } else { // Unknown.
$info = 'u'; $info = 'u';
} }
// Owner // Owner.
$info .= ( ( $perms & 0x0100 ) ? 'r' : '-' ); $info .= ( ( $perms & 0x0100 ) ? 'r' : '-' );
$info .= ( ( $perms & 0x0080 ) ? 'w' : '-' ); $info .= ( ( $perms & 0x0080 ) ? 'w' : '-' );
$info .= ( ( $perms & 0x0040 ) ? $info .= ( ( $perms & 0x0040 ) ?
( ( $perms & 0x0800 ) ? 's' : 'x' ) : ( ( $perms & 0x0800 ) ? 's' : 'x' ) :
( ( $perms & 0x0800 ) ? 'S' : '-' ) ); ( ( $perms & 0x0800 ) ? 'S' : '-' ) );
// Group // Group.
$info .= ( ( $perms & 0x0020 ) ? 'r' : '-' ); $info .= ( ( $perms & 0x0020 ) ? 'r' : '-' );
$info .= ( ( $perms & 0x0010 ) ? 'w' : '-' ); $info .= ( ( $perms & 0x0010 ) ? 'w' : '-' );
$info .= ( ( $perms & 0x0008 ) ? $info .= ( ( $perms & 0x0008 ) ?
( ( $perms & 0x0400 ) ? 's' : 'x' ) : ( ( $perms & 0x0400 ) ? 's' : 'x' ) :
( ( $perms & 0x0400 ) ? 'S' : '-' ) ); ( ( $perms & 0x0400 ) ? 'S' : '-' ) );
// World // World.
$info .= ( ( $perms & 0x0004 ) ? 'r' : '-' ); $info .= ( ( $perms & 0x0004 ) ? 'r' : '-' );
$info .= ( ( $perms & 0x0002 ) ? 'w' : '-' ); $info .= ( ( $perms & 0x0002 ) ? 'w' : '-' );
$info .= ( ( $perms & 0x0001 ) ? $info .= ( ( $perms & 0x0001 ) ?
@ -827,4 +828,4 @@ class WP_Filesystem_Base {
return false; return false;
} }
} // WP_Filesystem_Base }

View File

@ -131,7 +131,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
if ( ! $this->is_dir( $file ) ) { if ( ! $this->is_dir( $file ) ) {
return chgrp( $file, $group ); return chgrp( $file, $group );
} }
// Is a directory, and we want recursive // Is a directory, and we want recursive.
$file = trailingslashit( $file ); $file = trailingslashit( $file );
$filelist = $this->dirlist( $file ); $filelist = $this->dirlist( $file );
foreach ( $filelist as $filename ) { foreach ( $filelist as $filename ) {
@ -167,7 +167,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
if ( ! $recursive || ! $this->is_dir( $file ) ) { if ( ! $recursive || ! $this->is_dir( $file ) ) {
return chmod( $file, $mode ); return chmod( $file, $mode );
} }
// Is a directory, and we want recursive // Is a directory, and we want recursive.
$file = trailingslashit( $file ); $file = trailingslashit( $file );
$filelist = $this->dirlist( $file ); $filelist = $this->dirlist( $file );
foreach ( (array) $filelist as $filename => $filemeta ) { foreach ( (array) $filelist as $filename => $filemeta ) {
@ -198,7 +198,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
if ( ! $this->is_dir( $file ) ) { if ( ! $this->is_dir( $file ) ) {
return chown( $file, $owner ); return chown( $file, $owner );
} }
// Is a directory, and we want recursive // Is a directory, and we want recursive.
$filelist = $this->dirlist( $file ); $filelist = $this->dirlist( $file );
foreach ( $filelist as $filename ) { foreach ( $filelist as $filename ) {
$this->chown( $file . '/' . $filename, $owner, $recursive ); $this->chown( $file . '/' . $filename, $owner, $recursive );
@ -327,10 +327,11 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
* @return bool True on success, false on failure. * @return bool True on success, false on failure.
*/ */
public function delete( $file, $recursive = false, $type = false ) { public function delete( $file, $recursive = false, $type = false ) {
if ( empty( $file ) ) { // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem. if ( empty( $file ) ) {
// Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
return false; return false;
} }
$file = str_replace( '\\', '/', $file ); // for win32, occasional problems deleting files otherwise $file = str_replace( '\\', '/', $file ); // For Win32, occasional problems deleting files otherwise.
if ( 'f' == $type || $this->is_file( $file ) ) { if ( 'f' == $type || $this->is_file( $file ) ) {
return @unlink( $file ); return @unlink( $file );
@ -339,7 +340,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
return @rmdir( $file ); return @rmdir( $file );
} }
// At this point it's a folder, and we're in recursive mode // At this point it's a folder, and we're in recursive mode.
$file = trailingslashit( $file ); $file = trailingslashit( $file );
$filelist = $this->dirlist( $file, true ); $filelist = $this->dirlist( $file, true );

View File

@ -38,8 +38,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return; return;
} }
// This Class uses the timeout on a per-connection basis, Others use it on a per-action basis. // This class uses the timeout on a per-connection basis, others use it on a per-action basis.
if ( ! defined( 'FS_TIMEOUT' ) ) { if ( ! defined( 'FS_TIMEOUT' ) ) {
define( 'FS_TIMEOUT', 240 ); define( 'FS_TIMEOUT', 240 );
} }
@ -113,7 +112,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return false; return false;
} }
// Set the Connection to use Passive FTP // Set the connection to use Passive FTP.
ftp_pasv( $this->link, true ); ftp_pasv( $this->link, true );
if ( @ftp_get_option( $this->link, FTP_TIMEOUT_SEC ) < FS_TIMEOUT ) { if ( @ftp_get_option( $this->link, FTP_TIMEOUT_SEC ) < FS_TIMEOUT ) {
@ftp_set_option( $this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT ); @ftp_set_option( $this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT );
@ -146,7 +145,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return false; return false;
} }
fseek( $temp, 0 ); // Skip back to the start of the file being written to fseek( $temp, 0 ); // Skip back to the start of the file being written to.
$contents = ''; $contents = '';
while ( ! feof( $temp ) ) { while ( ! feof( $temp ) ) {
@ -203,7 +202,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return false; return false;
} }
fseek( $temp, 0 ); // Skip back to the start of the file being written to fseek( $temp, 0 ); // Skip back to the start of the file being written to.
$ret = ftp_fput( $this->link, $file, $temp, FTP_BINARY ); $ret = ftp_fput( $this->link, $file, $temp, FTP_BINARY );
@ -273,7 +272,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
} }
} }
// chmod the file or directory // chmod the file or directory.
if ( ! function_exists( 'ftp_chmod' ) ) { if ( ! function_exists( 'ftp_chmod' ) ) {
return (bool) ftp_site( $this->link, sprintf( 'CHMOD %o %s', $mode, $file ) ); return (bool) ftp_site( $this->link, sprintf( 'CHMOD %o %s', $mode, $file ) );
} }
@ -405,7 +404,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return true; // File is an empty directory. return true; // File is an empty directory.
} }
return ! empty( $list ); //empty list = no file, so invert. return ! empty( $list ); // Empty list = no file, so invert.
} }
/** /**
@ -573,7 +572,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
if ( $lucifer[3] < 70 ) { if ( $lucifer[3] < 70 ) {
$lucifer[3] += 2000; $lucifer[3] += 2000;
} else { } else {
$lucifer[3] += 1900; // 4digit year fix $lucifer[3] += 1900; // 4-digit year fix.
} }
$b['isdir'] = ( $lucifer[7] == '<DIR>' ); $b['isdir'] = ( $lucifer[7] == '<DIR>' );
if ( $b['isdir'] ) { if ( $b['isdir'] ) {
@ -593,7 +592,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
} elseif ( ! $is_windows ) { } elseif ( ! $is_windows ) {
$lucifer = preg_split( '/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY ); $lucifer = preg_split( '/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY );
if ( $lucifer ) { if ( $lucifer ) {
//echo $line."\n"; // echo $line."\n";
$lcount = count( $lucifer ); $lcount = count( $lucifer );
if ( $lcount < 8 ) { if ( $lcount < 8 ) {
return ''; return '';
@ -637,7 +636,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
} }
} }
// Replace symlinks formatted as "source -> target" with just the source name // Replace symlinks formatted as "source -> target" with just the source name.
if ( isset( $b['islink'] ) && $b['islink'] ) { if ( isset( $b['islink'] ) && $b['islink'] ) {
$b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] ); $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] );
} }

View File

@ -150,12 +150,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
reset_mbstring_encoding(); reset_mbstring_encoding();
return ''; // Blank document, File does exist, It's just blank. return ''; // Blank document. File does exist, it's just blank.
} }
reset_mbstring_encoding(); reset_mbstring_encoding();
fseek( $temphandle, 0 ); // Skip back to the start of the file being written to fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
$contents = ''; $contents = '';
while ( ! feof( $temphandle ) ) { while ( ! feof( $temphandle ) ) {
@ -198,7 +198,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
return false; return false;
} }
// The FTP class uses string functions internally during file download/upload // The FTP class uses string functions internally during file download/upload.
mbstring_binary_safe_encoding(); mbstring_binary_safe_encoding();
$bytes_written = fwrite( $temphandle, $contents ); $bytes_written = fwrite( $temphandle, $contents );
@ -211,7 +211,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
return false; return false;
} }
fseek( $temphandle, 0 ); // Skip back to the start of the file being written to fseek( $temphandle, 0 ); // Skip back to the start of the file being written to.
$ret = $this->ftp->fput( $file, $temphandle ); $ret = $this->ftp->fput( $file, $temphandle );
@ -283,7 +283,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
} }
} }
// chmod the file or directory // chmod the file or directory.
return $this->ftp->chmod( $file, $mode ); return $this->ftp->chmod( $file, $mode );
} }
@ -408,7 +408,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
return true; // File is an empty directory. return true; // File is an empty directory.
} }
return ! empty( $list ); //empty list = no file, so invert. return ! empty( $list ); // Empty list = no file, so invert.
// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server. // Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
} }
@ -635,12 +635,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
} }
} }
// Replace symlinks formatted as "source -> target" with just the source name // Replace symlinks formatted as "source -> target" with just the source name.
if ( $struc['islink'] ) { if ( $struc['islink'] ) {
$struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] ); $struc['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $struc['name'] );
} }
// Add the Octal representation of the file permissions // Add the octal representation of the file permissions.
$struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] ); $struc['permsn'] = $this->getnumchmodfromh( $struc['perms'] );
$ret[ $struc['name'] ] = $struc; $ret[ $struc['name'] ] = $struc;

View File

@ -64,7 +64,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
$this->method = 'ssh2'; $this->method = 'ssh2';
$this->errors = new WP_Error(); $this->errors = new WP_Error();
//Check if possible to use ssh2 functions. // Check if possible to use ssh2 functions.
if ( ! extension_loaded( 'ssh2' ) ) { if ( ! extension_loaded( 'ssh2' ) ) {
$this->errors->add( 'no_ssh2_ext', __( 'The ssh2 PHP extension is not available' ) ); $this->errors->add( 'no_ssh2_ext', __( 'The ssh2 PHP extension is not available' ) );
return; return;
@ -582,7 +582,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
* @return bool Whether $file is writable. * @return bool Whether $file is writable.
*/ */
public function is_writable( $file ) { public function is_writable( $file ) {
// PHP will base it's writable checks on system_user === file_owner, not ssh_user === file_owner // PHP will base its writable checks on system_user === file_owner, not ssh_user === file_owner.
return true; return true;
} }
@ -737,7 +737,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
$struc['name'] = $entry; $struc['name'] = $entry;
if ( '.' == $struc['name'] || '..' == $struc['name'] ) { if ( '.' == $struc['name'] || '..' == $struc['name'] ) {
continue; //Do not care about these folders. continue; // Do not care about these folders.
} }
if ( ! $include_hidden && '.' == $struc['name'][0] ) { if ( ! $include_hidden && '.' == $struc['name'][0] ) {

View File

@ -25,18 +25,18 @@ class WP_Importer {
$limit = 100; $limit = 100;
$offset = 0; $offset = 0;
// Grab all posts in chunks // Grab all posts in chunks.
do { do {
$meta_key = $importer_name . '_' . $bid . '_permalink'; $meta_key = $importer_name . '_' . $bid . '_permalink';
$sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit ); $sql = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit );
$results = $wpdb->get_results( $sql ); $results = $wpdb->get_results( $sql );
// Increment offset // Increment offset.
$offset = ( $limit + $offset ); $offset = ( $limit + $offset );
if ( ! empty( $results ) ) { if ( ! empty( $results ) ) {
foreach ( $results as $r ) { foreach ( $results as $r ) {
// Set permalinks into array // Set permalinks into array.
$hashtable[ $r->meta_value ] = intval( $r->post_id ); $hashtable[ $r->meta_value ] = intval( $r->post_id );
} }
} }
@ -62,7 +62,7 @@ class WP_Importer {
$count = 0; $count = 0;
// Get count of permalinks // Get count of permalinks.
$meta_key = $importer_name . '_' . $bid . '_permalink'; $meta_key = $importer_name . '_' . $bid . '_permalink';
$sql = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key ); $sql = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key );
@ -94,21 +94,21 @@ class WP_Importer {
$limit = 100; $limit = 100;
$offset = 0; $offset = 0;
// Grab all comments in chunks // Grab all comments in chunks.
do { do {
$sql = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit ); $sql = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit );
$results = $wpdb->get_results( $sql ); $results = $wpdb->get_results( $sql );
// Increment offset // Increment offset.
$offset = ( $limit + $offset ); $offset = ( $limit + $offset );
if ( ! empty( $results ) ) { if ( ! empty( $results ) ) {
foreach ( $results as $r ) { foreach ( $results as $r ) {
// Explode comment_agent key // Explode comment_agent key.
list ( $ca_bid, $source_comment_id ) = explode( '-', $r->comment_agent ); list ( $ca_bid, $source_comment_id ) = explode( '-', $r->comment_agent );
$source_comment_id = intval( $source_comment_id ); $source_comment_id = intval( $source_comment_id );
// Check if this comment came from this blog // Check if this comment came from this blog.
if ( $bid == $ca_bid ) { if ( $bid == $ca_bid ) {
$hashtable[ $source_comment_id ] = intval( $r->comment_ID ); $hashtable[ $source_comment_id ] = intval( $r->comment_ID );
} }
@ -203,7 +203,7 @@ class WP_Importer {
* @return array * @return array
*/ */
public function get_page( $url, $username = '', $password = '', $head = false ) { public function get_page( $url, $username = '', $password = '', $head = false ) {
// Increase the timeout // Increase the timeout.
add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) ); add_filter( 'http_request_timeout', array( $this, 'bump_request_timeout' ) );
$headers = array(); $headers = array();
@ -267,7 +267,7 @@ class WP_Importer {
global $wpdb, $wp_actions; global $wpdb, $wp_actions;
// Or define( 'WP_IMPORTING', true ); // Or define( 'WP_IMPORTING', true );
$wpdb->queries = array(); $wpdb->queries = array();
// Reset $wp_actions to keep it from growing out of control // Reset $wp_actions to keep it from growing out of control.
$wp_actions = array(); $wp_actions = array();
} }
} }
@ -317,15 +317,15 @@ function get_cli_args( $param, $required = false ) {
} }
} }
// Check array for specified param // Check array for specified param.
if ( isset( $out[ $param ] ) ) { if ( isset( $out[ $param ] ) ) {
// Set return value // Set return value.
$return = $out[ $param ]; $return = $out[ $param ];
} }
// Check for missing required param // Check for missing required param.
if ( ! isset( $out[ $param ] ) && $required ) { if ( ! isset( $out[ $param ] ) && $required ) {
// Display message and exit // Display message and exit.
echo "\"$param\" parameter is required but was not specified\n"; echo "\"$param\" parameter is required but was not specified\n";
exit(); exit();
} }

View File

@ -48,10 +48,10 @@ final class WP_Internal_Pointers {
* ) * )
*/ */
$registered_pointers = array( $registered_pointers = array(
//None currently. // None currently.
); );
// Check if screen related pointer is registered // Check if screen related pointer is registered.
if ( empty( $registered_pointers[ $hook_suffix ] ) ) { if ( empty( $registered_pointers[ $hook_suffix ] ) ) {
return; return;
} }
@ -75,7 +75,7 @@ final class WP_Internal_Pointers {
// None currently. // None currently.
); );
// Get dismissed pointers // Get dismissed pointers.
$dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
$got_pointers = false; $got_pointers = false;
@ -88,7 +88,7 @@ final class WP_Internal_Pointers {
} }
} }
// Bind pointer print function // Bind pointer print function.
add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) ); add_action( 'admin_print_footer_scripts', array( 'WP_Internal_Pointers', 'pointer_' . $pointer ) );
$got_pointers = true; $got_pointers = true;
} }
@ -97,7 +97,7 @@ final class WP_Internal_Pointers {
return; return;
} }
// Add pointers script and style to queue // Add pointers script and style to queue.
wp_enqueue_style( 'wp-pointer' ); wp_enqueue_style( 'wp-pointer' );
wp_enqueue_script( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' );
} }

View File

@ -451,7 +451,7 @@ class WP_List_Table {
* *
* @param string[] $actions An array of the available bulk actions. * @param string[] $actions An array of the available bulk actions.
*/ */
$this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
$two = ''; $two = '';
} else { } else {
$two = '2'; $two = '2';
@ -1004,8 +1004,8 @@ class WP_List_Table {
$columns = get_column_headers( $this->screen ); $columns = get_column_headers( $this->screen );
$default = $this->get_default_primary_column_name(); $default = $this->get_default_primary_column_name();
// If the primary column doesn't exist fall back to the // If the primary column doesn't exist,
// first non-checkbox column. // fall back to the first non-checkbox column.
if ( ! isset( $columns[ $default ] ) ) { if ( ! isset( $columns[ $default ] ) ) {
$default = WP_List_Table::get_default_primary_column_name(); $default = WP_List_Table::get_default_primary_column_name();
} }
@ -1035,7 +1035,7 @@ class WP_List_Table {
* @return array * @return array
*/ */
protected function get_column_info() { protected function get_column_info() {
// $_column_headers is already set / cached // $_column_headers is already set / cached.
if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) { if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
// Back-compat for list tables that have been manually setting $_column_headers for horse reasons. // Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
// In 4.3, we added a fourth argument for primary column. // In 4.3, we added a fourth argument for primary column.

View File

@ -114,7 +114,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
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}\.[0-9]{1,3}\.?$/', $s ) ||
preg_match( '/^[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 ) ) { preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
// IPv4 address // 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 ); $reg_blog_ids = $wpdb->get_col( $sql );
@ -133,7 +133,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
$order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : ''; $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : '';
if ( 'registered' === $order_by ) { if ( 'registered' === $order_by ) {
// registered is a valid field name. // 'registered' is a valid field name.
} elseif ( 'lastupdated' === $order_by ) { } elseif ( 'lastupdated' === $order_by ) {
$order_by = 'last_updated'; $order_by = 'last_updated';
} elseif ( 'blogname' === $order_by ) { } elseif ( 'blogname' === $order_by ) {

View File

@ -62,7 +62,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
* @return array * @return array
*/ */
protected function get_table_classes() { protected function get_table_classes() {
// todo: remove and add CSS for .themes // @todo Remove and add CSS for .themes.
return array( 'widefat', 'plugins' ); return array( 'widefat', 'plugins' );
} }

View File

@ -93,7 +93,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
$args = apply_filters( 'users_list_table_query_args', $args ); $args = apply_filters( 'users_list_table_query_args', $args );
// Query the user IDs for this page // Query the user IDs for this page.
$wp_user_search = new WP_User_Query( $args ); $wp_user_search = new WP_User_Query( $args );
$this->items = $wp_user_search->get_results(); $this->items = $wp_user_search->get_results();

View File

@ -95,7 +95,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$per_page = 36; $per_page = 36;
// These are the tabs which are shown on the page // These are the tabs which are shown on the page.
$tabs = array(); $tabs = array();
if ( 'search' === $tab ) { if ( 'search' === $tab ) {
@ -471,7 +471,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$plugin = (array) $plugin; $plugin = (array) $plugin;
} }
// Display the group heading if there is one // Display the group heading if there is one.
if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) { if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) {
if ( isset( $this->groups[ $plugin['group'] ] ) ) { if ( isset( $this->groups[ $plugin['group'] ] ) ) {
$group_name = $this->groups[ $plugin['group'] ]; $group_name = $this->groups[ $plugin['group'] ];
@ -482,13 +482,13 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
$group_name = $plugin['group']; $group_name = $plugin['group'];
} }
// Starting a new group, close off the divs of the last one // Starting a new group, close off the divs of the last one.
if ( ! empty( $group ) ) { if ( ! empty( $group ) ) {
echo '</div></div>'; echo '</div></div>';
} }
echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>'; echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>';
// needs an extra wrapping div for nth-child selectors to work // Needs an extra wrapping div for nth-child selectors to work.
echo '<div class="plugin-items">'; echo '<div class="plugin-items">';
$group = $plugin['group']; $group = $plugin['group'];
@ -768,7 +768,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
<?php <?php
} }
// Close off the group divs of the last one // Close off the group divs of the last one.
if ( ! empty( $group ) ) { if ( ! empty( $group ) ) {
echo '</div></div>'; echo '</div></div>';
} }

View File

@ -186,40 +186,40 @@ class WP_Plugins_List_Table extends WP_List_Table {
if ( isset( $plugin_info->response[ $plugin_file ] ) ) { if ( isset( $plugin_info->response[ $plugin_file ] ) ) {
$plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data ); $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
$plugins['all'][ $plugin_file ] = $plugin_data; $plugins['all'][ $plugin_file ] = $plugin_data;
// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade.
if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
$plugins['upgrade'][ $plugin_file ] = $plugin_data; $plugins['upgrade'][ $plugin_file ] = $plugin_data;
} }
} elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) { } elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
$plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data ); $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
$plugins['all'][ $plugin_file ] = $plugin_data; $plugins['all'][ $plugin_file ] = $plugin_data;
// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade.
if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
$plugins['upgrade'][ $plugin_file ] = $plugin_data; $plugins['upgrade'][ $plugin_file ] = $plugin_data;
} }
} }
// Filter into individual sections // Filter into individual sections.
if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) { if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
if ( $show_network_active ) { if ( $show_network_active ) {
// On the non-network screen, show inactive network-only plugins if allowed // On the non-network screen, show inactive network-only plugins if allowed.
$plugins['inactive'][ $plugin_file ] = $plugin_data; $plugins['inactive'][ $plugin_file ] = $plugin_data;
} else { } else {
// On the non-network screen, filter out network-only plugins as long as they're not individually active // On the non-network screen, filter out network-only plugins as long as they're not individually active.
unset( $plugins['all'][ $plugin_file ] ); unset( $plugins['all'][ $plugin_file ] );
} }
} elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) { } elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
if ( $show_network_active ) { if ( $show_network_active ) {
// On the non-network screen, show network-active plugins if allowed // On the non-network screen, show network-active plugins if allowed.
$plugins['active'][ $plugin_file ] = $plugin_data; $plugins['active'][ $plugin_file ] = $plugin_data;
} else { } else {
// On the non-network screen, filter out network-active plugins // On the non-network screen, filter out network-active plugins.
unset( $plugins['all'][ $plugin_file ] ); unset( $plugins['all'][ $plugin_file ] );
} }
} elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) ) } elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) )
|| ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $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 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 network admin screen, populate the active list with plugins that are network-activated.
$plugins['active'][ $plugin_file ] = $plugin_data; $plugins['active'][ $plugin_file ] = $plugin_data;
if ( ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file ) ) { if ( ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file ) ) {
@ -227,10 +227,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
} }
} else { } else {
if ( isset( $recently_activated[ $plugin_file ] ) ) { if ( isset( $recently_activated[ $plugin_file ] ) ) {
// Populate the recently activated list with plugins that have been recently activated // Populate the recently activated list with plugins that have been recently activated.
$plugins['recently_activated'][ $plugin_file ] = $plugin_data; $plugins['recently_activated'][ $plugin_file ] = $plugin_data;
} }
// Populate the inactive list with plugins that aren't activated // Populate the inactive list with plugins that aren't activated.
$plugins['inactive'][ $plugin_file ] = $plugin_data; $plugins['inactive'][ $plugin_file ] = $plugin_data;
} }
} }
@ -251,7 +251,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$this->items = array(); $this->items = array();
foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) { foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) {
// Translate, Don't Apply Markup, Sanitize HTML // Translate, don't apply markup, sanitize HTML.
$this->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true ); $this->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );
} }
@ -631,7 +631,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
'delete' => '', 'delete' => '',
); );
// Do not restrict by default // Do not restrict by default.
$restrict_network_active = false; $restrict_network_active = false;
$restrict_network_only = false; $restrict_network_only = false;
@ -643,10 +643,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
if ( $plugin_file != $plugin_data['Name'] ) { if ( $plugin_file != $plugin_data['Name'] ) {
$plugin_name .= '<br/>' . $plugin_data['Name']; $plugin_name .= '<br/>' . $plugin_data['Name'];
} }
if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant.
$is_active = true; $is_active = true;
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
} elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true } elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true.
$is_active = true; $is_active = true;
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
} else { } else {
@ -750,9 +750,9 @@ class WP_Plugins_List_Table extends WP_List_Table {
__( 'Delete' ) __( 'Delete' )
); );
} }
} // end if $is_active } // End if $is_active.
} // end if $screen->in_admin( 'network' ) } // End if $screen->in_admin( 'network' ).
} // end if $context } // End if $context.
$actions = array_filter( $actions ); $actions = array_filter( $actions );
@ -906,7 +906,7 @@ class WP_Plugins_List_Table extends WP_List_Table {
$plugin_meta[] = sprintf( __( 'By %s' ), $author ); $plugin_meta[] = sprintf( __( 'By %s' ), $author );
} }
// Details link using API info, if available // Details link using API info, if available.
if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) { if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) {
$plugin_meta[] = sprintf( $plugin_meta[] = sprintf(
'<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>', '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',

View File

@ -143,7 +143,7 @@ class WP_Posts_List_Table extends WP_List_Table {
public function prepare_items() { public function prepare_items() {
global $avail_post_stati, $wp_query, $per_page, $mode; global $avail_post_stati, $wp_query, $per_page, $mode;
// is going to call wp() // Is going to call wp().
$avail_post_stati = wp_edit_posts_query(); $avail_post_stati = wp_edit_posts_query();
$this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] ); $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] );
@ -877,7 +877,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$my_parents = array(); $my_parents = array();
$my_parent = $page->post_parent; $my_parent = $page->post_parent;
while ( $my_parent ) { while ( $my_parent ) {
// Get the ID from the list or the attribute if my_parent is an object // Get the ID from the list or the attribute if my_parent is an object.
$parent_id = $my_parent; $parent_id = $my_parent;
if ( is_object( $my_parent ) ) { if ( is_object( $my_parent ) ) {
$parent_id = $my_parent->ID; $parent_id = $my_parent->ID;
@ -906,7 +906,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); $this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display );
} }
unset( $children_pages[ $parent ] ); //required in order to keep track of orphans unset( $children_pages[ $parent ] ); // Required in order to keep track of orphans.
} }
/** /**
@ -1467,6 +1467,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$taxonomy_names = get_object_taxonomies( $screen->post_type ); $taxonomy_names = get_object_taxonomies( $screen->post_type );
$hierarchical_taxonomies = array(); $hierarchical_taxonomies = array();
$flat_taxonomies = array(); $flat_taxonomies = array();
foreach ( $taxonomy_names as $taxonomy_name ) { foreach ( $taxonomy_names as $taxonomy_name ) {
$taxonomy = get_taxonomy( $taxonomy_name ); $taxonomy = get_taxonomy( $taxonomy_name );
@ -1507,7 +1508,8 @@ class WP_Posts_List_Table extends WP_List_Table {
?> ?>
<form method="get"><table style="display: none"><tbody id="inlineedit"> <form method="get">
<table style="display: none"><tbody id="inlineedit">
<?php <?php
$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page';
$inline_edit_classes = "inline-edit-row inline-edit-row-$hclass"; $inline_edit_classes = "inline-edit-row inline-edit-row-$hclass";
@ -1515,346 +1517,358 @@ class WP_Posts_List_Table extends WP_List_Table {
$quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; $quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
$bulk = 0; $bulk = 0;
while ( $bulk < 2 ) { while ( $bulk < 2 ) :
$classes = $inline_edit_classes . ' ';
$classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes;
?> ?>
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none">
<td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class=" <fieldset class="inline-edit-col-left">
<?php <legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend>
echo $inline_edit_classes . ' '; <div class="inline-edit-col">
echo $bulk ? $bulk_edit_classes : $quick_edit_classes;
?>
" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
<fieldset class="inline-edit-col-left"> <?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?>
<legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend>
<div class="inline-edit-col">
<?php
if ( post_type_supports( $screen->post_type, 'title' ) ) : <?php if ( $bulk ) : ?>
if ( $bulk ) :
<div id="bulk-title-div">
<div id="bulk-titles"></div>
</div>
<?php else : // $bulk ?>
<label>
<span class="title"><?php _e( 'Title' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
</label>
<?php if ( is_post_type_viewable( $screen->post_type ) ) : ?>
<label>
<span class="title"><?php _e( 'Slug' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
</label>
<?php endif; // is_post_type_viewable() ?>
<?php endif; // $bulk ?>
<?php endif; // post_type_supports( ... 'title' ) ?>
<?php if ( ! $bulk ) : ?>
<fieldset class="inline-edit-date">
<legend><span class="title"><?php _e( 'Date' ); ?></span></legend>
<?php touch_time( 1, 1, 0, 1 ); ?>
</fieldset>
<br class="clear" />
<?php endif; // $bulk ?>
<?php
if ( post_type_supports( $screen->post_type, 'author' ) ) :
$authors_dropdown = '';
if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) :
$users_opt = array(
'hide_if_only_one_author' => false,
'who' => 'authors',
'name' => 'post_author',
'class' => 'authors',
'multi' => 1,
'echo' => 0,
'show' => 'display_name_with_login',
);
if ( $bulk ) {
$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
}
$authors = wp_dropdown_users( $users_opt );
if ( $authors ) :
$authors_dropdown = '<label class="inline-edit-author">';
$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
$authors_dropdown .= $authors;
$authors_dropdown .= '</label>';
endif;
endif; // current_user_can( 'edit_others_posts' )
?> ?>
<div id="bulk-title-div">
<div id="bulk-titles"></div>
</div>
<?php else : // $bulk ?>
<label>
<span class="title"><?php _e( 'Title' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
</label>
<?php if ( is_post_type_viewable( $screen->post_type ) ) : // is_post_type_viewable check ?>
<label>
<span class="title"><?php _e( 'Slug' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
</label>
<?php <?php
endif; // is_post_type_viewable check if ( ! $bulk ) {
endif; // $bulk echo $authors_dropdown;
endif; // post_type_supports title
?>
<?php if ( ! $bulk ) : ?>
<fieldset class="inline-edit-date">
<legend><span class="title"><?php _e( 'Date' ); ?></span></legend>
<?php touch_time( 1, 1, 0, 1 ); ?>
</fieldset>
<br class="clear" />
<?php
endif; // $bulk
if ( post_type_supports( $screen->post_type, 'author' ) ) :
$authors_dropdown = '';
if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) :
$users_opt = array(
'hide_if_only_one_author' => false,
'who' => 'authors',
'name' => 'post_author',
'class' => 'authors',
'multi' => 1,
'echo' => 0,
'show' => 'display_name_with_login',
);
if ( $bulk ) {
$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
} }
endif; // post_type_supports( ... 'author' )
$authors = wp_dropdown_users( $users_opt );
if ( $authors ) :
$authors_dropdown = '<label class="inline-edit-author">';
$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
$authors_dropdown .= $authors;
$authors_dropdown .= '</label>';
endif;
endif; // authors
?> ?>
<?php <?php if ( ! $bulk && $can_publish ) : ?>
if ( ! $bulk ) {
echo $authors_dropdown;}
endif; // post_type_supports author
if ( ! $bulk && $can_publish ) : <div class="inline-edit-group wp-clearfix">
?> <label class="alignleft">
<span class="title"><?php _e( 'Password' ); ?></span>
<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
</label>
<div class="inline-edit-group wp-clearfix"> <em class="alignleft inline-edit-or">
<label class="alignleft"> <?php
<span class="title"><?php _e( 'Password' ); ?></span> /* translators: Between password field and private checkbox on post quick edit interface. */
<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> _e( '&ndash;OR&ndash;' );
</label> ?>
</em>
<em class="alignleft inline-edit-or"> <label class="alignleft inline-edit-private">
<?php <input type="checkbox" name="keep_private" value="private" />
/* translators: Between password field and private checkbox on post quick edit interface. */ <span class="checkbox-title"><?php _e( 'Private' ); ?></span>
_e( '&ndash;OR&ndash;' ); </label>
?> </div>
</em>
<label class="alignleft inline-edit-private">
<input type="checkbox" name="keep_private" value="private" />
<span class="checkbox-title"><?php _e( 'Private' ); ?></span>
</label>
</div>
<?php endif; ?> <?php endif; ?>
</div></fieldset> </div>
</fieldset>
<?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?>
<fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> <fieldset class="inline-edit-col-center inline-edit-categories">
<div class="inline-edit-col">
<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
<input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> <input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist">
<?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?> <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?>
</ul> </ul>
<?php endforeach; //$hierarchical_taxonomies as $taxonomy ?> <?php endforeach; // $hierarchical_taxonomies as $taxonomy ?>
</div></fieldset> </div>
</fieldset>
<?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?> <?php endif; // count( $hierarchical_taxonomies ) && ! $bulk ?>
<fieldset class="inline-edit-col-right"><div class="inline-edit-col"> <fieldset class="inline-edit-col-right">
<div class="inline-edit-col">
<?php
if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) {
echo $authors_dropdown;
}
if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) :
if ( $post_type_object->hierarchical ) :
?>
<label>
<span class="title"><?php _e( 'Parent' ); ?></span>
<?php
$dropdown_args = array(
'post_type' => $post_type_object->name,
'selected' => $post->post_parent,
'name' => 'post_parent',
'show_option_none' => __( 'Main Page (no parent)' ),
'option_none_value' => 0,
'sort_column' => 'menu_order, post_title',
);
if ( $bulk ) {
$dropdown_args['show_option_no_change'] = __( '&mdash; No Change &mdash;' );
}
/**
* Filters the arguments used to generate the Quick Edit page-parent drop-down.
*
* @since 2.7.0
*
* @see wp_dropdown_pages()
*
* @param array $dropdown_args An array of arguments.
*/
$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
wp_dropdown_pages( $dropdown_args );
?>
</label>
<?php
endif; // hierarchical
if ( ! $bulk ) :
?>
<label>
<span class="title"><?php _e( 'Order' ); ?></span>
<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span>
</label>
<?php
endif; // !$bulk
endif; // page-attributes
?>
<?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?>
<label>
<span class="title"><?php _e( 'Template' ); ?></span>
<select name="page_template">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<?php endif; // $bulk ?>
<?php
/** This filter is documented in wp-admin/includes/meta-boxes.php */
$default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' );
?>
<option value="default"><?php echo esc_html( $default_title ); ?></option>
<?php page_template_dropdown( '', $screen->post_type ); ?>
</select>
</label>
<?php endif; ?>
<?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?>
<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
<?php
if ( current_user_can( $taxonomy->cap->assign_terms ) ) :
$taxonomy_name = esc_attr( $taxonomy->name );
?>
<label class="inline-edit-tags">
<span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
<textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea>
</label>
<?php endif; ?>
<?php endforeach; //$flat_taxonomies as $taxonomy ?>
<?php endif; // count( $flat_taxonomies ) && !$bulk ?>
<?php
if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) :
if ( $bulk ) :
?>
<div class="inline-edit-group wp-clearfix">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
<label class="alignleft">
<span class="title"><?php _e( 'Comments' ); ?></span>
<select name="comment_status">
<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="open"><?php _e( 'Allow' ); ?></option>
<option value="closed"><?php _e( 'Do not allow' ); ?></option>
</select>
</label>
<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<label class="alignright">
<span class="title"><?php _e( 'Pings' ); ?></span>
<select name="ping_status">
<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="open"><?php _e( 'Allow' ); ?></option>
<option value="closed"><?php _e( 'Do not allow' ); ?></option>
</select>
</label>
<?php endif; ?>
</div>
<?php else : // $bulk ?>
<div class="inline-edit-group wp-clearfix">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
<label class="alignleft">
<input type="checkbox" name="comment_status" value="open" />
<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
</label>
<?php endif; if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<label class="alignleft">
<input type="checkbox" name="ping_status" value="open" />
<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
</label>
<?php endif; ?>
</div>
<?php <?php
endif; // $bulk if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) {
endif; // post_type_supports comments or pings echo $authors_dropdown;
?>
<div class="inline-edit-group wp-clearfix">
<label class="inline-edit-status alignleft">
<span class="title"><?php _e( 'Status' ); ?></span>
<select name="_status">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<?php endif; // $bulk ?>
<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
<option value="publish"><?php _e( 'Published' ); ?></option>
<option value="future"><?php _e( 'Scheduled' ); ?></option>
<?php if ( $bulk ) : ?>
<option value="private"><?php _e( 'Private' ); ?></option>
<?php endif; // $bulk ?>
<?php endif; ?>
<option value="pending"><?php _e( 'Pending Review' ); ?></option>
<option value="draft"><?php _e( 'Draft' ); ?></option>
</select>
</label>
<?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
<?php if ( $bulk ) : ?>
<label class="alignright">
<span class="title"><?php _e( 'Sticky' ); ?></span>
<select name="sticky">
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="sticky"><?php _e( 'Sticky' ); ?></option>
<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
</select>
</label>
<?php else : // $bulk ?>
<label class="alignleft">
<input type="checkbox" name="sticky" value="sticky" />
<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
</label>
<?php endif; // $bulk ?>
<?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_cap' ) ?>
</div>
<?php
if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) {
$post_formats = get_theme_support( 'post-formats' );
?>
<label class="alignleft">
<span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
<select name="post_format">
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
<?php
if ( is_array( $post_formats[0] ) ) {
foreach ( $post_formats[0] as $format ) {
?>
<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
<?php
}
} }
?> ?>
</select></label>
<?php
} <?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : ?>
?> <?php if ( $post_type_object->hierarchical ) : ?>
</div></fieldset> <label>
<span class="title"><?php _e( 'Parent' ); ?></span>
<?php
$dropdown_args = array(
'post_type' => $post_type_object->name,
'selected' => $post->post_parent,
'name' => 'post_parent',
'show_option_none' => __( 'Main Page (no parent)' ),
'option_none_value' => 0,
'sort_column' => 'menu_order, post_title',
);
if ( $bulk ) {
$dropdown_args['show_option_no_change'] = __( '&mdash; No Change &mdash;' );
}
/**
* Filters the arguments used to generate the Quick Edit page-parent drop-down.
*
* @since 2.7.0
*
* @see wp_dropdown_pages()
*
* @param array $dropdown_args An array of arguments.
*/
$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
wp_dropdown_pages( $dropdown_args );
?>
</label>
<?php endif; // hierarchical ?>
<?php if ( ! $bulk ) : ?>
<label>
<span class="title"><?php _e( 'Order' ); ?></span>
<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span>
</label>
<?php endif; // ! $bulk ?>
<?php endif; // post_type_supports( ... 'page-attributes' ) ?>
<?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?>
<label>
<span class="title"><?php _e( 'Template' ); ?></span>
<select name="page_template">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<?php endif; // $bulk ?>
<?php
/** This filter is documented in wp-admin/includes/meta-boxes.php */
$default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' );
?>
<option value="default"><?php echo esc_html( $default_title ); ?></option>
<?php page_template_dropdown( '', $screen->post_type ); ?>
</select>
</label>
<?php endif; ?>
<?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?>
<?php foreach ( $flat_taxonomies as $taxonomy ) : ?>
<?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?>
<?php $taxonomy_name = esc_attr( $taxonomy->name ); ?>
<label class="inline-edit-tags">
<span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span>
<textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea>
</label>
<?php endif; // current_user_can( 'assign_terms' ) ?>
<?php endforeach; // $flat_taxonomies as $taxonomy ?>
<?php endif; // count( $flat_taxonomies ) && ! $bulk ?>
<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<?php if ( $bulk ) : ?>
<div class="inline-edit-group wp-clearfix">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
<label class="alignleft">
<span class="title"><?php _e( 'Comments' ); ?></span>
<select name="comment_status">
<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="open"><?php _e( 'Allow' ); ?></option>
<option value="closed"><?php _e( 'Do not allow' ); ?></option>
</select>
</label>
<?php endif; ?>
<?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<label class="alignright">
<span class="title"><?php _e( 'Pings' ); ?></span>
<select name="ping_status">
<option value=""><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="open"><?php _e( 'Allow' ); ?></option>
<option value="closed"><?php _e( 'Do not allow' ); ?></option>
</select>
</label>
<?php endif; ?>
</div>
<?php else : // $bulk ?>
<div class="inline-edit-group wp-clearfix">
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?>
<label class="alignleft">
<input type="checkbox" name="comment_status" value="open" />
<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
</label>
<?php endif; ?>
<?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?>
<label class="alignleft">
<input type="checkbox" name="ping_status" value="open" />
<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
</label>
<?php endif; ?>
</div>
<?php endif; // $bulk ?>
<?php endif; // post_type_supports( ... comments or pings ) ?>
<div class="inline-edit-group wp-clearfix">
<label class="inline-edit-status alignleft">
<span class="title"><?php _e( 'Status' ); ?></span>
<select name="_status">
<?php if ( $bulk ) : ?>
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<?php endif; // $bulk ?>
<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review". ?>
<option value="publish"><?php _e( 'Published' ); ?></option>
<option value="future"><?php _e( 'Scheduled' ); ?></option>
<?php if ( $bulk ) : ?>
<option value="private"><?php _e( 'Private' ); ?></option>
<?php endif; // $bulk ?>
<?php endif; ?>
<option value="pending"><?php _e( 'Pending Review' ); ?></option>
<option value="draft"><?php _e( 'Draft' ); ?></option>
</select>
</label>
<?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?>
<?php if ( $bulk ) : ?>
<label class="alignright">
<span class="title"><?php _e( 'Sticky' ); ?></span>
<select name="sticky">
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="sticky"><?php _e( 'Sticky' ); ?></option>
<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
</select>
</label>
<?php else : // $bulk ?>
<label class="alignleft">
<input type="checkbox" name="sticky" value="sticky" />
<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
</label>
<?php endif; // $bulk ?>
<?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_posts' ) ?>
</div>
<?php if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) : ?>
<?php $post_formats = get_theme_support( 'post-formats' ); ?>
<label class="alignleft">
<span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
<select name="post_format">
<option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
<option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
<?php if ( is_array( $post_formats[0] ) ) : ?>
<?php foreach ( $post_formats[0] as $format ) : ?>
<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</label>
<?php endif; ?>
</div>
</fieldset>
<?php <?php
list( $columns ) = $this->get_column_info(); list( $columns ) = $this->get_column_info();
@ -1890,35 +1904,38 @@ class WP_Posts_List_Table extends WP_List_Table {
} }
} }
?> ?>
<div class="submit inline-edit-save">
<button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button> <div class="submit inline-edit-save">
<?php <button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button>
if ( ! $bulk ) {
wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); <?php if ( ! $bulk ) : ?>
?> <?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?>
<button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button> <button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button>
<span class="spinner"></span> <span class="spinner"></span>
<?php <?php else : ?>
} else { <?php submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false ); ?>
submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false ); <?php endif; ?>
}
?> <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?>
<?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?> <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
<input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> <?php endif; ?>
<?php } ?> <br class="clear" />
<br class="clear" />
<div class="notice notice-error notice-alt inline hidden"> <div class="notice notice-error notice-alt inline hidden">
<p class="error"></p> <p class="error"></p>
</div>
</div> </div>
</div>
</td></tr> </td></tr>
<?php <?php
$bulk++; $bulk++;
} endwhile;
?> ?>
</tbody></table></form> </tbody></table>
</form>
<?php <?php
} }
} }

View File

@ -73,9 +73,11 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
* @return array Default sortable columns. * @return array Default sortable columns.
*/ */
protected function get_sortable_columns() { protected function get_sortable_columns() {
// The initial sorting is by 'Requested' (post_date) and descending. /*
// With initial sorting, the first click on 'Requested' should be ascending. * The initial sorting is by 'Requested' (post_date) and descending.
// With 'Requester' sorting active, the next click on 'Requested' should be descending. * With initial sorting, the first click on 'Requested' should be ascending.
* With 'Requester' sorting active, the next click on 'Requested' should be descending.
*/
$desc_first = isset( $_GET['orderby'] ); $desc_first = isset( $_GET['orderby'] );
return array( return array(
@ -146,7 +148,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$counts = $this->get_request_counts(); $counts = $this->get_request_counts();
$total_requests = absint( array_sum( (array) $counts ) ); $total_requests = absint( array_sum( (array) $counts ) );
// Normalized admin URL // Normalized admin URL.
$admin_url = $this->get_admin_url(); $admin_url = $this->get_admin_url();
$current_link_attributes = empty( $current_status ) ? ' class="current" aria-current="page"' : ''; $current_link_attributes = empty( $current_status ) ? ' class="current" aria-current="page"' : '';

View File

@ -226,7 +226,7 @@ final class WP_Screen {
// For those pesky meta boxes. // For those pesky meta boxes.
if ( $hook_name && post_type_exists( $hook_name ) ) { if ( $hook_name && post_type_exists( $hook_name ) ) {
$post_type = $id; $post_type = $id;
$id = 'post'; // changes later. ends up being $base. $id = 'post'; // Changes later. Ends up being $base.
} else { } else {
if ( '.php' == substr( $id, -4 ) ) { if ( '.php' == substr( $id, -4 ) ) {
$id = substr( $id, 0, -4 ); $id = substr( $id, 0, -4 );
@ -923,7 +923,7 @@ final class WP_Screen {
</div> </div>
</div> </div>
<?php <?php
// Setup layout columns // Setup layout columns.
/** /**
* Filters the array of screen layout columns. * Filters the array of screen layout columns.
@ -952,7 +952,7 @@ final class WP_Screen {
} }
$GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat. $GLOBALS['screen_layout_columns'] = $this->columns; // Set the global for back-compat.
// Add screen options // Add screen options.
if ( $this->show_screen_options() ) { if ( $this->show_screen_options() ) {
$this->render_screen_options(); $this->render_screen_options();
} }
@ -1156,7 +1156,7 @@ final class WP_Screen {
$special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' ); $special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' );
foreach ( $columns as $column => $title ) { foreach ( $columns as $column => $title ) {
// Can't hide these for they are special // Can't hide these for they are special.
if ( in_array( $column, $special ) ) { if ( in_array( $column, $special ) ) {
continue; continue;
} }
@ -1255,13 +1255,13 @@ final class WP_Screen {
$per_page = apply_filters( "{$option}", $per_page ); $per_page = apply_filters( "{$option}", $per_page );
} }
// Back compat // Back compat.
if ( isset( $this->post_type ) ) { if ( isset( $this->post_type ) ) {
/** This filter is documented in wp-admin/includes/post.php */ /** This filter is documented in wp-admin/includes/post.php */
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type ); $per_page = apply_filters( 'edit_posts_per_page', $per_page, $this->post_type );
} }
// This needs a submit button // This needs a submit button.
add_filter( 'screen_options_show_submit', '__return_true' ); add_filter( 'screen_options_show_submit', '__return_true' );
?> ?>
@ -1288,7 +1288,7 @@ final class WP_Screen {
public function render_view_mode() { public function render_view_mode() {
$screen = get_current_screen(); $screen = get_current_screen();
// Currently only enabled for posts lists // Currently only enabled for posts lists.
if ( 'edit' !== $screen->base ) { if ( 'edit' !== $screen->base ) {
return; return;
} }
@ -1316,7 +1316,7 @@ final class WP_Screen {
global $mode; global $mode;
// This needs a submit button // This needs a submit button.
add_filter( 'screen_options_show_submit', '__return_true' ); add_filter( 'screen_options_show_submit', '__return_true' );
?> ?>
<fieldset class="metabox-prefs view-mode"> <fieldset class="metabox-prefs view-mode">

View File

@ -353,12 +353,12 @@ class WP_Site_Health_Auto_Updates {
$checksums = get_core_checksums( $wp_version, 'en_US' ); $checksums = get_core_checksums( $wp_version, 'en_US' );
$dev = ( false !== strpos( $wp_version, '-' ) ); $dev = ( false !== strpos( $wp_version, '-' ) );
// Get the last stable version's files and test against that // Get the last stable version's files and test against that.
if ( ! $checksums && $dev ) { if ( ! $checksums && $dev ) {
$checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' ); $checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' );
} }
// There aren't always checksums for development releases, so just skip the test if we still can't find any // There aren't always checksums for development releases, so just skip the test if we still can't find any.
if ( ! $checksums && $dev ) { if ( ! $checksums && $dev ) {
return false; return false;
} }
@ -415,7 +415,7 @@ class WP_Site_Health_Auto_Updates {
*/ */
function test_accepts_dev_updates() { function test_accepts_dev_updates() {
include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
// Only for dev versions // Only for dev versions.
if ( false === strpos( $wp_version, '-' ) ) { if ( false === strpos( $wp_version, '-' ) ) {
return false; return false;
} }

View File

@ -103,7 +103,7 @@ class WP_Site_Health {
if ( 'site-health' === $screen->id && ! isset( $_GET['tab'] ) ) { if ( 'site-health' === $screen->id && ! isset( $_GET['tab'] ) ) {
$tests = WP_Site_Health::get_tests(); $tests = WP_Site_Health::get_tests();
// Don't run https test on localhost // Don't run https test on localhost.
if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) { if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) {
unset( $tests['direct']['https_status'] ); unset( $tests['direct']['https_status'] );
} }
@ -1217,7 +1217,7 @@ class WP_Site_Health {
__( 'Your MySQL version supports utf8mb4.' ) __( 'Your MySQL version supports utf8mb4.' )
); );
} }
} else { // MariaDB introduced utf8mb4 support in 5.5.0 } else { // MariaDB introduced utf8mb4 support in 5.5.0.
if ( version_compare( $this->mysql_server_version, '5.5.0', '<' ) ) { if ( version_compare( $this->mysql_server_version, '5.5.0', '<' ) ) {
$result['status'] = 'recommended'; $result['status'] = 'recommended';
@ -2235,7 +2235,7 @@ class WP_Site_Health {
'critical' => 0, 'critical' => 0,
); );
// Don't run https test on localhost // Don't run https test on localhost.
if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) { if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) {
unset( $tests['direct']['https_status'] ); unset( $tests['direct']['https_status'] );
} }

View File

@ -154,7 +154,7 @@ class WP_Site_Icon {
natsort( $this->site_icon_sizes ); natsort( $this->site_icon_sizes );
$this->site_icon_sizes = array_reverse( $this->site_icon_sizes ); $this->site_icon_sizes = array_reverse( $this->site_icon_sizes );
// ensure that we only resize the image into // Ensure that we only resize the image into sizes that allow cropping.
foreach ( $sizes as $name => $size_array ) { foreach ( $sizes as $name => $size_array ) {
if ( isset( $size_array['crop'] ) ) { if ( isset( $size_array['crop'] ) ) {
$only_crop_sizes[ $name ] = $size_array; $only_crop_sizes[ $name ] = $size_array;

View File

@ -139,7 +139,7 @@ class WP_Terms_List_Table extends WP_List_Table {
* @return bool * @return bool
*/ */
public function has_items() { public function has_items() {
// todo: populate $this->items in prepare_items() // @todo Populate $this->items in prepare_items().
return true; return true;
} }
@ -254,7 +254,11 @@ class WP_Terms_List_Table extends WP_List_Table {
} else { } else {
$children = _get_term_hierarchy( $taxonomy ); $children = _get_term_hierarchy( $taxonomy );
} }
// Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake
/*
* Some funky recursion to get the job done (paging & parents mainly) is contained within.
* Skip it for non-hierarchical taxonomies for performance sake.
*/
$this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count );
} else { } else {
foreach ( $terms as $term ) { foreach ( $terms as $term ) {
@ -628,8 +632,11 @@ class WP_Terms_List_Table extends WP_List_Table {
} }
?> ?>
<form method="get"><table style="display: none"><tbody id="inlineedit"> <form method="get">
<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> <table style="display: none"><tbody id="inlineedit">
<tr id="inline-edit" class="inline-edit-row" style="display: none">
<td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
<fieldset> <fieldset>
<legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend> <legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend>
@ -638,50 +645,56 @@ class WP_Terms_List_Table extends WP_List_Table {
<span class="title"><?php _ex( 'Name', 'term name' ); ?></span> <span class="title"><?php _ex( 'Name', 'term name' ); ?></span>
<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
</label> </label>
<?php if ( ! global_terms_enabled() ) { ?>
<label>
<span class="title"><?php _e( 'Slug' ); ?></span>
<span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
</label>
<?php } ?>
</div></fieldset>
<?php
$core_columns = array( <?php if ( ! global_terms_enabled() ) : ?>
'cb' => true, <label>
'description' => true, <span class="title"><?php _e( 'Slug' ); ?></span>
'name' => true, <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
'slug' => true, </label>
'posts' => true, <?php endif; ?>
); </div>
</fieldset>
list( $columns ) = $this->get_column_info(); <?php
$core_columns = array(
'cb' => true,
'description' => true,
'name' => true,
'slug' => true,
'posts' => true,
);
foreach ( $columns as $column_name => $column_display_name ) { list( $columns ) = $this->get_column_info();
if ( isset( $core_columns[ $column_name ] ) ) {
continue; foreach ( $columns as $column_name => $column_display_name ) {
if ( isset( $core_columns[ $column_name ] ) ) {
continue;
}
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
} }
?>
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ <div class="inline-edit-save submit">
do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); <button type="button" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></button>
} <button type="button" class="save button button-primary alignright"><?php echo $tax->labels->update_item; ?></button>
<span class="spinner"></span>
?> <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
<br class="clear" />
<div class="inline-edit-save submit"> <div class="notice notice-error notice-alt inline hidden">
<button type="button" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></button> <p class="error"></p>
<button type="button" class="save button button-primary alignright"><?php echo $tax->labels->update_item; ?></button> </div>
<span class="spinner"></span>
<?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
<br class="clear" />
<div class="notice notice-error notice-alt inline hidden">
<p class="error"></p>
</div> </div>
</div>
</td></tr> </td></tr>
</tbody></table></form>
</tbody></table>
</form>
<?php <?php
} }
} }

View File

@ -231,7 +231,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
?> ?>
</div> </div>
<?php <?php
} // end foreach $theme_names } // End foreach $theme_names.
$this->theme_installer(); $this->theme_installer();
} }

View File

@ -300,14 +300,14 @@ class WP_Themes_List_Table extends WP_List_Table {
* @return bool * @return bool
*/ */
public function search_theme( $theme ) { public function search_theme( $theme ) {
// Search the features // Search the features.
foreach ( $this->features as $word ) { foreach ( $this->features as $word ) {
if ( ! in_array( $word, $theme->get( 'Tags' ) ) ) { if ( ! in_array( $word, $theme->get( 'Tags' ) ) ) {
return false; return false;
} }
} }
// Match all phrases // Match all phrases.
foreach ( $this->search_terms as $word ) { foreach ( $this->search_terms as $word ) {
if ( in_array( $word, $theme->get( 'Tags' ) ) ) { if ( in_array( $word, $theme->get( 'Tags' ) ) ) {
continue; continue;

View File

@ -195,7 +195,7 @@ class WP_Upgrader {
if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) { if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_errors() ) {
$error = $wp_filesystem->errors; $error = $wp_filesystem->errors;
} }
// Failed to connect, Error and request again // Failed to connect. Error and request again.
$this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership ); $this->skin->request_filesystem_credentials( $error, $directories[0], $allow_relaxed_file_ownership );
return false; return false;
} }
@ -238,7 +238,7 @@ class WP_Upgrader {
} }
} }
return true; return true;
} //end fs_connect(); }
/** /**
* Download a package. * Download a package.
@ -267,8 +267,8 @@ class WP_Upgrader {
return $reply; return $reply;
} }
if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { //Local file or remote? if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { // Local file or remote?
return $package; //must be a local file.. return $package; // Must be a local file.
} }
if ( empty( $package ) ) { if ( empty( $package ) ) {
@ -305,7 +305,7 @@ class WP_Upgrader {
$upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/'; $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
//Clean up contents of upgrade directory beforehand. // Clean up contents of upgrade directory beforehand.
$upgrade_files = $wp_filesystem->dirlist( $upgrade_folder ); $upgrade_files = $wp_filesystem->dirlist( $upgrade_folder );
if ( ! empty( $upgrade_files ) ) { if ( ! empty( $upgrade_files ) ) {
foreach ( $upgrade_files as $file ) { foreach ( $upgrade_files as $file ) {
@ -313,15 +313,15 @@ class WP_Upgrader {
} }
} }
// We need a working directory - Strip off any .tmp or .zip suffixes // We need a working directory - strip off any .tmp or .zip suffixes.
$working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' ); $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );
// Clean up working directory // Clean up working directory.
if ( $wp_filesystem->is_dir( $working_dir ) ) { if ( $wp_filesystem->is_dir( $working_dir ) ) {
$wp_filesystem->delete( $working_dir, true ); $wp_filesystem->delete( $working_dir, true );
} }
// Unzip package to working directory // Unzip package to working directory.
$result = unzip_file( $package, $working_dir ); $result = unzip_file( $package, $working_dir );
// Once extracted, delete the package if required. // Once extracted, delete the package if required.
@ -356,11 +356,11 @@ class WP_Upgrader {
foreach ( $nested_files as $name => $details ) { foreach ( $nested_files as $name => $details ) {
$files[ $path . $name ] = $details; $files[ $path . $name ] = $details;
// Append children recursively // Append children recursively.
if ( ! empty( $details['files'] ) ) { if ( ! empty( $details['files'] ) ) {
$children = $this->flatten_dirlist( $details['files'], $path . $name . '/' ); $children = $this->flatten_dirlist( $details['files'], $path . $name . '/' );
// Merge keeping possible numeric keys, which array_merge() will reindex from 0..n // Merge keeping possible numeric keys, which array_merge() will reindex from 0..n.
$files = $files + $children; $files = $files + $children;
} }
} }
@ -388,7 +388,7 @@ class WP_Upgrader {
return true; return true;
} }
// Flatten the file list to iterate over // Flatten the file list to iterate over.
$files = $this->flatten_dirlist( $files ); $files = $this->flatten_dirlist( $files );
// Check all files are writable before attempting to clear the destination. // Check all files are writable before attempting to clear the destination.
@ -450,8 +450,8 @@ class WP_Upgrader {
global $wp_filesystem, $wp_theme_directories; global $wp_filesystem, $wp_theme_directories;
$defaults = array( $defaults = array(
'source' => '', // Please always pass this 'source' => '', // Please always pass this.
'destination' => '', // and this 'destination' => '', // ...and this.
'clear_destination' => false, 'clear_destination' => false,
'clear_working' => false, 'clear_working' => false,
'abort_if_destination_exists' => true, 'abort_if_destination_exists' => true,
@ -490,19 +490,23 @@ class WP_Upgrader {
return $res; return $res;
} }
//Retain the Original source and destinations // Retain the original source and destinations.
$remote_source = $args['source']; $remote_source = $args['source'];
$local_destination = $destination; $local_destination = $destination;
$source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) ); $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) );
$remote_destination = $wp_filesystem->find_folder( $local_destination ); $remote_destination = $wp_filesystem->find_folder( $local_destination );
//Locate which directory to copy to the new folder, This is based on the actual folder holding the files. // Locate which directory to copy to the new folder. This is based on the actual folder holding the files.
if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents. if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) {
// Only one folder? Then we want its contents.
$source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] ); $source = trailingslashit( $args['source'] ) . trailingslashit( $source_files[0] );
} elseif ( count( $source_files ) == 0 ) { } elseif ( count( $source_files ) == 0 ) {
return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); // There are no files? // There are 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. 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.
$source = trailingslashit( $args['source'] ); $source = trailingslashit( $args['source'] );
} }
@ -568,21 +572,22 @@ class WP_Upgrader {
return $removed; return $removed;
} }
} elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) { } 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. // 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. // But first check to see if there are actually any files in the folder.
$_files = $wp_filesystem->dirlist( $remote_destination ); $_files = $wp_filesystem->dirlist( $remote_destination );
if ( ! empty( $_files ) ) { if ( ! empty( $_files ) ) {
$wp_filesystem->delete( $remote_source, true ); //Clear out the source files. $wp_filesystem->delete( $remote_source, true ); // Clear out the source files.
return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination ); return new WP_Error( 'folder_exists', $this->strings['folder_exists'], $remote_destination );
} }
} }
//Create destination if needed // Create destination if needed.
if ( ! $wp_filesystem->exists( $remote_destination ) ) { if ( ! $wp_filesystem->exists( $remote_destination ) ) {
if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) { if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {
return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination ); return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination );
} }
} }
// Copy new version of item into place. // Copy new version of item into place.
$result = copy_dir( $source, $remote_destination ); $result = copy_dir( $source, $remote_destination );
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
@ -592,7 +597,7 @@ class WP_Upgrader {
return $result; return $result;
} }
//Clear the Working folder? // Clear the working folder?
if ( $args['clear_working'] ) { if ( $args['clear_working'] ) {
$wp_filesystem->delete( $remote_source, true ); $wp_filesystem->delete( $remote_source, true );
} }
@ -620,7 +625,7 @@ class WP_Upgrader {
return $res; return $res;
} }
//Bombard the calling function will all the info which we've just used. // Bombard the calling function will all the info which we've just used.
return $this->result; return $this->result;
} }
@ -661,9 +666,9 @@ class WP_Upgrader {
$defaults = array( $defaults = array(
'package' => '', // Please always pass this. 'package' => '', // Please always pass this.
'destination' => '', // And this 'destination' => '', // ...and this.
'clear_destination' => false, 'clear_destination' => false,
'abort_if_destination_exists' => true, // Abort if the Destination directory exists, Pass clear_destination as false please 'abort_if_destination_exists' => true, // Abort if the destination directory exists. Pass clear_destination as false please.
'clear_working' => true, 'clear_working' => true,
'is_multi' => false, 'is_multi' => false,
'hook_extra' => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters. 'hook_extra' => array(), // Pass any extra $hook_extra args here, this will be passed to any hooked filters.
@ -703,11 +708,11 @@ class WP_Upgrader {
*/ */
$options = apply_filters( 'upgrader_package_options', $options ); $options = apply_filters( 'upgrader_package_options', $options );
if ( ! $options['is_multi'] ) { // call $this->header separately if running multiple times if ( ! $options['is_multi'] ) { // Call $this->header separately if running multiple times.
$this->skin->header(); $this->skin->header();
} }
// Connect to the Filesystem first. // Connect to the filesystem first.
$res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) ); $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) );
// Mainly for non-connected filesystem. // Mainly for non-connected filesystem.
if ( ! $res ) { if ( ! $res ) {
@ -740,7 +745,7 @@ class WP_Upgrader {
// Don't output the 'no signature could be found' failure message for now. // Don't output the 'no signature could be found' failure message for now.
if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) { if ( 'signature_verification_no_signature' != $download->get_error_code() || WP_DEBUG ) {
// Outout the failure error as a normal feedback, and not as an error: // Output the failure error as a normal feedback, and not as an error.
$this->skin->feedback( $download->get_error_message() ); $this->skin->feedback( $download->get_error_message() );
// Report this failure back to WordPress.org for debugging purposes. // Report this failure back to WordPress.org for debugging purposes.
@ -765,7 +770,7 @@ class WP_Upgrader {
return $download; return $download;
} }
$delete_package = ( $download != $options['package'] ); // Do not delete a "local" file $delete_package = ( $download != $options['package'] ); // Do not delete a "local" file.
// Unzips the file into a temporary directory. // Unzips the file into a temporary directory.
$working_dir = $this->unpack_package( $download, $delete_package ); $working_dir = $this->unpack_package( $download, $delete_package );
@ -857,7 +862,7 @@ class WP_Upgrader {
$file = $wp_filesystem->abspath() . '.maintenance'; $file = $wp_filesystem->abspath() . '.maintenance';
if ( $enable ) { if ( $enable ) {
$this->skin->feedback( 'maintenance_start' ); $this->skin->feedback( 'maintenance_start' );
// Create maintenance file to signal that we are upgrading // Create maintenance file to signal that we are upgrading.
$maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
$wp_filesystem->delete( $file ); $wp_filesystem->delete( $file );
$wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE ); $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE );

View File

@ -137,7 +137,7 @@ class WP_Users_List_Table extends WP_List_Table {
*/ */
$args = apply_filters( 'users_list_table_query_args', $args ); $args = apply_filters( 'users_list_table_query_args', $args );
// Query the user IDs for this page // Query the user IDs for this page.
$wp_user_search = new WP_User_Query( $args ); $wp_user_search = new WP_User_Query( $args );
$this->items = $wp_user_search->get_results(); $this->items = $wp_user_search->get_results();
@ -166,7 +166,7 @@ class WP_Users_List_Table extends WP_List_Table {
* Provides a list of roles and user count for that role for easy * Provides a list of roles and user count for that role for easy
* Filtersing of the user table. * Filtersing of the user table.
* *
* @since 3.1.0 * @since 3.1.0
* *
* @global string $role * @global string $role
* *
@ -257,7 +257,7 @@ class WP_Users_List_Table extends WP_List_Table {
/** /**
* Retrieve an associative array of bulk actions available on this table. * Retrieve an associative array of bulk actions available on this table.
* *
* @since 3.1.0 * @since 3.1.0
* *
* @return string[] Array of bulk action labels keyed by their action. * @return string[] Array of bulk action labels keyed by their action.
*/ */
@ -330,7 +330,7 @@ class WP_Users_List_Table extends WP_List_Table {
* Overridden from the base class implementation to capture * Overridden from the base class implementation to capture
* the role change drop-down. * the role change drop-down.
* *
* @since 3.1.0 * @since 3.1.0
* *
* @return string The bulk action required. * @return string The bulk action required.
*/ */
@ -346,7 +346,7 @@ class WP_Users_List_Table extends WP_List_Table {
/** /**
* Get a list of columns for the list table. * Get a list of columns for the list table.
* *
* @since 3.1.0 * @since 3.1.0
* *
* @return string[] Array of column titles keyed by their column name. * @return string[] Array of column titles keyed by their column name.
*/ */
@ -389,7 +389,7 @@ class WP_Users_List_Table extends WP_List_Table {
* @since 3.1.0 * @since 3.1.0
*/ */
public function display_rows() { public function display_rows() {
// Query the post counts for this page // Query the post counts for this page.
if ( ! $this->is_site_users ) { if ( ! $this->is_site_users ) {
$post_counts = count_many_users_posts( array_keys( $this->items ) ); $post_counts = count_many_users_posts( array_keys( $this->items ) );
} }
@ -428,7 +428,7 @@ class WP_Users_List_Table extends WP_List_Table {
$user_roles = $this->get_role_list( $user_object ); $user_roles = $this->get_role_list( $user_object );
// Set up the hover actions for this user // Set up the hover actions for this user.
$actions = array(); $actions = array();
$checkbox = ''; $checkbox = '';
$super_admin = ''; $super_admin = '';
@ -439,9 +439,9 @@ class WP_Users_List_Table extends WP_List_Table {
} }
} }
// Check if the user for this row is editable // Check if the user for this row is editable.
if ( current_user_can( 'list_users' ) ) { if ( current_user_can( 'list_users' ) ) {
// Set up the user editing link // Set up the user editing link.
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) ); $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) );
if ( current_user_can( 'edit_user', $user_object->ID ) ) { if ( current_user_can( 'edit_user', $user_object->ID ) ) {
@ -485,7 +485,7 @@ class WP_Users_List_Table extends WP_List_Table {
// Role classes. // Role classes.
$role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) ); $role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) );
// Set up the checkbox ( because the user is editable, otherwise it's empty ) // Set up the checkbox (because the user is editable, otherwise it's empty).
$checkbox = sprintf( $checkbox = sprintf(
'<label class="screen-reader-text" for="user_%1$s">%2$s</label>' . '<label class="screen-reader-text" for="user_%1$s">%2$s</label>' .
'<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />', '<input type="checkbox" name="users[]" id="user_%1$s" class="%3$s" value="%1$s" />',
@ -514,7 +514,7 @@ class WP_Users_List_Table extends WP_List_Table {
$classes .= ' has-row-actions column-primary'; $classes .= ' has-row-actions column-primary';
} }
if ( 'posts' === $column_name ) { if ( 'posts' === $column_name ) {
$classes .= ' num'; // Special case for that column $classes .= ' num'; // Special case for that column.
} }
if ( in_array( $column_name, $hidden ) ) { if ( in_array( $column_name, $hidden ) ) {

View File

@ -79,16 +79,17 @@ function edit_comment() {
} }
if ( ! empty( $_POST['edit_date'] ) ) { if ( ! empty( $_POST['edit_date'] ) ) {
$aa = $_POST['aa']; $aa = $_POST['aa'];
$mm = $_POST['mm']; $mm = $_POST['mm'];
$jj = $_POST['jj']; $jj = $_POST['jj'];
$hh = $_POST['hh']; $hh = $_POST['hh'];
$mn = $_POST['mn']; $mn = $_POST['mn'];
$ss = $_POST['ss']; $ss = $_POST['ss'];
$jj = ( $jj > 31 ) ? 31 : $jj; $jj = ( $jj > 31 ) ? 31 : $jj;
$hh = ( $hh > 23 ) ? $hh - 24 : $hh; $hh = ( $hh > 23 ) ? $hh - 24 : $hh;
$mn = ( $mn > 59 ) ? $mn - 60 : $mn; $mn = ( $mn > 59 ) ? $mn - 60 : $mn;
$ss = ( $ss > 59 ) ? $ss - 60 : $ss; $ss = ( $ss > 59 ) ? $ss - 60 : $ss;
$_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
} }

View File

@ -15,7 +15,7 @@
* @return array|false A list of all of the contributors, or false on error. * @return array|false A list of all of the contributors, or false on error.
*/ */
function wp_credits() { function wp_credits() {
// include an unmodified $wp_version // Include an unmodified $wp_version.
include( ABSPATH . WPINC . '/version.php' ); include( ABSPATH . WPINC . '/version.php' );
$locale = get_user_locale(); $locale = get_user_locale();

View File

@ -263,7 +263,7 @@ function wp_dashboard() {
} }
// //
// Dashboard Widgets // Dashboard Widgets.
// //
/** /**
@ -1116,7 +1116,7 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
} }
// //
// Dashboard Widgets Controls // Dashboard Widgets Controls.
// //
/** /**
@ -1627,7 +1627,7 @@ function wp_dashboard_browser_nag() {
* @param string $notice The notice content. * @param string $notice The notice content.
* @param array $response An array containing web browser information. See `wp_check_browser_version()`. * @param array $response An array containing web browser information. See `wp_check_browser_version()`.
*/ */
echo apply_filters( 'browse-happy-notice', $notice, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores echo apply_filters( 'browse-happy-notice', $notice, $response ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
} }
/** /**

View File

@ -1214,7 +1214,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f
// Check for a edge-case affecting PHP Maths abilities. // Check for a edge-case affecting PHP Maths abilities.
if ( if (
! extension_loaded( 'sodium' ) && ! extension_loaded( 'sodium' ) &&
in_array( PHP_VERSION_ID, [ 70200, 70201, 70202 ], true ) && in_array( PHP_VERSION_ID, array( 70200, 70201, 70202 ), true ) &&
extension_loaded( 'opcache' ) 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. // 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.
@ -1546,7 +1546,7 @@ function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) {
return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) ); return new WP_Error( 'stat_failed_ziparchive', __( 'Could not retrieve file from archive.' ) );
} }
if ( '/' == substr( $info['name'], -1 ) ) { // directory if ( '/' == substr( $info['name'], -1 ) ) { // Directory.
continue; continue;
} }

View File

@ -272,8 +272,8 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
*/ */
$threshold = (int) apply_filters( 'big_image_size_threshold', 2560, $imagesize, $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 // If the original image's dimensions are over the threshold,
// and use it as the "full" size. // scale the image and use it as the "full" size.
if ( $threshold && ( $image_meta['width'] > $threshold || $image_meta['height'] > $threshold ) ) { if ( $threshold && ( $image_meta['width'] > $threshold || $image_meta['height'] > $threshold ) ) {
$editor = wp_get_image_editor( $file ); $editor = wp_get_image_editor( $file );
@ -282,7 +282,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
return $image_meta; return $image_meta;
} }
// Resize the image // Resize the image.
$resized = $editor->resize( $threshold, $threshold ); $resized = $editor->resize( $threshold, $threshold );
$rotated = null; $rotated = null;
@ -305,10 +305,10 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
$image_meta['image_meta']['orientation'] = 1; $image_meta['image_meta']['orientation'] = 1;
} }
} else { } else {
// TODO: log errors. // TODO: Log errors.
} }
} else { } else {
// TODO: log errors. // TODO: Log errors.
} }
} elseif ( ! empty( $exif_meta['orientation'] ) && (int) $exif_meta['orientation'] !== 1 ) { } elseif ( ! empty( $exif_meta['orientation'] ) && (int) $exif_meta['orientation'] !== 1 ) {
// Rotate the whole original image if there is EXIF data and "orientation" is not 1. // Rotate the whole original image if there is EXIF data and "orientation" is not 1.
@ -335,7 +335,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) {
$image_meta['image_meta']['orientation'] = 1; $image_meta['image_meta']['orientation'] = 1;
} }
} else { } else {
// TODO: log errors. // TODO: Log errors.
} }
} }
} }
@ -434,7 +434,7 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) {
$rotated = $editor->maybe_exif_rotate(); $rotated = $editor->maybe_exif_rotate();
if ( is_wp_error( $rotated ) ) { if ( is_wp_error( $rotated ) ) {
// TODO: log errors. // TODO: Log errors.
} }
} }
@ -443,7 +443,7 @@ function _wp_make_subsizes( $new_sizes, $file, $image_meta, $attachment_id ) {
$new_size_meta = $editor->make_subsize( $new_size_data ); $new_size_meta = $editor->make_subsize( $new_size_data );
if ( is_wp_error( $new_size_meta ) ) { if ( is_wp_error( $new_size_meta ) ) {
// TODO: log errors. // TODO: Log errors.
} else { } else {
// Save the size meta value. // Save the size meta value.
$image_meta['sizes'][ $new_size_name ] = $new_size_meta; $image_meta['sizes'][ $new_size_name ] = $new_size_meta;
@ -575,7 +575,7 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
if ( ! empty( $merged_sizes ) ) { if ( ! empty( $merged_sizes ) ) {
$editor = wp_get_image_editor( $file ); $editor = wp_get_image_editor( $file );
if ( ! is_wp_error( $editor ) ) { // No support for this type of file if ( ! is_wp_error( $editor ) ) { // No support for this type of file.
/* /*
* PDFs may have the same file filename as JPEGs. * PDFs may have the same file filename as JPEGs.
* Ensure the PDF preview image does not overwrite any JPEG images that already exist. * Ensure the PDF preview image does not overwrite any JPEG images that already exist.
@ -715,18 +715,18 @@ function wp_read_image_metadata( $file ) {
if ( ! empty( $info['APP13'] ) ) { if ( ! empty( $info['APP13'] ) ) {
$iptc = @iptcparse( $info['APP13'] ); $iptc = @iptcparse( $info['APP13'] );
// Headline, "A brief synopsis of the caption." // Headline, "A brief synopsis of the caption".
if ( ! empty( $iptc['2#105'][0] ) ) { if ( ! empty( $iptc['2#105'][0] ) ) {
$meta['title'] = trim( $iptc['2#105'][0] ); $meta['title'] = trim( $iptc['2#105'][0] );
/* /*
* Title, "Many use the Title field to store the filename of the image, * Title, "Many use the Title field to store the filename of the image,
* though the field may be used in many ways." * though the field may be used in many ways".
*/ */
} elseif ( ! empty( $iptc['2#005'][0] ) ) { } elseif ( ! empty( $iptc['2#005'][0] ) ) {
$meta['title'] = trim( $iptc['2#005'][0] ); $meta['title'] = trim( $iptc['2#005'][0] );
} }
if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption if ( ! empty( $iptc['2#120'][0] ) ) { // Description / legacy caption.
$caption = trim( $iptc['2#120'][0] ); $caption = trim( $iptc['2#120'][0] );
mbstring_binary_safe_encoding(); mbstring_binary_safe_encoding();

View File

@ -136,7 +136,8 @@ function wp_import_handle_upload() {
* @return array Importers with metadata for each. * @return array Importers with metadata for each.
*/ */
function wp_get_popular_importers() { function wp_get_popular_importers() {
include( ABSPATH . WPINC . '/version.php' ); // Include an unmodified $wp_version. // Include an unmodified $wp_version.
include( ABSPATH . WPINC . '/version.php' );
$locale = get_user_locale(); $locale = get_user_locale();
$cache_key = 'popular_importers_' . md5( $locale . $wp_version ); $cache_key = 'popular_importers_' . md5( $locale . $wp_version );

View File

@ -770,7 +770,7 @@ function media_upload_form_handler() {
if ( $image_alt != get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) { if ( $image_alt != get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) {
$image_alt = wp_strip_all_tags( $image_alt, true ); $image_alt = wp_strip_all_tags( $image_alt, true );
// Update_meta expects slashed. // update_post_meta() expects slashed.
update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) ); update_post_meta( $attachment_id, '_wp_attachment_image_alt', wp_slash( $image_alt ) );
} }
} }
@ -2529,7 +2529,7 @@ function media_upload_gallery_form( $errors ) {
</div> </div>
<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form"> <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="gallery-form">
<?php wp_nonce_field( 'media-form' ); ?> <?php wp_nonce_field( 'media-form' ); ?>
<?php //media_upload_form( $errors ); ?> <?php // media_upload_form( $errors ); ?>
<table class="widefat"> <table class="widefat">
<thead><tr> <thead><tr>
<th><?php _e( 'Media' ); ?></th> <th><?php _e( 'Media' ); ?></th>
@ -2831,7 +2831,7 @@ function media_upload_library_form( $errors ) {
<form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form"> <form enctype="multipart/form-data" method="post" action="<?php echo esc_url( $form_action_url ); ?>" class="<?php echo $form_class; ?>" id="library-form">
<?php wp_nonce_field( 'media-form' ); ?> <?php wp_nonce_field( 'media-form' ); ?>
<?php //media_upload_form( $errors ); ?> <?php // media_upload_form( $errors ); ?>
<script type="text/javascript"> <script type="text/javascript">
jQuery(function($){ jQuery(function($){

View File

@ -321,7 +321,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
} }
$stripped_email = str_replace( '@', '-at-', $email_address ); $stripped_email = str_replace( '@', '-at-', $email_address );
$stripped_email = sanitize_title( $stripped_email ); // slugify the email address $stripped_email = sanitize_title( $stripped_email ); // Slugify the email address.
$obscura = wp_generate_password( 32, false, false ); $obscura = wp_generate_password( 32, false, false );
$file_basename = 'wp-personal-data-file-' . $stripped_email . '-' . $obscura; $file_basename = 'wp-personal-data-file-' . $stripped_email . '-' . $obscura;
$html_report_filename = $file_basename . '.html'; $html_report_filename = $file_basename . '.html';

View File

@ -55,7 +55,7 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
$compare_to = $temp; $compare_to = $temp;
} }
// Add default title if title field is empty // Add default title if title field is empty.
if ( $compare_from && empty( $compare_from->post_title ) ) { if ( $compare_from && empty( $compare_from->post_title ) ) {
$compare_from->post_title = __( '(no title)' ); $compare_from->post_title = __( '(no title)' );
} }
@ -340,7 +340,7 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
'from' => $from, 'from' => $from,
'diffData' => $diffs, 'diffData' => $diffs,
'baseUrl' => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ), 'baseUrl' => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ),
'compareTwoMode' => absint( $compare_two_mode ), // Apparently booleans are not allowed 'compareTwoMode' => absint( $compare_two_mode ), // Apparently booleans are not allowed.
'revisionIds' => array_keys( $revisions ), 'revisionIds' => array_keys( $revisions ),
); );
} }

View File

@ -52,7 +52,7 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
*/ */
$max_index_length = 191; $max_index_length = 191;
// Blog specific tables. // Blog-specific tables.
$blog_tables = "CREATE TABLE $wpdb->termmeta ( $blog_tables = "CREATE TABLE $wpdb->termmeta (
meta_id bigint(20) unsigned NOT NULL auto_increment, meta_id bigint(20) unsigned NOT NULL auto_increment,
term_id bigint(20) unsigned NOT NULL default '0', term_id bigint(20) unsigned NOT NULL default '0',
@ -205,7 +205,7 @@ CREATE TABLE $wpdb->posts (
KEY user_email (user_email) KEY user_email (user_email)
) $charset_collate;\n"; ) $charset_collate;\n";
// Multisite users table // Multisite users table.
$users_multi_table = "CREATE TABLE $wpdb->users ( $users_multi_table = "CREATE TABLE $wpdb->users (
ID bigint(20) unsigned NOT NULL auto_increment, ID bigint(20) unsigned NOT NULL auto_increment,
user_login varchar(60) NOT NULL default '', user_login varchar(60) NOT NULL default '',
@ -236,7 +236,7 @@ CREATE TABLE $wpdb->posts (
KEY meta_key (meta_key($max_index_length)) KEY meta_key (meta_key($max_index_length))
) $charset_collate;\n"; ) $charset_collate;\n";
// Global tables // Global tables.
if ( $is_multisite ) { if ( $is_multisite ) {
$global_tables = $users_multi_table . $usermeta_table; $global_tables = $users_multi_table . $usermeta_table;
} else { } else {
@ -547,7 +547,7 @@ function populate_options( array $options = array() ) {
? $wp_current_db_version : $wp_db_version; ? $wp_current_db_version : $wp_db_version;
} }
// 3.0 multisite // 3.0 multisite.
if ( is_multisite() ) { if ( is_multisite() ) {
/* translators: %s: Network title. */ /* translators: %s: Network title. */
$defaults['blogdescription'] = sprintf( __( 'Just another %s site' ), get_network()->site_name ); $defaults['blogdescription'] = sprintf( __( 'Just another %s site' ), get_network()->site_name );
@ -556,7 +556,7 @@ function populate_options( array $options = array() ) {
$options = wp_parse_args( $options, $defaults ); $options = wp_parse_args( $options, $defaults );
// Set autoload to no for these options // Set autoload to no for these options.
$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' ); $fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' );
$keys = "'" . implode( "', '", array_keys( $options ) ) . "'"; $keys = "'" . implode( "', '", array_keys( $options ) ) . "'";
@ -677,7 +677,7 @@ function populate_options( array $options = array() ) {
// Delete obsolete magpie stuff. // Delete obsolete magpie stuff.
$wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'" ); $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name REGEXP '^rss_[0-9a-f]{32}(_ts)?$'" );
// Clear expired transients // Clear expired transients.
delete_expired_transients( true ); delete_expired_transients( true );
} }
@ -703,15 +703,14 @@ function populate_roles() {
* @since 2.0.0 * @since 2.0.0
*/ */
function populate_roles_160() { function populate_roles_160() {
// Add roles // Add roles.
add_role( 'administrator', 'Administrator' ); add_role( 'administrator', 'Administrator' );
add_role( 'editor', 'Editor' ); add_role( 'editor', 'Editor' );
add_role( 'author', 'Author' ); add_role( 'author', 'Author' );
add_role( 'contributor', 'Contributor' ); add_role( 'contributor', 'Contributor' );
add_role( 'subscriber', 'Subscriber' ); add_role( 'subscriber', 'Subscriber' );
// Add caps for Administrator role // Add caps for Administrator role.
$role = get_role( 'administrator' ); $role = get_role( 'administrator' );
$role->add_cap( 'switch_themes' ); $role->add_cap( 'switch_themes' );
$role->add_cap( 'edit_themes' ); $role->add_cap( 'edit_themes' );
@ -744,7 +743,7 @@ function populate_roles_160() {
$role->add_cap( 'level_1' ); $role->add_cap( 'level_1' );
$role->add_cap( 'level_0' ); $role->add_cap( 'level_0' );
// Add caps for Editor role // Add caps for Editor role.
$role = get_role( 'editor' ); $role = get_role( 'editor' );
$role->add_cap( 'moderate_comments' ); $role->add_cap( 'moderate_comments' );
$role->add_cap( 'manage_categories' ); $role->add_cap( 'manage_categories' );
@ -766,7 +765,7 @@ function populate_roles_160() {
$role->add_cap( 'level_1' ); $role->add_cap( 'level_1' );
$role->add_cap( 'level_0' ); $role->add_cap( 'level_0' );
// Add caps for Author role // Add caps for Author role.
$role = get_role( 'author' ); $role = get_role( 'author' );
$role->add_cap( 'upload_files' ); $role->add_cap( 'upload_files' );
$role->add_cap( 'edit_posts' ); $role->add_cap( 'edit_posts' );
@ -777,14 +776,14 @@ function populate_roles_160() {
$role->add_cap( 'level_1' ); $role->add_cap( 'level_1' );
$role->add_cap( 'level_0' ); $role->add_cap( 'level_0' );
// Add caps for Contributor role // Add caps for Contributor role.
$role = get_role( 'contributor' ); $role = get_role( 'contributor' );
$role->add_cap( 'edit_posts' ); $role->add_cap( 'edit_posts' );
$role->add_cap( 'read' ); $role->add_cap( 'read' );
$role->add_cap( 'level_1' ); $role->add_cap( 'level_1' );
$role->add_cap( 'level_0' ); $role->add_cap( 'level_0' );
// Add caps for Subscriber role // Add caps for Subscriber role.
$role = get_role( 'subscriber' ); $role = get_role( 'subscriber' );
$role->add_cap( 'read' ); $role->add_cap( 'read' );
$role->add_cap( 'level_0' ); $role->add_cap( 'level_0' );
@ -1244,7 +1243,7 @@ We hope you enjoy your new site. Thanks!
'welcome_email' => $welcome_email, 'welcome_email' => $welcome_email,
/* translators: %s: Site link. */ /* translators: %s: Site link. */
'first_post' => __( 'Welcome to %s. This is your first post. Edit or delete it, then start writing!' ), 'first_post' => __( 'Welcome to %s. This is your first post. Edit or delete it, then start writing!' ),
// @todo - network admins should have a method of editing the network siteurl (used for cookie hash) // @todo - Network admins should have a method of editing the network siteurl (used for cookie hash).
'siteurl' => get_option( 'siteurl' ) . '/', 'siteurl' => get_option( 'siteurl' ) . '/',
'add_new_users' => '0', 'add_new_users' => '0',
'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', 'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1',

View File

@ -117,7 +117,7 @@ function meta_box_prefs( $screen ) {
if ( false == $box || ! $box['title'] ) { if ( false == $box || ! $box['title'] ) {
continue; continue;
} }
// Submit box cannot be hidden // Submit box cannot be hidden.
if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) { if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) {
continue; continue;
} }
@ -156,7 +156,7 @@ function get_hidden_meta_boxes( $screen ) {
$use_defaults = ! is_array( $hidden ); $use_defaults = ! is_array( $hidden );
// Hide slug boxes by default // Hide slug boxes by default.
if ( $use_defaults ) { if ( $use_defaults ) {
$hidden = array(); $hidden = array();
if ( 'post' == $screen->base ) { if ( 'post' == $screen->base ) {

View File

@ -7,7 +7,7 @@
*/ */
// //
// Category // Category.
// //
/** /**
@ -192,7 +192,7 @@ function wp_update_category( $catarr ) {
return false; return false;
} }
// First, get all of the original fields // First, get all of the original fields.
$category = get_term( $cat_ID, 'category', ARRAY_A ); $category = get_term( $cat_ID, 'category', ARRAY_A );
_make_cat_compat( $category ); _make_cat_compat( $category );
@ -206,7 +206,7 @@ function wp_update_category( $catarr ) {
} }
// //
// Tags // Tags.
// //
/** /**

View File

@ -15,7 +15,7 @@ require_once( ABSPATH . 'wp-admin/includes/class-walker-category-checklist.php'
require_once( ABSPATH . 'wp-admin/includes/class-wp-internal-pointers.php' ); require_once( ABSPATH . 'wp-admin/includes/class-wp-internal-pointers.php' );
// //
// Category Checklists // Category Checklists.
// //
/** /**
@ -165,7 +165,8 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
$output = ''; $output = '';
if ( $parsed_args['checked_ontop'] ) { 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(); $checked_categories = array();
$keys = array_keys( $categories ); $keys = array_keys( $categories );
@ -176,10 +177,10 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) {
} }
} }
// Put checked cats on top // Put checked categories on top.
$output .= $walker->walk( $checked_categories, 0, $args ); $output .= $walker->walk( $checked_categories, 0, $args );
} }
// Then the rest of them // Then the rest of them.
$output .= $walker->walk( $categories, 0, $args ); $output .= $walker->walk( $categories, 0, $args );
if ( $parsed_args['echo'] ) { if ( $parsed_args['echo'] ) {
@ -265,7 +266,7 @@ function wp_link_category_checklist( $link_id = 0 ) {
if ( $link_id ) { if ( $link_id ) {
$checked_categories = wp_get_link_cats( $link_id ); $checked_categories = wp_get_link_cats( $link_id );
// No selected categories, strange // No selected categories, strange.
if ( ! count( $checked_categories ) ) { if ( ! count( $checked_categories ) ) {
$checked_categories[] = $default; $checked_categories[] = $default;
} }
@ -559,7 +560,7 @@ function wp_comment_trashnotice() {
* @param array $meta * @param array $meta
*/ */
function list_meta( $meta ) { function list_meta( $meta ) {
// Exit if no meta // Exit if no meta.
if ( ! $meta ) { if ( ! $meta ) {
echo ' echo '
<table id="list-table" style="display: none;"> <table id="list-table" style="display: none;">
@ -572,7 +573,7 @@ function list_meta( $meta ) {
<tbody id="the-list" data-wp-lists="list:meta"> <tbody id="the-list" data-wp-lists="list:meta">
<tr><td></td></tr> <tr><td></td></tr>
</tbody> </tbody>
</table>'; //TBODY needed for list-manipulation JS </table>'; // TBODY needed for list-manipulation JS.
return; return;
} }
$count = 0; $count = 0;
@ -632,7 +633,7 @@ function _list_meta_row( $entry, &$count ) {
} }
$entry['meta_key'] = esc_attr( $entry['meta_key'] ); $entry['meta_key'] = esc_attr( $entry['meta_key'] );
$entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // using a <textarea /> $entry['meta_value'] = esc_textarea( $entry['meta_value'] ); // Using a <textarea />.
$entry['meta_id'] = (int) $entry['meta_id']; $entry['meta_id'] = (int) $entry['meta_id'];
$delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] );
@ -790,7 +791,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
$tab_index_attribute = " tabindex=\"$tab_index\""; $tab_index_attribute = " tabindex=\"$tab_index\"";
} }
// todo: Remove this? // @todo Remove this?
// echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
$post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date; $post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
@ -925,7 +926,7 @@ function wp_dropdown_roles( $selected = '' ) {
foreach ( $editable_roles as $role => $details ) { foreach ( $editable_roles as $role => $details ) {
$name = translate_user_role( $details['name'] ); $name = translate_user_role( $details['name'] );
// preselect specified role // Preselect specified role.
if ( $selected == $role ) { if ( $selected == $role ) {
$r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>"; $r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>";
} else { } else {
@ -1052,7 +1053,7 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
// If a core box was previously added or removed by a plugin, don't add. // If a core box was previously added or removed by a plugin, don't add.
if ( 'core' == $priority ) { if ( 'core' == $priority ) {
// If core box previously deleted, don't add // If core box previously deleted, don't add.
if ( false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) { if ( false === $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ) {
return; return;
} }
@ -1067,7 +1068,7 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
} }
return; return;
} }
// If no priority given and id already present, use existing priority. // If no priority given and ID already present, use existing priority.
if ( empty( $priority ) ) { if ( empty( $priority ) ) {
$priority = $a_priority; $priority = $a_priority;
/* /*
@ -1079,7 +1080,7 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan
$callback = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback']; $callback = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['callback'];
$callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args']; $callback_args = $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ]['args'];
} }
// An id can be in only one priority and one context. // An ID can be in only one priority and one context.
if ( $priority != $a_priority || $context != $a_context ) { if ( $priority != $a_priority || $context != $a_context ) {
unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] ); unset( $wp_meta_boxes[ $page ][ $a_context ][ $a_priority ][ $id ] );
} }
@ -1245,7 +1246,8 @@ function do_meta_boxes( $screen, $context, $object ) {
printf( '<div id="%s-sortables" class="meta-box-sortables">', esc_attr( $context ) ); 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" ); $sorted = get_user_option( "meta-box-order_$page" );
if ( ! $already_sorted && $sorted ) { if ( ! $already_sorted && $sorted ) {
foreach ( $sorted as $box_context => $ids ) { foreach ( $sorted as $box_context => $ids ) {
@ -2192,12 +2194,12 @@ function _media_states( $post ) {
} else { } else {
$header_image = get_header_image(); $header_image = get_header_image();
// Display "Header Image" if the image was ever used as a header image // Display "Header Image" if the image was ever used as a header image.
if ( ! empty( $meta_header ) && $meta_header == $stylesheet && $header_image !== wp_get_attachment_url( $post->ID ) ) { if ( ! empty( $meta_header ) && $meta_header == $stylesheet && $header_image !== wp_get_attachment_url( $post->ID ) ) {
$media_states[] = __( 'Header Image' ); $media_states[] = __( 'Header Image' );
} }
// Display "Current Header Image" if the image is currently the header image // Display "Current Header Image" if the image is currently the header image.
if ( $header_image && $header_image == wp_get_attachment_url( $post->ID ) ) { if ( $header_image && $header_image == wp_get_attachment_url( $post->ID ) ) {
$media_states[] = __( 'Current Header Image' ); $media_states[] = __( 'Current Header Image' );
} }
@ -2378,7 +2380,7 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit
$text = $text ? $text : __( 'Save Changes' ); $text = $text ? $text : __( 'Save Changes' );
// Default the id attribute to $name unless an id was specifically provided in $other_attributes // Default the id attribute to $name unless an id was specifically provided in $other_attributes.
$id = $name; $id = $name;
if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) { if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) {
$id = $other_attributes['id']; $id = $other_attributes['id'];
@ -2388,9 +2390,9 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit
$attributes = ''; $attributes = '';
if ( is_array( $other_attributes ) ) { if ( is_array( $other_attributes ) ) {
foreach ( $other_attributes as $attribute => $value ) { foreach ( $other_attributes as $attribute => $value ) {
$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important $attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important.
} }
} elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string } elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string.
$attributes = $other_attributes; $attributes = $other_attributes;
} }
@ -2533,15 +2535,15 @@ function wp_star_rating( $args = array() ) {
); );
$parsed_args = wp_parse_args( $args, $defaults ); $parsed_args = wp_parse_args( $args, $defaults );
// Non-English decimal places when the $rating is coming from a string // Non-English decimal places when the $rating is coming from a string.
$rating = (float) str_replace( ',', '.', $parsed_args['rating'] ); $rating = (float) str_replace( ',', '.', $parsed_args['rating'] );
// Convert Percentage to star rating, 0..5 in .5 increments // Convert percentage to star rating, 0..5 in .5 increments.
if ( 'percent' === $parsed_args['type'] ) { if ( 'percent' === $parsed_args['type'] ) {
$rating = round( $rating / 10, 0 ) / 2; $rating = round( $rating / 10, 0 ) / 2;
} }
// Calculate the number of each type of star needed // Calculate the number of each type of star needed.
$full_stars = floor( $rating ); $full_stars = floor( $rating );
$half_stars = ceil( $rating - $full_stars ); $half_stars = ceil( $rating - $full_stars );
$empty_stars = 5 - $full_stars - $half_stars; $empty_stars = 5 - $full_stars - $half_stars;

View File

@ -45,7 +45,8 @@ function delete_theme( $stylesheet, $redirect = '' ) {
if ( ! WP_Filesystem( $credentials ) ) { if ( ! WP_Filesystem( $credentials ) ) {
ob_start(); ob_start();
request_filesystem_credentials( $redirect, '', true ); // Failed to connect, Error and request again. // Failed to connect. Error and request again.
request_filesystem_credentials( $redirect, '', true );
$data = ob_get_clean(); $data = ob_get_clean();
if ( ! empty( $data ) ) { if ( ! empty( $data ) ) {
@ -194,7 +195,7 @@ function get_theme_update_available( $theme ) {
'height' => 800, 'height' => 800,
), ),
$update['url'] $update['url']
); //Theme browser inside WP? replace this, Also, theme preview JS will override this on the available list. ); // Theme browser inside WP? Replace this. Also, theme preview JS will override this on the available list.
$update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet ); $update_url = wp_nonce_url( admin_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet );
if ( ! is_multisite() ) { if ( ! is_multisite() ) {
@ -260,7 +261,7 @@ function get_theme_update_available( $theme ) {
* @return array Array of features keyed by category with translations keyed by slug. * @return array Array of features keyed by category with translations keyed by slug.
*/ */
function get_theme_feature_list( $api = true ) { function get_theme_feature_list( $api = true ) {
// Hard-coded list is used if api not accessible. // Hard-coded list is used if API is not accessible.
$features = array( $features = array(
__( 'Subject' ) => array( __( 'Subject' ) => array(
@ -331,7 +332,7 @@ function get_theme_feature_list( $api = true ) {
'Subject' => __( 'Subject' ), 'Subject' => __( 'Subject' ),
); );
// Loop over the wporg canonical list and apply translations // Loop over the wp.org canonical list and apply translations.
$wporg_features = array(); $wporg_features = array();
foreach ( (array) $feature_list as $feature_category => $feature_items ) { foreach ( (array) $feature_list as $feature_category => $feature_items ) {
if ( isset( $category_translations[ $feature_category ] ) ) { if ( isset( $category_translations[ $feature_category ] ) ) {
@ -433,7 +434,7 @@ function get_theme_feature_list( $api = true ) {
* for more information on the make-up of possible return objects depending on the value of `$action`. * for more information on the make-up of possible return objects depending on the value of `$action`.
*/ */
function themes_api( $action, $args = array() ) { function themes_api( $action, $args = array() ) {
// include an unmodified $wp_version // Include an unmodified $wp_version.
include( ABSPATH . WPINC . '/version.php' ); include( ABSPATH . WPINC . '/version.php' );
if ( is_array( $args ) ) { if ( is_array( $args ) ) {
@ -451,7 +452,7 @@ function themes_api( $action, $args = array() ) {
} }
if ( ! isset( $args->wp_version ) ) { if ( ! isset( $args->wp_version ) ) {
$args->wp_version = substr( $wp_version, 0, 3 ); // X.y $args->wp_version = substr( $wp_version, 0, 3 ); // x.y
} }
/** /**
@ -655,7 +656,7 @@ function wp_prepare_themes_for_js( $themes = null ) {
$prepared_themes[ $slug ] = array( $prepared_themes[ $slug ] = array(
'id' => $slug, 'id' => $slug,
'name' => $theme->display( 'Name' ), 'name' => $theme->display( 'Name' ),
'screenshot' => array( $theme->get_screenshot() ), // @todo multiple 'screenshot' => array( $theme->get_screenshot() ), // @todo Multiple screenshots.
'description' => $theme->display( 'Description' ), 'description' => $theme->display( 'Description' ),
'author' => $theme->display( 'Author', false, true ), 'author' => $theme->display( 'Author', false, true ),
'authorAndUri' => $theme->display( 'Author' ), 'authorAndUri' => $theme->display( 'Author' ),
@ -674,7 +675,7 @@ function wp_prepare_themes_for_js( $themes = null ) {
); );
} }
// Remove 'delete' action if theme has an active child // Remove 'delete' action if theme has an active child.
if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) { if ( ! empty( $parents ) && array_key_exists( $current_theme, $parents ) ) {
unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] ); unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] );
} }

View File

@ -17,7 +17,8 @@
* @return object|WP_Error On success an object of translations, WP_Error on failure. * @return object|WP_Error On success an object of translations, WP_Error on failure.
*/ */
function translations_api( $type, $args = null ) { function translations_api( $type, $args = null ) {
include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version // Include an unmodified $wp_version.
include( ABSPATH . WPINC . '/version.php' );
if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ) ) ) { if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ) ) ) {
return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) ); return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
@ -47,12 +48,12 @@ function translations_api( $type, $args = null ) {
'body' => array( 'body' => array(
'wp_version' => $wp_version, 'wp_version' => $wp_version,
'locale' => get_locale(), 'locale' => get_locale(),
'version' => $args['version'], // Version of plugin, theme or core 'version' => $args['version'], // Version of plugin, theme or core.
), ),
); );
if ( 'core' !== $type ) { if ( 'core' !== $type ) {
$options['body']['slug'] = $args['slug']; // Plugin or theme slug $options['body']['slug'] = $args['slug']; // Plugin or theme slug.
} }
$request = wp_remote_post( $url, $options ); $request = wp_remote_post( $url, $options );
@ -126,7 +127,8 @@ function wp_get_available_translations() {
} }
} }
include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version // Include an unmodified $wp_version.
include( ABSPATH . WPINC . '/version.php' );
$api = translations_api( 'core', array( 'version' => $wp_version ) ); $api = translations_api( 'core', array( 'version' => $wp_version ) );

View File

@ -253,7 +253,7 @@ $_old_files = array(
'wp-includes/js/jquery/autocomplete.js', 'wp-includes/js/jquery/autocomplete.js',
'wp-includes/js/jquery/interface.js', 'wp-includes/js/jquery/interface.js',
'wp-includes/js/scriptaculous/prototype.js', 'wp-includes/js/scriptaculous/prototype.js',
// Following file added back in 5.1 see #45645 // Following file added back in 5.1, see #45645.
//'wp-includes/js/tinymce/wp-tinymce.js', //'wp-includes/js/tinymce/wp-tinymce.js',
// 3.1 // 3.1
'wp-admin/edit-attachment-rows.php', 'wp-admin/edit-attachment-rows.php',
@ -536,7 +536,7 @@ $_old_files = array(
'wp-admin/images/screenshots/twitter-embed-1.png', 'wp-admin/images/screenshots/twitter-embed-1.png',
'wp-admin/images/screenshots/twitter-embed-2.png', 'wp-admin/images/screenshots/twitter-embed-2.png',
'wp-admin/js/utils.js', 'wp-admin/js/utils.js',
// Added back in 5.3 [45448], see #43895 // Added back in 5.3 [45448], see #43895.
// 'wp-admin/options-privacy.php', // 'wp-admin/options-privacy.php',
'wp-app.php', 'wp-app.php',
'wp-includes/class-wp-atom-server.php', 'wp-includes/class-wp-atom-server.php',
@ -600,7 +600,7 @@ $_old_files = array(
'wp-admin/css/colors.min.css', 'wp-admin/css/colors.min.css',
'wp-admin/css/colors-rtl.css', 'wp-admin/css/colors-rtl.css',
'wp-admin/css/colors-rtl.min.css', 'wp-admin/css/colors-rtl.min.css',
// Following files added back in 4.5 see #36083 // Following files added back in 4.5, see #36083.
// 'wp-admin/css/media-rtl.min.css', // 'wp-admin/css/media-rtl.min.css',
// 'wp-admin/css/media.min.css', // 'wp-admin/css/media.min.css',
// 'wp-admin/css/farbtastic-rtl.min.css', // 'wp-admin/css/farbtastic-rtl.min.css',
@ -615,7 +615,7 @@ $_old_files = array(
'wp-includes/js/plupload/changelog.txt', 'wp-includes/js/plupload/changelog.txt',
'wp-includes/js/plupload/plupload.silverlight.js', 'wp-includes/js/plupload/plupload.silverlight.js',
'wp-includes/js/plupload/plupload.flash.js', 'wp-includes/js/plupload/plupload.flash.js',
// Added back in 4.9 [41328], see #41755 // Added back in 4.9 [41328], see #41755.
// 'wp-includes/js/plupload/plupload.js', // 'wp-includes/js/plupload/plupload.js',
'wp-includes/js/tinymce/plugins/spellchecker', 'wp-includes/js/tinymce/plugins/spellchecker',
'wp-includes/js/tinymce/plugins/inlinepopups', 'wp-includes/js/tinymce/plugins/inlinepopups',
@ -787,7 +787,7 @@ $_old_files = array(
'wp-includes/random_compat/random_bytes_openssl.php', 'wp-includes/random_compat/random_bytes_openssl.php',
'wp-includes/js/tinymce/wp-tinymce.js.gz', 'wp-includes/js/tinymce/wp-tinymce.js.gz',
// 5.3 // 5.3
'wp-includes/js/wp-a11y.js', // Moved to: wp-includes/js/dist/a11y.js 'wp-includes/js/wp-a11y.js', // Moved to: wp-includes/js/dist/a11y.js
'wp-includes/js/wp-a11y.min.js', // Moved to: wp-includes/js/dist/a11y.min.js 'wp-includes/js/wp-a11y.min.js', // Moved to: wp-includes/js/dist/a11y.min.js
); );
@ -938,8 +938,8 @@ function update_core( $from, $to ) {
$php_version = phpversion(); $php_version = phpversion();
$mysql_version = $wpdb->db_version(); $mysql_version = $wpdb->db_version();
$old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from $old_wp_version = $GLOBALS['wp_version']; // The version of WordPress we're updating from.
$development_build = ( false !== strpos( $old_wp_version . $wp_version, '-' ) ); // a dash in the version indicates a Development release $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, '>=' ); $php_compat = version_compare( $php_version, $required_php_version, '>=' );
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) {
$mysql_compat = true; $mysql_compat = true;
@ -1017,19 +1017,19 @@ function update_core( $from, $to ) {
/** This filter is documented in wp-admin/includes/update-core.php */ /** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', __( 'Preparing to install the latest version&#8230;' ) ); apply_filters( 'update_feedback', __( 'Preparing to install the latest version&#8230;' ) );
// Don't copy wp-content, we'll deal with that below // Don't copy wp-content, we'll deal with that below.
// We also copy version.php last so failed updates report their old version // We also copy version.php last so failed updates report their old version.
$skip = array( 'wp-content', 'wp-includes/version.php' ); $skip = array( 'wp-content', 'wp-includes/version.php' );
$check_is_writable = array(); $check_is_writable = array();
// Check to see which files don't really need updating - only available for 3.7 and higher // Check to see which files don't really need updating - only available for 3.7 and higher.
if ( function_exists( 'get_core_checksums' ) ) { if ( function_exists( 'get_core_checksums' ) ) {
// Find the local version of the working directory // Find the local version of the working directory.
$working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro; $working_dir_local = WP_CONTENT_DIR . '/upgrade/' . basename( $from ) . $distro;
$checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' );
if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) { if ( is_array( $checksums ) && isset( $checksums[ $wp_version ] ) ) {
$checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2 $checksums = $checksums[ $wp_version ]; // Compat code for 3.7-beta2.
} }
if ( is_array( $checksums ) ) { if ( is_array( $checksums ) ) {
foreach ( $checksums as $file => $checksum ) { foreach ( $checksums as $file => $checksum ) {
@ -1078,7 +1078,7 @@ function update_core( $from, $to ) {
/** This filter is documented in wp-admin/includes/update-core.php */ /** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', __( 'Enabling Maintenance mode&#8230;' ) ); apply_filters( 'update_feedback', __( 'Enabling Maintenance mode&#8230;' ) );
// Create maintenance file to signal that we are upgrading // Create maintenance file to signal that we are upgrading.
$maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; $maintenance_string = '<?php $upgrading = ' . time() . '; ?>';
$maintenance_file = $to . '.maintenance'; $maintenance_file = $to . '.maintenance';
$wp_filesystem->delete( $maintenance_file ); $wp_filesystem->delete( $maintenance_file );
@ -1092,7 +1092,7 @@ function update_core( $from, $to ) {
$result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) ); $result = new WP_Error( $result->get_error_code(), $result->get_error_message(), substr( $result->get_error_data(), strlen( $to ) ) );
} }
// Since we know the core files have copied over, we can now copy the version file // Since we know the core files have copied over, we can now copy the version file.
if ( ! is_wp_error( $result ) ) { if ( ! is_wp_error( $result ) ) {
if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) { if ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) {
$wp_filesystem->delete( $from, true ); $wp_filesystem->delete( $from, true );
@ -1101,7 +1101,7 @@ function update_core( $from, $to ) {
$wp_filesystem->chmod( $to . 'wp-includes/version.php', FS_CHMOD_FILE ); $wp_filesystem->chmod( $to . 'wp-includes/version.php', FS_CHMOD_FILE );
} }
// Check to make sure everything copied correctly, ignoring the contents of wp-content // Check to make sure everything copied correctly, ignoring the contents of wp-content.
$skip = array( 'wp-content' ); $skip = array( 'wp-content' );
$failed = array(); $failed = array();
if ( isset( $checksums ) && is_array( $checksums ) ) { if ( isset( $checksums ) && is_array( $checksums ) ) {
@ -1124,7 +1124,7 @@ function update_core( $from, $to ) {
} }
} }
// Some files didn't copy properly // Some files didn't copy properly.
if ( ! empty( $failed ) ) { if ( ! empty( $failed ) ) {
$total_size = 0; $total_size = 0;
foreach ( $failed as $file ) { foreach ( $failed as $file ) {
@ -1146,8 +1146,8 @@ function update_core( $from, $to ) {
} }
} }
// Custom Content Directory needs updating now. // Custom content directory needs updating now.
// Copy Languages // Copy languages.
if ( ! is_wp_error( $result ) && $wp_filesystem->is_dir( $from . $distro . 'wp-content/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 ) ) { if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) {
$lang_dir = WP_LANG_DIR; $lang_dir = WP_LANG_DIR;
@ -1155,9 +1155,11 @@ function update_core( $from, $to ) {
$lang_dir = WP_CONTENT_DIR . '/languages'; $lang_dir = WP_CONTENT_DIR . '/languages';
} }
if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) { // Check the language directory exists first // Check if the language directory exists first.
$wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR ); // If it's within the ABSPATH we can handle it here, otherwise they're out of luck. if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) {
clearstatcache(); // for FTP, Need to clear the stat cache // If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
$wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR );
clearstatcache(); // For FTP, need to clear the stat cache.
} }
if ( @is_dir( $lang_dir ) ) { if ( @is_dir( $lang_dir ) ) {
@ -1173,7 +1175,7 @@ function update_core( $from, $to ) {
/** This filter is documented in wp-admin/includes/update-core.php */ /** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', __( 'Disabling Maintenance mode&#8230;' ) ); apply_filters( 'update_feedback', __( 'Disabling Maintenance mode&#8230;' ) );
// Remove maintenance file, we're done with potential site-breaking changes // Remove maintenance file, we're done with potential site-breaking changes.
$wp_filesystem->delete( $maintenance_file ); $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.
@ -1183,17 +1185,20 @@ function update_core( $from, $to ) {
} }
} }
// Copy New bundled plugins & themes /*
// This gives us the ability to install new plugins & themes bundled with future versions of WordPress whilst avoiding the re-install upon upgrade issue. * Copy new bundled plugins & themes.
// $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated * This gives us the ability to install new plugins & themes bundled with
* future versions of WordPress whilst avoiding the re-install upon upgrade issue.
* $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated.
*/
if ( ! is_wp_error( $result ) && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) { if ( ! is_wp_error( $result ) && ( ! defined( 'CORE_UPGRADE_SKIP_NEW_BUNDLED' ) || ! CORE_UPGRADE_SKIP_NEW_BUNDLED ) ) {
foreach ( (array) $_new_bundled_files as $file => $introduced_version ) { foreach ( (array) $_new_bundled_files as $file => $introduced_version ) {
// If a $development_build or if $introduced version is greater than what the site was previously running // If a $development_build or if $introduced version is greater than what the site was previously running.
if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) { if ( $development_build || version_compare( $introduced_version, $old_wp_version, '>' ) ) {
$directory = ( '/' == $file[ strlen( $file ) - 1 ] ); $directory = ( '/' == $file[ strlen( $file ) - 1 ] );
list($type, $filename) = explode( '/', $file, 2 ); list($type, $filename) = explode( '/', $file, 2 );
// Check to see if the bundled items exist before attempting to copy them // Check to see if the bundled items exist before attempting to copy them.
if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) ) { if ( ! $wp_filesystem->exists( $from . $distro . 'wp-content/' . $file ) ) {
continue; continue;
} }
@ -1201,7 +1206,8 @@ function update_core( $from, $to ) {
if ( 'plugins' == $type ) { if ( 'plugins' == $type ) {
$dest = $wp_filesystem->wp_plugins_dir(); $dest = $wp_filesystem->wp_plugins_dir();
} elseif ( 'themes' == $type ) { } elseif ( 'themes' == $type ) {
$dest = trailingslashit( $wp_filesystem->wp_themes_dir() ); // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2 // Back-compat, ::wp_themes_dir() did not return trailingslash'd pre-3.2.
$dest = trailingslashit( $wp_filesystem->wp_themes_dir() );
} else { } else {
continue; continue;
} }
@ -1231,16 +1237,16 @@ function update_core( $from, $to ) {
} }
} }
} }
} //end foreach } // End foreach.
} }
// Handle $result error from the above blocks // Handle $result error from the above blocks.
if ( is_wp_error( $result ) ) { if ( is_wp_error( $result ) ) {
$wp_filesystem->delete( $from, true ); $wp_filesystem->delete( $from, true );
return $result; return $result;
} }
// Remove old files // Remove old files.
foreach ( $_old_files as $old_file ) { foreach ( $_old_files as $old_file ) {
$old_file = $to . $old_file; $old_file = $to . $old_file;
if ( ! $wp_filesystem->exists( $old_file ) ) { if ( ! $wp_filesystem->exists( $old_file ) ) {
@ -1253,27 +1259,27 @@ function update_core( $from, $to ) {
} }
} }
// Remove any Genericons example.html's from the filesystem // Remove any Genericons example.html's from the filesystem.
_upgrade_422_remove_genericons(); _upgrade_422_remove_genericons();
// Remove the REST API plugin if its version is Beta 4 or lower // Remove the REST API plugin if its version is Beta 4 or lower.
_upgrade_440_force_deactivate_incompatible_plugins(); _upgrade_440_force_deactivate_incompatible_plugins();
// Upgrade DB with separate request // Upgrade DB with separate request.
/** This filter is documented in wp-admin/includes/update-core.php */ /** This filter is documented in wp-admin/includes/update-core.php */
apply_filters( 'update_feedback', __( 'Upgrading database&#8230;' ) ); apply_filters( 'update_feedback', __( 'Upgrading database&#8230;' ) );
$db_upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' ); $db_upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' );
wp_remote_post( $db_upgrade_url, array( 'timeout' => 60 ) ); wp_remote_post( $db_upgrade_url, array( 'timeout' => 60 ) );
// Clear the cache to prevent an update_option() from saving a stale db_version to the cache // Clear the cache to prevent an update_option() from saving a stale db_version to the cache.
wp_cache_flush(); wp_cache_flush();
// (Not all cache back ends listen to 'flush') // Not all cache back ends listen to 'flush'.
wp_cache_delete( 'alloptions', 'options' ); wp_cache_delete( 'alloptions', 'options' );
// Remove working directory // Remove working directory.
$wp_filesystem->delete( $from, true ); $wp_filesystem->delete( $from, true );
// Force refresh of update information // Force refresh of update information.
if ( function_exists( 'delete_site_transient' ) ) { if ( function_exists( 'delete_site_transient' ) ) {
delete_site_transient( 'update_core' ); delete_site_transient( 'update_core' );
} else { } else {
@ -1396,7 +1402,7 @@ function _redirect_to_about_wordpress( $new_version ) {
// Load the updated default text localization domain for new strings. // Load the updated default text localization domain for new strings.
load_default_textdomain(); load_default_textdomain();
// See do_core_upgrade() // See do_core_upgrade().
show_message( __( 'WordPress updated successfully' ) ); show_message( __( 'WordPress updated successfully' ) );
// self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional. // self_admin_url() won't exist when upgrading from <= 3.0, so relative URLs are intentional.
@ -1442,13 +1448,13 @@ function _upgrade_422_remove_genericons() {
// A list of the affected files using the filesystem absolute paths. // A list of the affected files using the filesystem absolute paths.
$affected_files = array(); $affected_files = array();
// Themes // Themes.
foreach ( $wp_theme_directories as $directory ) { foreach ( $wp_theme_directories as $directory ) {
$affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory ); $affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory );
$affected_files = array_merge( $affected_files, $affected_theme_files ); $affected_files = array_merge( $affected_files, $affected_theme_files );
} }
// Plugins // Plugins.
$affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR ); $affected_plugin_files = _upgrade_422_find_genericons_files_in_folder( WP_PLUGIN_DIR );
$affected_files = array_merge( $affected_files, $affected_plugin_files ); $affected_files = array_merge( $affected_files, $affected_plugin_files );
@ -1458,7 +1464,7 @@ function _upgrade_422_remove_genericons() {
continue; continue;
} }
// The path when the file is accessed via WP_Filesystem may differ in the case of FTP // The path when the file is accessed via WP_Filesystem may differ in the case of FTP.
$remote_file = $gen_dir . basename( $file ); $remote_file = $gen_dir . basename( $file );
if ( ! $wp_filesystem->exists( $remote_file ) ) { if ( ! $wp_filesystem->exists( $remote_file ) ) {

View File

@ -723,7 +723,8 @@ function wp_theme_update_row( $theme_key, $theme ) {
* @return void|false * @return void|false
*/ */
function maintenance_nag() { function maintenance_nag() {
include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version // Include an unmodified $wp_version.
include( ABSPATH . WPINC . '/version.php' );
global $upgrading; global $upgrading;
$nag = isset( $upgrading ); $nag = isset( $upgrading );
if ( ! $nag ) { if ( ! $nag ) {

View File

@ -154,7 +154,7 @@ if ( ! function_exists( 'wp_install_defaults' ) ) :
function wp_install_defaults( $user_id ) { function wp_install_defaults( $user_id ) {
global $wpdb, $wp_rewrite, $table_prefix; global $wpdb, $wp_rewrite, $table_prefix;
// Default category // Default category.
$cat_name = __( 'Uncategorized' ); $cat_name = __( 'Uncategorized' );
/* translators: Default category slug. */ /* translators: Default category slug. */
$cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) ); $cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) );
@ -199,7 +199,7 @@ if ( ! function_exists( 'wp_install_defaults' ) ) :
); );
$cat_tt_id = $wpdb->insert_id; $cat_tt_id = $wpdb->insert_id;
// First post // First post.
$now = current_time( 'mysql' ); $now = current_time( 'mysql' );
$now_gmt = current_time( 'mysql', 1 ); $now_gmt = current_time( 'mysql', 1 );
$first_post_guid = get_option( 'home' ) . '/?p=1'; $first_post_guid = get_option( 'home' ) . '/?p=1';
@ -219,7 +219,7 @@ if ( ! function_exists( 'wp_install_defaults' ) ) :
sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_network()->site_name ) sprintf( '<a href="%s">%s</a>', esc_url( network_home_url() ), get_network()->site_name )
); );
// Back-compat for pre-4.4 // Back-compat for pre-4.4.
$first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post ); $first_post = str_replace( 'SITE_URL', esc_url( network_home_url() ), $first_post );
$first_post = str_replace( 'SITE_NAME', get_network()->site_name, $first_post ); $first_post = str_replace( 'SITE_NAME', get_network()->site_name, $first_post );
} else { } else {
@ -257,7 +257,7 @@ if ( ! function_exists( 'wp_install_defaults' ) ) :
) )
); );
// Default comment // Default comment.
if ( is_multisite() ) { if ( is_multisite() ) {
$first_comment_author = get_site_option( 'first_comment_author' ); $first_comment_author = get_site_option( 'first_comment_author' );
$first_comment_email = get_site_option( 'first_comment_email' ); $first_comment_email = get_site_option( 'first_comment_email' );
@ -286,7 +286,7 @@ Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.'
) )
); );
// First Page // First page.
if ( is_multisite() ) { if ( is_multisite() ) {
$first_page = get_site_option( 'first_page' ); $first_page = get_site_option( 'first_page' );
} }
@ -352,7 +352,7 @@ Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.'
) )
); );
// Privacy Policy page // Privacy Policy page.
if ( is_multisite() ) { if ( is_multisite() ) {
// Disable by default unless the suggested content is provided. // Disable by default unless the suggested content is provided.
$privacy_policy_content = get_site_option( 'default_privacy_policy_content' ); $privacy_policy_content = get_site_option( 'default_privacy_policy_content' );
@ -493,7 +493,8 @@ Commenter avatars come from <a href="https://gravatar.com">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 . 'user_level' ) );
$wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix . 'capabilities' ) ); $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 ) && $user_id != 1 ) { if ( ! is_super_admin( $user_id ) && $user_id != 1 ) {
$wpdb->delete( $wpdb->delete(
$wpdb->usermeta, $wpdb->usermeta,
@ -550,7 +551,7 @@ function wp_install_maybe_enable_pretty_permalinks() {
$test_url = ''; $test_url = '';
// Test against a real WordPress Post // Test against a real WordPress post.
$first_post = get_page_by_path( sanitize_title( _x( 'hello-world', 'Default post slug' ) ), OBJECT, 'post' ); $first_post = get_page_by_path( sanitize_title( _x( 'hello-world', 'Default post slug' ) ), OBJECT, 'post' );
if ( $first_post ) { if ( $first_post ) {
$test_url = get_permalink( $first_post->ID ); $test_url = get_permalink( $first_post->ID );
@ -852,7 +853,7 @@ function upgrade_all() {
function upgrade_100() { function upgrade_100() {
global $wpdb; global $wpdb;
// Get the title and ID of every post, post_name to check if it already has a value // Get the title and ID of every post, post_name to check if it already has a value.
$posts = $wpdb->get_results( "SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''" ); $posts = $wpdb->get_results( "SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''" );
if ( $posts ) { if ( $posts ) {
foreach ( $posts as $post ) { foreach ( $posts as $post ) {
@ -891,9 +892,9 @@ function upgrade_100() {
$allposts = $wpdb->get_results( "SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere" ); $allposts = $wpdb->get_results( "SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere" );
if ( $allposts ) : if ( $allposts ) :
foreach ( $allposts as $post ) { foreach ( $allposts as $post ) {
// Check to see if it's already been imported // Check to see if it's already been imported.
$cat = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category ) ); $cat = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->post2cat WHERE post_id = %d AND category_id = %d", $post->ID, $post->post_category ) );
if ( ! $cat && 0 != $post->post_category ) { // If there's no result if ( ! $cat && 0 != $post->post_category ) { // If there's no result.
$wpdb->insert( $wpdb->insert(
$wpdb->post2cat, $wpdb->post2cat,
array( array(
@ -917,7 +918,7 @@ function upgrade_100() {
function upgrade_101() { function upgrade_101() {
global $wpdb; global $wpdb;
// Clean up indices, add a few // Clean up indices, add a few.
add_clean_index( $wpdb->posts, 'post_name' ); add_clean_index( $wpdb->posts, 'post_name' );
add_clean_index( $wpdb->posts, 'post_status' ); add_clean_index( $wpdb->posts, 'post_status' );
add_clean_index( $wpdb->categories, 'category_nicename' ); add_clean_index( $wpdb->categories, 'category_nicename' );
@ -954,7 +955,7 @@ function upgrade_110() {
} }
} }
// Get the GMT offset, we'll use that later on // Get the GMT offset, we'll use that later on.
$all_options = get_alloptions_110(); $all_options = get_alloptions_110();
$time_difference = $all_options->time_difference; $time_difference = $all_options->time_difference;
@ -968,17 +969,19 @@ function upgrade_110() {
$diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server; $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
$gmt_offset = -$diff_gmt_weblogger; $gmt_offset = -$diff_gmt_weblogger;
// Add a gmt_offset option, with value $gmt_offset // Add a gmt_offset option, with value $gmt_offset.
add_option( 'gmt_offset', $gmt_offset ); add_option( 'gmt_offset', $gmt_offset );
// Check if we already set the GMT fields (if we did, then /*
// MAX(post_date_gmt) can't be '0000-00-00 00:00:00' * Check if we already set the GMT fields. If we did, then
// <michel_v> I just slapped myself silly for not thinking about it earlier * MAX(post_date_gmt) can't be '0000-00-00 00:00:00'.
* <michel_v> I just slapped myself silly for not thinking about it earlier.
*/
$got_gmt_fields = ! ( $wpdb->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) == '0000-00-00 00:00:00' ); $got_gmt_fields = ! ( $wpdb->get_var( "SELECT MAX(post_date_gmt) FROM $wpdb->posts" ) == '0000-00-00 00:00:00' );
if ( ! $got_gmt_fields ) { if ( ! $got_gmt_fields ) {
// Add or subtract time to all dates, to get GMT dates // Add or subtract time to all dates, to get GMT dates.
$add_hours = intval( $diff_gmt_weblogger ); $add_hours = intval( $diff_gmt_weblogger );
$add_minutes = intval( 60 * ( $diff_gmt_weblogger - $add_hours ) ); $add_minutes = intval( 60 * ( $diff_gmt_weblogger - $add_hours ) );
$wpdb->query( "UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" ); $wpdb->query( "UPDATE $wpdb->posts SET post_date_gmt = DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)" );
@ -1052,17 +1055,17 @@ function upgrade_130() {
update_option( 'active_plugins', $active_plugins ); update_option( 'active_plugins', $active_plugins );
} }
// Obsolete tables // Obsolete tables.
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues' );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes' );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups' );
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options' );
// Update comments table to use comment_type // Update comments table to use comment_type.
$wpdb->query( "UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'" ); $wpdb->query( "UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'" );
$wpdb->query( "UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'" ); $wpdb->query( "UPDATE $wpdb->comments SET comment_type='pingback', comment_content = REPLACE(comment_content, '<pingback />', '') WHERE comment_content LIKE '<pingback />%'" );
// Some versions have multiple duplicate option_name rows with the same values // Some versions have multiple duplicate option_name rows with the same values.
$options = $wpdb->get_results( "SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name" ); $options = $wpdb->get_results( "SELECT option_name, COUNT(option_name) AS dupes FROM `$wpdb->options` GROUP BY option_name" );
foreach ( $options as $option ) { foreach ( $options as $option ) {
if ( 1 != $option->dupes ) { // Could this be done in the query? if ( 1 != $option->dupes ) { // Could this be done in the query?
@ -1370,7 +1373,7 @@ function upgrade_230() {
if ( $wp_current_db_version < 3570 ) { if ( $wp_current_db_version < 3570 ) {
/* /*
* Create link_category terms for link categories. Create a map of link * Create link_category terms for link categories. Create a map of link
* cat IDs to link_category terms. * category IDs to link_category terms.
*/ */
$link_cat_id_map = array(); $link_cat_id_map = array();
$default_link_cat = 0; $default_link_cat = 0;
@ -1411,7 +1414,7 @@ function upgrade_230() {
$tt_ids[ $term_id ] = (int) $wpdb->insert_id; $tt_ids[ $term_id ] = (int) $wpdb->insert_id;
} }
// Associate links to cats. // Associate links to categories.
$links = $wpdb->get_results( "SELECT link_id, link_category FROM $wpdb->links" ); $links = $wpdb->get_results( "SELECT link_id, link_category FROM $wpdb->links" );
if ( ! empty( $links ) ) { if ( ! empty( $links ) ) {
foreach ( $links as $link ) { foreach ( $links as $link ) {
@ -1460,11 +1463,11 @@ function upgrade_230() {
} }
if ( $wp_current_db_version < 4772 ) { if ( $wp_current_db_version < 4772 ) {
// Obsolete linkcategories table // Obsolete linkcategories table.
$wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'linkcategories' );
} }
// Recalculate all counts // Recalculate all counts.
$terms = $wpdb->get_results( "SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy" ); $terms = $wpdb->get_results( "SELECT term_taxonomy_id, taxonomy FROM $wpdb->term_taxonomy" );
foreach ( (array) $terms as $term ) { foreach ( (array) $terms as $term ) {
if ( ( 'post_tag' == $term->taxonomy ) || ( 'category' == $term->taxonomy ) ) { if ( ( 'post_tag' == $term->taxonomy ) || ( 'category' == $term->taxonomy ) ) {
@ -1586,7 +1589,7 @@ function upgrade_270() {
populate_roles_270(); populate_roles_270();
} }
// Update post_date for unpublished posts with empty timestamp // Update post_date for unpublished posts with empty timestamp.
if ( $wp_current_db_version < 8921 ) { if ( $wp_current_db_version < 8921 ) {
$wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" ); $wpdb->query( "UPDATE $wpdb->posts SET post_date = post_modified WHERE post_date = '0000-00-00 00:00:00'" );
} }
@ -1637,7 +1640,8 @@ function upgrade_290() {
global $wp_current_db_version; global $wp_current_db_version;
if ( $wp_current_db_version < 11958 ) { 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' ) { if ( get_option( 'thread_comments_depth' ) == '1' ) {
update_option( 'thread_comments_depth', 2 ); update_option( 'thread_comments_depth', 2 );
update_option( 'thread_comments', 0 ); update_option( 'thread_comments', 0 );
@ -1769,7 +1773,7 @@ function upgrade_330() {
$sidebars_widgets = $_sidebars_widgets; $sidebars_widgets = $_sidebars_widgets;
unset( $_sidebars_widgets ); unset( $_sidebars_widgets );
// intentional fall-through to upgrade to the next version. // Intentional fall-through to upgrade to the next version.
case 2: case 2:
$sidebars_widgets = retrieve_widgets(); $sidebars_widgets = retrieve_widgets();
$sidebars_widgets['array_version'] = 3; $sidebars_widgets['array_version'] = 3;
@ -1827,7 +1831,7 @@ function upgrade_350() {
global $wp_current_db_version, $wpdb; global $wp_current_db_version, $wpdb;
if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) { if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) ) {
update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options() update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options().
} }
if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) { if ( $wp_current_db_version < 21811 && wp_should_upgrade_global_tables() ) {
@ -2021,7 +2025,7 @@ function upgrade_430_fix_comments() {
* @since 4.3.1 * @since 4.3.1
*/ */
function upgrade_431() { function upgrade_431() {
// Fix incorrect cron entries for term splitting // Fix incorrect cron entries for term splitting.
$cron_array = _get_cron_array(); $cron_array = _get_cron_array();
if ( isset( $cron_array['wp_batch_split_terms'] ) ) { if ( isset( $cron_array['wp_batch_split_terms'] ) ) {
unset( $cron_array['wp_batch_split_terms'] ); unset( $cron_array['wp_batch_split_terms'] );
@ -2138,11 +2142,13 @@ function upgrade_510() {
* @since 5.3.0 * @since 5.3.0
*/ */
function upgrade_530() { function upgrade_530() {
// The `admin_email_lifespan` option may have been set by an admin that just logged in, /*
// saw the verification screen, clicked on a button there, and is now upgrading the db, * The `admin_email_lifespan` option may have been set by an admin that just logged in,
// or by populate_options() that is called earlier in upgrade_all(). * saw the verification screen, clicked on a button there, and is now upgrading the db,
// In the second case `admin_email_lifespan` should be reset so the verification screen * or by populate_options() that is called earlier in upgrade_all().
// is shown next time an admin logs in. * In the second case `admin_email_lifespan` should be reset so the verification screen
* is shown next time an admin logs in.
*/
if ( function_exists( 'current_user_can' ) && ! current_user_can( 'manage_options' ) ) { if ( function_exists( 'current_user_can' ) && ! current_user_can( 'manage_options' ) ) {
update_option( 'admin_email_lifespan', 0 ); update_option( 'admin_email_lifespan', 0 );
} }
@ -2159,10 +2165,10 @@ function upgrade_530() {
function upgrade_network() { function upgrade_network() {
global $wp_current_db_version, $wpdb; global $wp_current_db_version, $wpdb;
// Always clear expired transients // Always clear expired transients.
delete_expired_transients( true ); delete_expired_transients( true );
// 2.8. // 2.8
if ( $wp_current_db_version < 11549 ) { if ( $wp_current_db_version < 11549 ) {
$wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' ); $wpmu_sitewide_plugins = get_site_option( 'wpmu_sitewide_plugins' );
$active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' ); $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
@ -2301,7 +2307,7 @@ function upgrade_network() {
} }
// //
// General functions we use to actually do stuff // General functions we use to actually do stuff.
// //
/** /**
@ -2328,7 +2334,7 @@ function maybe_create_table( $table_name, $create_ddl ) {
return true; return true;
} }
// Didn't find it try to create it.. // Didn't find it, so try to create it.
$wpdb->query( $create_ddl ); $wpdb->query( $create_ddl );
// We cannot directly tell that whether this succeeded! // We cannot directly tell that whether this succeeded!
@ -2353,7 +2359,7 @@ function drop_index( $table, $index ) {
global $wpdb; global $wpdb;
$wpdb->hide_errors(); $wpdb->hide_errors();
$wpdb->query( "ALTER TABLE `$table` DROP INDEX `$index`" ); $wpdb->query( "ALTER TABLE `$table` DROP INDEX `$index`" );
// Now we need to take out all the extra ones we may have created // Now we need to take out all the extra ones we may have created.
for ( $i = 0; $i < 25; $i++ ) { for ( $i = 0; $i < 25; $i++ ) {
$wpdb->query( "ALTER TABLE `$table` DROP INDEX `{$index}_$i`" ); $wpdb->query( "ALTER TABLE `$table` DROP INDEX `{$index}_$i`" );
} }
@ -2399,7 +2405,7 @@ function maybe_add_column( $table_name, $column_name, $create_ddl ) {
} }
} }
// Didn't find it try to create it. // Didn't find it, so try to create it.
$wpdb->query( $create_ddl ); $wpdb->query( $create_ddl );
// We cannot directly tell that whether this succeeded! // We cannot directly tell that whether this succeeded!
@ -2566,7 +2572,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
$queries = wp_get_db_schema( $queries ); $queries = wp_get_db_schema( $queries );
} }
// Separate individual queries into an array // Separate individual queries into an array.
if ( ! is_array( $queries ) ) { if ( ! is_array( $queries ) ) {
$queries = explode( ';', $queries ); $queries = explode( ';', $queries );
$queries = array_filter( $queries ); $queries = array_filter( $queries );
@ -2581,11 +2587,11 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
*/ */
$queries = apply_filters( 'dbdelta_queries', $queries ); $queries = apply_filters( 'dbdelta_queries', $queries );
$cqueries = array(); // Creation Queries $cqueries = array(); // Creation queries.
$iqueries = array(); // Insertion Queries $iqueries = array(); // Insertion queries.
$for_update = array(); $for_update = array();
// Create a tablename index for an array ($cqueries) of queries // Create a tablename index for an array ($cqueries) of queries.
foreach ( $queries as $qry ) { foreach ( $queries as $qry ) {
if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) { if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) {
$cqueries[ trim( $matches[1], '`' ) ] = $qry; $cqueries[ trim( $matches[1], '`' ) ] = $qry;
@ -2597,7 +2603,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
} elseif ( preg_match( '|UPDATE ([^ ]*)|', $qry, $matches ) ) { } elseif ( preg_match( '|UPDATE ([^ ]*)|', $qry, $matches ) ) {
$iqueries[] = $qry; $iqueries[] = $qry;
} else { } else {
// Unrecognized query type // Unrecognized query type.
} }
} }
@ -2634,7 +2640,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
continue; continue;
} }
// Fetch the table column structure from the database // Fetch the table column structure from the database.
$suppress = $wpdb->suppress_errors(); $suppress = $wpdb->suppress_errors();
$tablefields = $wpdb->get_results( "DESCRIBE {$table};" ); $tablefields = $wpdb->get_results( "DESCRIBE {$table};" );
$wpdb->suppress_errors( $suppress ); $wpdb->suppress_errors( $suppress );
@ -2782,7 +2788,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
$tablefield_field_lowercased = strtolower( $tablefield->Field ); $tablefield_field_lowercased = strtolower( $tablefield->Field );
$tablefield_type_lowercased = strtolower( $tablefield->Type ); $tablefield_type_lowercased = strtolower( $tablefield->Type );
// If the table field exists in the field array ... // If the table field exists in the field array...
if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) { if ( array_key_exists( $tablefield_field_lowercased, $cfields ) ) {
// Get the field type from the query. // Get the field type from the query.
@ -2807,7 +2813,8 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
if ( $do_change ) { if ( $do_change ) {
// Add a query to change the column type. // Add a query to change the column type.
$cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ]; $cqueries[] = "ALTER TABLE {$table} CHANGE COLUMN `{$tablefield->Field}` " . $cfields[ $tablefield_field_lowercased ];
$for_update[ $table . '.' . $tablefield->Field ] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; $for_update[ $table . '.' . $tablefield->Field ] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
} }
} }
@ -2817,7 +2824,8 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
$default_value = $matches[1]; $default_value = $matches[1];
if ( $tablefield->Default != $default_value ) { if ( $tablefield->Default != $default_value ) {
// Add a query to change the column's default value // Add a query to change the column's default value
$cqueries[] = "ALTER TABLE {$table} ALTER COLUMN `{$tablefield->Field}` SET DEFAULT '{$default_value}'"; $cqueries[] = "ALTER TABLE {$table} ALTER COLUMN `{$tablefield->Field}` SET DEFAULT '{$default_value}'";
$for_update[ $table . '.' . $tablefield->Field ] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}"; $for_update[ $table . '.' . $tablefield->Field ] = "Changed default value of {$table}.{$tablefield->Field} from {$tablefield->Default} to {$default_value}";
} }
} }
@ -2832,7 +2840,8 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
// For every remaining field specified for the table. // For every remaining field specified for the table.
foreach ( $cfields as $fieldname => $fielddef ) { foreach ( $cfields as $fieldname => $fielddef ) {
// Push a query line into $cqueries that adds the field to that table. // Push a query line into $cqueries that adds the field to that table.
$cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef"; $cqueries[] = "ALTER TABLE {$table} ADD COLUMN $fielddef";
$for_update[ $table . '.' . $fieldname ] = 'Added column ' . $table . '.' . $fieldname; $for_update[ $table . '.' . $fieldname ] = 'Added column ' . $table . '.' . $fieldname;
} }
@ -2845,9 +2854,9 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
// For every index in the table. // For every index in the table.
foreach ( $tableindices as $tableindex ) { foreach ( $tableindices as $tableindex ) {
$keyname = strtolower( $tableindex->Key_name );
// Add the index to the index data array. // Add the index to the index data array.
$keyname = strtolower( $tableindex->Key_name );
$index_ary[ $keyname ]['columns'][] = array( $index_ary[ $keyname ]['columns'][] = array(
'fieldname' => $tableindex->Column_name, 'fieldname' => $tableindex->Column_name,
'subpart' => $tableindex->Sub_part, 'subpart' => $tableindex->Sub_part,
@ -2904,7 +2913,8 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
// For every remaining index specified for the table. // For every remaining index specified for the table.
foreach ( (array) $indices as $index ) { foreach ( (array) $indices as $index ) {
// Push a query line into $cqueries that adds the index to that table. // Push a query line into $cqueries that adds the index to that table.
$cqueries[] = "ALTER TABLE {$table} ADD $index"; $cqueries[] = "ALTER TABLE {$table} ADD $index";
$for_update[] = 'Added index ' . $table . ' ' . $index; $for_update[] = 'Added index ' . $table . ' ' . $index;
} }
@ -3068,7 +3078,7 @@ function make_site_theme_from_default( $theme_name, $template ) {
$default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME; $default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME;
// Copy files from the default theme to the site 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'); // $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' );
$theme_dir = @opendir( $default_dir ); $theme_dir = @opendir( $default_dir );
if ( $theme_dir ) { if ( $theme_dir ) {
@ -3269,7 +3279,7 @@ function maybe_disable_link_manager() {
function pre_schema_upgrade() { function pre_schema_upgrade() {
global $wp_current_db_version, $wpdb; global $wp_current_db_version, $wpdb;
// Upgrade versions prior to 2.9 // Upgrade versions prior to 2.9.
if ( $wp_current_db_version < 11557 ) { if ( $wp_current_db_version < 11557 ) {
// Delete duplicate options. Keep the option with the highest option_id. // Delete duplicate options. Keep the option with the highest option_id.
$wpdb->query( "DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id" ); $wpdb->query( "DELETE o1 FROM $wpdb->options AS o1 JOIN $wpdb->options AS o2 USING (`option_name`) WHERE o2.option_id > o1.option_id" );
@ -3284,7 +3294,7 @@ function pre_schema_upgrade() {
// Multisite schema upgrades. // Multisite schema upgrades.
if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) { if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) {
// Upgrade versions prior to 3.7 // Upgrade versions prior to 3.7.
if ( $wp_current_db_version < 25179 ) { if ( $wp_current_db_version < 25179 ) {
// New primary key for signups. // New primary key for signups.
$wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" ); $wpdb->query( "ALTER TABLE $wpdb->signups ADD signup_id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST" );
@ -3342,7 +3352,7 @@ CREATE TABLE $wpdb->sitecategories (
KEY last_updated (last_updated) KEY last_updated (last_updated)
) $charset_collate; ) $charset_collate;
"; ";
// now create tables // Now create tables.
dbDelta( $ms_queries ); dbDelta( $ms_queries );
} }
endif; endif;
@ -3367,20 +3377,20 @@ endif;
*/ */
function wp_should_upgrade_global_tables() { function wp_should_upgrade_global_tables() {
// Return false early if explicitly not upgrading // Return false early if explicitly not upgrading.
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
return false; return false;
} }
// Assume global tables should be upgraded // Assume global tables should be upgraded.
$should_upgrade = true; $should_upgrade = true;
// Set to false if not on main network (does not matter if not multi-network) // Set to false if not on main network (does not matter if not multi-network).
if ( ! is_main_network() ) { if ( ! is_main_network() ) {
$should_upgrade = false; $should_upgrade = false;
} }
// Set to false if not on main site of current network (does not matter if not multi-site) // Set to false if not on main site of current network (does not matter if not multi-site).
if ( ! is_main_site() ) { if ( ! is_main_site() ) {
$should_upgrade = false; $should_upgrade = false;
} }

View File

@ -393,7 +393,7 @@ function wp_delete_user( $id, $reassign = null ) {
} }
} }
// Clean links // Clean links.
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) ); $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id ) );
if ( $link_ids ) { if ( $link_ids ) {
@ -418,7 +418,7 @@ function wp_delete_user( $id, $reassign = null ) {
} }
} }
// FINALLY, delete user // FINALLY, delete user.
if ( is_multisite() ) { if ( is_multisite() ) {
remove_user_from_blog( $id, get_current_blog_id() ); remove_user_from_blog( $id, get_current_blog_id() );
} else { } else {
@ -474,7 +474,7 @@ function default_password_nag_handler( $errors = false ) {
return; return;
} }
// get_user_setting = JS saved UI setting. else no-js-fallback code. // 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'] ) { if ( 'hide' == get_user_setting( 'default_password_nag' ) || isset( $_GET['default_password_nag'] ) && '0' == $_GET['default_password_nag'] ) {
delete_user_setting( 'default_password_nag' ); delete_user_setting( 'default_password_nag' );
update_user_option( $user_ID, 'default_password_nag', false, true ); update_user_option( $user_ID, 'default_password_nag', false, true );

View File

@ -22,7 +22,7 @@ function wp_list_widgets() {
$done = array(); $done = array();
foreach ( $sort as $widget ) { foreach ( $sort as $widget ) {
if ( in_array( $widget['callback'], $done, true ) ) { // We already showed this multi-widget if ( in_array( $widget['callback'], $done, true ) ) { // We already showed this multi-widget.
continue; continue;
} }
@ -142,8 +142,8 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) {
$params[0]['before_widget'] = "<div id='widget-{$i}_{$id}' class='widget'$hidden>"; $params[0]['before_widget'] = "<div id='widget-{$i}_{$id}' class='widget'$hidden>";
$params[0]['after_widget'] = '</div>'; $params[0]['after_widget'] = '</div>';
$params[0]['before_title'] = '%BEG_OF_TITLE%'; // deprecated $params[0]['before_title'] = '%BEG_OF_TITLE%'; // Deprecated.
$params[0]['after_title'] = '%END_OF_TITLE%'; // deprecated $params[0]['after_title'] = '%END_OF_TITLE%'; // Deprecated.
if ( is_callable( $wp_registered_widgets[ $widget_id ]['callback'] ) ) { if ( is_callable( $wp_registered_widgets[ $widget_id ]['callback'] ) ) {
$wp_registered_widgets[ $widget_id ]['_callback'] = $wp_registered_widgets[ $widget_id ]['callback']; $wp_registered_widgets[ $widget_id ]['_callback'] = $wp_registered_widgets[ $widget_id ]['callback'];
@ -192,7 +192,7 @@ function wp_widget_control( $sidebar_args ) {
$widget_id = $sidebar_args['widget_id']; $widget_id = $sidebar_args['widget_id'];
$sidebar_id = isset( $sidebar_args['id'] ) ? $sidebar_args['id'] : false; $sidebar_id = isset( $sidebar_args['id'] ) ? $sidebar_args['id'] : false;
$key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[ $sidebar_id ] ) : '-1'; // position of widget in sidebar $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[ $sidebar_id ] ) : '-1'; // Position of widget in sidebar.
$control = isset( $wp_registered_widget_controls[ $widget_id ] ) ? $wp_registered_widget_controls[ $widget_id ] : array(); $control = isset( $wp_registered_widget_controls[ $widget_id ] ) ? $wp_registered_widget_controls[ $widget_id ] : array();
$widget = $wp_registered_widgets[ $widget_id ]; $widget = $wp_registered_widgets[ $widget_id ];
@ -226,7 +226,7 @@ function wp_widget_control( $sidebar_args ) {
* for a multi-widget control. * for a multi-widget control.
*/ */
if ( isset( $sidebar_args['_display'] ) && 'template' == $sidebar_args['_display'] && $widget_number ) { if ( isset( $sidebar_args['_display'] ) && 'template' == $sidebar_args['_display'] && $widget_number ) {
// number == -1 implies a template where id numbers are replaced by a generic '__i__' // number == -1 implies a template where id numbers are replaced by a generic '__i__'.
$control['params'][0]['number'] = -1; $control['params'][0]['number'] = -1;
// With id_base widget id's are constructed like {$id_base}-{$id_number}. // With id_base widget id's are constructed like {$id_base}-{$id_number}.
if ( isset( $control['id_base'] ) ) { if ( isset( $control['id_base'] ) ) {

View File

@ -44,7 +44,7 @@ $screen->add_help_tab(
) )
); );
// Help tabs // Help tabs.
$help = '<p>' . __( 'The left-hand navigation menu provides links to all of the WordPress administration screens, with submenu items displayed on hover. You can minimize this menu to a narrow icon strip by clicking on the Collapse Menu arrow at the bottom.' ) . '</p>'; $help = '<p>' . __( 'The left-hand navigation menu provides links to all of the WordPress administration screens, with submenu items displayed on hover. You can minimize this menu to a narrow icon strip by clicking on the Collapse Menu arrow at the bottom.' ) . '</p>';
$help .= '<p>' . __( 'Links in the Toolbar at the top of the screen connect your dashboard and the front end of your site, and provide access to your profile and helpful WordPress information.' ) . '</p>'; $help .= '<p>' . __( 'Links in the Toolbar at the top of the screen connect your dashboard and the front end of your site, and provide access to your profile and helpful WordPress information.' ) . '</p>';
@ -119,7 +119,7 @@ if ( has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) )
$classes = 'welcome-panel'; $classes = 'welcome-panel';
$option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true ); $option = get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
// 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner.
$hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) ); $hide = 0 == $option || ( 2 == $option && wp_get_current_user()->user_email != get_option( 'admin_email' ) );
if ( $hide ) { if ( $hide ) {
$classes .= ' hidden'; $classes .= ' hidden';

View File

@ -18,7 +18,7 @@
* $error_count = 0; * $error_count = 0;
* $tablename = $wpdb->links; * $tablename = $wpdb->links;
* // Check the column. * // Check the column.
* if ( ! check_column($wpdb->links, 'link_description', 'varchar( 255 )' ) ) { * if ( ! check_column( $wpdb->links, 'link_description', 'varchar( 255 )' ) ) {
* $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' "; * $ddl = "ALTER TABLE $wpdb->links MODIFY COLUMN link_description varchar(255) NOT NULL DEFAULT '' ";
* $q = $wpdb->query( $ddl ); * $q = $wpdb->query( $ddl );
* } * }
@ -194,7 +194,7 @@ function check_column( $table_name, $col_name, $col_type, $is_null = null, $key
return false; return false;
} }
return true; return true;
} // end if found our column } // End if found our column.
} }
return false; return false;
} }

View File

@ -77,7 +77,7 @@ function display_header( $body_classes = '' ) {
<p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></p> <p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></p>
<?php <?php
} // end display_header() } // End display_header().
/** /**
* Display installer setup form. * Display installer setup form.
@ -94,7 +94,7 @@ function display_setup_form( $error = null ) {
$sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) ); $sql = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->users ) );
$user_table = ( $wpdb->get_var( $sql ) != null ); $user_table = ( $wpdb->get_var( $sql ) != null );
// Ensure that Blogs appear in search engines by default. // Ensure that sites appear in search engines by default.
$blog_public = 1; $blog_public = 1;
if ( isset( $_POST['weblog_title'] ) ) { if ( isset( $_POST['weblog_title'] ) ) {
$blog_public = isset( $_POST['blog_public'] ); $blog_public = isset( $_POST['blog_public'] );
@ -209,7 +209,7 @@ function display_setup_form( $error = null ) {
<input type="hidden" name="language" value="<?php echo isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : ''; ?>" /> <input type="hidden" name="language" value="<?php echo isset( $_REQUEST['language'] ) ? esc_attr( $_REQUEST['language'] ) : ''; ?>" />
</form> </form>
<?php <?php
} // end display_setup_form() } // End display_setup_form().
// Let's check to make sure WP isn't already installed. // Let's check to make sure WP isn't already installed.
if ( is_blog_installed() ) { if ( is_blog_installed() ) {
@ -303,7 +303,7 @@ if ( ! empty( $_REQUEST['language'] ) ) {
$scripts_to_print = array( 'jquery' ); $scripts_to_print = array( 'jquery' );
switch ( $step ) { switch ( $step ) {
case 0: // Step 0 case 0: // Step 0.
if ( wp_can_install_language_pack() && empty( $language ) ) { if ( wp_can_install_language_pack() && empty( $language ) ) {
$languages = wp_get_available_translations(); $languages = wp_get_available_translations();
if ( $languages ) { if ( $languages ) {
@ -355,7 +355,7 @@ switch ( $step ) {
$scripts_to_print[] = 'user-profile'; $scripts_to_print[] = 'user-profile';
display_header(); display_header();
// Fill in the data we gathered // Fill in the data we gathered.
$weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : ''; $weblog_title = isset( $_POST['weblog_title'] ) ? trim( wp_unslash( $_POST['weblog_title'] ) ) : '';
$user_name = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; $user_name = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : '';
$admin_password = isset( $_POST['admin_password'] ) ? wp_unslash( $_POST['admin_password'] ) : ''; $admin_password = isset( $_POST['admin_password'] ) ? wp_unslash( $_POST['admin_password'] ) : '';
@ -366,22 +366,22 @@ switch ( $step ) {
// Check email address. // Check email address.
$error = false; $error = false;
if ( empty( $user_name ) ) { if ( empty( $user_name ) ) {
// TODO: poka-yoke // TODO: Poka-yoke.
display_setup_form( __( 'Please provide a valid username.' ) ); display_setup_form( __( 'Please provide a valid username.' ) );
$error = true; $error = true;
} elseif ( $user_name != sanitize_user( $user_name, true ) ) { } elseif ( $user_name != sanitize_user( $user_name, true ) ) {
display_setup_form( __( 'The username you provided has invalid characters.' ) ); display_setup_form( __( 'The username you provided has invalid characters.' ) );
$error = true; $error = true;
} elseif ( $admin_password != $admin_password_check ) { } elseif ( $admin_password != $admin_password_check ) {
// TODO: poka-yoke // TODO: Poka-yoke.
display_setup_form( __( 'Your passwords do not match. Please try again.' ) ); display_setup_form( __( 'Your passwords do not match. Please try again.' ) );
$error = true; $error = true;
} elseif ( empty( $admin_email ) ) { } elseif ( empty( $admin_email ) ) {
// TODO: poka-yoke // TODO: Poka-yoke.
display_setup_form( __( 'You must provide an email address.' ) ); display_setup_form( __( 'You must provide an email address.' ) );
$error = true; $error = true;
} elseif ( ! is_email( $admin_email ) ) { } elseif ( ! is_email( $admin_email ) ) {
// TODO: poka-yoke // TODO: Poka-yoke.
display_setup_form( __( 'Sorry, that isn&#8217;t a valid email address. Email addresses look like <code>username@example.com</code>.' ) ); display_setup_form( __( 'Sorry, that isn&#8217;t a valid email address. Email addresses look like <code>username@example.com</code>.' ) );
$error = true; $error = true;
} }

View File

@ -35,11 +35,11 @@
// Expand/Collapse accordion sections on click. // Expand/Collapse accordion sections on click.
$( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) { $( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) {
if ( e.type === 'keydown' && 13 !== e.which ) { // "return" key if ( e.type === 'keydown' && 13 !== e.which ) { // "Return" key.
return; return;
} }
e.preventDefault(); // Keep this AFTER the key filter above e.preventDefault(); // Keep this AFTER the key filter above.
accordionSwitch( $( this ) ); accordionSwitch( $( this ) );
}); });
@ -80,7 +80,7 @@
section.toggleClass( 'open' ); section.toggleClass( 'open' );
} }
// We have to wait for the animations to finish // We have to wait for the animations to finish.
setTimeout(function(){ setTimeout(function(){
container.removeClass( 'opening' ); container.removeClass( 'opening' );
}, 150); }, 150);

View File

@ -79,7 +79,11 @@ if ( 'undefined' === typeof window.wp.codeEditor ) {
options = $.extend( {}, options ); options = $.extend( {}, options );
} }
// Note that rules must be sent in the "deprecated" lint.options property to prevent linter from complaining about unrecognized options. See <https://github.com/codemirror/CodeMirror/pull/4944>. /*
* Note that rules must be sent in the "deprecated" lint.options property
* to prevent linter from complaining about unrecognized options.
* See <https://github.com/codemirror/CodeMirror/pull/4944>.
*/
if ( ! options.options ) { if ( ! options.options ) {
options.options = {}; options.options = {};
} }

View File

@ -36,7 +36,6 @@
* Creates a color picker that only allows you to adjust the hue. * Creates a color picker that only allows you to adjust the hue.
* *
* @since 3.5.0 * @since 3.5.0
*
* @access private * @access private
* *
* @return {void} * @return {void}
@ -80,7 +79,6 @@
* Creates the color picker, sets default values, css classes and wraps it all in HTML. * Creates the color picker, sets default values, css classes and wraps it all in HTML.
* *
* @since 3.5.0 * @since 3.5.0
*
* @access private * @access private
* *
* @return {void} * @return {void}
@ -209,7 +207,6 @@
* Binds event listeners to the color picker. * Binds event listeners to the color picker.
* *
* @since 3.5.0 * @since 3.5.0
*
* @access private * @access private
* *
* @return {void} * @return {void}

View File

@ -70,7 +70,7 @@ jQuery(document).ready( function($) {
* @param {Event} event The event object. * @param {Event} event The event object.
* @return {void} * @return {void}
*/ */
$timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels $timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels.
var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(), var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(),
newD = new Date( aa, mm - 1, jj, hh, mn ); newD = new Date( aa, mm - 1, jj, hh, mn );

View File

@ -168,7 +168,7 @@ window.validateForm = function( form ) {
.length; .length;
}; };
// stub for doing better warnings // Stub for doing better warnings.
/** /**
* Shows message pop-up notice or confirmation message. * Shows message pop-up notice or confirmation message.
* *
@ -334,13 +334,13 @@ $('.contextual-help-tabs').delegate('a', 'click', function(e) {
if ( link.is('.active a') ) if ( link.is('.active a') )
return false; return false;
// Links // Links.
$('.contextual-help-tabs .active').removeClass('active'); $('.contextual-help-tabs .active').removeClass('active');
link.parent('li').addClass('active'); link.parent('li').addClass('active');
panel = $( link.attr('href') ); panel = $( link.attr('href') );
// Panels // Panels.
$('.help-tab-content').not( panel ).removeClass('active').hide(); $('.help-tab-content').not( panel ).removeClass('active').hide();
panel.addClass('active').show(); panel.addClass('active').show();
}); });
@ -517,7 +517,7 @@ $document.ready( function() {
$( '#collapse-button' ).on( 'click.collapse-menu', function() { $( '#collapse-button' ).on( 'click.collapse-menu', function() {
var viewportWidth = getViewportWidth() || 961; var viewportWidth = getViewportWidth() || 961;
// reset any compensation for submenus near the bottom of the screen // Reset any compensation for submenus near the bottom of the screen.
$('#adminmenu div.wp-submenu').css('margin-top', ''); $('#adminmenu div.wp-submenu').css('margin-top', '');
if ( viewportWidth < 960 ) { if ( viewportWidth < 960 ) {
@ -582,12 +582,12 @@ $document.ready( function() {
menutop = $menuItem.offset().top; menutop = $menuItem.offset().top;
wintop = $window.scrollTop(); wintop = $window.scrollTop();
maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar maxtop = menutop - wintop - 30; // max = make the top of the sub almost touch admin bar.
bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu.
pageHeight = $wpwrap.height(); // Height of the entire page pageHeight = $wpwrap.height(); // Height of the entire page.
adjustment = 60 + bottomOffset - pageHeight; adjustment = 60 + bottomOffset - pageHeight;
theFold = $window.height() + wintop - 50; // The fold theFold = $window.height() + wintop - 50; // The fold.
if ( theFold < ( bottomOffset - adjustment ) ) { if ( theFold < ( bottomOffset - adjustment ) ) {
adjustment = bottomOffset - theFold; adjustment = bottomOffset - theFold;
@ -604,8 +604,8 @@ $document.ready( function() {
} }
} }
if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // Touch screen device.
// iOS Safari works with touchstart, the rest work with click // iOS Safari works with touchstart, the rest work with click.
mobileEvent = isIOS ? 'touchstart' : 'click'; mobileEvent = isIOS ? 'touchstart' : 'click';
/** /**
@ -639,9 +639,11 @@ $document.ready( function() {
return; return;
} }
// Show the sub instead of following the link if: /*
// - the submenu is not open * Show the sub instead of following the link if:
// - the submenu is not shown inline or the menu is not folded * - the submenu is not open.
* - the submenu is not shown inline or the menu is not folded.
*/
if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) { if ( ! $menuItem.hasClass( 'opensub' ) && ( ! $menuItem.hasClass( 'wp-menu-open' ) || $menuItem.width() < 40 ) ) {
event.preventDefault(); event.preventDefault();
adjustSubmenu( $menuItem ); adjustSubmenu( $menuItem );
@ -664,12 +666,12 @@ $document.ready( function() {
$submenu = $menuItem.find( '.wp-submenu' ), $submenu = $menuItem.find( '.wp-submenu' ),
top = parseInt( $submenu.css( 'top' ), 10 ); top = parseInt( $submenu.css( 'top' ), 10 );
if ( isNaN( top ) || top > -5 ) { // the submenu is visible if ( isNaN( top ) || top > -5 ) { // The submenu is visible.
return; return;
} }
if ( $adminmenu.data( 'wp-responsive' ) ) { if ( $adminmenu.data( 'wp-responsive' ) ) {
// The menu is in responsive mode, bail // The menu is in responsive mode, bail.
return; return;
} }
@ -685,7 +687,7 @@ $document.ready( function() {
*/ */
out: function(){ out: function(){
if ( $adminmenu.data( 'wp-responsive' ) ) { if ( $adminmenu.data( 'wp-responsive' ) ) {
// The menu is in responsive mode, bail // The menu is in responsive mode, bail.
return; return;
} }
@ -705,7 +707,7 @@ $document.ready( function() {
*/ */
$adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) { $adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) {
if ( $adminmenu.data( 'wp-responsive' ) ) { if ( $adminmenu.data( 'wp-responsive' ) ) {
// The menu is in responsive mode, bail // The menu is in responsive mode, bail.
return; return;
} }
@ -759,7 +761,7 @@ $document.ready( function() {
$button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ), $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ),
btnText = commonL10n.dismiss || ''; btnText = commonL10n.dismiss || '';
// Ensure plain text // Ensure plain text.
$button.find( '.screen-reader-text' ).text( btnText ); $button.find( '.screen-reader-text' ).text( btnText );
$button.on( 'click.wp-dismiss-notice', function( event ) { $button.on( 'click.wp-dismiss-notice', function( event ) {
event.preventDefault(); event.preventDefault();
@ -776,7 +778,7 @@ $document.ready( function() {
$document.on( 'wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error', makeNoticesDismissible ); $document.on( 'wp-updates-notice-added wp-plugin-install-error wp-plugin-update-error wp-plugin-delete-error wp-theme-install-error wp-theme-delete-error', makeNoticesDismissible );
// Init screen meta // Init screen meta.
screenMeta.init(); screenMeta.init();
/** /**
@ -902,7 +904,7 @@ $document.ready( function() {
} }
}, '.has-row-actions' ); }, '.has-row-actions' );
// Toggle list table rows on small screens // Toggle list table rows on small screens.
$( 'tbody' ).on( 'click', '.toggle-row', function() { $( 'tbody' ).on( 'click', '.toggle-row', function() {
$( this ).closest( 'tr' ).toggleClass( 'is-expanded' ); $( this ).closest( 'tr' ).toggleClass( 'is-expanded' );
}); });
@ -925,7 +927,7 @@ $document.ready( function() {
// After pressing escape key (keyCode: 27), the tab key should tab out of the textarea. // After pressing escape key (keyCode: 27), the tab key should tab out of the textarea.
if ( e.keyCode == 27 ) { if ( e.keyCode == 27 ) {
// when pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them // When pressing Escape: Opera 12 and 27 blur form fields, IE 8 clears them.
e.preventDefault(); e.preventDefault();
$(el).data('tab-out', true); $(el).data('tab-out', true);
return; return;
@ -1276,7 +1278,7 @@ $document.ready( function() {
this.maybeDisableSortables = this.maybeDisableSortables.bind( this ); this.maybeDisableSortables = this.maybeDisableSortables.bind( this );
// Modify functionality based on custom activate/deactivate event // Modify functionality based on custom activate/deactivate event.
$document.on( 'wp-responsive-activate.wp-responsive', function() { $document.on( 'wp-responsive-activate.wp-responsive', function() {
self.activate(); self.activate();
}).on( 'wp-responsive-deactivate.wp-responsive', function() { }).on( 'wp-responsive-deactivate.wp-responsive', function() {
@ -1289,7 +1291,7 @@ $document.ready( function() {
$( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) { $( '#wp-admin-bar-menu-toggle' ).on( 'click.wp-responsive', function( event ) {
event.preventDefault(); event.preventDefault();
// close any open toolbar submenus. // Close any open toolbar submenus.
$adminbar.find( '.hover' ).removeClass( 'hover' ); $adminbar.find( '.hover' ).removeClass( 'hover' );
$wpwrap.toggleClass( 'wp-responsive-open' ); $wpwrap.toggleClass( 'wp-responsive-open' );

View File

@ -578,7 +578,8 @@
return deferred.promise(); return deferred.promise();
} }
// A status would cause a revision to be made, and for this wp.customize.previewer.save() should be used. Status is also disallowed for revisions regardless. // A status would cause a revision to be made, and for this wp.customize.previewer.save() should be used.
// Status is also disallowed for revisions regardless.
if ( submittedArgs.status ) { if ( submittedArgs.status ) {
return deferred.reject( { code: 'illegal_status_in_changeset_update' } ).promise(); return deferred.reject( { code: 'illegal_status_in_changeset_update' } ).promise();
} }
@ -772,13 +773,13 @@
*/ */
api.utils.areElementListsEqual = function ( listA, listB ) { api.utils.areElementListsEqual = function ( listA, listB ) {
var equal = ( var equal = (
listA.length === listB.length && // if lists are different lengths, then naturally they are not equal listA.length === listB.length && // If lists are different lengths, then naturally they are not equal.
-1 === _.indexOf( _.map( // are there any false values in the list returned by map? -1 === _.indexOf( _.map( // Are there any false values in the list returned by map?
_.zip( listA, listB ), // pair up each element between the two lists _.zip( listA, listB ), // Pair up each element between the two lists.
function ( pair ) { function ( pair ) {
return $( pair[0] ).is( pair[1] ); // compare to see if each pair are equal return $( pair[0] ).is( pair[1] ); // Compare to see if each pair is equal.
} }
), false ) // check for presence of false in map's return value ), false ) // Check for presence of false in map's return value.
); );
return equal; return equal;
}; };
@ -1128,7 +1129,8 @@
} }
if ( ! $.contains( document, headContainer.get( 0 ) ) ) { if ( ! $.contains( document, headContainer.get( 0 ) ) ) {
// If the element is not in the DOM, then jQuery.fn.slideUp() does nothing. In this case, a hard toggle is required instead. // If the element is not in the DOM, then jQuery.fn.slideUp() does nothing.
// In this case, a hard toggle is required instead.
headContainer.toggle( active ); headContainer.toggle( active );
if ( args.completeCallback ) { if ( args.completeCallback ) {
args.completeCallback(); args.completeCallback();
@ -1479,7 +1481,7 @@
}); });
} ); } );
} else { } else {
// There is no panel, so embed the section in the root of the customizer // There is no panel, so embed the section in the root of the customizer.
parentContainer = api.ensure( section.containerPaneParent ); parentContainer = api.ensure( section.containerPaneParent );
if ( ! section.headContainer.parent().is( parentContainer ) ) { if ( ! section.headContainer.parent().is( parentContainer ) ) {
parentContainer.append( section.headContainer ); parentContainer.append( section.headContainer );
@ -1511,7 +1513,7 @@
if ( api.utils.isKeydownButNotEnterEvent( event ) ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
return; return;
} }
event.preventDefault(); // Keep this AFTER the key filter above event.preventDefault(); // Keep this AFTER the key filter above.
if ( section.expanded() ) { if ( section.expanded() ) {
section.collapse(); section.collapse();
@ -1718,12 +1720,12 @@
var inject, var inject,
section = this; section = this;
// Watch for changes to the panel state // Watch for changes to the panel state.
inject = function( panelId ) { inject = function( panelId ) {
var parentContainer; var parentContainer;
api.panel( panelId, function( panel ) { api.panel( panelId, function( panel ) {
// The panel has been registered, wait for it to become ready/initialized // The panel has been registered, wait for it to become ready/initialized.
panel.deferred.embedded.done( function() { panel.deferred.embedded.done( function() {
parentContainer = panel.contentContainer; parentContainer = panel.contentContainer;
if ( ! section.headContainer.parent().is( parentContainer ) ) { if ( ! section.headContainer.parent().is( parentContainer ) ) {
@ -1737,7 +1739,7 @@
} ); } );
}; };
section.panel.bind( inject ); section.panel.bind( inject );
inject( section.panel.get() ); // Since a section may never get a panel, assume that it won't ever get one inject( section.panel.get() ); // Since a section may never get a panel, assume that it won't ever get one.
}, },
/** /**
@ -1758,17 +1760,17 @@
return; return;
} }
// Pressing the right arrow key fires a theme:next event // Pressing the right arrow key fires a theme:next event.
if ( 39 === event.keyCode ) { if ( 39 === event.keyCode ) {
section.nextTheme(); section.nextTheme();
} }
// Pressing the left arrow key fires a theme:previous event // Pressing the left arrow key fires a theme:previous event.
if ( 37 === event.keyCode ) { if ( 37 === event.keyCode ) {
section.previousTheme(); section.previousTheme();
} }
// Pressing the escape key fires a theme:collapse event // Pressing the escape key fires a theme:collapse event.
if ( 27 === event.keyCode ) { if ( 27 === event.keyCode ) {
if ( section.$body.hasClass( 'modal-open' ) ) { if ( section.$body.hasClass( 'modal-open' ) ) {
@ -1818,7 +1820,7 @@
if ( api.utils.isKeydownButNotEnterEvent( event ) ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
return; return;
} }
event.preventDefault(); // Keep this AFTER the key filter above event.preventDefault(); // Keep this AFTER the key filter above.
section.collapse(); section.collapse();
}); });
@ -1957,11 +1959,11 @@
*/ */
onChangeExpanded: function ( expanded, args ) { onChangeExpanded: function ( expanded, args ) {
// Note: there is a second argument 'args' passed // Note: there is a second argument 'args' passed.
var section = this, var section = this,
container = section.contentContainer.closest( '.customize-themes-full-container' ); container = section.contentContainer.closest( '.customize-themes-full-container' );
// Immediately call the complete callback if there were no changes // Immediately call the complete callback if there were no changes.
if ( args.unchanged ) { if ( args.unchanged ) {
if ( args.completeCallback ) { if ( args.completeCallback ) {
args.completeCallback(); args.completeCallback();
@ -1976,7 +1978,7 @@
section.loadThemes(); section.loadThemes();
} }
// Collapse any sibling sections/panels // Collapse any sibling sections/panels.
api.section.each( function ( otherSection ) { api.section.each( function ( otherSection ) {
var searchTerm; var searchTerm;
@ -2123,7 +2125,8 @@
_.delay( section.renderScreenshots, 100 ); // Wait for the controls to become visible. _.delay( section.renderScreenshots, 100 ); // Wait for the controls to become visible.
if ( 'local' === section.params.filter_type || 100 > themes.length ) { // If we have less than the requested 100 themes, it's the end of the list. if ( 'local' === section.params.filter_type || 100 > themes.length ) {
// If we have less than the requested 100 themes, it's the end of the list.
section.fullyLoaded = true; section.fullyLoaded = true;
} }
} else { } else {
@ -2202,7 +2205,9 @@
container = section.container.closest( '.customize-themes-full-container' ); container = section.container.closest( '.customize-themes-full-container' );
bottom = container.scrollTop() + container.height(); bottom = container.scrollTop() + container.height();
threshold = container.prop( 'scrollHeight' ) - 3000; // Use a fixed distance to the bottom of loaded results to avoid unnecessarily loading results sooner when using a percentage of scroll distance. // Use a fixed distance to the bottom of loaded results to avoid unnecessarily
// loading results sooner when using a percentage of scroll distance.
threshold = container.prop( 'scrollHeight' ) - 3000;
if ( bottom > threshold ) { if ( bottom > threshold ) {
section.loadThemes(); section.loadThemes();
@ -2614,15 +2619,15 @@
el.on( 'keydown', function( event ) { el.on( 'keydown', function( event ) {
// Return if it's not the tab key // Return if it's not the tab key
// When navigating with prev/next focus is already handled // When navigating with prev/next focus is already handled.
if ( 9 !== event.keyCode ) { if ( 9 !== event.keyCode ) {
return; return;
} }
// uses jQuery UI to get the tabbable elements // Uses jQuery UI to get the tabbable elements.
tabbables = $( ':tabbable', el ); tabbables = $( ':tabbable', el );
// Keep focus within the overlay // Keep focus within the overlay.
if ( tabbables.last()[0] === event.target && ! event.shiftKey ) { if ( tabbables.last()[0] === event.target && ! event.shiftKey ) {
tabbables.first().focus(); tabbables.first().focus();
return false; return false;
@ -2797,7 +2802,7 @@
embed: function () { embed: function () {
var panel = this, var panel = this,
container = $( '#customize-theme-controls' ), container = $( '#customize-theme-controls' ),
parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable.
if ( ! panel.headContainer.parent().is( parentContainer ) ) { if ( ! panel.headContainer.parent().is( parentContainer ) ) {
parentContainer.append( panel.headContainer ); parentContainer.append( panel.headContainer );
@ -2821,7 +2826,7 @@
if ( api.utils.isKeydownButNotEnterEvent( event ) ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
return; return;
} }
event.preventDefault(); // Keep this AFTER the key filter above event.preventDefault(); // Keep this AFTER the key filter above.
if ( ! panel.expanded() ) { if ( ! panel.expanded() ) {
panel.expand(); panel.expand();
@ -2833,7 +2838,7 @@
if ( api.utils.isKeydownButNotEnterEvent( event ) ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
return; return;
} }
event.preventDefault(); // Keep this AFTER the key filter above event.preventDefault(); // Keep this AFTER the key filter above.
if ( panel.expanded() ) { if ( panel.expanded() ) {
panel.collapse(); panel.collapse();
@ -2908,7 +2913,7 @@
*/ */
onChangeExpanded: function ( expanded, args ) { onChangeExpanded: function ( expanded, args ) {
// Immediately call the complete callback if there were no changes // Immediately call the complete callback if there were no changes.
if ( args.unchanged ) { if ( args.unchanged ) {
if ( args.completeCallback ) { if ( args.completeCallback ) {
args.completeCallback(); args.completeCallback();
@ -2916,7 +2921,7 @@
return; return;
} }
// Note: there is a second argument 'args' passed // Note: there is a second argument 'args' passed.
var panel = this, var panel = this,
accordionSection = panel.contentContainer, accordionSection = panel.contentContainer,
overlay = accordionSection.closest( '.wp-full-overlay' ), overlay = accordionSection.closest( '.wp-full-overlay' ),
@ -2927,7 +2932,7 @@
skipTransition; skipTransition;
if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) { if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) {
// Collapse any sibling sections/panels // Collapse any sibling sections/panels.
api.section.each( function ( section ) { api.section.each( function ( section ) {
if ( panel.id !== section.panel() ) { if ( panel.id !== section.panel() ) {
section.collapse( { duration: 0 } ); section.collapse( { duration: 0 } );
@ -3067,7 +3072,7 @@
// Attach regular panel events. // Attach regular panel events.
api.Panel.prototype.attachEvents.apply( panel ); api.Panel.prototype.attachEvents.apply( panel );
// Temporary since supplying SFTP credentials does not work yet. See #42184 // Temporary since supplying SFTP credentials does not work yet. See #42184.
if ( api.settings.theme._canInstall && api.settings.theme._filesystemCredentialsNeeded ) { if ( api.settings.theme._canInstall && api.settings.theme._filesystemCredentialsNeeded ) {
panel.notifications.add( new api.Notification( 'theme_install_unavailable', { panel.notifications.add( new api.Notification( 'theme_install_unavailable', {
message: api.l10n.themeInstallUnavailable, message: api.l10n.themeInstallUnavailable,
@ -3140,7 +3145,7 @@
// Expand/collapse the panel normally. // Expand/collapse the panel normally.
api.Panel.prototype.onChangeExpanded.apply( this, [ expanded, args ] ); api.Panel.prototype.onChangeExpanded.apply( this, [ expanded, args ] );
// Immediately call the complete callback if there were no changes // Immediately call the complete callback if there were no changes.
if ( args.unchanged ) { if ( args.unchanged ) {
if ( args.completeCallback ) { if ( args.completeCallback ) {
args.completeCallback(); args.completeCallback();
@ -3682,15 +3687,15 @@
var control = this, var control = this,
inject; inject;
// Watch for changes to the section state // Watch for changes to the section state.
inject = function ( sectionId ) { inject = function ( sectionId ) {
var parentContainer; var parentContainer;
if ( ! sectionId ) { // @todo allow a control to be embedded without a section, for instance a control embedded in the front end. if ( ! sectionId ) { // @todo Allow a control to be embedded without a section, for instance a control embedded in the front end.
return; return;
} }
// Wait for the section to be registered // Wait for the section to be registered.
api.section( sectionId, function ( section ) { api.section( sectionId, function ( section ) {
// Wait for the section to be ready/initialized // Wait for the section to be ready/initialized.
section.deferred.embedded.done( function () { section.deferred.embedded.done( function () {
parentContainer = ( section.contentContainer.is( 'ul' ) ) ? section.contentContainer : section.contentContainer.find( 'ul:first' ); parentContainer = ( section.contentContainer.is( 'ul' ) ) ? section.contentContainer : section.contentContainer.find( 'ul:first' );
if ( ! control.container.parent().is( parentContainer ) ) { if ( ! control.container.parent().is( parentContainer ) ) {
@ -3724,7 +3729,7 @@
control.addNewPage(); control.addNewPage();
}); });
control.container.on( 'keydown', '.create-item-input', function( e ) { control.container.on( 'keydown', '.create-item-input', function( e ) {
if ( 13 === e.which ) { // Enter if ( 13 === e.which ) { // Enter.
control.addNewPage(); control.addNewPage();
} }
}); });
@ -3909,7 +3914,7 @@
} }
if ( ! $.contains( document, this.container[0] ) ) { if ( ! $.contains( document, this.container[0] ) ) {
// jQuery.fn.slideUp is not hiding an element if it is not in the DOM // jQuery.fn.slideUp is not hiding an element if it is not in the DOM.
this.container.toggle( active ); this.container.toggle( active );
if ( args.completeCallback ) { if ( args.completeCallback ) {
args.completeCallback(); args.completeCallback();
@ -3957,7 +3962,7 @@
} }
}; };
// Support the .dropdown class to open/close complex elements // Support the .dropdown class to open/close complex elements.
this.container.on( 'click keydown', '.dropdown', function( event ) { this.container.on( 'click keydown', '.dropdown', function( event ) {
if ( api.utils.isKeydownButNotEnterEvent( event ) ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
return; return;
@ -3973,7 +3978,7 @@
control.container.parent().parent().find( 'li.library-selected' ).focus(); control.container.parent().parent().find( 'li.library-selected' ).focus();
} }
// Don't want to fire focus and click at same time // Don't want to fire focus and click at same time.
toggleFreeze = true; toggleFreeze = true;
setTimeout(function () { setTimeout(function () {
toggleFreeze = false; toggleFreeze = false;
@ -4017,7 +4022,8 @@
templateId = control.templateSelector; templateId = control.templateSelector;
// Use default content template when a standard HTML type is used, there isn't a more specific template existing, and the control container is empty. // Use default content template when a standard HTML type is used,
// there isn't a more specific template existing, and the control container is empty.
if ( templateId === 'customize-control-' + control.params.type + '-content' && if ( templateId === 'customize-control-' + control.params.type + '-content' &&
_.contains( standardTypes, control.params.type ) && _.contains( standardTypes, control.params.type ) &&
! document.getElementById( 'tmpl-' + templateId ) && ! document.getElementById( 'tmpl-' + templateId ) &&
@ -4047,6 +4053,7 @@
* *
* @since 4.7.0 * @since 4.7.0
* @access private * @access private
*
* @return {void} * @return {void}
*/ */
addNewPage: function () { addNewPage: function () {
@ -4070,7 +4077,8 @@
input.removeClass( 'invalid' ); input.removeClass( 'invalid' );
input.attr( 'disabled', 'disabled' ); input.attr( 'disabled', 'disabled' );
// The menus functions add the page, publish when appropriate, and also add the new page to the dropdown-pages controls. // The menus functions add the page, publish when appropriate,
// and also add the new page to the dropdown-pages controls.
promise = api.Menus.insertAutoDraftPost( { promise = api.Menus.insertAutoDraftPost( {
post_title: title, post_title: title,
post_type: 'page' post_type: 'page'
@ -4199,7 +4207,7 @@
control.container.on( 'click keydown', '.remove-button', control.removeFile ); control.container.on( 'click keydown', '.remove-button', control.removeFile );
control.container.on( 'click keydown', '.remove-button', control.cleanupPlayer ); control.container.on( 'click keydown', '.remove-button', control.cleanupPlayer );
// Resize the player controls when it becomes visible (ie when section is expanded) // Resize the player controls when it becomes visible (ie when section is expanded).
api.section( control.section() ).container api.section( control.section() ).container
.on( 'expanded', function() { .on( 'expanded', function() {
if ( control.player ) { if ( control.player ) {
@ -5128,7 +5136,7 @@
return; return;
} }
event.preventDefault(); // Keep this AFTER the key filter above event.preventDefault(); // Keep this AFTER the key filter above.
section = api.section( control.section() ); section = api.section( control.section() );
section.showDetails( control.params.theme, function() { section.showDetails( control.params.theme, function() {
@ -5196,7 +5204,7 @@
control.params.priority = 101 - matchCount; // Sort results by match count. control.params.priority = 101 - matchCount; // Sort results by match count.
return true; return true;
} else { } else {
control.deactivate(); // Hide control control.deactivate(); // Hide control.
control.params.priority = 101; control.params.priority = 101;
return false; return false;
} }
@ -6498,13 +6506,15 @@
urlParser.href = previewer.origin(); urlParser.href = previewer.origin();
previewer.add( 'scheme', urlParser.protocol.replace( /:$/, '' ) ); previewer.add( 'scheme', urlParser.protocol.replace( /:$/, '' ) );
// Limit the URL to internal, front-end links. /*
// * Limit the URL to internal, front-end links.
// If the front end and the admin are served from the same domain, load the *
// preview over ssl if the Customizer is being loaded over ssl. This avoids * If the front end and the admin are served from the same domain, load the
// insecure content warnings. This is not attempted if the admin and front end * preview over ssl if the Customizer is being loaded over ssl. This avoids
// are on different domains to avoid the case where the front end doesn't have * insecure content warnings. This is not attempted if the admin and front end
// ssl certs. * are on different domains to avoid the case where the front end doesn't have
* ssl certs.
*/
previewer.add( 'previewUrl', params.previewUrl ).setter( function( to ) { previewer.add( 'previewUrl', params.previewUrl ).setter( function( to ) {
var result = null, urlParser, queryParams, parsedAllowedUrl, parsedCandidateUrls = []; var result = null, urlParser, queryParams, parsedAllowedUrl, parsedCandidateUrls = [];
@ -6735,12 +6745,13 @@
* *
* @since 3.4.0 * @since 3.4.0
* @access public * @access public
*
* @return {void} * @return {void}
*/ */
refresh: function() { refresh: function() {
var previewer = this, onSettingChange; var previewer = this, onSettingChange;
// Display loading indicator // Display loading indicator.
previewer.send( 'loading-initiated' ); previewer.send( 'loading-initiated' );
previewer.abort(); previewer.abort();
@ -7013,7 +7024,7 @@
activeElement = $( document.activeElement ); activeElement = $( document.activeElement );
} }
// Sort the sections within each panel // Sort the sections within each panel.
api.panel.each( function ( panel ) { api.panel.each( function ( panel ) {
if ( 'themes' === panel.id ) { if ( 'themes' === panel.id ) {
return; // Don't reflow theme sections, as doing so moves them after the themes container. return; // Don't reflow theme sections, as doing so moves them after the themes container.
@ -7031,7 +7042,7 @@
} }
} ); } );
// Sort the controls within each section // Sort the controls within each section.
api.section.each( function ( section ) { api.section.each( function ( section ) {
var controls = section.controls(), var controls = section.controls(),
controlContainers = _.pluck( controls, 'container' ); controlContainers = _.pluck( controls, 'container' );
@ -7047,10 +7058,10 @@
} }
} ); } );
// Sort the root panels and sections // Sort the root panels and sections.
rootNodes.sort( api.utils.prioritySort ); rootNodes.sort( api.utils.prioritySort );
rootHeadContainers = _.pluck( rootNodes, 'headContainer' ); rootHeadContainers = _.pluck( rootNodes, 'headContainer' );
appendContainer = $( '#customize-theme-controls .customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable appendContainer = $( '#customize-theme-controls .customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable.
if ( ! api.utils.areElementListsEqual( rootHeadContainers, appendContainer.children() ) ) { if ( ! api.utils.areElementListsEqual( rootHeadContainers, appendContainer.children() ) ) {
_( rootNodes ).each( function ( rootNode ) { _( rootNodes ).each( function ( rootNode ) {
appendContainer.append( rootNode.headContainer ); appendContainer.append( rootNode.headContainer );
@ -7058,7 +7069,7 @@
wasReflowed = true; wasReflowed = true;
} }
// Now re-trigger the active Value callbacks to that the panels and sections can decide whether they can be rendered // Now re-trigger the active Value callbacks so that the panels and sections can decide whether they can be rendered.
api.panel.each( function ( panel ) { api.panel.each( function ( panel ) {
var value = panel.active(); var value = panel.active();
panel.active.callbacks.fireWith( panel.active, [ value, value ] ); panel.active.callbacks.fireWith( panel.active, [ value, value ] );
@ -7068,7 +7079,7 @@
section.active.callbacks.fireWith( section.active, [ value, value ] ); section.active.callbacks.fireWith( section.active, [ value, value ] );
} ); } );
// Restore focus if there was a reflow and there was an active (focused) element // Restore focus if there was a reflow and there was an active (focused) element.
if ( wasReflowed && activeElement ) { if ( wasReflowed && activeElement ) {
activeElement.focus(); activeElement.focus();
} }
@ -7208,9 +7219,11 @@
cancelScheduleButtonReminder = api.utils.highlightButton( btnWrapper, { cancelScheduleButtonReminder = api.utils.highlightButton( btnWrapper, {
delay: 1000, delay: 1000,
// Only abort the reminder when the save button is focused. /*
// If the user clicks the settings button to toggle the * Only abort the reminder when the save button is focused.
// settings closed, we'll still remind them. * If the user clicks the settings button to toggle the
* settings closed, we'll still remind them.
*/
focusTarget: saveBtn focusTarget: saveBtn
} ); } );
} }
@ -7579,7 +7592,7 @@
if ( '0' === response ) { if ( '0' === response ) {
response = 'not_logged_in'; response = 'not_logged_in';
} else if ( '-1' === response ) { } else if ( '-1' === response ) {
// Back-compat in case any other check_ajax_referer() call is dying // Back-compat in case any other check_ajax_referer() call is dying.
response = 'invalid_nonce'; response = 'invalid_nonce';
} }
@ -7812,7 +7825,7 @@
api.previewer.send( 'nonce-refresh', nonce ); api.previewer.send( 'nonce-refresh', nonce );
}); });
// Create Settings // Create Settings.
$.each( api.settings.settings, function( id, data ) { $.each( api.settings.settings, function( id, data ) {
var Constructor = api.settingConstructor[ data.type ] || api.Setting; var Constructor = api.settingConstructor[ data.type ] || api.Setting;
api.add( new Constructor( id, data.value, { api.add( new Constructor( id, data.value, {
@ -7822,28 +7835,31 @@
} ) ); } ) );
}); });
// Create Panels // Create Panels.
$.each( api.settings.panels, function ( id, data ) { $.each( api.settings.panels, function ( id, data ) {
var Constructor = api.panelConstructor[ data.type ] || api.Panel, options; var Constructor = api.panelConstructor[ data.type ] || api.Panel, options;
options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom panels that expect to augment this property. // Inclusion of params alias is for back-compat for custom panels that expect to augment this property.
options = _.extend( { params: data }, data );
api.panel.add( new Constructor( id, options ) ); api.panel.add( new Constructor( id, options ) );
}); });
// Create Sections // Create Sections.
$.each( api.settings.sections, function ( id, data ) { $.each( api.settings.sections, function ( id, data ) {
var Constructor = api.sectionConstructor[ data.type ] || api.Section, options; var Constructor = api.sectionConstructor[ data.type ] || api.Section, options;
options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom sections that expect to augment this property. // Inclusion of params alias is for back-compat for custom sections that expect to augment this property.
options = _.extend( { params: data }, data );
api.section.add( new Constructor( id, options ) ); api.section.add( new Constructor( id, options ) );
}); });
// Create Controls // Create Controls.
$.each( api.settings.controls, function( id, data ) { $.each( api.settings.controls, function( id, data ) {
var Constructor = api.controlConstructor[ data.type ] || api.Control, options; var Constructor = api.controlConstructor[ data.type ] || api.Control, options;
options = _.extend( { params: data }, data ); // Inclusion of params alias is for back-compat for custom controls that expect to augment this property. // Inclusion of params alias is for back-compat for custom controls that expect to augment this property.
options = _.extend( { params: data }, data );
api.control.add( new Constructor( id, options ) ); api.control.add( new Constructor( id, options ) );
}); });
// Focus the autofocused element // Focus the autofocused element.
_.each( [ 'panel', 'section', 'control' ], function( type ) { _.each( [ 'panel', 'section', 'control' ], function( type ) {
var id = api.settings.autofocus[ type ]; var id = api.settings.autofocus[ type ];
if ( ! id ) { if ( ! id ) {
@ -7896,7 +7912,7 @@
api.notifications.render(); api.notifications.render();
}); });
// Save and activated states // Save and activated states.
(function( state ) { (function( state ) {
var saved = state.instance( 'saved' ), var saved = state.instance( 'saved' ),
saving = state.instance( 'saving' ), saving = state.instance( 'saving' ),
@ -8690,7 +8706,8 @@
}; };
}()); }());
// Previewed device bindings. (The api.previewedDevice property is how this Value was first introduced, but since it has moved to api.state.) // Previewed device bindings. (The api.previewedDevice property
// is how this Value was first introduced, but since it has moved to api.state.)
api.previewedDevice = api.state( 'previewedDevice' ); api.previewedDevice = api.state( 'previewedDevice' );
// Set the default device. // Set the default device.
@ -8797,7 +8814,7 @@
api.state( 'selectedChangesetStatus' ).unbind( startPromptingBeforeUnload ); api.state( 'selectedChangesetStatus' ).unbind( startPromptingBeforeUnload );
api.state( 'selectedChangesetDate' ).unbind( startPromptingBeforeUnload ); api.state( 'selectedChangesetDate' ).unbind( startPromptingBeforeUnload );
// Prompt user with AYS dialog if leaving the Customizer with unsaved changes // Prompt user with AYS dialog if leaving the Customizer with unsaved changes.
$( window ).on( 'beforeunload.customize-confirm', function() { $( window ).on( 'beforeunload.customize-confirm', function() {
if ( ! isCleanState() && ! api.state( 'changesetLocked' ).get() ) { if ( ! isCleanState() && ! api.state( 'changesetLocked' ).get() ) {
setTimeout( function() { setTimeout( function() {
@ -8882,7 +8899,7 @@
}); });
} ); } );
// Pass titles to the parent // Pass titles to the parent.
api.bind( 'title', function( newTitle ) { api.bind( 'title', function( newTitle ) {
parent.send( 'title', newTitle ); parent.send( 'title', newTitle );
}); });
@ -8894,7 +8911,7 @@
// Initialize the connection with the parent frame. // Initialize the connection with the parent frame.
parent.send( 'ready' ); parent.send( 'ready' );
// Control visibility for default controls // Control visibility for default controls.
$.each({ $.each({
'background_image': { 'background_image': {
controls: [ 'background_preset', 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], controls: [ 'background_preset', 'background_position', 'background_size', 'background_repeat', 'background_attachment' ],
@ -8926,7 +8943,7 @@
api.control( 'background_preset', function( control ) { api.control( 'background_preset', function( control ) {
var visibility, defaultValues, values, toggleVisibility, updateSettings, preset; var visibility, defaultValues, values, toggleVisibility, updateSettings, preset;
visibility = { // position, size, repeat, attachment visibility = { // position, size, repeat, attachment.
'default': [ false, false, false, false ], 'default': [ false, false, false, false ],
'fill': [ true, false, false, false ], 'fill': [ true, false, false, false ],
'fit': [ true, false, true, false ], 'fit': [ true, false, true, false ],
@ -8942,14 +8959,15 @@
_wpCustomizeBackground.defaults['default-attachment'] _wpCustomizeBackground.defaults['default-attachment']
]; ];
values = { // position_x, position_y, size, repeat, attachment values = { // position_x, position_y, size, repeat, attachment.
'default': defaultValues, 'default': defaultValues,
'fill': [ 'left', 'top', 'cover', 'no-repeat', 'fixed' ], 'fill': [ 'left', 'top', 'cover', 'no-repeat', 'fixed' ],
'fit': [ 'left', 'top', 'contain', 'no-repeat', 'fixed' ], 'fit': [ 'left', 'top', 'contain', 'no-repeat', 'fixed' ],
'repeat': [ 'left', 'top', 'auto', 'repeat', 'scroll' ] 'repeat': [ 'left', 'top', 'auto', 'repeat', 'scroll' ]
}; };
// @todo These should actually toggle the active state, but without the preview overriding the state in data.activeControls. // @todo These should actually toggle the active state,
// but without the preview overriding the state in data.activeControls.
toggleVisibility = function( preset ) { toggleVisibility = function( preset ) {
_.each( [ 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], function( controlId, i ) { _.each( [ 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], function( controlId, i ) {
var control = api.control( controlId ); var control = api.control( controlId );
@ -9009,7 +9027,7 @@
} ); } );
} ); } );
// Juggle the two controls that use header_textcolor // Juggle the two controls that use header_textcolor.
api.control( 'display_header_text', function( control ) { api.control( 'display_header_text', function( control ) {
var last = ''; var last = '';

View File

@ -203,9 +203,11 @@
_.bindAll( this, 'close' ); _.bindAll( this, 'close' );
// If the available menu items panel is open and the customize controls are /*
// interacted with (other than an item being deleted), then close the * If the available menu items panel is open and the customize controls
// available menu items panel. Also close on back button click. * are interacted with (other than an item being deleted), then close
* the available menu items panel. Also close on back button click.
*/
$( '#customize-controls, .customize-section-back' ).on( 'click keydown', function( e ) { $( '#customize-controls, .customize-section-back' ).on( 'click keydown', function( e ) {
var isDeleteBtn = $( e.target ).is( '.item-delete, .item-delete *' ), var isDeleteBtn = $( e.target ).is( '.item-delete, .item-delete *' ),
isAddNewBtn = $( e.target ).is( '.add-new-menu-item, .add-new-menu-item *' ); isAddNewBtn = $( e.target ).is( '.add-new-menu-item, .add-new-menu-item *' );
@ -252,7 +254,7 @@
} }
}); });
// Close the panel if the URL in the preview changes // Close the panel if the URL in the preview changes.
api.previewer.bind( 'url', this.close ); api.previewer.bind( 'url', this.close );
self.delegateEvents(); self.delegateEvents();
@ -496,7 +498,7 @@
// Submit handler for keypress and click on menu item. // Submit handler for keypress and click on menu item.
_submit: function( event ) { _submit: function( event ) {
// Only proceed with keypress if it is Enter or Spacebar // Only proceed with keypress if it is Enter or Spacebar.
if ( 'keypress' === event.type && ( 13 !== event.which && 32 !== event.which ) ) { if ( 'keypress' === event.type && ( 13 !== event.which && 32 !== event.which ) ) {
return; return;
} }
@ -717,7 +719,7 @@
this.$search.focus(); this.$search.focus();
}, },
// Closes the panel // Closes the panel.
close: function( options ) { close: function( options ) {
options = options || {}; options = options || {};
@ -741,7 +743,7 @@
isBackTab = ( 9 === event.which && event.shiftKey ), isBackTab = ( 9 === event.which && event.shiftKey ),
isSearchFocused = $( event.target ).is( this.$search ); isSearchFocused = $( event.target ).is( this.$search );
// If enter pressed but nothing entered, don't do anything // If enter pressed but nothing entered, don't do anything.
if ( isEnter && ! this.$search.val() ) { if ( isEnter && ! this.$search.val() ) {
return; return;
} }
@ -781,7 +783,7 @@
} }
event.preventDefault(); event.preventDefault();
// Hide description // Hide description.
if ( content.not( ':hidden' ) ) { if ( content.not( ':hidden' ) ) {
content.slideUp( 'fast' ); content.slideUp( 'fast' );
help.attr( 'aria-expanded', 'false' ); help.attr( 'aria-expanded', 'false' );
@ -802,7 +804,7 @@
return false; return false;
} ); } );
// Help toggle // Help toggle.
help.on( 'click keydown', function( event ) { help.on( 'click keydown', function( event ) {
if ( api.utils.isKeydownButNotEnterEvent( event ) ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) {
return; return;
@ -1062,7 +1064,7 @@
menuAutoAddControl.active.set( true ); menuAutoAddControl.active.set( true );
} }
// Add the control for deleting the menu // Add the control for deleting the menu.
menuDeleteControlId = section.id + '[delete]'; menuDeleteControlId = section.id + '[delete]';
menuDeleteControl = api.control( menuDeleteControlId ); menuDeleteControl = api.control( menuDeleteControlId );
if ( ! menuDeleteControl ) { if ( ! menuDeleteControl ) {
@ -1126,7 +1128,7 @@
wpNavMenu.menuList = section.contentContainer; wpNavMenu.menuList = section.contentContainer;
wpNavMenu.targetList = wpNavMenu.menuList; wpNavMenu.targetList = wpNavMenu.menuList;
// Add attributes needed by wpNavMenu // Add attributes needed by wpNavMenu.
$( '#menu-to-edit' ).removeAttr( 'id' ); $( '#menu-to-edit' ).removeAttr( 'id' );
wpNavMenu.menuList.attr( 'id', 'menu-to-edit' ).addClass( 'menu' ); wpNavMenu.menuList.attr( 'id', 'menu-to-edit' ).addClass( 'menu' );
@ -1145,7 +1147,8 @@
wpNavMenu.initSortables(); // Depends on menu-to-edit ID being set above. wpNavMenu.initSortables(); // Depends on menu-to-edit ID being set above.
section.deferred.initSortables.resolve( wpNavMenu.menuList ); // Now MenuControl can extend the sortable. section.deferred.initSortables.resolve( wpNavMenu.menuList ); // Now MenuControl can extend the sortable.
// @todo Note that wp.customize.reflowPaneContents() is debounced, so this immediate change will show a slight flicker while priorities get updated. // @todo Note that wp.customize.reflowPaneContents() is debounced,
// so this immediate change will show a slight flicker while priorities get updated.
api.control( 'nav_menu[' + String( section.params.menu_id ) + ']' ).reflowMenuItems(); api.control( 'nav_menu[' + String( section.params.menu_id ) + ']' ).reflowMenuItems();
} }
if ( _.isFunction( completeCallback ) ) { if ( _.isFunction( completeCallback ) ) {
@ -1415,7 +1418,7 @@
navMenuLocationSetting = api( 'nav_menu_locations[' + checkbox.data( 'location-id' ) + ']' ); navMenuLocationSetting = api( 'nav_menu_locations[' + checkbox.data( 'location-id' ) + ']' );
navMenuLocationSetting.set( menuSection.params.menu_id ); navMenuLocationSetting.set( menuSection.params.menu_id );
// Reset state for next new menu // Reset state for next new menu.
checkbox.prop( 'checked', false ); checkbox.prop( 'checked', false );
} }
} ); } );
@ -1698,7 +1701,8 @@
control.elements.classes = new api.Element( control.container.find( '.edit-menu-item-classes' ) ); control.elements.classes = new api.Element( control.container.find( '.edit-menu-item-classes' ) );
control.elements.xfn = new api.Element( control.container.find( '.edit-menu-item-xfn' ) ); control.elements.xfn = new api.Element( control.container.find( '.edit-menu-item-xfn' ) );
control.elements.description = new api.Element( control.container.find( '.edit-menu-item-description' ) ); control.elements.description = new api.Element( control.container.find( '.edit-menu-item-description' ) );
// @todo allow other elements, added by plugins, to be automatically picked up here; allow additional values to be added to setting array. // @todo Allow other elements, added by plugins, to be automatically picked up here;
// allow additional values to be added to setting array.
_.each( control.elements, function( element, property ) { _.each( control.elements, function( element, property ) {
element.bind(function( value ) { element.bind(function( value ) {
@ -1790,7 +1794,7 @@
$removeBtn = control.container.find( '.item-delete' ); $removeBtn = control.container.find( '.item-delete' );
$removeBtn.on( 'click', function() { $removeBtn.on( 'click', function() {
// Find an adjacent element to add focus to when this menu item goes away // Find an adjacent element to add focus to when this menu item goes away.
var addingItems = true, $adjacentFocusTarget, $next, $prev; var addingItems = true, $adjacentFocusTarget, $next, $prev;
if ( ! $( 'body' ).hasClass( 'adding-menu-items' ) ) { if ( ! $( 'body' ).hasClass( 'adding-menu-items' ) ) {
@ -1811,7 +1815,7 @@
control.container.slideUp( function() { control.container.slideUp( function() {
control.setting.set( false ); control.setting.set( false );
wp.a11y.speak( api.Menus.data.l10n.itemDeleted ); wp.a11y.speak( api.Menus.data.l10n.itemDeleted );
$adjacentFocusTarget.focus(); // keyboard accessibility $adjacentFocusTarget.focus(); // Keyboard accessibility.
} ); } );
control.setting.set( false ); control.setting.set( false );
@ -2778,13 +2782,13 @@
action = sectionTitle.find( '.customize-action' ), action = sectionTitle.find( '.customize-action' ),
name = displayNavMenuName( menu.name ); name = displayNavMenuName( menu.name );
// Update the control title // Update the control title.
controlTitle.text( name ); controlTitle.text( name );
if ( location.length ) { if ( location.length ) {
location.appendTo( controlTitle ); location.appendTo( controlTitle );
} }
// Update the section title // Update the section title.
sectionTitle.text( name ); sectionTitle.text( name );
if ( action.length ) { if ( action.length ) {
action.prependTo( sectionTitle ); action.prependTo( sectionTitle );
@ -2981,7 +2985,7 @@
position: position position: position
} }
); );
delete item.id; // only used by Backbone delete item.id; // Only used by Backbone.
placeholderId = api.Menus.generatePlaceholderAutoIncrementId(); placeholderId = api.Menus.generatePlaceholderAutoIncrementId();
customizeId = 'nav_menu_item[' + String( placeholderId ) + ']'; customizeId = 'nav_menu_item[' + String( placeholderId ) + ']';

View File

@ -17,7 +17,7 @@
api.Widgets = api.Widgets || {}; api.Widgets = api.Widgets || {};
api.Widgets.savedWidgetIds = {}; api.Widgets.savedWidgetIds = {};
// Link settings // Link settings.
api.Widgets.data = _wpCustomizeWidgetsSettings || {}; api.Widgets.data = _wpCustomizeWidgetsSettings || {};
l10n = api.Widgets.data.l10n; l10n = api.Widgets.data.l10n;
@ -59,16 +59,16 @@
model: api.Widgets.WidgetModel, model: api.Widgets.WidgetModel,
// Controls searching on the current widget collection // Controls searching on the current widget collection
// and triggers an update event // and triggers an update event.
doSearch: function( value ) { doSearch: function( value ) {
// Don't do anything if we've already done this search // Don't do anything if we've already done this search.
// Useful because the search handler fires multiple times per keystroke // Useful because the search handler fires multiple times per keystroke.
if ( this.terms === value ) { if ( this.terms === value ) {
return; return;
} }
// Updates terms with the value passed // Updates terms with the value passed.
this.terms = value; this.terms = value;
// If we have terms, run a search... // If we have terms, run a search...
@ -84,16 +84,16 @@
} }
}, },
// Performs a search within the collection // Performs a search within the collection.
// @uses RegExp // @uses RegExp
search: function( term ) { search: function( term ) {
var match, haystack; var match, haystack;
// Escape the term string for RegExp meta characters // Escape the term string for RegExp meta characters.
term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' ); term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' );
// Consider spaces as word delimiters and match the whole string // Consider spaces as word delimiters and match the whole string
// so matching terms can be combined // so matching terms can be combined.
term = term.replace( / /g, ')(?=.*' ); term = term.replace( / /g, ')(?=.*' );
match = new RegExp( '^(?=.*' + term + ').+', 'i' ); match = new RegExp( '^(?=.*' + term + ').+', 'i' );
@ -150,10 +150,10 @@
'keydown' : 'keyboardAccessible' 'keydown' : 'keyboardAccessible'
}, },
// Cache current selected widget // Cache current selected widget.
selected: null, selected: null,
// Cache sidebar control which has opened panel // Cache sidebar control which has opened panel.
currentSidebarControl: null, currentSidebarControl: null,
$search: null, $search: null,
$clearResults: null, $clearResults: null,
@ -181,9 +181,11 @@
// Set the initial search count to the number of available widgets. // Set the initial search count to the number of available widgets.
this.searchMatchesCount = this.collection.length; this.searchMatchesCount = this.collection.length;
// If the available widgets panel is open and the customize controls are /*
// interacted with (i.e. available widgets panel is blurred) then close the * If the available widgets panel is open and the customize controls
// available widgets panel. Also close on back button click. * are interacted with (i.e. available widgets panel is blurred) then
* close the available widgets panel. Also close on back button click.
*/
$( '#customize-controls, #available-widgets .customize-section-title' ).on( 'click keydown', function( e ) { $( '#customize-controls, #available-widgets .customize-section-title' ).on( 'click keydown', function( e ) {
var isAddNewBtn = $( e.target ).is( '.add-new-widget, .add-new-widget *' ); var isAddNewBtn = $( e.target ).is( '.add-new-widget, .add-new-widget *' );
if ( $( 'body' ).hasClass( 'adding-widget' ) && ! isAddNewBtn ) { if ( $( 'body' ).hasClass( 'adding-widget' ) && ! isAddNewBtn ) {
@ -197,7 +199,7 @@
self.collection.doSearch( '' ); self.collection.doSearch( '' );
} ); } );
// Close the panel if the URL in the preview changes // Close the panel if the URL in the preview changes.
api.previewer.bind( 'url', this.close ); api.previewer.bind( 'url', this.close );
}, },
@ -213,19 +215,19 @@
// Announce how many search results. // Announce how many search results.
this.announceSearchMatches(); this.announceSearchMatches();
// Remove a widget from being selected if it is no longer visible // Remove a widget from being selected if it is no longer visible.
if ( this.selected && ! this.selected.is( ':visible' ) ) { if ( this.selected && ! this.selected.is( ':visible' ) ) {
this.selected.removeClass( 'selected' ); this.selected.removeClass( 'selected' );
this.selected = null; this.selected = null;
} }
// If a widget was selected but the filter value has been cleared out, clear selection // If a widget was selected but the filter value has been cleared out, clear selection.
if ( this.selected && ! event.target.value ) { if ( this.selected && ! event.target.value ) {
this.selected.removeClass( 'selected' ); this.selected.removeClass( 'selected' );
this.selected = null; this.selected = null;
} }
// If a filter has been entered and a widget hasn't been selected, select the first one shown // If a filter has been entered and a widget hasn't been selected, select the first one shown.
if ( ! this.selected && event.target.value ) { if ( ! this.selected && event.target.value ) {
firstVisible = this.$el.find( '> .widget-tpl:visible:first' ); firstVisible = this.$el.find( '> .widget-tpl:visible:first' );
if ( firstVisible.length ) { if ( firstVisible.length ) {
@ -301,7 +303,7 @@
* Handles submit for keypress and click on widget. * Handles submit for keypress and click on widget.
*/ */
_submit: function( event ) { _submit: function( event ) {
// Only proceed with keypress if it is Enter or Spacebar // Only proceed with keypress if it is Enter or Spacebar.
if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) { if ( event.type === 'keypress' && ( event.which !== 13 && event.which !== 32 ) ) {
return; return;
} }
@ -345,7 +347,7 @@
open: function( sidebarControl ) { open: function( sidebarControl ) {
this.currentSidebarControl = sidebarControl; this.currentSidebarControl = sidebarControl;
// Wide widget controls appear over the preview, and so they need to be collapsed when the panel opens // Wide widget controls appear over the preview, and so they need to be collapsed when the panel opens.
_( this.currentSidebarControl.getWidgetFormControls() ).each( function( control ) { _( this.currentSidebarControl.getWidgetFormControls() ).each( function( control ) {
if ( control.params.is_wide ) { if ( control.params.is_wide ) {
control.collapseForm(); control.collapseForm();
@ -360,7 +362,7 @@
this.$el.find( '.selected' ).removeClass( 'selected' ); this.$el.find( '.selected' ).removeClass( 'selected' );
// Reset search // Reset search.
this.collection.doSearch( '' ); this.collection.doSearch( '' );
if ( ! api.settings.browser.mobile ) { if ( ! api.settings.browser.mobile ) {
@ -428,7 +430,7 @@
return; return;
} }
// If enter pressed but nothing entered, don't do anything // If enter pressed but nothing entered, don't do anything.
if ( isEnter && ! this.$search.val() ) { if ( isEnter && ! this.$search.val() ) {
return; return;
} }
@ -602,7 +604,7 @@
_setupModel: function() { _setupModel: function() {
var self = this, rememberSavedWidgetId; var self = this, rememberSavedWidgetId;
// Remember saved widgets so we know which to trash (move to inactive widgets sidebar) // Remember saved widgets so we know which to trash (move to inactive widgets sidebar).
rememberSavedWidgetId = function() { rememberSavedWidgetId = function() {
api.Widgets.savedWidgetIds[self.params.widget_id] = true; api.Widgets.savedWidgetIds[self.params.widget_id] = true;
}; };
@ -613,7 +615,7 @@
this.isWidgetUpdating = false; this.isWidgetUpdating = false;
this.liveUpdateMode = true; this.liveUpdateMode = true;
// Update widget whenever model changes // Update widget whenever model changes.
this.setting.bind( function( to, from ) { this.setting.bind( function( to, from ) {
if ( ! _( from ).isEqual( to ) && ! self.isWidgetUpdating ) { if ( ! _( from ).isEqual( to ) && ! self.isWidgetUpdating ) {
self.updateWidget( { instance: to } ); self.updateWidget( { instance: to } );
@ -658,10 +660,10 @@
top; top;
$widgetInside.css( 'max-height', windowHeight ); $widgetInside.css( 'max-height', windowHeight );
top = Math.max( top = Math.max(
0, // prevent top from going off screen 0, // Prevent top from going off screen.
Math.min( Math.min(
Math.max( offsetTop, 0 ), // distance widget in panel is from top of screen Math.max( offsetTop, 0 ), // Distance widget in panel is from top of screen.
windowHeight - formHeight // flush up against bottom of screen windowHeight - formHeight // Flush up against bottom of screen.
) )
); );
$widgetInside.css( 'top', top ); $widgetInside.css( 'top', top );
@ -680,7 +682,7 @@
$themeControlsContainer.off( 'expanded collapsed', positionWidget ); $themeControlsContainer.off( 'expanded collapsed', positionWidget );
} ); } );
// Reposition whenever a sidebar's widgets are changed // Reposition whenever a sidebar's widgets are changed.
api.each( function( setting ) { api.each( function( setting ) {
if ( 0 === setting.id.indexOf( 'sidebars_widgets[' ) ) { if ( 0 === setting.id.indexOf( 'sidebars_widgets[' ) ) {
setting.bind( function() { setting.bind( function() {
@ -711,7 +713,7 @@
$closeBtn = this.container.find( '.widget-control-close' ); $closeBtn = this.container.find( '.widget-control-close' );
$closeBtn.on( 'click', function() { $closeBtn.on( 'click', function() {
self.collapse(); self.collapse();
self.container.find( '.widget-top .widget-action:first' ).focus(); // keyboard accessibility self.container.find( '.widget-top .widget-action:first' ).focus(); // Keyboard accessibility.
} ); } );
}, },
@ -838,7 +840,7 @@
wp.a11y.speak( l10n.widgetMovedDown ); wp.a11y.speak( l10n.widgetMovedDown );
} }
$( this ).focus(); // re-focus after the container was moved $( this ).focus(); // Re-focus after the container was moved.
} }
} ); } );
@ -886,12 +888,12 @@
_setupHighlightEffects: function() { _setupHighlightEffects: function() {
var self = this; var self = this;
// Highlight whenever hovering or clicking over the form // Highlight whenever hovering or clicking over the form.
this.container.on( 'mouseenter click', function() { this.container.on( 'mouseenter click', function() {
self.setting.previewer.send( 'highlight-widget', self.params.widget_id ); self.setting.previewer.send( 'highlight-widget', self.params.widget_id );
} ); } );
// Highlight when the setting is updated // Highlight when the setting is updated.
this.setting.bind( function() { this.setting.bind( function() {
self.setting.previewer.send( 'highlight-widget', self.params.widget_id ); self.setting.previewer.send( 'highlight-widget', self.params.widget_id );
} ); } );
@ -907,7 +909,7 @@
$widgetRoot = this.container.find( '.widget:first' ); $widgetRoot = this.container.find( '.widget:first' );
$widgetContent = $widgetRoot.find( '.widget-content:first' ); $widgetContent = $widgetRoot.find( '.widget-content:first' );
// Configure update button // Configure update button.
$saveBtn = this.container.find( '.widget-control-save' ); $saveBtn = this.container.find( '.widget-control-save' );
$saveBtn.val( l10n.saveBtnLabel ); $saveBtn.val( l10n.saveBtnLabel );
$saveBtn.attr( 'title', l10n.saveBtnTooltip ); $saveBtn.attr( 'title', l10n.saveBtnTooltip );
@ -921,15 +923,15 @@
self.updateWidget(); self.updateWidget();
}, 250 ); }, 250 );
// Trigger widget form update when hitting Enter within an input // Trigger widget form update when hitting Enter within an input.
$widgetContent.on( 'keydown', 'input', function( e ) { $widgetContent.on( 'keydown', 'input', function( e ) {
if ( 13 === e.which ) { // Enter if ( 13 === e.which ) { // Enter.
e.preventDefault(); e.preventDefault();
self.updateWidget( { ignoreActiveElement: true } ); self.updateWidget( { ignoreActiveElement: true } );
} }
} ); } );
// Handle widgets that support live previews // Handle widgets that support live previews.
$widgetContent.on( 'change input propertychange', ':input', function( e ) { $widgetContent.on( 'change input propertychange', ':input', function( e ) {
if ( ! self.liveUpdateMode ) { if ( ! self.liveUpdateMode ) {
return; return;
@ -939,7 +941,7 @@
} }
} ); } );
// Remove loading indicators when the setting is saved and the preview updates // Remove loading indicators when the setting is saved and the preview updates.
this.setting.previewer.channel.bind( 'synced', function() { this.setting.previewer.channel.bind( 'synced', function() {
self.container.removeClass( 'previewer-loading' ); self.container.removeClass( 'previewer-loading' );
} ); } );
@ -972,7 +974,7 @@
* @param {function} args.completeCallback * @param {function} args.completeCallback
*/ */
onChangeActive: function ( active, args ) { onChangeActive: function ( active, args ) {
// Note: there is a second 'args' parameter being passed, merged on top of this.defaultActiveArguments // Note: there is a second 'args' parameter being passed, merged on top of this.defaultActiveArguments.
this.container.toggleClass( 'widget-rendered', active ); this.container.toggleClass( 'widget-rendered', active );
if ( args.completeCallback ) { if ( args.completeCallback ) {
args.completeCallback(); args.completeCallback();
@ -985,10 +987,10 @@
_setupRemoveUI: function() { _setupRemoveUI: function() {
var self = this, $removeBtn, replaceDeleteWithRemove; var self = this, $removeBtn, replaceDeleteWithRemove;
// Configure remove button // Configure remove button.
$removeBtn = this.container.find( '.widget-control-remove' ); $removeBtn = this.container.find( '.widget-control-remove' );
$removeBtn.on( 'click', function() { $removeBtn.on( 'click', function() {
// Find an adjacent element to add focus to when this widget goes away // Find an adjacent element to add focus to when this widget goes away.
var $adjacentFocusTarget; var $adjacentFocusTarget;
if ( self.container.next().is( '.customize-control-widget_form' ) ) { if ( self.container.next().is( '.customize-control-widget_form' ) ) {
$adjacentFocusTarget = self.container.next().find( '.widget-action:first' ); $adjacentFocusTarget = self.container.next().find( '.widget-action:first' );
@ -1015,12 +1017,12 @@
sidebarWidgetIds.splice( i, 1 ); sidebarWidgetIds.splice( i, 1 );
sidebarsWidgetsControl.setting( sidebarWidgetIds ); sidebarsWidgetsControl.setting( sidebarWidgetIds );
$adjacentFocusTarget.focus(); // keyboard accessibility $adjacentFocusTarget.focus(); // Keyboard accessibility.
} ); } );
} ); } );
replaceDeleteWithRemove = function() { replaceDeleteWithRemove = function() {
$removeBtn.text( l10n.removeBtnLabel ); // wp_widget_control() outputs the button as "Delete" $removeBtn.text( l10n.removeBtnLabel ); // wp_widget_control() outputs the button as "Delete".
$removeBtn.attr( 'title', l10n.removeBtnTooltip ); $removeBtn.attr( 'title', l10n.removeBtnTooltip );
}; };
@ -1105,7 +1107,7 @@
if ( ! $.isArray( state ) ) { if ( ! $.isArray( state ) ) {
state = []; state = [];
} else { } else {
// Make sure all state items are strings since the DOM value is a string // Make sure all state items are strings since the DOM value is a string.
state = _.map( state, function ( value ) { state = _.map( state, function ( value ) {
return String( value ); return String( value );
} ); } );
@ -1169,7 +1171,7 @@
$widgetRoot = this.container.find( '.widget:first' ); $widgetRoot = this.container.find( '.widget:first' );
$widgetContent = $widgetRoot.find( '.widget-content:first' ); $widgetContent = $widgetRoot.find( '.widget-content:first' );
// Remove a previous error message // Remove a previous error message.
$widgetContent.find( '.widget-error' ).remove(); $widgetContent.find( '.widget-error' ).remove();
this.container.addClass( 'widget-form-loading' ); this.container.addClass( 'widget-form-loading' );
@ -1191,9 +1193,11 @@
data = $.param( params ); data = $.param( params );
$inputs = this._getInputs( $widgetContent ); $inputs = this._getInputs( $widgetContent );
// Store the value we're submitting in data so that when the response comes back, /*
// we know if it got sanitized; if there is no difference in the sanitized value, * Store the value we're submitting in data so that when the response comes back,
// then we do not need to touch the UI and mess up the user's ongoing editing. * we know if it got sanitized; if there is no difference in the sanitized value,
* then we do not need to touch the UI and mess up the user's ongoing editing.
*/
$inputs.each( function() { $inputs.each( function() {
$( this ).data( 'state' + updateNumber, self._getInputState( this ) ); $( this ).data( 'state' + updateNumber, self._getInputState( this ) );
} ); } );
@ -1236,14 +1240,14 @@
$sanitizedInputs = self._getInputs( sanitizedForm ); $sanitizedInputs = self._getInputs( sanitizedForm );
hasSameInputsInResponse = self._getInputsSignature( $inputs ) === self._getInputsSignature( $sanitizedInputs ); hasSameInputsInResponse = self._getInputsSignature( $inputs ) === self._getInputsSignature( $sanitizedInputs );
// Restore live update mode if sanitized fields are now aligned with the existing fields // Restore live update mode if sanitized fields are now aligned with the existing fields.
if ( hasSameInputsInResponse && ! self.liveUpdateMode ) { if ( hasSameInputsInResponse && ! self.liveUpdateMode ) {
self.liveUpdateMode = true; self.liveUpdateMode = true;
self.container.removeClass( 'widget-form-disabled' ); self.container.removeClass( 'widget-form-disabled' );
self.container.find( 'input[name="savewidget"]' ).hide(); self.container.find( 'input[name="savewidget"]' ).hide();
} }
// Sync sanitized field states to existing fields if they are aligned // Sync sanitized field states to existing fields if they are aligned.
if ( hasSameInputsInResponse && self.liveUpdateMode ) { if ( hasSameInputsInResponse && self.liveUpdateMode ) {
$inputs.each( function( i ) { $inputs.each( function( i ) {
var $input = $( this ), var $input = $( this ),
@ -1262,13 +1266,13 @@
$( document ).trigger( 'widget-synced', [ $widgetRoot, r.data.form ] ); $( document ).trigger( 'widget-synced', [ $widgetRoot, r.data.form ] );
// Otherwise, if sanitized fields are not aligned with existing fields, disable live update mode if enabled // Otherwise, if sanitized fields are not aligned with existing fields, disable live update mode if enabled.
} else if ( self.liveUpdateMode ) { } else if ( self.liveUpdateMode ) {
self.liveUpdateMode = false; self.liveUpdateMode = false;
self.container.find( 'input[name="savewidget"]' ).show(); self.container.find( 'input[name="savewidget"]' ).show();
isLiveUpdateAborted = true; isLiveUpdateAborted = true;
// Otherwise, replace existing form with the sanitized form // Otherwise, replace existing form with the sanitized form.
} else { } else {
$widgetContent.html( r.data.form ); $widgetContent.html( r.data.form );
@ -1284,11 +1288,11 @@
*/ */
isChanged = ! isLiveUpdateAborted && ! _( self.setting() ).isEqual( r.data.instance ); isChanged = ! isLiveUpdateAborted && ! _( self.setting() ).isEqual( r.data.instance );
if ( isChanged ) { if ( isChanged ) {
self.isWidgetUpdating = true; // suppress triggering another updateWidget self.isWidgetUpdating = true; // Suppress triggering another updateWidget.
self.setting( r.data.instance ); self.setting( r.data.instance );
self.isWidgetUpdating = false; self.isWidgetUpdating = false;
} else { } else {
// no change was made, so stop the spinner now instead of when the preview would updates // No change was made, so stop the spinner now instead of when the preview would updates.
self.container.removeClass( 'previewer-loading' ); self.container.removeClass( 'previewer-loading' );
} }
@ -1296,7 +1300,7 @@
completeCallback.call( self, null, { noChange: ! isChanged, ajaxFinished: true } ); completeCallback.call( self, null, { noChange: ! isChanged, ajaxFinished: true } );
} }
} else { } else {
// General error message // General error message.
message = l10n.error; message = l10n.error;
if ( r.data && r.data.message ) { if ( r.data && r.data.message ) {
@ -1406,7 +1410,7 @@
self.embedWidgetContent(); self.embedWidgetContent();
} }
// If the expanded state is unchanged only manipulate container expanded states // If the expanded state is unchanged only manipulate container expanded states.
if ( args.unchanged ) { if ( args.unchanged ) {
if ( expanded ) { if ( expanded ) {
api.Control.prototype.expand.call( self, { api.Control.prototype.expand.call( self, {
@ -1422,7 +1426,7 @@
expandControl = function() { expandControl = function() {
// Close all other widget controls before expanding this one // Close all other widget controls before expanding this one.
api.control.each( function( otherControl ) { api.control.each( function( otherControl ) {
if ( self.params.type === otherControl.params.type && self !== otherControl ) { if ( self.params.type === otherControl.params.type && self !== otherControl ) {
otherControl.collapse(); otherControl.collapse();
@ -1535,7 +1539,7 @@
i = this.getWidgetSidebarPosition(); i = this.getWidgetSidebarPosition();
sidebarWidgetsSetting = this.getSidebarWidgetsControl().setting; sidebarWidgetsSetting = this.getSidebarWidgetsControl().setting;
sidebarWidgetIds = Array.prototype.slice.call( sidebarWidgetsSetting() ); // clone sidebarWidgetIds = Array.prototype.slice.call( sidebarWidgetsSetting() ); // Clone.
adjacentWidgetId = sidebarWidgetIds[i + offset]; adjacentWidgetId = sidebarWidgetIds[i + offset];
sidebarWidgetIds[i + offset] = this.params.widget_id; sidebarWidgetIds[i + offset] = this.params.widget_id;
sidebarWidgetIds[i] = adjacentWidgetId; sidebarWidgetIds[i] = adjacentWidgetId;
@ -1558,7 +1562,7 @@
} }
if ( showOrHide ) { if ( showOrHide ) {
// reset the selected sidebar // Reset the selected sidebar.
$moveWidgetArea.find( '.selected' ).removeClass( 'selected' ); $moveWidgetArea.find( '.selected' ).removeClass( 'selected' );
$moveWidgetArea.find( 'li' ).filter( function() { $moveWidgetArea.find( 'li' ).filter( function() {
@ -1781,7 +1785,7 @@
removedWidgetIds = _( oldWidgetIds ).difference( newWidgetIds ); removedWidgetIds = _( oldWidgetIds ).difference( newWidgetIds );
// Filter out any persistent widget IDs for widgets which have been deactivated // Filter out any persistent widget IDs for widgets which have been deactivated.
newWidgetIds = _( newWidgetIds ).filter( function( newWidgetId ) { newWidgetIds = _( newWidgetIds ).filter( function( newWidgetId ) {
var parsedWidgetId = parseWidgetId( newWidgetId ); var parsedWidgetId = parseWidgetId( newWidgetId );
@ -1798,7 +1802,7 @@
return widgetFormControl; return widgetFormControl;
} ); } );
// Sort widget controls to their new positions // Sort widget controls to their new positions.
widgetFormControls.sort( function( a, b ) { widgetFormControls.sort( function( a, b ) {
var aIndex = _.indexOf( newWidgetIds, a.params.widget_id ), var aIndex = _.indexOf( newWidgetIds, a.params.widget_id ),
bIndex = _.indexOf( newWidgetIds, b.params.widget_id ); bIndex = _.indexOf( newWidgetIds, b.params.widget_id );
@ -1811,25 +1815,26 @@
control.section( self.section() ); control.section( self.section() );
priority += 1; priority += 1;
}); });
self.priority( priority ); // Make sure sidebar control remains at end self.priority( priority ); // Make sure sidebar control remains at end.
// Re-sort widget form controls (including widgets form other sidebars newly moved here) // Re-sort widget form controls (including widgets form other sidebars newly moved here).
self._applyCardinalOrderClassNames(); self._applyCardinalOrderClassNames();
// If the widget was dragged into the sidebar, make sure the sidebar_id param is updated // If the widget was dragged into the sidebar, make sure the sidebar_id param is updated.
_( widgetFormControls ).each( function( widgetFormControl ) { _( widgetFormControls ).each( function( widgetFormControl ) {
widgetFormControl.params.sidebar_id = self.params.sidebar_id; widgetFormControl.params.sidebar_id = self.params.sidebar_id;
} ); } );
// Cleanup after widget removal // Cleanup after widget removal.
_( removedWidgetIds ).each( function( removedWidgetId ) { _( removedWidgetIds ).each( function( removedWidgetId ) {
// Using setTimeout so that when moving a widget to another sidebar, the other sidebars_widgets settings get a chance to update // Using setTimeout so that when moving a widget to another sidebar,
// the other sidebars_widgets settings get a chance to update.
setTimeout( function() { setTimeout( function() {
var removedControl, wasDraggedToAnotherSidebar, inactiveWidgets, removedIdBase, var removedControl, wasDraggedToAnotherSidebar, inactiveWidgets, removedIdBase,
widget, isPresentInAnotherSidebar = false; widget, isPresentInAnotherSidebar = false;
// Check if the widget is in another sidebar // Check if the widget is in another sidebar.
api.each( function( otherSetting ) { api.each( function( otherSetting ) {
if ( otherSetting.id === self.setting.id || 0 !== otherSetting.id.indexOf( 'sidebars_widgets[' ) || otherSetting.id === 'sidebars_widgets[wp_inactive_widgets]' ) { if ( otherSetting.id === self.setting.id || 0 !== otherSetting.id.indexOf( 'sidebars_widgets[' ) || otherSetting.id === 'sidebars_widgets[wp_inactive_widgets]' ) {
return; return;
@ -1850,24 +1855,24 @@
removedControl = api.Widgets.getWidgetFormControlForWidget( removedWidgetId ); removedControl = api.Widgets.getWidgetFormControlForWidget( removedWidgetId );
// Detect if widget control was dragged to another sidebar // Detect if widget control was dragged to another sidebar.
wasDraggedToAnotherSidebar = removedControl && $.contains( document, removedControl.container[0] ) && ! $.contains( self.$sectionContent[0], removedControl.container[0] ); wasDraggedToAnotherSidebar = removedControl && $.contains( document, removedControl.container[0] ) && ! $.contains( self.$sectionContent[0], removedControl.container[0] );
// Delete any widget form controls for removed widgets // Delete any widget form controls for removed widgets.
if ( removedControl && ! wasDraggedToAnotherSidebar ) { if ( removedControl && ! wasDraggedToAnotherSidebar ) {
api.control.remove( removedControl.id ); api.control.remove( removedControl.id );
removedControl.container.remove(); removedControl.container.remove();
} }
// Move widget to inactive widgets sidebar (move it to trash) if has been previously saved // Move widget to inactive widgets sidebar (move it to trash) if has been previously saved.
// This prevents the inactive widgets sidebar from overflowing with throwaway widgets // This prevents the inactive widgets sidebar from overflowing with throwaway widgets.
if ( api.Widgets.savedWidgetIds[removedWidgetId] ) { if ( api.Widgets.savedWidgetIds[removedWidgetId] ) {
inactiveWidgets = api.value( 'sidebars_widgets[wp_inactive_widgets]' )().slice(); inactiveWidgets = api.value( 'sidebars_widgets[wp_inactive_widgets]' )().slice();
inactiveWidgets.push( removedWidgetId ); inactiveWidgets.push( removedWidgetId );
api.value( 'sidebars_widgets[wp_inactive_widgets]' )( _( inactiveWidgets ).unique() ); api.value( 'sidebars_widgets[wp_inactive_widgets]' )( _( inactiveWidgets ).unique() );
} }
// Make old single widget available for adding again // Make old single widget available for adding again.
removedIdBase = parseWidgetId( removedWidgetId ).id_base; removedIdBase = parseWidgetId( removedWidgetId ).id_base;
widget = api.Widgets.availableWidgets.findWhere( { id_base: removedIdBase } ); widget = api.Widgets.availableWidgets.findWhere( { id_base: removedIdBase } );
if ( widget && ! widget.get( 'is_multi' ) ) { if ( widget && ! widget.get( 'is_multi' ) ) {
@ -1916,9 +1921,9 @@
over: function() { over: function() {
var section = api.section( self.section.get() ); var section = api.section( self.section.get() );
section.expand({ section.expand({
allowMultiple: true, // Prevent the section being dragged from to be collapsed allowMultiple: true, // Prevent the section being dragged from to be collapsed.
completeCallback: function () { completeCallback: function () {
// @todo It is not clear when refreshPositions should be called on which sections, or if it is even needed // @todo It is not clear when refreshPositions should be called on which sections, or if it is even needed.
api.section.each( function ( otherSection ) { api.section.each( function ( otherSection ) {
if ( otherSection.container.find( '.customize-control-sidebar_widgets' ).length ) { if ( otherSection.container.find( '.customize-control-sidebar_widgets' ).length ) {
otherSection.container.find( '.accordion-section-content:first' ).sortable( 'refreshPositions' ); otherSection.container.find( '.accordion-section-content:first' ).sortable( 'refreshPositions' );
@ -2079,7 +2084,7 @@
return false; return false;
} }
// Set up new multi widget // Set up new multi widget.
if ( widget.get( 'is_multi' ) && ! widgetNumber ) { if ( widget.get( 'is_multi' ) && ! widgetNumber ) {
widget.set( 'multi_number', widget.get( 'multi_number' ) + 1 ); widget.set( 'multi_number', widget.get( 'multi_number' ) + 1 );
widgetNumber = widget.get( 'multi_number' ); widgetNumber = widget.get( 'multi_number' );
@ -2091,7 +2096,7 @@
return m.replace( /__i__|%i%/g, widgetNumber ); return m.replace( /__i__|%i%/g, widgetNumber );
} ); } );
} else { } else {
widget.set( 'is_disabled', true ); // Prevent single widget from being added again now widget.set( 'is_disabled', true ); // Prevent single widget from being added again now.
} }
$widget = $( controlHtml ); $widget = $( controlHtml );
@ -2101,7 +2106,7 @@
.addClass( 'customize-control-' + controlType ) .addClass( 'customize-control-' + controlType )
.append( $widget ); .append( $widget );
// Remove icon which is visible inside the panel // Remove icon which is visible inside the panel.
controlContainer.find( '> .widget-icon' ).remove(); controlContainer.find( '> .widget-icon' ).remove();
if ( widget.get( 'is_multi' ) ) { if ( widget.get( 'is_multi' ) ) {
@ -2111,7 +2116,7 @@
widgetId = controlContainer.find( '[name="widget-id"]' ).val(); widgetId = controlContainer.find( '[name="widget-id"]' ).val();
controlContainer.hide(); // to be slid-down below controlContainer.hide(); // To be slid-down below.
settingId = 'widget_' + widget.get( 'id_base' ); settingId = 'widget_' + widget.get( 'id_base' );
if ( widget.get( 'is_multi' ) ) { if ( widget.get( 'is_multi' ) ) {
@ -2119,7 +2124,7 @@
} }
controlContainer.attr( 'id', 'customize-control-' + settingId.replace( /\]/g, '' ).replace( /\[/g, '-' ) ); controlContainer.attr( 'id', 'customize-control-' + settingId.replace( /\]/g, '' ).replace( /\[/g, '-' ) );
// Only create setting if it doesn't already exist (if we're adding a pre-existing inactive widget) // Only create setting if it doesn't already exist (if we're adding a pre-existing inactive widget).
isExistingWidget = api.has( settingId ); isExistingWidget = api.has( settingId );
if ( ! isExistingWidget ) { if ( ! isExistingWidget ) {
settingArgs = { settingArgs = {
@ -2127,7 +2132,7 @@
previewer: this.setting.previewer previewer: this.setting.previewer
}; };
setting = api.create( settingId, settingId, '', settingArgs ); setting = api.create( settingId, settingId, '', settingArgs );
setting.set( {} ); // mark dirty, changing from '' to {} setting.set( {} ); // Mark dirty, changing from '' to {}.
} }
controlConstructor = api.controlConstructor[controlType]; controlConstructor = api.controlConstructor[controlType];
@ -2147,7 +2152,7 @@
} ); } );
api.control.add( widgetFormControl ); api.control.add( widgetFormControl );
// Make sure widget is removed from the other sidebars // Make sure widget is removed from the other sidebars.
api.each( function( otherSetting ) { api.each( function( otherSetting ) {
if ( otherSetting.id === self.setting.id ) { if ( otherSetting.id === self.setting.id ) {
return; return;
@ -2166,7 +2171,7 @@
} }
} ); } );
// Add widget to this sidebar // Add widget to this sidebar.
sidebarWidgets = this.setting().slice(); sidebarWidgets = this.setting().slice();
if ( -1 === _.indexOf( sidebarWidgets, widgetId ) ) { if ( -1 === _.indexOf( sidebarWidgets, widgetId ) ) {
sidebarWidgets.push( widgetId ); sidebarWidgets.push( widgetId );
@ -2185,7 +2190,7 @@
} }
} ); } );
// Register models for custom panel, section, and control types // Register models for custom panel, section, and control types.
$.extend( api.panelConstructor, { $.extend( api.panelConstructor, {
widgets: api.Widgets.WidgetsPanel widgets: api.Widgets.WidgetsPanel
}); });
@ -2201,15 +2206,15 @@
* Init Customizer for widgets. * Init Customizer for widgets.
*/ */
api.bind( 'ready', function() { api.bind( 'ready', function() {
// Set up the widgets panel // Set up the widgets panel.
api.Widgets.availableWidgetsPanel = new api.Widgets.AvailableWidgetsPanelView({ api.Widgets.availableWidgetsPanel = new api.Widgets.AvailableWidgetsPanelView({
collection: api.Widgets.availableWidgets collection: api.Widgets.availableWidgets
}); });
// Highlight widget control // Highlight widget control.
api.previewer.bind( 'highlight-widget-control', api.Widgets.highlightWidgetFormControl ); api.previewer.bind( 'highlight-widget-control', api.Widgets.highlightWidgetFormControl );
// Open and focus widget control // Open and focus widget control.
api.previewer.bind( 'focus-widget-control', api.Widgets.focusWidgetFormControl ); api.previewer.bind( 'focus-widget-control', api.Widgets.focusWidgetFormControl );
} ); } );
@ -2247,7 +2252,7 @@
api.Widgets.getSidebarWidgetControlContainingWidget = function( widgetId ) { api.Widgets.getSidebarWidgetControlContainingWidget = function( widgetId ) {
var foundControl = null; var foundControl = null;
// @todo this can use widgetIdToSettingId(), then pass into wp.customize.control( x ).getSidebarWidgetsControl() // @todo This can use widgetIdToSettingId(), then pass into wp.customize.control( x ).getSidebarWidgetsControl().
api.control.each( function( control ) { api.control.each( function( control ) {
if ( control.params.type === 'sidebar_widgets' && -1 !== _.indexOf( control.setting(), widgetId ) ) { if ( control.params.type === 'sidebar_widgets' && -1 !== _.indexOf( control.setting(), widgetId ) ) {
foundControl = control; foundControl = control;
@ -2266,7 +2271,7 @@
api.Widgets.getWidgetFormControlForWidget = function( widgetId ) { api.Widgets.getWidgetFormControlForWidget = function( widgetId ) {
var foundControl = null; var foundControl = null;
// @todo We can just use widgetIdToSettingId() here // @todo We can just use widgetIdToSettingId() here.
api.control.each( function( control ) { api.control.each( function( control ) {
if ( control.params.type === 'widget_form' && control.params.widget_id === widgetId ) { if ( control.params.type === 'widget_form' && control.params.widget_id === widgetId ) {
foundControl = control; foundControl = control;
@ -2343,7 +2348,7 @@
parsed.id_base = matches[1]; parsed.id_base = matches[1];
parsed.number = parseInt( matches[2], 10 ); parsed.number = parseInt( matches[2], 10 );
} else { } else {
// likely an old single widget // Likely an old single widget.
parsed.id_base = widgetId; parsed.id_base = widgetId;
} }

View File

@ -192,7 +192,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved,
var newTitle, regExMatch, titleCount, commentFrag; var newTitle, regExMatch, titleCount, commentFrag;
titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' ); titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' );
// count funcs operate on a $'d element // Count funcs operate on a $'d element.
titleDiv = titleDiv || $( '<div />' ); titleDiv = titleDiv || $( '<div />' );
newTitle = adminTitle; newTitle = adminTitle;
@ -256,7 +256,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved,
return; return;
} }
// cache selectors to not get dupes // Cache selectors to not get dupes.
pending = $( 'span.' + pendingClass, postSelector ); pending = $( 'span.' + pendingClass, postSelector );
noPending = $( 'span.' + noClass, postSelector ); noPending = $( 'span.' + noClass, postSelector );
@ -444,7 +444,7 @@ window.setCommentsList = function() {
a.click(function( e ){ a.click(function( e ){
e.preventDefault(); e.preventDefault();
e.stopPropagation(); // ticket #35904 e.stopPropagation(); // Ticket #35904.
list.wpList.del(this); list.wpList.del(this);
$('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){ $('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){
$(this).remove(); $(this).remove();
@ -491,17 +491,19 @@ window.setCommentsList = function() {
unapproved = commentRow.hasClass( 'unapproved' ), unapproved = commentRow.hasClass( 'unapproved' ),
spammed = commentRow.hasClass( 'spam' ), spammed = commentRow.hasClass( 'spam' ),
trashed = commentRow.hasClass( 'trash' ), trashed = commentRow.hasClass( 'trash' ),
undoing = false; // ticket #35904 undoing = false; // Ticket #35904.
updateDashboardText( newTotal ); updateDashboardText( newTotal );
updateInModerationText( newTotal ); updateInModerationText( newTotal );
// the order of these checks is important /*
// .unspam can also have .approve or .unapprove * The order of these checks is important.
// .untrash can also have .approve or .unapprove * .unspam can also have .approve or .unapprove.
* .untrash can also have .approve or .unapprove.
*/
if ( targetParent.is( 'span.undo' ) ) { if ( targetParent.is( 'span.undo' ) ) {
// the comment was spammed // The comment was spammed.
if ( targetParent.hasClass( 'unspam' ) ) { if ( targetParent.hasClass( 'unspam' ) ) {
spamDiff = -1; spamDiff = -1;
@ -513,7 +515,7 @@ window.setCommentsList = function() {
pendingDiff = 1; pendingDiff = 1;
} }
// the comment was trashed // The comment was trashed.
} else if ( targetParent.hasClass( 'untrash' ) ) { } else if ( targetParent.hasClass( 'untrash' ) ) {
trashDiff = -1; trashDiff = -1;
@ -528,32 +530,32 @@ window.setCommentsList = function() {
undoing = true; undoing = true;
// user clicked "Spam" // User clicked "Spam".
} else if ( targetParent.is( 'span.spam' ) ) { } else if ( targetParent.is( 'span.spam' ) ) {
// the comment is currently approved // The comment is currently approved.
if ( approved ) { if ( approved ) {
approvedDiff = -1; approvedDiff = -1;
// the comment is currently pending // The comment is currently pending.
} else if ( unapproved ) { } else if ( unapproved ) {
pendingDiff = -1; pendingDiff = -1;
// the comment was in the trash // The comment was in the trash.
} else if ( trashed ) { } else if ( trashed ) {
trashDiff = -1; trashDiff = -1;
} }
// you can't spam an item on the spam screen // You can't spam an item on the Spam screen.
spamDiff = 1; spamDiff = 1;
// user clicked "Unspam" // User clicked "Unspam".
} else if ( targetParent.is( 'span.unspam' ) ) { } else if ( targetParent.is( 'span.unspam' ) ) {
if ( approved ) { if ( approved ) {
pendingDiff = 1; pendingDiff = 1;
} else if ( unapproved ) { } else if ( unapproved ) {
approvedDiff = 1; approvedDiff = 1;
} else if ( trashed ) { } else if ( trashed ) {
// the comment was previously approved // The comment was previously approved.
if ( targetParent.hasClass( 'approve' ) ) { if ( targetParent.hasClass( 'approve' ) ) {
approvedDiff = 1; approvedDiff = 1;
// the comment was previously pending // The comment was previously pending.
} else if ( targetParent.hasClass( 'unapprove' ) ) { } else if ( targetParent.hasClass( 'unapprove' ) ) {
pendingDiff = 1; pendingDiff = 1;
} }
@ -565,23 +567,23 @@ window.setCommentsList = function() {
pendingDiff = 1; pendingDiff = 1;
} }
} }
// you can Unspam an item on the spam screen // You can unspam an item on the Spam screen.
spamDiff = -1; spamDiff = -1;
// user clicked "Trash" // User clicked "Trash".
} else if ( targetParent.is( 'span.trash' ) ) { } else if ( targetParent.is( 'span.trash' ) ) {
if ( approved ) { if ( approved ) {
approvedDiff = -1; approvedDiff = -1;
} else if ( unapproved ) { } else if ( unapproved ) {
pendingDiff = -1; pendingDiff = -1;
// the comment was in the spam queue // The comment was in the spam queue.
} else if ( spammed ) { } else if ( spammed ) {
spamDiff = -1; spamDiff = -1;
} }
// you can't trash an item on the trash screen // You can't trash an item on the Trash screen.
trashDiff = 1; trashDiff = 1;
// user clicked "Restore" // User clicked "Restore".
} else if ( targetParent.is( 'span.untrash' ) ) { } else if ( targetParent.is( 'span.untrash' ) ) {
if ( approved ) { if ( approved ) {
pendingDiff = 1; pendingDiff = 1;
@ -594,21 +596,21 @@ window.setCommentsList = function() {
pendingDiff = 1; pendingDiff = 1;
} }
} }
// you can't go from trash to spam // You can't go from Trash to Spam.
// you can untrash on the trash screen // You can untrash on the Trash screen.
trashDiff = -1; trashDiff = -1;
// User clicked "Approve" // User clicked "Approve".
} else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) { } else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) {
approvedDiff = 1; approvedDiff = 1;
pendingDiff = -1; pendingDiff = -1;
// User clicked "Unapprove" // User clicked "Unapprove".
} else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) { } else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) {
approvedDiff = -1; approvedDiff = -1;
pendingDiff = 1; pendingDiff = 1;
// User clicked "Delete Permanently" // User clicked "Delete Permanently".
} else if ( targetParent.is( 'span.delete' ) ) { } else if ( targetParent.is( 'span.delete' ) ) {
if ( spammed ) { if ( spammed ) {
spamDiff = -1; spamDiff = -1;
@ -713,17 +715,17 @@ window.setCommentsList = function() {
if (ev) { if (ev) {
theExtraList.empty(); theExtraList.empty();
args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php args.number = Math.min(8, per_page); // See WP_Comments_List_Table::prepare_items() in class-wp-comments-list-table.php.
} else { } else {
args.number = 1; args.number = 1;
args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list args.offset = Math.min(8, per_page) - 1; // Fetch only the next item on the extra list.
} }
args.no_placeholder = true; args.no_placeholder = true;
args.paged ++; args.paged ++;
// $.query.get() needs some correction to be sent into an ajax request // $.query.get() needs some correction to be sent into an Ajax request.
if ( true === args.comment_type ) if ( true === args.comment_type )
args.comment_type = ''; args.comment_type = '';
@ -781,9 +783,9 @@ window.commentReply = {
/** /**
* Initializes the comment reply functionality. * Initializes the comment reply functionality.
* *
* @memberof commentReply
*
* @since 2.7.0 * @since 2.7.0
*
* @memberof commentReply
*/ */
init : function() { init : function() {
var row = $('#replyrow'); var row = $('#replyrow');
@ -798,7 +800,7 @@ window.commentReply = {
} }
}); });
// add events // Add events.
$('#the-comment-list .column-comment > p').dblclick(function(){ $('#the-comment-list .column-comment > p').dblclick(function(){
commentReply.toggle($(this).parent()); commentReply.toggle($(this).parent());
}); });
@ -911,7 +913,7 @@ window.commentReply = {
.focus(); .focus();
} }
// reset the Quicktags buttons // Reset the Quicktags buttons.
if ( typeof QTags != 'undefined' ) if ( typeof QTags != 'undefined' )
QTags.closeAllTags('replycontent'); QTags.closeAllTags('replycontent');
@ -1029,7 +1031,7 @@ window.commentReply = {
$('#replycontent').focus().keyup(function(e){ $('#replycontent').focus().keyup(function(e){
if ( e.which == 27 ) if ( e.which == 27 )
commentReply.revert(); // close on Escape commentReply.revert(); // Close on Escape.
}); });
}, 600); }, 600);
@ -1130,7 +1132,7 @@ window.commentReply = {
updateCountText( 'span.all-count', 1 ); updateCountText( 'span.all-count', 1 );
} }
c = $.trim(r.data); // Trim leading whitespaces c = $.trim(r.data); // Trim leading whitespaces.
$(c).hide(); $(c).hide();
$('#replyrow').after(c); $('#replyrow').after(c);

View File

@ -246,10 +246,11 @@
function mceKeyup( event ) { function mceKeyup( event ) {
var key = event.keyCode; var key = event.keyCode;
// Bail on special keys. Key code 47 is a / // Bail on special keys. Key code 47 is a '/'.
if ( key <= 47 && ! ( key === VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE || key === VK.UP || key === VK.LEFT || key === VK.DOWN || key === VK.UP ) ) { if ( key <= 47 && ! ( key === VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE || key === VK.UP || key === VK.LEFT || key === VK.DOWN || key === VK.UP ) ) {
return; return;
// OS keys, function keys, num lock, scroll lock. Key code 91-93 are OS keys. Key code 112-123 are F1 to F12. Key code 144 is num lock. Key code 145 is scroll lock. // OS keys, function keys, num lock, scroll lock. Key code 91-93 are OS keys.
// Key code 112-123 are F1 to F12. Key code 144 is num lock. Key code 145 is scroll lock.
} else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) { } else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) {
return; return;
} }
@ -516,7 +517,7 @@
* If in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + topHeight. * If in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + topHeight.
* If not in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + 20. * If not in visual mode, checks if the editorHeight is greater than the autoresizeMinHeight + 20.
*/ */
canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding.
canPin = editorHeight > ( canPin + 5 ); canPin = editorHeight > ( canPin + 5 );
if ( ! canPin ) { if ( ! canPin ) {
@ -910,7 +911,7 @@
// Adjust when entering or exiting fullscreen mode. // Adjust when entering or exiting fullscreen mode.
fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide ); fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide );
// Reset all css // Reset all CSS.
$.each( [ $visualTop, $textTop, $tools, $menuBar, $bottom, $statusBar, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) { $.each( [ $visualTop, $textTop, $tools, $menuBar, $bottom, $statusBar, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) {
element && element.attr( 'style', '' ); element && element.attr( 'style', '' );
}); });
@ -1179,15 +1180,15 @@
// Return if any of the following keys or combinations of keys is pressed. // Return if any of the following keys or combinations of keys is pressed.
if ( event && ( event.metaKey || ( event.ctrlKey && ! event.altKey ) || ( event.altKey && event.shiftKey ) || ( key && ( if ( event && ( event.metaKey || ( event.ctrlKey && ! event.altKey ) || ( event.altKey && event.shiftKey ) || ( key && (
// Special keys ( tab, ctrl, alt, esc, arrow keys... ) // Special keys ( tab, ctrl, alt, esc, arrow keys... ).
( key <= 47 && key !== 8 && key !== 13 && key !== 32 && key !== 46 ) || ( key <= 47 && key !== 8 && key !== 13 && key !== 32 && key !== 46 ) ||
// Windows keys // Windows keys.
( key >= 91 && key <= 93 ) || ( key >= 91 && key <= 93 ) ||
// F keys // F keys.
( key >= 112 && key <= 135 ) || ( key >= 112 && key <= 135 ) ||
// Num Lock, Scroll Lock, OEM // Num Lock, Scroll Lock, OEM.
( key >= 144 && key <= 150 ) || ( key >= 144 && key <= 150 ) ||
// OEM or non-printable // OEM or non-printable.
key >= 224 key >= 224
) ) ) ) { ) ) ) ) {
return; return;

View File

@ -112,7 +112,7 @@ window.wp = window.wp || {};
} }
if ( keepSelection ) { if ( keepSelection ) {
// Save the selection // Save the selection.
addHTMLBookmarkInTextAreaContent( $textarea ); addHTMLBookmarkInTextAreaContent( $textarea );
} }
@ -131,7 +131,7 @@ window.wp = window.wp || {};
} }
if ( editor.getParam( 'wp_keep_scroll_position' ) ) { if ( editor.getParam( 'wp_keep_scroll_position' ) ) {
// Restore the selection // Restore the selection.
focusHTMLBookmarkInVisualEditor( editor ); focusHTMLBookmarkInVisualEditor( editor );
} }
} else { } else {
@ -149,7 +149,8 @@ window.wp = window.wp || {};
} }
if ( editor ) { if ( editor ) {
// Don't resize the textarea in iOS. The iframe is forced to 100% height there, we shouldn't match it. // Don't resize the textarea in iOS.
// The iframe is forced to 100% height there, we shouldn't match it.
if ( ! tinymce.Env.iOS ) { if ( ! tinymce.Env.iOS ) {
iframe = editor.iframeElement; iframe = editor.iframeElement;
editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0; editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0;
@ -177,7 +178,8 @@ window.wp = window.wp || {};
selectTextInTextArea( editor, selectionRange ); selectTextInTextArea( editor, selectionRange );
} }
} else { } else {
// There is probably a JS error on the page. The TinyMCE editor instance doesn't exist. Show the textarea. // There is probably a JS error on the page.
// The TinyMCE editor instance doesn't exist. Show the textarea.
$textarea.css({ 'display': '', 'visibility': '' }); $textarea.css({ 'display': '', 'visibility': '' });
} }
@ -209,7 +211,7 @@ window.wp = window.wp || {};
lastGtPos = content.lastIndexOf( '>', cursorPosition ); lastGtPos = content.lastIndexOf( '>', cursorPosition );
if ( lastLtPos > lastGtPos || content.substr( cursorPosition, 1 ) === '>' ) { if ( lastLtPos > lastGtPos || content.substr( cursorPosition, 1 ) === '>' ) {
// find what the tag is // Find what the tag is.
var tagContent = content.substr( lastLtPos ), var tagContent = content.substr( lastLtPos ),
tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ ); tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ );
@ -222,7 +224,7 @@ window.wp = window.wp || {};
return { return {
ltPos: lastLtPos, ltPos: lastLtPos,
gtPos: lastLtPos + closingGt + 1, // offset by one to get the position _after_ the character, gtPos: lastLtPos + closingGt + 1, // Offset by one to get the position _after_ the character.
tagType: tagType, tagType: tagType,
isClosingTag: !! tagMatch[1] isClosingTag: !! tagMatch[1]
}; };
@ -248,7 +250,7 @@ window.wp = window.wp || {};
* @param {number} cursorPosition The cursor position to check. * @param {number} cursorPosition The cursor position to check.
* *
* @return {(undefined|Object)} Undefined if the cursor is not wrapped in a shortcode tag. * @return {(undefined|Object)} Undefined if the cursor is not wrapped in a shortcode tag.
* Information about the wrapping shortcode tag if it's wrapped in one. * Information about the wrapping shortcode tag if it's wrapped in one.
*/ */
function getShortcodeWrapperInfo( content, cursorPosition ) { function getShortcodeWrapperInfo( content, cursorPosition ) {
var contentShortcodes = getShortCodePositionsInText( content ); var contentShortcodes = getShortCodePositionsInText( content );
@ -403,7 +405,7 @@ window.wp = window.wp || {};
var cursorStart = cursorPositions.cursorStart, var cursorStart = cursorPositions.cursorStart,
cursorEnd = cursorPositions.cursorEnd, cursorEnd = cursorPositions.cursorEnd,
// check if the cursor is in a tag and if so, adjust it // Check if the cursor is in a tag and if so, adjust it.
isCursorStartInTag = getContainingTagInfo( content, cursorStart ); isCursorStartInTag = getContainingTagInfo( content, cursorStart );
if ( isCursorStartInTag ) { if ( isCursorStartInTag ) {
@ -506,11 +508,11 @@ window.wp = window.wp || {};
} }
textArea.value = [ textArea.value = [
textArea.value.slice( 0, htmlModeCursorStartPosition ), // text until the cursor/selection position textArea.value.slice( 0, htmlModeCursorStartPosition ), // Text until the cursor/selection position.
cursorMarkerSkeleton.clone() // cursor/selection start marker cursorMarkerSkeleton.clone() // Cursor/selection start marker.
.addClass( 'mce_SELRES_start' )[0].outerHTML, .addClass( 'mce_SELRES_start' )[0].outerHTML,
selectedText, // selected text with end cursor/position marker selectedText, // Selected text with end cursor/position marker.
textArea.value.slice( htmlModeCursorEndPosition ) // text from last cursor/selection position to end textArea.value.slice( htmlModeCursorEndPosition ) // Text from last cursor/selection position to end.
].join( '' ); ].join( '' );
} }
@ -804,7 +806,7 @@ window.wp = window.wp || {};
endMatchIndex -= endMatch[1].length; endMatchIndex -= endMatch[1].length;
} }
// We need to adjust the end position to discard the length of the range start marker // We need to adjust the end position to discard the length of the range start marker.
endIndex = endMatchIndex - startMatchLength; endIndex = endMatchIndex - startMatchLength;
} }
@ -826,7 +828,7 @@ window.wp = window.wp || {};
* @param {Object} selection Selection data. * @param {Object} selection Selection data.
*/ */
function selectTextInTextArea( editor, selection ) { function selectTextInTextArea( editor, selection ) {
// only valid in the text area mode and if we have selection // Only valid in the text area mode and if we have selection.
if ( ! selection ) { if ( ! selection ) {
return; return;
} }
@ -836,11 +838,11 @@ window.wp = window.wp || {};
end = selection.end || selection.start; end = selection.end || selection.start;
if ( textArea.focus ) { if ( textArea.focus ) {
// Wait for the Visual editor to be hidden, then focus and scroll to the position // Wait for the Visual editor to be hidden, then focus and scroll to the position.
setTimeout( function() { setTimeout( function() {
textArea.setSelectionRange( start, end ); textArea.setSelectionRange( start, end );
if ( textArea.blur ) { if ( textArea.blur ) {
// defocus before focusing // Defocus before focusing.
textArea.blur(); textArea.blur();
} }
textArea.focus(); textArea.focus();
@ -1249,7 +1251,7 @@ window.wp = window.wp || {};
defaults = wp.editor.getDefaultSettings(); defaults = wp.editor.getDefaultSettings();
// Initialize TinyMCE by default // Initialize TinyMCE by default.
if ( ! settings ) { if ( ! settings ) {
settings = { settings = {
tinymce: true tinymce: true

View File

@ -15,7 +15,7 @@ jQuery(document).ready(function($) {
distance: 2, distance: 2,
handle: 'div.filename', handle: 'div.filename',
stop: function() { stop: function() {
// When an update has occurred, adjust the order for each item // When an update has occurred, adjust the order for each item.
var all = $('#media-items').sortable('toArray'), len = all.length; var all = $('#media-items').sortable('toArray'), len = all.length;
$.each(all, function(i, id) { $.each(all, function(i, id) {
var order = desc ? (len - i) : (1 + i); var order = desc ? (len - i) : (1 + i);
@ -71,7 +71,7 @@ jQuery(document).ready(function($) {
$('img.pinkynail').toggle(true); $('img.pinkynail').toggle(true);
}); });
// initialize sortable // Initialize sortable.
gallerySortableInit(); gallerySortableInit();
clearAll(); clearAll();
@ -88,7 +88,7 @@ jQuery(document).ready(function($) {
} }
}); });
jQuery(window).unload( function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup jQuery(window).unload( function () { window.tinymce = window.tinyMCE = window.wpgallery = null; } ); // Cleanup.
/* gallery settings */ /* gallery settings */
window.tinymce = null; window.tinymce = null;
@ -122,7 +122,7 @@ window.wpgallery = {
document.domain = q.mce_rdomain; document.domain = q.mce_rdomain;
} }
// Find window & API // Find window & API.
window.tinymce = w.tinymce; window.tinymce = w.tinymce;
window.tinyMCE = w.tinyMCE; window.tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor; t.editor = tinymce.EditorManager.activeEditor;

View File

@ -48,8 +48,9 @@
/** /**
* Converts a value to an integer. * Converts a value to an integer.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} f The float value that should be converted. * @param {number} f The float value that should be converted.
* *
@ -66,8 +67,9 @@
/** /**
* Adds the disabled attribute and class to a single form element or a field set. * Adds the disabled attribute and class to a single form element or a field set.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {jQuery} el The element that should be modified. * @param {jQuery} el The element that should be modified.
* @param {bool|number} s The state for the element. If set to true * @param {bool|number} s The state for the element. If set to true
@ -95,8 +97,9 @@
/** /**
* Initializes the image editor. * Initializes the image editor.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* *
@ -121,12 +124,12 @@
$('input[type="text"]', '#imgedit-panel-' + postid).keypress(function(e) { $('input[type="text"]', '#imgedit-panel-' + postid).keypress(function(e) {
var k = e.keyCode; var k = e.keyCode;
// Key codes 37 thru 40 are the arrow keys. // Key codes 37 through 40 are the arrow keys.
if ( 36 < k && k < 41 ) { if ( 36 < k && k < 41 ) {
$(this).blur(); $(this).blur();
} }
// The key code 13 is the enter key. // The key code 13 is the Enter key.
if ( 13 === k ) { if ( 13 === k ) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -138,8 +141,9 @@
/** /**
* Toggles the wait/load icon in the editor. * Toggles the wait/load icon in the editor.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {number} toggle Is 0 or 1, fades the icon in then 1 and out when 0. * @param {number} toggle Is 0 or 1, fades the icon in then 1 and out when 0.
@ -159,8 +163,9 @@
/** /**
* Shows or hides the image edit help box. * Shows or hides the image edit help box.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {HTMLElement} el The element to create the help window in. * @param {HTMLElement} el The element to create the help window in.
* *
@ -181,8 +186,9 @@
* The image edit target contains the image sizes where the (possible) changes * The image edit target contains the image sizes where the (possible) changes
* have to be applied to. * have to be applied to.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* *
@ -198,8 +204,9 @@
* *
* If the original image size is exceeded a red exclamation mark is shown. * If the original image size is exceeded a red exclamation mark is shown.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The current post id. * @param {number} postid The current post id.
* @param {number} x Is 0 when it applies the y-axis * @param {number} x Is 0 when it applies the y-axis
@ -234,8 +241,9 @@
/** /**
* Gets the selected aspect ratio. * Gets the selected aspect ratio.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* *
@ -261,8 +269,9 @@
* Removes the last action from the image edit history. * Removes the last action from the image edit history.
* The history consist of (edit) actions performed on the image. * The history consist of (edit) actions performed on the image.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {number} setSize 0 or 1, when 1 the image resets to its original size. * @param {number} setSize 0 or 1, when 1 the image resets to its original size.
@ -295,13 +304,13 @@
// Restore original 'o'. // Restore original 'o'.
o = history[history.length - 1]; o = history[history.length - 1];
// c = 'crop', r = 'rotate', f = 'flip' // c = 'crop', r = 'rotate', f = 'flip'.
o = o.c || o.r || o.f || false; o = o.c || o.r || o.f || false;
if ( o ) { if ( o ) {
// fw = Full image width // fw = Full image width.
this.hold.w = o.fw; this.hold.w = o.fw;
// fh = Full image height // fh = Full image height.
this.hold.h = o.fh; this.hold.h = o.fh;
} }
} }
@ -326,8 +335,9 @@
* *
* When the image source is reloaded the image will be reloaded. * When the image source is reloaded the image will be reloaded.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {string} nonce The nonce to verify the request. * @param {string} nonce The nonce to verify the request.
@ -371,7 +381,7 @@
parent.empty().append(img); parent.empty().append(img);
// w, h are the new full size dims // w, h are the new full size dimensions.
max1 = Math.max( t.hold.w, t.hold.h ); max1 = Math.max( t.hold.w, t.hold.h );
max2 = Math.max( $(img).width(), $(img).height() ); max2 = Math.max( $(img).width(), $(img).height() );
t.hold.sizer = max1 > max2 ? max2 / max1 : 1; t.hold.sizer = max1 > max2 ? max2 / max1 : 1;
@ -399,8 +409,9 @@
/** /**
* Performs an image edit action. * Performs an image edit action.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {string} nonce The nonce to verify the request. * @param {string} nonce The nonce to verify the request.
@ -456,7 +467,7 @@
$.post(ajaxurl, data, function(r) { $.post(ajaxurl, data, function(r) {
$('#image-editor-' + postid).empty().append(r); $('#image-editor-' + postid).empty().append(r);
t.toggleEditor(postid, 0); t.toggleEditor(postid, 0);
// refresh the attachment model so that changes propagate // Refresh the attachment model so that changes propagate.
if ( t._view ) { if ( t._view ) {
t._view.refresh(); t._view.refresh();
} }
@ -466,8 +477,9 @@
/** /**
* Stores the changes that are made to the image. * Stores the changes that are made to the image.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id to get the image from the database. * @param {number} postid The post id to get the image from the database.
* @param {string} nonce The nonce to verify the request. * @param {string} nonce The nonce to verify the request.
@ -531,8 +543,9 @@
/** /**
* Creates the image edit window. * Creates the image edit window.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id for the image. * @param {number} postid The post id for the image.
* @param {string} nonce The nonce to verify the request. * @param {string} nonce The nonce to verify the request.
@ -588,8 +601,9 @@
/** /**
* Initializes the cropping tool and sets a default cropping selection. * Initializes the cropping tool and sets a default cropping selection.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* *
@ -614,8 +628,9 @@
/** /**
* Initializes the cropping tool. * Initializes the cropping tool.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {HTMLElement} image The preview image. * @param {HTMLElement} image The preview image.
@ -645,8 +660,8 @@
* @param {jQuery} img The preview image. * @param {jQuery} img The preview image.
*/ */
onInit: function( img ) { onInit: function( img ) {
// Ensure that the imgAreaSelect wrapper elements are position:absolute. // Ensure that the imgAreaSelect wrapper elements are position:absolute
// (even if we're in a position:fixed modal) // (even if we're in a position:fixed modal).
$img = $( img ); $img = $( img );
$img.next().css( 'position', 'absolute' ) $img.next().css( 'position', 'absolute' )
.nextAll( '.imgareaselect-outer' ).css( 'position', 'absolute' ); .nextAll( '.imgareaselect-outer' ).css( 'position', 'absolute' );
@ -715,8 +730,9 @@
/** /**
* Stores the current crop selection. * Stores the current crop selection.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {object} c The selection. * @param {object} c The selection.
@ -746,8 +762,9 @@
/** /**
* Closes the image editor. * Closes the image editor.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {bool} warn Warning message. * @param {bool} warn Warning message.
@ -764,13 +781,14 @@
this.iasapi = {}; this.iasapi = {};
this.hold = {}; this.hold = {};
// If we've loaded the editor in the context of a Media Modal, then switch to the previous view, // If we've loaded the editor in the context of a Media Modal,
// whatever that might have been. // then switch to the previous view, whatever that might have been.
if ( this._view ){ if ( this._view ){
this._view.back(); this._view.back();
} }
// In case we are not accessing the image editor in the context of a View, close the editor the old-skool way // In case we are not accessing the image editor in the context of a View,
// close the editor the old-school way.
else { else {
$('#image-editor-' + postid).fadeOut('fast', function() { $('#image-editor-' + postid).fadeOut('fast', function() {
$( '#media-head-' + postid ).fadeIn( 'fast', function() { $( '#media-head-' + postid ).fadeIn( 'fast', function() {
@ -787,8 +805,9 @@
/** /**
* Checks if the image edit history is saved. * Checks if the image edit history is saved.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* *
@ -811,8 +830,9 @@
/** /**
* Adds an image edit action to the history. * Adds an image edit action to the history.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {object} op The original position. * @param {object} op The original position.
* @param {number} postid The post id. * @param {number} postid The post id.
@ -830,7 +850,7 @@
history.pop(); history.pop();
pop--; pop--;
} }
undone.val(0); // reset undone.val(0); // Reset.
history.push(op); history.push(op);
elem.val( JSON.stringify(history) ); elem.val( JSON.stringify(history) );
@ -844,8 +864,9 @@
/** /**
* Rotates the image. * Rotates the image.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {string} angle The angle the image is rotated with. * @param {string} angle The angle the image is rotated with.
* @param {number} postid The post id. * @param {number} postid The post id.
@ -865,8 +886,9 @@
/** /**
* Flips the image. * Flips the image.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} axis The axle the image is flipped on. * @param {number} axis The axle the image is flipped on.
* @param {number} postid The post id. * @param {number} postid The post id.
@ -886,8 +908,9 @@
/** /**
* Crops the image. * Crops the image.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {string} nonce The nonce. * @param {string} nonce The nonce.
@ -915,8 +938,9 @@
/** /**
* Undoes an image edit action. * Undoes an image edit action.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {string} nonce The nonce. * @param {string} nonce The nonce.
@ -948,8 +972,9 @@
/** /**
* Reverts a undo action. * Reverts a undo action.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {string} nonce The nonce. * @param {string} nonce The nonce.
@ -978,8 +1003,9 @@
/** /**
* Sets the selection for the height and width in pixels. * Sets the selection for the height and width in pixels.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {jQuery} el The element containing the values. * @param {jQuery} el The element containing the values.
@ -1035,8 +1061,9 @@
/** /**
* Rounds a number to a whole. * Rounds a number to a whole.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} num The number. * @param {number} num The number.
* *
@ -1064,8 +1091,9 @@
/** /**
* Sets a locked aspect ratio for the selection. * Sets a locked aspect ratio for the selection.
* *
* @since 2.9.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 2.9.0
* *
* @param {number} postid The post id. * @param {number} postid The post id.
* @param {number} n The ratio to set. * @param {number} n The ratio to set.
@ -1108,8 +1136,9 @@
/** /**
* Validates if a value in a jQuery.HTMLElement is numeric. * Validates if a value in a jQuery.HTMLElement is numeric.
* *
* @since 4.6.0
*
* @memberof imageEdit * @memberof imageEdit
* @since 4.6
* *
* @param {jQuery} el The html element. * @param {jQuery} el The html element.
* *

View File

@ -29,41 +29,42 @@ window.wp = window.wp || {};
/** /**
* Initializes the inline and bulk post editor. * Initializes the inline and bulk post editor.
* *
* Binds event handlers to the escape key to close the inline editor * Binds event handlers to the Escape key to close the inline editor
* and to the save and close buttons. Changes DOM to be ready for inline * and to the save and close buttons. Changes DOM to be ready for inline
* editing. Adds event handler to bulk edit. * editing. Adds event handler to bulk edit.
* *
* @memberof inlineEditPost
* @since 2.7.0 * @since 2.7.0
* *
* @memberof inlineEditPost
*
* @return {void} * @return {void}
*/ */
init : function(){ init : function(){
var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit'); var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit');
t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post'; t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post';
// Post id prefix. // Post ID prefix.
t.what = '#post-'; t.what = '#post-';
/** /**
* Binds the escape key to revert the changes and close the quick editor. * Binds the Escape key to revert the changes and close the quick editor.
* *
* @return {boolean} The result of revert. * @return {boolean} The result of revert.
*/ */
qeRow.keyup(function(e){ qeRow.keyup(function(e){
// Revert changes if escape key is pressed. // Revert changes if Escape key is pressed.
if ( e.which === 27 ) { if ( e.which === 27 ) {
return inlineEditPost.revert(); return inlineEditPost.revert();
} }
}); });
/** /**
* Binds the escape key to revert the changes and close the bulk editor. * Binds the Escape key to revert the changes and close the bulk editor.
* *
* @return {boolean} The result of revert. * @return {boolean} The result of revert.
*/ */
bulkRow.keyup(function(e){ bulkRow.keyup(function(e){
// Revert changes if escape key is pressed. // Revert changes if Escape key is pressed.
if ( e.which === 27 ) { if ( e.which === 27 ) {
return inlineEditPost.revert(); return inlineEditPost.revert();
} }
@ -88,7 +89,7 @@ window.wp = window.wp || {};
}); });
/** /**
* If enter is pressed, and the target is not the cancel button, save the post. * If Enter is pressed, and the target is not the cancel button, save the post.
* *
* @return {boolean} The result of save. * @return {boolean} The result of save.
*/ */
@ -157,9 +158,10 @@ window.wp = window.wp || {};
* Toggles the quick edit window, hiding it when it's active and showing it when * Toggles the quick edit window, hiding it when it's active and showing it when
* inactive. * inactive.
* *
* @memberof inlineEditPost
* @since 2.7.0 * @since 2.7.0
* *
* @memberof inlineEditPost
*
* @param {Object} el Element within a post table row. * @param {Object} el Element within a post table row.
*/ */
toggle : function(el){ toggle : function(el){
@ -170,8 +172,9 @@ window.wp = window.wp || {};
/** /**
* Creates the bulk editor row to edit multiple posts at once. * Creates the bulk editor row to edit multiple posts at once.
* *
* @memberof inlineEditPost
* @since 2.7.0 * @since 2.7.0
*
* @memberof inlineEditPost
*/ */
setBulk : function(){ setBulk : function(){
var te = '', type = this.type, c = true; var te = '', type = this.type, c = true;
@ -242,9 +245,10 @@ window.wp = window.wp || {};
/** /**
* Creates a quick edit window for the post that has been clicked. * Creates a quick edit window for the post that has been clicked.
* *
* @memberof inlineEditPost
* @since 2.7.0 * @since 2.7.0
* *
* @memberof inlineEditPost
*
* @param {number|Object} id The id of the clicked post or an element within a post * @param {number|Object} id The id of the clicked post or an element within a post
* table row. * table row.
* @return {boolean} Always returns false at the end of execution. * @return {boolean} Always returns false at the end of execution.
@ -409,7 +413,7 @@ window.wp = window.wp || {};
fields = $('#edit-'+id).find(':input').serialize(); fields = $('#edit-'+id).find(':input').serialize();
params = fields + '&' + $.param(params); params = fields + '&' + $.param(params);
// Make ajax request. // Make Ajax request.
$.post( ajaxurl, params, $.post( ajaxurl, params,
function(r) { function(r) {
var $errorNotice = $( '#edit-' + id + ' .inline-edit-save .notice-error' ), var $errorNotice = $( '#edit-' + id + ' .inline-edit-save .notice-error' ),
@ -450,9 +454,10 @@ window.wp = window.wp || {};
/** /**
* Hides and empties the Quick Edit and/or Bulk Edit windows. * Hides and empties the Quick Edit and/or Bulk Edit windows.
* *
* @memberof inlineEditPost
* @since 2.7.0 * @since 2.7.0
* *
* @memberof inlineEditPost
*
* @return {boolean} Always returns false. * @return {boolean} Always returns false.
*/ */
revert : function(){ revert : function(){
@ -494,9 +499,10 @@ window.wp = window.wp || {};
* Gets the id for a the post that you want to quick edit from the row in the quick * Gets the id for a the post that you want to quick edit from the row in the quick
* edit table. * edit table.
* *
* @memberof inlineEditPost
* @since 2.7.0 * @since 2.7.0
* *
* @memberof inlineEditPost
*
* @param {Object} o DOM row object to get the id for. * @param {Object} o DOM row object to get the id for.
* @return {string} The post id extracted from the table row in the object. * @return {string} The post id extracted from the table row in the object.
*/ */
@ -546,7 +552,7 @@ $( document ).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
} }
}).ready( function() { }).ready( function() {
// Set the heartbeat interval to 15 sec. // Set the heartbeat interval to 15 seconds.
if ( typeof wp !== 'undefined' && wp.heartbeat ) { if ( typeof wp !== 'undefined' && wp.heartbeat ) {
wp.heartbeat.interval( 15 ); wp.heartbeat.interval( 15 );
} }

View File

@ -43,12 +43,12 @@ window.inlineEditTax = {
}); });
/** /**
* Cancels inline editing when pressing escape inside the inline editor. * Cancels inline editing when pressing Escape inside the inline editor.
* *
* @param {Object} e The keyup event that has been triggered. * @param {Object} e The keyup event that has been triggered.
*/ */
row.keyup( function( e ) { row.keyup( function( e ) {
// 27 = [escape] // 27 = [Escape].
if ( e.which === 27 ) { if ( e.which === 27 ) {
return inlineEditTax.revert(); return inlineEditTax.revert();
} }
@ -69,10 +69,10 @@ window.inlineEditTax = {
}); });
/** /**
* Saves the inline edits when pressing enter inside the inline editor. * Saves the inline edits when pressing Enter inside the inline editor.
*/ */
$( 'input, select', row ).keydown( function( e ) { $( 'input, select', row ).keydown( function( e ) {
// 13 = [enter] // 13 = [Enter].
if ( e.which === 13 ) { if ( e.which === 13 ) {
return inlineEditTax.save( this ); return inlineEditTax.save( this );
} }
@ -184,7 +184,7 @@ window.inlineEditTax = {
fields = $('#edit-'+id).find(':input').serialize(); fields = $('#edit-'+id).find(':input').serialize();
params = fields + '&' + $.param(params); params = fields + '&' + $.param(params);
// Do the ajax request to save the data to the server. // Do the Ajax request to save the data to the server.
$.post( ajaxurl, params, $.post( ajaxurl, params,
/** /**
* Handles the response from the server * Handles the response from the server

View File

@ -9,7 +9,7 @@ jQuery(document).ready( function($) {
var newCat, noSyncChecks = false, syncChecks, catAddAfter; var newCat, noSyncChecks = false, syncChecks, catAddAfter;
$('#link_name').focus(); $('#link_name').focus();
// postboxes // Postboxes.
postboxes.add_postbox_toggles('link'); postboxes.add_postbox_toggles('link');
/** /**
@ -33,7 +33,7 @@ jQuery(document).ready( function($) {
if ( getUserSetting('cats') ) if ( getUserSetting('cats') )
$('#category-tabs a[href="#categories-pop"]').click(); $('#category-tabs a[href="#categories-pop"]').click();
// Ajax Cat // Ajax Cat.
newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } ); newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } );
/** /**

View File

@ -43,16 +43,16 @@ window.send_to_editor = function( html ) {
editor = tinymce.get( wpActiveEditor ); editor = tinymce.get( wpActiveEditor );
} }
// If the editor is set and not hidden, insert the HTML into the content of the // If the editor is set and not hidden,
// editor. // insert the HTML into the content of the editor.
if ( editor && ! editor.isHidden() ) { if ( editor && ! editor.isHidden() ) {
editor.execCommand( 'mceInsertContent', false, html ); editor.execCommand( 'mceInsertContent', false, html );
} else if ( hasQuicktags ) { } else if ( hasQuicktags ) {
// If quick tags are available, insert the HTML into its content. // If quick tags are available, insert the HTML into its content.
QTags.insertContent( html ); QTags.insertContent( html );
} else { } else {
// If neither the TinyMCE editor and the quick tags are available, add the HTML // If neither the TinyMCE editor and the quick tags are available,
// to the current active editor. // add the HTML to the current active editor.
document.getElementById( wpActiveEditor ).value += html; document.getElementById( wpActiveEditor ).value += html;
} }

View File

@ -69,7 +69,7 @@
}, },
jQueryExtensions : function() { jQueryExtensions : function() {
// jQuery extensions // jQuery extensions.
$.fn.extend({ $.fn.extend({
menuItemDepth : function() { menuItemDepth : function() {
var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left'); var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left');
@ -114,7 +114,7 @@
depth = t.menuItemDepth(), depth = t.menuItemDepth(),
newDepth = depth + dir; newDepth = depth + dir;
// Change .menu-item-depth-n class // Change .menu-item-depth-n class.
t.moveHorizontally( newDepth, depth ); t.moveHorizontally( newDepth, depth );
}); });
}, },
@ -125,10 +125,10 @@
diff = newDepth - depth, diff = newDepth - depth,
subItemText = t.find('.is-submenu'); subItemText = t.find('.is-submenu');
// Change .menu-item-depth-n class // Change .menu-item-depth-n class.
t.updateDepthClass( newDepth, depth ).updateParentMenuItemDBId(); t.updateDepthClass( newDepth, depth ).updateParentMenuItemDBId();
// If it has children, move those too // If it has children, move those too.
if ( children ) { if ( children ) {
children.each(function() { children.each(function() {
var t = $(this), var t = $(this),
@ -138,7 +138,7 @@
}); });
} }
// Show "Sub item" helper text // Show "Sub item" helper text.
if (0 === newDepth) if (0 === newDepth)
subItemText.hide(); subItemText.hide();
else else
@ -153,7 +153,7 @@
parentDepth = depth - 1, parentDepth = depth - 1,
parent = item.prevAll( '.menu-item-depth-' + parentDepth ).first(); parent = item.prevAll( '.menu-item-depth-' + parentDepth ).first();
if ( 0 === depth ) { // Item is on the top level, has no parent if ( 0 === depth ) { // Item is on the top level, has no parent.
input.val(0); input.val(0);
} else { // Find the parent item, and retrieve its object id. } else { // Find the parent item, and retrieve its object id.
input.val( parent.find( '.menu-item-data-db-id' ).val() ); input.val( parent.find( '.menu-item-data-db-id' ).val() );
@ -191,10 +191,10 @@
if ( !checkboxes.length ) if ( !checkboxes.length )
return false; return false;
// Show the ajax spinner // Show the Ajax spinner.
t.find( '.button-controls .spinner' ).addClass( 'is-active' ); t.find( '.button-controls .spinner' ).addClass( 'is-active' );
// Retrieve menu item data // Retrieve menu item data.
$(checkboxes).each(function(){ $(checkboxes).each(function(){
var t = $(this), var t = $(this),
listItemDBIDMatch = re.exec( t.attr('name') ), listItemDBIDMatch = re.exec( t.attr('name') ),
@ -205,9 +205,9 @@
menuItems[listItemDBID] = t.closest('li').getItemData( 'add-menu-item', listItemDBID ); menuItems[listItemDBID] = t.closest('li').getItemData( 'add-menu-item', listItemDBID );
}); });
// Add the items // Add the items.
api.addItemToMenu(menuItems, processMethod, function(){ api.addItemToMenu(menuItems, processMethod, function(){
// Deselect the items and hide the ajax spinner // Deselect the items and hide the Ajax spinner.
checkboxes.prop( 'checked', false ); checkboxes.prop( 'checked', false );
t.find( '.button-controls .select-all' ).prop( 'checked', false ); t.find( '.button-controls .select-all' ).prop( 'checked', false );
t.find( '.button-controls .spinner' ).removeClass( 'is-active' ); t.find( '.button-controls .spinner' ).removeClass( 'is-active' );
@ -312,22 +312,22 @@
case 'up': case 'up':
newItemPosition = thisItemPosition - 1; newItemPosition = thisItemPosition - 1;
// Already at top // Already at top.
if ( 0 === thisItemPosition ) if ( 0 === thisItemPosition )
break; break;
// If a sub item is moved to top, shift it to 0 depth // If a sub item is moved to top, shift it to 0 depth.
if ( 0 === newItemPosition && 0 !== thisItemDepth ) if ( 0 === newItemPosition && 0 !== thisItemDepth )
thisItem.moveHorizontally( 0, thisItemDepth ); thisItem.moveHorizontally( 0, thisItemDepth );
// If prev item is sub item, shift to match depth // If prev item is sub item, shift to match depth.
if ( 0 !== prevItemDepth ) if ( 0 !== prevItemDepth )
thisItem.moveHorizontally( prevItemDepth, thisItemDepth ); thisItem.moveHorizontally( prevItemDepth, thisItemDepth );
// Does this item have sub items? // Does this item have sub items?
if ( thisItemChildren ) { if ( thisItemChildren ) {
items = thisItem.add( thisItemChildren ); items = thisItem.add( thisItemChildren );
// Move the entire block // Move the entire block.
items.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId(); items.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId();
} else { } else {
thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId(); thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId();
@ -351,40 +351,40 @@
items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) ).updateParentMenuItemDBId(); items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) ).updateParentMenuItemDBId();
} else { } else {
// If next item has sub items, shift depth // If next item has sub items, shift depth.
if ( 0 !== nextItemChildren.length ) if ( 0 !== nextItemChildren.length )
thisItem.moveHorizontally( nextItemDepth, thisItemDepth ); thisItem.moveHorizontally( nextItemDepth, thisItemDepth );
// Have we reached the bottom // Have we reached the bottom?
if ( menuItemsCount === thisItemPosition + 1 ) if ( menuItemsCount === thisItemPosition + 1 )
break; break;
thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) ).updateParentMenuItemDBId(); thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) ).updateParentMenuItemDBId();
} }
break; break;
case 'top': case 'top':
// Already at top // Already at top.
if ( 0 === thisItemPosition ) if ( 0 === thisItemPosition )
break; break;
// Does this item have sub items? // Does this item have sub items?
if ( thisItemChildren ) { if ( thisItemChildren ) {
items = thisItem.add( thisItemChildren ); items = thisItem.add( thisItemChildren );
// Move the entire block // Move the entire block.
items.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId(); items.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId();
} else { } else {
thisItem.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId(); thisItem.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId();
} }
break; break;
case 'left': case 'left':
// As far left as possible // As far left as possible.
if ( 0 === thisItemDepth ) if ( 0 === thisItemDepth )
break; break;
thisItem.shiftHorizontally( -1 ); thisItem.shiftHorizontally( -1 );
break; break;
case 'right': case 'right':
// Can't be sub item at top // Can't be sub item at top.
if ( 0 === thisItemPosition ) if ( 0 === thisItemPosition )
break; break;
// Already sub item of prevItem // Already sub item of prevItem.
if ( thisItemData['menu-item-parent-id'] === prevItemId ) if ( thisItemData['menu-item-parent-id'] === prevItemId )
break; break;
thisItem.shiftHorizontally( 1 ); thisItem.shiftHorizontally( 1 );
@ -402,7 +402,7 @@
api.refreshKeyboardAccessibility(); api.refreshKeyboardAccessibility();
api.refreshAdvancedAccessibility(); api.refreshAdvancedAccessibility();
// Refresh the accessibility when the user comes close to the item in any way // Refresh the accessibility when the user comes close to the item in any way.
menu.on( 'mouseenter.refreshAccessibility focus.refreshAccessibility touchstart.refreshAccessibility' , '.menu-item' , function(){ menu.on( 'mouseenter.refreshAccessibility focus.refreshAccessibility touchstart.refreshAccessibility' , '.menu-item' , function(){
api.refreshAdvancedAccessibilityOfItem( $( this ).find( 'a.item-edit' ) ); api.refreshAdvancedAccessibilityOfItem( $( this ).find( 'a.item-edit' ) );
} ); } );
@ -412,7 +412,7 @@
api.refreshAdvancedAccessibilityOfItem( $( this ) ); api.refreshAdvancedAccessibilityOfItem( $( this ) );
} ); } );
// Links for moving items // Links for moving items.
menu.on( 'click', '.menus-move', function () { menu.on( 'click', '.menus-move', function () {
var $this = $( this ), var $this = $( this ),
dir = $this.data( 'dir' ); dir = $this.data( 'dir' );
@ -433,7 +433,7 @@
*/ */
refreshAdvancedAccessibilityOfItem : function( itemToRefresh ) { refreshAdvancedAccessibilityOfItem : function( itemToRefresh ) {
// Only refresh accessibility when necessary // Only refresh accessibility when necessary.
if ( true !== $( itemToRefresh ).data( 'needs_accessibility_refresh' ) ) { if ( true !== $( itemToRefresh ).data( 'needs_accessibility_refresh' ) ) {
return; return;
} }
@ -494,7 +494,7 @@
itemPosition = primaryItems.index( menuItem ) + 1, itemPosition = primaryItems.index( menuItem ) + 1,
totalMenuItems = primaryItems.length, totalMenuItems = primaryItems.length,
// String together help text for primary menu items // String together help text for primary menu items.
title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems ); title = menus.menuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$d', totalMenuItems );
} else { } else {
parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1, 10 ) ).first(), parentItem = menuItem.prevAll( '.menu-item-depth-' + parseInt( depth - 1, 10 ) ).first(),
@ -503,13 +503,13 @@
subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ), subItems = $( '.menu-item .menu-item-data-parent-id[value="' + parentItemId + '"]' ),
itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1; itemPosition = $( subItems.parents('.menu-item').get().reverse() ).index( menuItem ) + 1;
// String together help text for sub menu items // String together help text for sub menu items.
title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$s', parentItemName ); title = menus.subMenuFocus.replace( '%1$s', itemName ).replace( '%2$d', itemPosition ).replace( '%3$s', parentItemName );
} }
$this.attr( 'aria-label', title ); $this.attr( 'aria-label', title );
// Mark this item's accessibility as refreshed // Mark this item's accessibility as refreshed.
$this.data( 'needs_accessibility_refresh', false ); $this.data( 'needs_accessibility_refresh', false );
}, },
@ -523,10 +523,10 @@
// Hide all the move buttons by default. // Hide all the move buttons by default.
$( '.menu-item-settings .field-move .menus-move' ).hide(); $( '.menu-item-settings .field-move .menus-move' ).hide();
// Mark all menu items as unprocessed // Mark all menu items as unprocessed.
$( 'a.item-edit' ).data( 'needs_accessibility_refresh', true ); $( 'a.item-edit' ).data( 'needs_accessibility_refresh', true );
// All open items have to be refreshed or they will show no links // All open items have to be refreshed or they will show no links.
$( '.menu-item-edit-active a.item-edit' ).each( function() { $( '.menu-item-edit-active a.item-edit' ).each( function() {
api.refreshAdvancedAccessibilityOfItem( this ); api.refreshAdvancedAccessibilityOfItem( this );
} ); } );
@ -541,18 +541,18 @@
thisItem = $this.parents( 'li.menu-item' ), thisItem = $this.parents( 'li.menu-item' ),
thisItemData = thisItem.getItemData(); thisItemData = thisItem.getItemData();
// Bail if it's not an arrow key // Bail if it's not an arrow key.
if ( 37 != e.which && 38 != e.which && 39 != e.which && 40 != e.which ) if ( 37 != e.which && 38 != e.which && 39 != e.which && 40 != e.which )
return; return;
// Avoid multiple keydown events // Avoid multiple keydown events.
$this.off('keydown'); $this.off('keydown');
// Bail if there is only one menu item // Bail if there is only one menu item.
if ( 1 === $('#menu-to-edit li').length ) if ( 1 === $('#menu-to-edit li').length )
return; return;
// If RTL, swap left/right arrows // If RTL, swap left/right arrows.
arrows = { '38': 'up', '40': 'down', '37': 'left', '39': 'right' }; arrows = { '38': 'up', '40': 'down', '37': 'left', '39': 'right' };
if ( $('body').hasClass('rtl') ) if ( $('body').hasClass('rtl') )
arrows = { '38' : 'up', '40' : 'down', '39' : 'left', '37' : 'right' }; arrows = { '38' : 'up', '40' : 'down', '39' : 'left', '37' : 'right' };
@ -571,7 +571,7 @@
api.moveMenuItem( $this, 'right' ); api.moveMenuItem( $this, 'right' );
break; break;
} }
// Put focus back on same menu item // Put focus back on same menu item.
$( '#edit-' + thisItemData['menu-item-db-id'] ).focus(); $( '#edit-' + thisItemData['menu-item-db-id'] ).focus();
return false; return false;
}); });
@ -594,10 +594,10 @@
}, },
initToggles : function() { initToggles : function() {
// init postboxes // Init postboxes.
postboxes.add_postbox_toggles('nav-menus'); postboxes.add_postbox_toggles('nav-menus');
// adjust columns functions for menus UI // Adjust columns functions for menus UI.
columns.useCheckboxesForHidden(); columns.useCheckboxesForHidden();
columns.checked = function(field) { columns.checked = function(field) {
$('.field-' + field).removeClass('hidden-field'); $('.field-' + field).removeClass('hidden-field');
@ -605,7 +605,7 @@
columns.unchecked = function(field) { columns.unchecked = function(field) {
$('.field-' + field).addClass('hidden-field'); $('.field-' + field).addClass('hidden-field');
}; };
// hide fields // Hide fields.
api.menuList.hideAdvancedMenuItemFields(); api.menuList.hideAdvancedMenuItemFields();
$('.hide-postbox-tog').click(function () { $('.hide-postbox-tog').click(function () {
@ -639,7 +639,7 @@
start: function(e, ui) { start: function(e, ui) {
var height, width, parent, children, tempHolder; var height, width, parent, children, tempHolder;
// handle placement for rtl orientation // Handle placement for RTL orientation.
if ( api.isRTL ) if ( api.isRTL )
ui.item[0].style.right = 'auto'; ui.item[0].style.right = 'auto';
@ -649,19 +649,19 @@
originalDepth = ui.item.menuItemDepth(); originalDepth = ui.item.menuItemDepth();
updateCurrentDepth(ui, originalDepth); updateCurrentDepth(ui, originalDepth);
// Attach child elements to parent // Attach child elements to parent.
// Skip the placeholder // Skip the placeholder.
parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item; parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item;
children = parent.childMenuItems(); children = parent.childMenuItems();
transport.append( children ); transport.append( children );
// Update the height of the placeholder to match the moving item. // Update the height of the placeholder to match the moving item.
height = transport.outerHeight(); height = transport.outerHeight();
// If there are children, account for distance between top of children and parent // If there are children, account for distance between top of children and parent.
height += ( height > 0 ) ? (ui.placeholder.css('margin-top').slice(0, -2) * 1) : 0; height += ( height > 0 ) ? (ui.placeholder.css('margin-top').slice(0, -2) * 1) : 0;
height += ui.helper.outerHeight(); height += ui.helper.outerHeight();
helperHeight = height; helperHeight = height;
height -= 2; // Subtract 2 for borders height -= 2; // Subtract 2 for borders.
ui.placeholder.height(height); ui.placeholder.height(height);
// Update the width of the placeholder to match the moving item. // Update the width of the placeholder to match the moving item.
@ -670,18 +670,18 @@
var depth = $(this).menuItemDepth(); var depth = $(this).menuItemDepth();
maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth; maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth;
}); });
width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width.
width += api.depthToPx(maxChildDepth - originalDepth); // Account for children width += api.depthToPx(maxChildDepth - originalDepth); // Account for children.
width -= 2; // Subtract 2 for borders width -= 2; // Subtract 2 for borders.
ui.placeholder.width(width); ui.placeholder.width(width);
// Update the list of menu items. // Update the list of menu items.
tempHolder = ui.placeholder.next( '.menu-item' ); tempHolder = ui.placeholder.next( '.menu-item' );
tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder tempHolder.css( 'margin-top', helperHeight + 'px' ); // Set the margin to absorb the placeholder.
ui.placeholder.detach(); // detach or jQuery UI will think the placeholder is a menu item ui.placeholder.detach(); // Detach or jQuery UI will think the placeholder is a menu item.
$(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQ UI know. $(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQuery UI know.
ui.item.after( ui.placeholder ); // reattach the placeholder. ui.item.after( ui.placeholder ); // Reattach the placeholder.
tempHolder.css('margin-top', 0); // reset the margin tempHolder.css('margin-top', 0); // Reset the margin.
// Now that the element is complete, we can update... // Now that the element is complete, we can update...
updateSharedVars(ui); updateSharedVars(ui);
@ -690,31 +690,31 @@
var children, subMenuTitle, var children, subMenuTitle,
depthChange = currentDepth - originalDepth; depthChange = currentDepth - originalDepth;
// Return child elements to the list // Return child elements to the list.
children = transport.children().insertAfter(ui.item); children = transport.children().insertAfter(ui.item);
// Add "sub menu" description // Add "sub menu" description.
subMenuTitle = ui.item.find( '.item-title .is-submenu' ); subMenuTitle = ui.item.find( '.item-title .is-submenu' );
if ( 0 < currentDepth ) if ( 0 < currentDepth )
subMenuTitle.show(); subMenuTitle.show();
else else
subMenuTitle.hide(); subMenuTitle.hide();
// Update depth classes // Update depth classes.
if ( 0 !== depthChange ) { if ( 0 !== depthChange ) {
ui.item.updateDepthClass( currentDepth ); ui.item.updateDepthClass( currentDepth );
children.shiftDepthClass( depthChange ); children.shiftDepthClass( depthChange );
updateMenuMaxDepth( depthChange ); updateMenuMaxDepth( depthChange );
} }
// Register a change // Register a change.
api.registerChange(); api.registerChange();
// Update the item data. // Update the item data.
ui.item.updateParentMenuItemDBId(); ui.item.updateParentMenuItemDBId();
// address sortable's incorrectly-calculated top in opera // Address sortable's incorrectly-calculated top in Opera.
ui.item[0].style.top = 0; ui.item[0].style.top = 0;
// handle drop placement for rtl orientation // Handle drop placement for rtl orientation.
if ( api.isRTL ) { if ( api.isRTL ) {
ui.item[0].style.left = 'auto'; ui.item[0].style.left = 'auto';
ui.item[0].style.right = 0; ui.item[0].style.right = 0;
@ -736,9 +736,11 @@
edge = api.isRTL ? offset.left + ui.helper.width() : offset.left, edge = api.isRTL ? offset.left + ui.helper.width() : offset.left,
depth = api.negateIfRTL * api.pxToDepth( edge - menuEdge ); depth = api.negateIfRTL * api.pxToDepth( edge - menuEdge );
// Check and correct if depth is not within range. /*
// Also, if the dragged element is dragged upwards over * Check and correct if depth is not within range.
// an item, shift the placeholder to a child position. * Also, if the dragged element is dragged upwards over an item,
* shift the placeholder to a child position.
*/
if ( depth > maxDepth || offset.top < ( prevBottom - api.options.targetTolerance ) ) { if ( depth > maxDepth || offset.top < ( prevBottom - api.options.targetTolerance ) ) {
depth = maxDepth; depth = maxDepth;
} else if ( depth < minDepth ) { } else if ( depth < minDepth ) {
@ -748,7 +750,7 @@
if( depth != currentDepth ) if( depth != currentDepth )
updateCurrentDepth(ui, depth); updateCurrentDepth(ui, depth);
// If we overlap the next element, manually shift downwards // If we overlap the next element, manually shift downwards.
if( nextThreshold && offset.top + helperHeight > nextThreshold ) { if( nextThreshold && offset.top + helperHeight > nextThreshold ) {
next.after( ui.placeholder ); next.after( ui.placeholder );
updateSharedVars( ui ); updateSharedVars( ui );
@ -955,12 +957,12 @@
return false; return false;
} }
// Show the ajax spinner // Show the Ajax spinner.
$( '.customlinkdiv .spinner' ).addClass( 'is-active' ); $( '.customlinkdiv .spinner' ).addClass( 'is-active' );
this.addLinkToMenu( url, label, processMethod, function() { this.addLinkToMenu( url, label, processMethod, function() {
// Remove the ajax spinner // Remove the Ajax spinner.
$( '.customlinkdiv .spinner' ).removeClass( 'is-active' ); $( '.customlinkdiv .spinner' ).removeClass( 'is-active' );
// Set custom link form back to defaults // Set custom link form back to defaults.
$('#custom-menu-item-name').val('').blur(); $('#custom-menu-item-name').val('').blur();
$( '#custom-menu-item-url' ).val( '' ).attr( 'placeholder', 'https://' ); $( '#custom-menu-item-url' ).val( '' ).attr( 'placeholder', 'https://' );
}); });
@ -997,10 +999,10 @@
$.post( ajaxurl, params, function(menuMarkup) { $.post( ajaxurl, params, function(menuMarkup) {
var ins = $('#menu-instructions'); var ins = $('#menu-instructions');
menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces.
processMethod(menuMarkup, params); processMethod(menuMarkup, params);
// Make it stand out a bit more visually, by adding a fadeIn // Make it stand out a bit more visually, by adding a fadeIn.
$( 'li.pending' ).hide().fadeIn('slow'); $( 'li.pending' ).hide().fadeIn('slow');
$( '.drag-instructions' ).show(); $( '.drag-instructions' ).show();
if( ! ins.hasClass( 'menu-instructions-inactive' ) && ins.siblings().length ) if( ! ins.hasClass( 'menu-instructions-inactive' ) && ins.siblings().length )
@ -1051,7 +1053,7 @@
return navMenuL10n.saveAlert; return navMenuL10n.saveAlert;
}; };
} else { } else {
// Make the post boxes read-only, as they can't be used yet // Make the post boxes read-only, as they can't be used yet.
$( '#menu-settings-column' ).find( 'input,select' ).end().find( 'a' ).attr( 'href', '#' ).unbind( 'click' ); $( '#menu-settings-column' ).find( 'input,select' ).end().find( 'a' ).attr( 'href', '#' ).unbind( 'click' );
} }
}, },
@ -1071,7 +1073,7 @@
wrapper = target.parents('.accordion-section-content').first(); wrapper = target.parents('.accordion-section-content').first();
// upon changing tabs, we want to uncheck all checkboxes // Upon changing tabs, we want to uncheck all checkboxes.
$( 'input', wrapper ).prop( 'checked', false ); $( 'input', wrapper ).prop( 'checked', false );
$('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive'); $('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive');
@ -1080,7 +1082,7 @@
$('.tabs', wrapper).removeClass('tabs'); $('.tabs', wrapper).removeClass('tabs');
target.parent().addClass('tabs'); target.parent().addClass('tabs');
// select the search bar // Select the search bar.
$('.quick-search', wrapper).focus(); $('.quick-search', wrapper).focus();
// Hide controls in the search tab if no items found. // Hide controls in the search tab if no items found.
@ -1193,17 +1195,17 @@
var locs = '', var locs = '',
menuName = $('#menu-name'), menuName = $('#menu-name'),
menuNameVal = menuName.val(); menuNameVal = menuName.val();
// Cancel and warn if invalid menu name // Cancel and warn if invalid menu name.
if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) { if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) {
menuName.parent().addClass( 'form-invalid' ); menuName.parent().addClass( 'form-invalid' );
return false; return false;
} }
// Copy menu theme locations // Copy menu theme locations.
$('#nav-menu-theme-locations select').each(function() { $('#nav-menu-theme-locations select').each(function() {
locs += '<input type="hidden" name="' + this.name + '" value="' + $(this).val() + '" />'; locs += '<input type="hidden" name="' + this.name + '" value="' + $(this).val() + '" />';
}); });
$('#update-nav-menu').append( locs ); $('#update-nav-menu').append( locs );
// Update menu item position data // Update menu item position data.
api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } ); api.menuList.find('.menu-item-data-position').val( function(index) { return index + 1; } );
window.onbeforeunload = null; window.onbeforeunload = null;
@ -1211,7 +1213,7 @@
}, },
eventOnClickMenuDelete : function() { eventOnClickMenuDelete : function() {
// Delete warning AYS // Delete warning AYS.
if ( window.confirm( navMenuL10n.warnDeleteMenu ) ) { if ( window.confirm( navMenuL10n.warnDeleteMenu ) ) {
window.onbeforeunload = null; window.onbeforeunload = null;
return true; return true;
@ -1253,7 +1255,7 @@
$items.each(function(){ $items.each(function(){
$item = $(this); $item = $(this);
// make a unique DB ID number // Make a unique DB ID number.
matched = pattern.exec($item.html()); matched = pattern.exec($item.html());
if ( matched && matched[1] ) { if ( matched && matched[1] ) {

View File

@ -183,11 +183,12 @@ jQuery( document ).ready( function( $ ) {
var tab = $( this ).attr( 'name' ); var tab = $( this ).attr( 'name' );
event.preventDefault(); event.preventDefault();
// Flip the tab // Flip the tab.
$( '#plugin-information-tabs a.current' ).removeClass( 'current' ); $( '#plugin-information-tabs a.current' ).removeClass( 'current' );
$( this ).addClass( 'current' ); $( this ).addClass( 'current' );
// Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top. // Only show the fyi box in the description section, on smaller screen,
// where it's otherwise always displayed at the top.
if ( 'description' !== tab && $( window ).width() < 772 ) { if ( 'description' !== tab && $( window ).width() < 772 ) {
$( '#plugin-information-content' ).find( '.fyi' ).hide(); $( '#plugin-information-content' ).find( '.fyi' ).hide();
} else { } else {

Some files were not shown because too many files have changed in this diff Show More