Commit edb38c6d authored by lucha's avatar lucha

Wordpress 4.9.4

parent 8c9ddada
......@@ -32,6 +32,42 @@ include( ABSPATH . 'wp-admin/admin-header.php' );
<div class="changelog point-releases">
<h3><?php _e( 'Maintenance and Security Releases' ); ?></h3>
<p>
<?php
printf(
/* translators: 1: WordPress version number, 2: plural number of bugs. */
_n(
'<strong>Version %1$s</strong> addressed %2$s bug.',
'<strong>Version %1$s</strong> addressed %2$s bugs.',
1
),
'4.9.4',
number_format_i18n( 1 )
);
?>
<?php
/* translators: %s: Codex URL */
printf( __( 'For more information, see <a href="%s">the release notes</a>.' ), 'https://codex.wordpress.org/Version_4.9.4' );
?>
</p>
<p>
<?php
printf(
/* translators: 1: WordPress version number, 2: plural number of bugs. */
_n(
'<strong>Version %1$s</strong> addressed %2$s bug.',
'<strong>Version %1$s</strong> addressed %2$s bugs.',
34
),
'4.9.3',
number_format_i18n( 34 )
);
?>
<?php
/* translators: %s: Codex URL */
printf( __( 'For more information, see <a href="%s">the release notes</a>.' ), 'https://codex.wordpress.org/Version_4.9.3' );
?>
</p>
<p>
<?php
printf(
......
......@@ -177,9 +177,7 @@
cursor: pointer;
}
.media-widget-preview.media_image,
.media-widget-preview.media_audio,
.attachment-media-view {
.media-widget-preview .placeholder {
background: #f1f1f1;
}
......@@ -190,7 +188,7 @@
background: transparent;
}
.media-widget-gallery-preview .gallery-item .gallery-icon {
.media-widget-gallery-preview .gallery-item .gallery-icon {
margin: 4.5%;
}
......
This diff is collapsed.
......@@ -177,9 +177,7 @@
cursor: pointer;
}
.media-widget-preview.media_image,
.media-widget-preview.media_audio,
.attachment-media-view {
.media-widget-preview .placeholder {
background: #f1f1f1;
}
......@@ -190,7 +188,7 @@
background: transparent;
}
.media-widget-gallery-preview .gallery-item .gallery-icon {
.media-widget-gallery-preview .gallery-item .gallery-icon {
margin: 4.5%;
}
......
This diff is collapsed.
......@@ -77,7 +77,7 @@ if ( $wp_customize->changeset_post_id() ) {
if ( in_array( get_post_status( $changeset_post->ID ), array( 'publish', 'trash' ), true ) ) {
wp_die(
'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
'<p>' . __( 'This changeset has already been published and cannot be further modified.' ) . '</p>' .
'<p>' . __( 'This changeset cannot be further modified.' ) . '</p>' .
'<p><a href="' . esc_url( remove_query_arg( 'changeset_uuid' ) ) . '">' . __( 'Customize New Changes' ) . '</a></p>',
403
);
......
......@@ -628,7 +628,7 @@ function install_plugin_information() {
) );
?>
<div class="counter-container">
<span class="counter-label"><a href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
<span class="counter-label"><a href="https://wordpress.org/support/plugin/<?php echo $api->slug; ?>/reviews/?filter=<?php echo $key; ?>"
target="_blank" aria-label="<?php echo $aria_label; ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span>
<span class="counter-back">
<span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
......
......@@ -2564,7 +2564,7 @@
// Temporary special function since supplying SFTP credentials does not work yet. See #42184.
function disableInstallButtons() {
return disableSwitchButtons() || true === api.settings.theme._filesystemCredentialsNeeded;
return disableSwitchButtons() || false === api.settings.theme._canInstall || true === api.settings.theme._filesystemCredentialsNeeded;
}
section.overlay.find( 'button.preview, button.preview-theme' ).toggleClass( 'disabled', disableSwitchButtons() );
......@@ -3074,7 +3074,7 @@
api.Panel.prototype.attachEvents.apply( panel );
// Temporary since supplying SFTP credentials does not work yet. See #42184
if ( api.settings.theme._filesystemCredentialsNeeded ) {
if ( api.settings.theme._canInstall && api.settings.theme._filesystemCredentialsNeeded ) {
panel.notifications.add( new api.Notification( 'theme_install_unavailable', {
message: api.l10n.themeInstallUnavailable,
type: 'info',
......@@ -5132,7 +5132,7 @@
// Temporary special function since supplying SFTP credentials does not work yet. See #42184.
function disableInstallButtons() {
return disableSwitchButtons() || true === api.settings.theme._filesystemCredentialsNeeded;
return disableSwitchButtons() || false === api.settings.theme._canInstall || true === api.settings.theme._filesystemCredentialsNeeded;
}
function updateButtons() {
control.container.find( 'button.preview, button.preview-theme' ).toggleClass( 'disabled', disableSwitchButtons() );
......@@ -7931,7 +7931,7 @@
previewerAlive = state.instance( 'previewerAlive' ),
editShortcutVisibility = state.instance( 'editShortcutVisibility' ),
changesetLocked = state.instance( 'changesetLocked' ),
populateChangesetUuidParam;
populateChangesetUuidParam, defaultSelectedChangesetStatus;
state.bind( 'change', function() {
var canSave;
......@@ -7965,9 +7965,7 @@
} else {
saveBtn.val( api.l10n.schedule );
}
} else if ( ! api.settings.changeset.currentUserCanPublish ) {
selectedChangesetStatus( 'draft' );
} else {
} else if ( api.settings.changeset.currentUserCanPublish ) {
saveBtn.val( api.l10n.publish );
}
closeBtn.find( '.screen-reader-text' ).text( api.l10n.cancel );
......@@ -7989,12 +7987,14 @@
return status;
};
defaultSelectedChangesetStatus = api.settings.changeset.currentUserCanPublish ? 'publish' : 'draft';
// Set default states.
changesetStatus( api.settings.changeset.status );
changesetLocked( Boolean( api.settings.changeset.lockUser ) );
changesetDate( api.settings.changeset.publishDate );
selectedChangesetDate( api.settings.changeset.publishDate );
selectedChangesetStatus( '' === api.settings.changeset.status || 'auto-draft' === api.settings.changeset.status ? 'publish' : api.settings.changeset.status );
selectedChangesetStatus( '' === api.settings.changeset.status || 'auto-draft' === api.settings.changeset.status ? defaultSelectedChangesetStatus : api.settings.changeset.status );
selectedChangesetStatus.link( changesetStatus ); // Ensure that direct updates to status on server via wp.customizer.previewer.save() will update selection.
saved( true );
if ( '' === changesetStatus() ) { // Handle case for loading starter content.
......@@ -8240,6 +8240,7 @@
// Check for lock when sending heartbeat requests.
$( document ).on( 'heartbeat-send.update_lock_notice', function( event, data ) {
data.check_changeset_lock = true;
data.changeset_uuid = api.settings.changeset.uuid;
} );
// Handle heartbeat ticks.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -280,30 +280,6 @@ window.wp = window.wp || {};
return result;
}
/**
* @summary Check if a shortcode has Live Preview enabled for it.
*
* Previewable shortcodes here refers to shortcodes that have Live Preview enabled.
*
* These shortcodes get rewritten when the editor is in Visual mode, which means that
* we don't want to change anything inside them, i.e. inserting a selection marker
* inside the shortcode will break it :(
*
* @link wp-includes/js/mce-view.js
*
* @param {string} shortcode The shortcode to check.
* @return {boolean} If a shortcode has Live Preview or not
*/
function isShortcodePreviewable( shortcode ) {
var defaultPreviewableShortcodes = [ 'caption' ];
return (
defaultPreviewableShortcodes.indexOf( shortcode ) !== -1 ||
wp.mce.views.get( shortcode ) !== undefined
);
}
/**
* @summary Get all shortcodes and their positions in the content
*
......@@ -340,23 +316,12 @@ window.wp = window.wp || {};
*/
var showAsPlainText = shortcodeMatch[1] === '[';
/**
* For more context check the docs for:
*
* @link isShortcodePreviewable
*
* In addition, if the shortcode will get rendered as plain text ( see above ),
* we can treat it as text and use the selection markers in it.
*/
var isPreviewable = ! showAsPlainText && isShortcodePreviewable( shortcodeMatch[2] );
shortcodeInfo = {
shortcodeName: shortcodeMatch[2],
showAsPlainText: showAsPlainText,
startIndex: shortcodeMatch.index,
endIndex: shortcodeMatch.index + shortcodeMatch[0].length,
length: shortcodeMatch[0].length,
isPreviewable: isPreviewable
length: shortcodeMatch[0].length
};
shortcodesDetails.push( shortcodeInfo );
......@@ -382,7 +347,6 @@ window.wp = window.wp || {};
startIndex: shortcodeMatch.index,
endIndex: shortcodeMatch.index + shortcodeMatch[ 0 ].length,
length: shortcodeMatch[ 0 ].length,
isPreviewable: true,
urlAtStartOfContent: shortcodeMatch[ 1 ] === '',
urlAtEndOfContent: shortcodeMatch[ 3 ] === ''
};
......@@ -465,7 +429,7 @@ window.wp = window.wp || {};
}
var isCursorStartInShortcode = getShortcodeWrapperInfo( content, cursorStart );
if ( isCursorStartInShortcode && isCursorStartInShortcode.isPreviewable ) {
if ( isCursorStartInShortcode && ! isCursorStartInShortcode.showAsPlainText ) {
/**
* If a URL is at the start or the end of the content,
* the selection doesn't work, because it inserts a marker in the text,
......@@ -482,7 +446,7 @@ window.wp = window.wp || {};
}
var isCursorEndInShortcode = getShortcodeWrapperInfo( content, cursorEnd );
if ( isCursorEndInShortcode && isCursorEndInShortcode.isPreviewable ) {
if ( isCursorEndInShortcode && ! isCursorEndInShortcode.showAsPlainText ) {
if ( isCursorEndInShortcode.urlAtEndOfContent ) {
cursorEnd = isCursorEndInShortcode.startIndex;
} else {
......
This diff is collapsed.
......@@ -2437,7 +2437,7 @@
return;
}
if ( 'undefined' === typeof message.action ) {
if ( ! message || 'undefined' === typeof message.action ) {
return;
}
......
This diff is collapsed.
......@@ -513,9 +513,10 @@ wpWidgets = {
save : function( widget, del, animate, order ) {
var self = this, data, a,
sidebarId = widget.closest( 'div.widgets-sortables' ).attr( 'id' ),
form = widget.find( 'form' );
form = widget.find( 'form' ),
isAdd = widget.find( 'input.add_new' ).val();
if ( ! del && form.prop( 'checkValidity' ) && ! form[0].checkValidity() ) {
if ( ! del && ! isAdd && form.prop( 'checkValidity' ) && ! form[0].checkValidity() ) {
return;
}
......
This diff is collapsed.
......@@ -83,7 +83,7 @@ if ( $_POST ) {
);
// Handle translation installation.
if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) {
if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
$language = wp_download_language_pack( $_POST['WPLANG'] );
if ( $language ) {
$_POST['WPLANG'] = $language;
......@@ -374,14 +374,16 @@ if ( isset( $_GET['updated'] ) ) {
$lang = '';
}
wp_dropdown_languages( array(
'name' => 'WPLANG',
'id' => 'WPLANG',
'selected' => $lang,
'languages' => $languages,
'translations' => $translations,
'show_available_translations' => current_user_can( 'install_languages' ),
) );
wp_dropdown_languages(
array(
'name' => 'WPLANG',
'id' => 'WPLANG',
'selected' => $lang,
'languages' => $languages,
'translations' => $translations,
'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
)
);
?>
</td>
</tr>
......
......@@ -68,7 +68,7 @@ if ( isset($_REQUEST['action']) && 'add-site' == $_REQUEST['action'] ) {
$meta['WPLANG'] = ''; // en_US
} elseif ( in_array( $_POST['WPLANG'], get_available_languages() ) ) {
$meta['WPLANG'] = $_POST['WPLANG'];
} elseif ( current_user_can( 'install_languages' ) ) {
} elseif ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
$language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
if ( $language ) {
$meta['WPLANG'] = $language;
......@@ -230,14 +230,16 @@ if ( ! empty( $messages ) ) {
$lang = '';
}
wp_dropdown_languages( array(
'name' => 'WPLANG',
'id' => 'site-language',
'selected' => $lang,
'languages' => $languages,
'translations' => $translations,
'show_available_translations' => current_user_can( 'install_languages' ),
) );
wp_dropdown_languages(
array(
'name' => 'WPLANG',
'id' => 'site-language',
'selected' => $lang,
'languages' => $languages,
'translations' => $translations,
'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
)
);
?>
</td>
</tr>
......
......@@ -158,7 +158,7 @@ if ( ! empty( $languages ) || ! empty( $translations ) ) {
'selected' => $locale,
'languages' => $languages,
'translations' => $translations,
'show_available_translations' => current_user_can( 'install_languages' ),
'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
) );
// Add note about deprecated WPLANG constant.
......
......@@ -180,9 +180,11 @@ if ( 'update' == $action ) {
if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) {
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
$language = wp_download_language_pack( $_POST['WPLANG'] );
if ( $language ) {
$_POST['WPLANG'] = $language;
if ( wp_can_install_language_pack() ) {
$language = wp_download_language_pack( $_POST['WPLANG'] );
if ( $language ) {
$_POST['WPLANG'] = $language;
}
}
}
}
......
......@@ -432,15 +432,7 @@ function map_meta_cap( $cap, $user_id ) {
break;
case 'install_languages':
case 'update_languages':
if ( ! function_exists( 'request_filesystem_credentials' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
if ( ! function_exists( 'wp_can_install_language_pack' ) ) {
require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
}
if ( ! wp_can_install_language_pack() ) {
if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
$caps[] = 'do_not_allow';
} elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
$caps[] = 'do_not_allow';
......
......@@ -607,8 +607,11 @@ final class WP_Customize_Manager {
* enabled, then a new UUID will be generated.
*
* @since 4.9.0
* @global string $pagenow
*/
public function establish_loaded_changeset() {
global $pagenow;
if ( empty( $this->_changeset_uuid ) ) {
$changeset_uuid = null;
......@@ -635,7 +638,9 @@ final class WP_Customize_Manager {
$this->_changeset_uuid = $changeset_uuid;
}
$this->set_changeset_lock( $this->changeset_post_id() );
if ( is_admin() && 'customize.php' === $pagenow ) {
$this->set_changeset_lock( $this->changeset_post_id() );
}
}
/**
......@@ -1130,7 +1135,7 @@ final class WP_Customize_Manager {
if ( ! $changeset_post_id ) {
$this->_changeset_data = array();
} else {
if ( $this->autosaved() ) {
if ( $this->autosaved() && is_user_logged_in() ) {
$autosave_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
if ( $autosave_post ) {
$data = $this->get_changeset_post_data( $autosave_post->ID );
......@@ -2873,10 +2878,12 @@ final class WP_Customize_Manager {
$post_array['edit_date'] = true; // Prevent date clearing.
$r = wp_update_post( wp_slash( $post_array ), true );
// Delete autosave revision when the changeset is updated.
$autosave_draft = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
if ( $autosave_draft ) {
wp_delete_post( $autosave_draft->ID, true );
// Delete autosave revision for user when the changeset is updated.
if ( ! empty( $args['user_id'] ) ) {
$autosave_draft = wp_get_post_autosave( $changeset_post_id, $args['user_id'] );
if ( $autosave_draft ) {
wp_delete_post( $autosave_draft->ID, true );
}
}
}
} else {
......@@ -3163,15 +3170,26 @@ final class WP_Customize_Manager {
* @return array The Heartbeat response.
*/
public function check_changeset_lock_with_heartbeat( $response, $data, $screen_id ) {
if ( array_key_exists( 'check_changeset_lock', $data ) && 'customize' === $screen_id && current_user_can( 'customize' ) && $this->changeset_post_id() ) {
$lock_user_id = wp_check_post_lock( $this->changeset_post_id() );
if ( isset( $data['changeset_uuid'] ) ) {
$changeset_post_id = $this->find_changeset_post_id( $data['changeset_uuid'] );
} else {
$changeset_post_id = $this->changeset_post_id();
}
if (
array_key_exists( 'check_changeset_lock', $data )
&& 'customize' === $screen_id
&& $changeset_post_id
&& current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $changeset_post_id )
) {
$lock_user_id = wp_check_post_lock( $changeset_post_id );
if ( $lock_user_id ) {
$response['customize_changeset_lock_user'] = $this->get_lock_user_data( $lock_user_id );
} else {
// Refreshing time will ensure that the user is sitting on customizer and has not closed the customizer tab.
$this->refresh_changeset_lock( $this->changeset_post_id() );
$this->refresh_changeset_lock( $changeset_post_id );
}
}
......@@ -3488,6 +3506,11 @@ final class WP_Customize_Manager {
* @since 4.9.0
*/
public function handle_dismiss_autosave_or_lock_request() {
// Calls to dismiss_user_auto_draft_changesets() and wp_get_post_autosave() require non-zero get_current_user_id().
if ( ! is_user_logged_in() ) {
wp_send_json_error( 'unauthenticated', 401 );
}
if ( ! $this->is_preview() ) {
wp_send_json_error( 'not_preview', 400 );
}
......@@ -3939,6 +3962,22 @@ final class WP_Customize_Manager {
* @since 4.1.0
*/
public function render_control_templates() {
if ( $this->branching() ) {
$l10n = array(
/* translators: %s: User who is customizing the changeset in customizer. */
'locked' => __( '%s is already customizing this changeset. Please wait until they are done to try customizing. Your latest changes have been autosaved.' ),
/* translators: %s: User who is customizing the changeset in customizer. */
'locked_allow_override' => __( '%s is already customizing this changeset. Do you want to take over?' ),
);
} else {
$l10n = array(
/* translators: %s: User who is customizing the changeset in customizer. */
'locked' => __( '%s is already customizing this site. Please wait until they are done to try customizing. Your latest changes have been autosaved.' ),
/* translators: %s: User who is customizing the changeset in customizer. */
'locked_allow_override' => __( '%s is already customizing this site. Do you want to take over?' ),
);
}
foreach ( $this->registered_control_types as $control_type ) {
$control = new $control_type( $this, 'temp', array(
'settings' => array(),
......@@ -4101,13 +4140,11 @@ final class WP_Customize_Manager {
{{{ data.message }}}
<# } else if ( data.allowOverride ) { #>
<?php
/* translators: %s: User who is customizing the changeset in customizer. */
printf( __( '%s is already customizing this site. Do you want to take over?' ), '{{ data.lockUser.name }}' );
echo esc_html( sprintf( $l10n['locked_allow_override'], '{{ data.lockUser.name }}' ) );
?>
<# } else { #>
<?php
/* translators: %s: User who is customizing the changeset in customizer. */
printf( __( '%s is already customizing this site. Please wait until they are done to try customizing. Your latest changes have been autosaved.' ), '{{ data.lockUser.name }}' );
echo esc_html( sprintf( $l10n['locked'], '{{ data.lockUser.name }}' ) );
?>
<# } #>
</p>
......@@ -4555,7 +4592,9 @@ final class WP_Customize_Manager {
$changeset_post_id = $this->changeset_post_id();
if ( ! $this->saved_starter_content_changeset && ! $this->autosaved() ) {
if ( $changeset_post_id ) {
$autosave_revision_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
if ( is_user_logged_in() ) {
$autosave_revision_post = wp_get_post_autosave( $changeset_post_id, get_current_user_id() );
}
} else {
$autosave_autodraft_posts = $this->get_changeset_posts( array(
'posts_per_page' => 1,
......@@ -4636,8 +4675,9 @@ final class WP_Customize_Manager {
'previewFrameSensitivity' => 2000,
),
'theme' => array(
'stylesheet' => $this->get_stylesheet(),
'active' => $this->is_theme_active(),
'stylesheet' => $this->get_stylesheet(),
'active' => $this->is_theme_active(),
'_canInstall' => current_user_can( 'install_themes' ),
),
'url' => array(
'preview' => esc_url_raw( $this->get_preview_url() ),
......
......@@ -370,6 +370,22 @@ final class WP_Customize_Nav_Menus {
}
}
// Add "Home" link if search term matches. Treat as a page, but switch to custom on add.
if ( isset( $args['s'] ) ) {
$title = _x( 'Home', 'nav menu home label' );
$matches = function_exists( 'mb_stripos' ) ? false !== mb_stripos( $title, $args['s'] ) : false !== stripos( $title, $args['s'] );
if ( $matches ) {
$items[] = array(
'id' => 'home',
'title' => $title,
'type' => 'custom',
'type_label' => __( 'Custom Link' ),
'object' => '',
'url' => home_url(),
);
}
}
/**
* Filters the available menu items during a search request.
*
......
......@@ -3032,7 +3032,15 @@ class WP_Query {
*/
$this->found_posts = $wpdb->get_var( apply_filters_ref_array( 'found_posts_query', array( 'SELECT FOUND_ROWS()', &$this ) ) );
} else {
$this->found_posts = count( $this->posts );
if ( is_array( $this->posts ) ) {
$this->found_posts = count( $this->posts );
} else {
if ( null === $this->posts ) {
$this->found_posts = 0;
} else {
$this->found_posts = 1;
}
}
}
/**
......
......@@ -730,10 +730,10 @@ div.mce-menu .mce-menu-item-sep,
cursor: default;
}
.mce-menubtn.mce-fixed-width button {
.mce-menubtn.mce-fixed-width span {
overflow-x: hidden;
text-overflow: ellipsis;
width: 110px;
width: 82px;
}
/* Charmap modal */
......
This diff is collapsed.
......@@ -730,10 +730,10 @@ div.mce-menu .mce-menu-item-sep,
cursor: default;
}
.mce-menubtn.mce-fixed-width button {