Update WordPress to latest trunk.

parent 7952350b
......@@ -1207,6 +1207,10 @@ table.form-table td .updated p {
color: #72777c;
}
.privacy_requests .row-actions.processing {
position: static;
}
.privacy_requests tbody .has-request-results th {
box-shadow: none;
}
......@@ -1225,8 +1229,8 @@ table.form-table td .updated p {
}
.privacy_requests .next_steps .button {
word-break: break-all;
white-space: unset;
word-wrap: break-word;
white-space: normal;
}
.privacy_requests .status-request-confirmed th,
......
This diff is collapsed.
......@@ -1206,6 +1206,10 @@ table.form-table td .updated p {
color: #72777c;
}
.privacy_requests .row-actions.processing {
position: static;
}
.privacy_requests tbody .has-request-results th {
box-shadow: none;
}
......@@ -1224,8 +1228,8 @@ table.form-table td .updated p {
}
.privacy_requests .next_steps .button {
word-break: break-all;
white-space: unset;
word-wrap: break-word;
white-space: normal;
}
.privacy_requests .status-request-confirmed th,
......
This diff is collapsed.
......@@ -608,6 +608,10 @@ div#widgets-right .closed .widgets-sortables {
background: #fff;
}
.widget-inside select {
max-width: 100%;
}
/* Dragging widgets over the available widget area show's a "Deactivate" message */
#removing-widget {
display: none;
......
This diff is collapsed.
......@@ -607,6 +607,10 @@ div#widgets-right .closed .widgets-sortables {
background: #fff;
}
.widget-inside select {
max-width: 100%;
}
/* Dragging widgets over the available widget area show's a "Deactivate" message */
#removing-widget {
display: none;
......
This diff is collapsed.
......@@ -245,7 +245,7 @@ $form_extra .= "<input type='hidden' id='post_ID' name='post_ID' value='" . esc
// 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 ) ) {
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 ) ) {
$notice = sprintf(
/* translators: %s: URL to view the autosave. */
__( 'There is an autosave of this post that is more recent than the version below. <a href="%s">View the autosave</a>' ),
......
......@@ -1829,7 +1829,7 @@ function wp_create_post_autosave( $post_data ) {
// If the new autosave has the same content as the post, delete the autosave.
$autosave_is_different = false;
foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
if ( normalize_whitespace( $new_autosave[ $field ] ) != normalize_whitespace( $post->$field ) ) {
if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) {
$autosave_is_different = true;
break;
}
......
......@@ -1795,7 +1795,11 @@
$removeBtn.on( 'click', function() {
// 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,
instanceCounter = 0, // Instance count of the menu item deleted.
deleteItemOriginalItemId = control.params.original_item_id,
addedItems = control.getMenuControl().$sectionContent.find( '.menu-item' ),
availableMenuItem;
if ( ! $( 'body' ).hasClass( 'adding-menu-items' ) ) {
addingItems = false;
......@@ -1812,6 +1816,39 @@
$adjacentFocusTarget = control.container.nextAll( '.customize-control-nav_menu' ).find( '.add-new-menu-item' ).first();
}
/*
* If the menu item deleted is the only of its instance left,
* remove the check icon of this menu item in the right panel.
*/
_.each( addedItems, function( addedItem ) {
var menuItemId, menuItemControl, matches;
// This is because menu item that's deleted is just hidden.
if ( ! $( addedItem ).is( ':visible' ) ) {
return;
}
matches = addedItem.getAttribute( 'id' ).match( /^customize-control-nav_menu_item-(-?\d+)$/, '' );
if ( ! matches ) {
return;
}
menuItemId = parseInt( matches[1], 10 );
menuItemControl = api.control( 'nav_menu_item[' + String( menuItemId ) + ']' );
// Check for duplicate menu items.
if ( menuItemControl && deleteItemOriginalItemId == menuItemControl.params.original_item_id ) {
instanceCounter++;
}
} );
if ( instanceCounter <= 1 ) {
// Revert the check icon to add icon.
availableMenuItem = $( '#menu-item-tpl-' + control.params.original_item_id );
availableMenuItem.removeClass( 'selected' );
availableMenuItem.find( '.menu-item-handle' ).removeClass( 'item-added' );
}
control.container.slideUp( function() {
control.setting.set( false );
wp.a11y.speak( api.Menus.data.l10n.itemDeleted );
......@@ -2961,7 +2998,8 @@
* @return {wp.customize.Menus.controlConstructor.nav_menu_item} The newly-created nav_menu_item control instance.
*/
addItemToMenu: function( item ) {
var menuControl = this, customizeId, settingArgs, setting, menuItemControl, placeholderId, position = 0, priority = 10;
var menuControl = this, customizeId, settingArgs, setting, menuItemControl, placeholderId, position = 0, priority = 10,
originalItemId = item.id || '';
_.each( menuControl.getMenuItemControls(), function( control ) {
if ( false === control.setting() ) {
......@@ -3005,7 +3043,8 @@
settings: {
'default': customizeId
},
menu_item_id: placeholderId
menu_item_id: placeholderId,
original_item_id: originalItemId
} );
api.control.add( menuItemControl );
......
This diff is collapsed.
......@@ -60,6 +60,7 @@ jQuery( document ).ready( function( $ ) {
$action = $this.parents( '.export-personal-data' ),
$requestRow = $this.parents( 'tr' ),
$progress = $requestRow.find( '.export-progress' ),
$rowActions = $this.parents( '.row-actions' ),
requestID = $action.data( 'request-id' ),
nonce = $action.data( 'nonce' ),
exportersCount = $action.data( 'exporters-count' ),
......@@ -68,6 +69,8 @@ jQuery( document ).ready( function( $ ) {
event.preventDefault();
event.stopPropagation();
$rowActions.addClass( 'processing' );
$action.blur();
clearResultsAfterRow( $requestRow );
setExportProgress( 0 );
......@@ -78,13 +81,14 @@ jQuery( document ).ready( function( $ ) {
setActionState( $action, 'export-personal-data-success' );
appendResultsAfterRow( $requestRow, 'notice-success', summaryMessage, [] );
$this.hide();
if ( 'undefined' !== typeof zipUrl ) {
window.location = zipUrl;
} else if ( ! sendAsEmail ) {
onExportFailure( strings.noExportFile );
}
setTimeout( function(){ $rowActions.removeClass( 'processing' ); }, 500 );
}
function onExportFailure( errorMessage ) {
......@@ -92,6 +96,8 @@ jQuery( document ).ready( function( $ ) {
if ( errorMessage ) {
appendResultsAfterRow( $requestRow, 'notice-error', strings.exportError, [ errorMessage ] );
}
setTimeout( function(){ $rowActions.removeClass( 'processing' ); }, 500 );
}
function setExportProgress( exporterIndex ) {
......@@ -118,26 +124,24 @@ jQuery( document ).ready( function( $ ) {
var responseData = response.data;
if ( ! response.success ) {
// e.g. invalid request ID.
onExportFailure( response.data );
setTimeout( function(){ onExportFailure( response.data ); }, 500 );
return;
}
if ( ! responseData.done ) {
setTimeout( doNextExport( exporterIndex, pageIndex + 1 ) );
} else {
setExportProgress( exporterIndex );
if ( exporterIndex < exportersCount ) {
setExportProgress( exporterIndex );
setTimeout( doNextExport( exporterIndex + 1, 1 ) );
} else {
onExportDoneSuccess( responseData.url );
setTimeout( function(){ onExportDoneSuccess( responseData.url ); }, 500 );
}
}
}).fail( function( jqxhr, textStatus, error ) {
// e.g. Nonce failure.
onExportFailure( error );
setTimeout( function(){ onExportFailure( error ); }, 500 );
});
}
......@@ -151,6 +155,7 @@ jQuery( document ).ready( function( $ ) {
$action = $this.parents( '.remove-personal-data' ),
$requestRow = $this.parents( 'tr' ),
$progress = $requestRow.find( '.erasure-progress' ),
$rowActions = $this.parents( '.row-actions' ),
requestID = $action.data( 'request-id' ),
nonce = $action.data( 'nonce' ),
erasersCount = $action.data( 'erasers-count' ),
......@@ -158,8 +163,11 @@ jQuery( document ).ready( function( $ ) {
hasRetained = false,
messages = [];
event.preventDefault();
event.stopPropagation();
$rowActions.addClass( 'processing' );
$action.blur();
clearResultsAfterRow( $requestRow );
setErasureProgress( 0 );
......@@ -186,12 +194,15 @@ jQuery( document ).ready( function( $ ) {
}
}
appendResultsAfterRow( $requestRow, classes, summaryMessage, messages );
$this.hide();
setTimeout( function(){ $rowActions.removeClass( 'processing' ); }, 500 );
}
function onErasureFailure() {
setActionState( $action, 'remove-personal-data-failed' );
appendResultsAfterRow( $requestRow, 'notice-error', strings.removalError, [] );
setTimeout( function(){ $rowActions.removeClass( 'processing' ); }, 500 );
}
function setErasureProgress( eraserIndex ) {
......@@ -215,7 +226,7 @@ jQuery( document ).ready( function( $ ) {
var responseData = response.data;
if ( ! response.success ) {
onErasureFailure();
setTimeout( function(){ onErasureFailure(); }, 500 );
return;
}
if ( responseData.items_removed ) {
......@@ -230,15 +241,15 @@ jQuery( document ).ready( function( $ ) {
if ( ! responseData.done ) {
setTimeout( doNextErasure( eraserIndex, pageIndex + 1 ) );
} else {
setErasureProgress( eraserIndex );
if ( eraserIndex < erasersCount ) {
setErasureProgress( eraserIndex );
setTimeout( doNextErasure( eraserIndex + 1, 1 ) );
} else {
onErasureDoneSuccess();
setTimeout( function(){ onErasureDoneSuccess(); }, 500 );
}
}
}).fail( function() {
onErasureFailure();
setTimeout( function(){ onErasureFailure(); }, 500 );
});
}
......
/*! This file is auto-generated */
jQuery(document).ready(function(f){var h=window.privacyToolsL10n||{};function g(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function x(e){e.removeClass("has-request-results"),e.next().hasClass("request-results")&&e.next().remove()}function w(e,t,a,n){var o="",r="request-results";x(e),n.length&&(f.each(n,function(e,t){o=o+"<li>"+t+"</li>"}),o="<ul>"+o+"</ul>"),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(r+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(r+=" status-request-failed"),e.after(function(){return'<tr class="'+r+'"><th colspan="5"><div class="notice inline notice-alt '+t+'"><p>'+a+"</p>"+o+"</div></td></tr>"})}f(".export-personal-data-handle").click(function(e){var r=f(this),s=r.parents(".export-personal-data"),i=r.parents("tr"),n=i.find(".export-progress"),t=s.data("request-id"),d=s.data("nonce"),c=s.data("exporters-count"),l=!!s.data("send-as-email");function u(e){g(s,"export-personal-data-failed"),e&&w(i,"notice-error",h.exportError,[e])}function p(e){var t=0<c?e/c:0,a=Math.round(100*t).toString()+"%";n.html(a)}e.preventDefault(),e.stopPropagation(),s.blur(),x(i),p(0),g(s,"export-personal-data-processing"),function a(n,o){f.ajax({url:window.ajaxurl,data:{action:"wp-privacy-export-personal-data",exporter:n,id:t,page:o,security:d,sendAsEmail:l},method:"post"}).done(function(e){var t=e.data;e.success?t.done?n<c?(p(n),setTimeout(a(n+1,1))):function(e){var t=h.emailSent;g(s,"export-personal-data-success"),w(i,"notice-success",t,[]),r.hide(),void 0!==e?window.location=e:l||u(h.noExportFile)}(t.url):setTimeout(a(n,o+1)):u(e.data)}).fail(function(e,t,a){u(a)})}(1,1)}),f(".remove-personal-data-handle").click(function(e){var r=f(this),s=r.parents(".remove-personal-data"),i=r.parents("tr"),n=i.find(".erasure-progress"),t=s.data("request-id"),d=s.data("nonce"),c=s.data("erasers-count"),l=!1,u=!1,p=[];function m(){g(s,"remove-personal-data-failed"),w(i,"notice-error",h.removalError,[])}function v(e){var t=0<c?e/c:0,a=Math.round(100*t).toString()+"%";n.html(a)}e.stopPropagation(),s.blur(),x(i),v(0),g(s,"remove-personal-data-processing"),function a(n,o){f.ajax({url:window.ajaxurl,data:{action:"wp-privacy-erase-personal-data",eraser:n,id:t,page:o,security:d},method:"post"}).done(function(e){var t=e.data;e.success?(t.items_removed&&(l=l||t.items_removed),t.items_retained&&(u=u||t.items_retained),t.messages&&(p=p.concat(t.messages)),t.done?n<c?(v(n),setTimeout(a(n+1,1))):function(){var e=h.noDataFound,t="notice-success";g(s,"remove-personal-data-success"),!1===l?!1===u?e=h.noDataFound:(e=h.noneRemoved,t="notice-warning"):!1===u?e=h.foundAndRemoved:(e=h.someNotRemoved,t="notice-warning"),w(i,t,e,p),r.hide()}():setTimeout(a(n,o+1))):m()}).fail(function(){m()})}(1,1)}),f(document).on("click",function(e){var t,a,n,o=f(e.target);if(o.is("button.privacy-text-copy")&&((a=(t=o.parent().parent()).find("div.wp-suggested-text")).length||(a=t.find("div.policy-text")),a.length))try{window.getSelection().removeAllRanges(),n=document.createRange(),a.addClass("hide-privacy-policy-tutorial"),n.selectNodeContents(a[0]),window.getSelection().addRange(n),document.execCommand("copy"),a.removeClass("hide-privacy-policy-tutorial"),window.getSelection().removeAllRanges()}catch(e){}})});
\ No newline at end of file
jQuery(document).ready(function(g){var h=window.privacyToolsL10n||{};function w(e,t){e.children().addClass("hidden"),e.children("."+t).removeClass("hidden")}function x(e){e.removeClass("has-request-results"),e.next().hasClass("request-results")&&e.next().remove()}function C(e,t,n,a){var o="",s="request-results";x(e),a.length&&(g.each(a,function(e,t){o=o+"<li>"+t+"</li>"}),o="<ul>"+o+"</ul>"),e.addClass("has-request-results"),e.hasClass("status-request-confirmed")&&(s+=" status-request-confirmed"),e.hasClass("status-request-failed")&&(s+=" status-request-failed"),e.after(function(){return'<tr class="'+s+'"><th colspan="5"><div class="notice inline notice-alt '+t+'"><p>'+n+"</p>"+o+"</div></td></tr>"})}g(".export-personal-data-handle").click(function(e){var t=g(this),s=t.parents(".export-personal-data"),r=t.parents("tr"),a=r.find(".export-progress"),i=t.parents(".row-actions"),c=s.data("request-id"),d=s.data("nonce"),u=s.data("exporters-count"),l=!!s.data("send-as-email");function p(e){w(s,"export-personal-data-failed"),e&&C(r,"notice-error",h.exportError,[e]),setTimeout(function(){i.removeClass("processing")},500)}function m(e){var t=0<u?e/u:0,n=Math.round(100*t).toString()+"%";a.html(n)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),s.blur(),x(r),m(0),w(s,"export-personal-data-processing"),function n(a,o){g.ajax({url:window.ajaxurl,data:{action:"wp-privacy-export-personal-data",exporter:a,id:c,page:o,security:d,sendAsEmail:l},method:"post"}).done(function(e){var t=e.data;e.success?t.done?(m(a),a<u?setTimeout(n(a+1,1)):setTimeout(function(){!function(e){var t=h.emailSent;w(s,"export-personal-data-success"),C(r,"notice-success",t,[]),void 0!==e?window.location=e:l||p(h.noExportFile),setTimeout(function(){i.removeClass("processing")},500)}(t.url)},500)):setTimeout(n(a,o+1)):setTimeout(function(){p(e.data)},500)}).fail(function(e,t,n){setTimeout(function(){p(n)},500)})}(1,1)}),g(".remove-personal-data-handle").click(function(e){var t=g(this),s=t.parents(".remove-personal-data"),r=t.parents("tr"),a=r.find(".erasure-progress"),i=t.parents(".row-actions"),c=s.data("request-id"),d=s.data("nonce"),u=s.data("erasers-count"),l=!1,p=!1,m=[];function f(){w(s,"remove-personal-data-failed"),C(r,"notice-error",h.removalError,[]),setTimeout(function(){i.removeClass("processing")},500)}function v(e){var t=0<u?e/u:0,n=Math.round(100*t).toString()+"%";a.html(n)}e.preventDefault(),e.stopPropagation(),i.addClass("processing"),s.blur(),x(r),v(0),w(s,"remove-personal-data-processing"),function n(a,o){g.ajax({url:window.ajaxurl,data:{action:"wp-privacy-erase-personal-data",eraser:a,id:c,page:o,security:d},method:"post"}).done(function(e){var t=e.data;e.success?(t.items_removed&&(l=l||t.items_removed),t.items_retained&&(p=p||t.items_retained),t.messages&&(m=m.concat(t.messages)),t.done?(v(a),a<u?setTimeout(n(a+1,1)):setTimeout(function(){!function(){var e=h.noDataFound,t="notice-success";w(s,"remove-personal-data-success"),!1===l?!1===p?e=h.noDataFound:(e=h.noneRemoved,t="notice-warning"):!1===p?e=h.foundAndRemoved:(e=h.someNotRemoved,t="notice-warning"),C(r,t,e,m),setTimeout(function(){i.removeClass("processing")},500)}()},500)):setTimeout(n(a,o+1))):setTimeout(function(){f()},500)}).fail(function(){setTimeout(function(){f()},500)})}(1,1)}),g(document).on("click",function(e){var t,n,a,o=g(e.target);if(o.is("button.privacy-text-copy")&&((n=(t=o.parent().parent()).find("div.wp-suggested-text")).length||(n=t.find("div.policy-text")),n.length))try{window.getSelection().removeAllRanges(),a=document.createRange(),n.addClass("hide-privacy-policy-tutorial"),a.selectNodeContents(n[0]),window.getSelection().addRange(a),document.execCommand("copy"),n.removeClass("hide-privacy-policy-tutorial"),window.getSelection().removeAllRanges()}catch(e){}})});
\ No newline at end of file
......@@ -174,7 +174,7 @@ class WP_Customize_Control {
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
* @param string $id Control ID.
* @param array $args {
* Optional. Arguments to override class property defaults.
* Optional. Array of properties for the new Control object. Default empty array.
*
* @type int $instance_number Order in which this instance was created in relation
* to other instances.
......@@ -184,6 +184,8 @@ class WP_Customize_Control {
* be used.
* @type string $setting The primary setting for the control (if there is one).
* Default 'default'.
* @type string $capability Capability required to use this control. Normally this is empty
* and the capability is derived from `$settings`.
* @type int $priority Order priority to load the control. Default 10.
* @type string $section Section the control belongs to. Default empty.
* @type string $label Label for the control. Default empty.
......@@ -195,11 +197,14 @@ class WP_Customize_Control {
* attribute names are the keys and values are the values. Not
* used for 'checkbox', 'radio', 'select', 'textarea', or
* 'dropdown-pages' control types. Default empty array.
* @type bool $allow_addition Show UI for adding new content, currently only used for the
* dropdown-pages control. Default false.
* @type array $json Deprecated. Use WP_Customize_Control::json() instead.
* @type string $type Control type. Core controls include 'text', 'checkbox',
* 'textarea', 'radio', 'select', and 'dropdown-pages'. Additional
* input types such as 'email', 'url', 'number', 'hidden', and
* 'date' are supported implicitly. Default 'text'.
* @type callback $active_callback Active callback.
* }
*/
public function __construct( $manager, $id, $args = array() ) {
......
This diff is collapsed.
......@@ -39,7 +39,7 @@ final class WP_Customize_Nav_Menus {
*
* @since 4.3.0
*
* @param WP_Customize_Manager $manager An instance of the WP_Customize_Manager class.
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
*/
public function __construct( $manager ) {
$this->manager = $manager;
......
......@@ -69,10 +69,10 @@ class WP_Customize_Panel {
public $capability = 'edit_theme_options';
/**
* Theme feature support for the panel.
* Theme features required to support the panel.
*
* @since 4.0.0
* @var string|array
* @var string|string[]
*/
public $theme_supports = '';
......@@ -138,8 +138,20 @@ class WP_Customize_Panel {
* @since 4.0.0
*
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
* @param string $id An specific ID for the panel.
* @param array $args Panel arguments.
* @param string $id A specific ID for the panel.
* @param array $args {
* Optional. Array of properties for the new Panel object. Default empty array.
*
* @type int $priority Priority of the panel, defining the display order
* of panels and sections. Default 160.
* @type string $capability Capability required for the panel.
* Default `edit_theme_options`.
* @type string|string[] $theme_supports Theme features required to support the panel.
* @type string $title Title of the panel to show in UI.
* @type string $description Description to show in the UI.
* @type string $type Type of the panel.
* @type callable $active_callback Active callback.
* }
*/
public function __construct( $manager, $id, $args = array() ) {
$keys = array_keys( get_object_vars( $this ) );
......
......@@ -77,10 +77,10 @@ class WP_Customize_Section {
public $capability = 'edit_theme_options';
/**
* Theme feature support for the section.
* Theme features required to support the section.
*
* @since 3.4.0
* @var string|array
* @var string|string[]
*/
public $theme_supports = '';
......@@ -149,8 +149,25 @@ class WP_Customize_Section {
* @since 3.4.0
*
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
* @param string $id An specific ID of the section.
* @param array $args Section arguments.
* @param string $id A specific ID of the section.
* @param array $args {
* Optional. Array of properties for the new Section object. Default empty array.
*
* @type int $priority Priority of the section, defining the display order
* of panels and sections. Default 160.
* @type string $panel The panel this section belongs to (if any).
* Default empty.
* @type string $capability Capability required for the section.
* Default 'edit_theme_options'
* @type string|string[] $theme_supports Theme features required to support the section.
* @type string $title Title of the section to show in UI.
* @type string $description Description to show in the UI.
* @type string $type Type of the section.
* @type callable $active_callback Active callback.
* @type bool $description_hidden Hide the description behind a help icon,
* instead of inline above the first control.
* Default false.
* }
*/
public function __construct( $manager, $id, $args = array() ) {
$keys = array_keys( get_object_vars( $this ) );
......
......@@ -51,10 +51,10 @@ class WP_Customize_Setting {
public $capability = 'edit_theme_options';
/**
* Feature a theme is required to support to enable this setting.
* Theme features required to support the setting.
*
* @since 3.4.0
* @var string
* @var string|string[]
*/
public $theme_supports = '';
......@@ -153,10 +153,26 @@ class WP_Customize_Setting {
*
* @since 3.4.0
*
* @param WP_Customize_Manager $manager
* @param string $id An specific ID of the setting. Can be a
* theme mod or option name.
* @param array $args Setting arguments.
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
* @param string $id A specific ID of the setting.
* Can be a theme mod or option name.
* @param array $args {
* Optional. Array of properties for the new Setting object. Default empty array.
*
* @type string $type Type of the setting. Default 'theme_mod'.
* @type string $capability Capability required for the setting. Default 'edit_theme_options'
* @type string|string[] $theme_supports Theme features required to support the panel. Default is none.
* @type string $default Default value for the setting. Default is empty string.
* @type string $transport Options for rendering the live preview of changes in Customizer.
* Using 'refresh' makes the change visible by reloading the whole preview.
* Using 'postMessage' allows a custom JavaScript to handle live changes.
* Default is 'refresh'.
* @type callable $validate_callback Server-side validation callback for the setting's value.
* @type callable $sanitize_callback Callback to filter a Customize setting value in un-slashed form.
* @type callable $sanitize_js_callback Callback to convert a Customize PHP setting value to a value that is
* JSON serializable.
* @type bool $dirty Whether or not the setting is initially dirty when created.
* }
*/
public function __construct( $manager, $id, $args = array() ) {
$keys = array_keys( get_object_vars( $this ) );
......
......@@ -94,7 +94,7 @@ final class WP_Customize_Widgets {
*
* @since 3.9.0
*
* @param WP_Customize_Manager $manager Customize manager bootstrap instance.
* @param WP_Customize_Manager $manager Customizer bootstrap instance.
*/
public function __construct( $manager ) {
$this->manager = $manager;
......
......@@ -75,6 +75,14 @@ class WP_Dependencies {
*/
public $group = 0;
/**
* Cached lookup array of flattened queued items and dependencies.
*
* @since 5.4.0
* @var array
*/
private $all_queued_deps;
/**
* Processes the items and dependencies.
*
......@@ -302,8 +310,13 @@ class WP_Dependencies {
public function enqueue( $handles ) {
foreach ( (array) $handles as $handle ) {
$handle = explode( '?', $handle );
if ( ! in_array( $handle[0], $this->queue ) && isset( $this->registered[ $handle[0] ] ) ) {
if ( ! in_array( $handle[0], $this->queue, true ) && isset( $this->registered[ $handle[0] ] ) ) {
$this->queue[] = $handle[0];
// Reset all dependencies so they must be recalculated in recurse_deps().
$this->all_queued_deps = null;
if ( isset( $handle[1] ) ) {
$this->args[ $handle[0] ] = $handle[1];
}
......@@ -325,8 +338,12 @@ class WP_Dependencies {
public function dequeue( $handles ) {
foreach ( (array) $handles as $handle ) {
$handle = explode( '?', $handle );
$key = array_search( $handle[0], $this->queue );
$key = array_search( $handle[0], $this->queue, true );
if ( false !== $key ) {
// Reset all dependencies so they must be recalculated in recurse_deps().
$this->all_queued_deps = null;
unset( $this->queue[ $key ] );
unset( $this->args[ $handle[0] ] );
}
......@@ -334,7 +351,7 @@ class WP_Dependencies {
}
/**
* Recursively search the passed dependency tree for $handle
* Recursively search the passed dependency tree for $handle.
*
* @since 4.0.0
*
......@@ -343,19 +360,31 @@ class WP_Dependencies {
* @return bool Whether the handle is found after recursively searching the dependency tree.
*/
protected function recurse_deps( $queue, $handle ) {
foreach ( $queue as $queued ) {
if ( ! isset( $this->registered[ $queued ] ) ) {
continue;
}
if ( isset( $this->all_queued_deps ) ) {
return isset( $this->all_queued_deps[ $handle ] );
}
if ( in_array( $handle, $this->registered[ $queued ]->deps ) ) {
return true;
} elseif ( $this->recurse_deps( $this->registered[ $queued ]->deps, $handle ) ) {
return true;
$all_deps = array_fill_keys( $queue, true );
$queues = array();
$done = array();
while ( $queue ) {
foreach ( $queue as $queued ) {
if ( ! isset( $done[ $queued ] ) && isset( $this->registered[ $queued ] ) ) {
$deps = $this->registered[ $queued ]->deps;
if ( $deps ) {
$all_deps += array_fill_keys( $deps, true );
array_push( $queues, $deps );
}
$done[ $queued ] = true;
}
}
$queue = array_pop( $queues );
}
return false;
$this->all_queued_deps = $all_deps;
return isset( $this->all_queued_deps[ $handle ] );
}
/**
......@@ -379,18 +408,18 @@ class WP_Dependencies {
case 'enqueued':
case 'queue':
if ( in_array( $handle, $this->queue ) ) {
if ( in_array( $handle, $this->queue, true ) ) {
return true;
}
return $this->recurse_deps( $this->queue, $handle );
case 'to_do':
case 'to_print': // Back compat.
return in_array( $handle, $this->to_do );
return in_array( $handle, $this->to_do, true );
case 'done':
case 'printed': // Back compat.
return in_array( $handle, $this->done );
return in_array( $handle, $this->done, true );
}
return false;
}
......
......@@ -870,18 +870,14 @@ function get_comments_number( $post_id = 0 ) {
* Displays the language string for the number of comments the current post has.
*
* @since 0.71
* @since 5.4.0 Added the `$post_id` parameter.
* @since 5.4.0 The `$deprecated` parameter was changed to `$post_id`.
*
* @param string $zero Optional. Text for no comments. Default false.
* @param string $one Optional. Text for one comment. Default false.
* @param string $more Optional. Text for more than one comment. Default false.
* @param string $deprecated Not used.
* @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is the global `$post`.
*/
function comments_number( $zero = false, $one = false, $more = false, $deprecated = '', $post_id = 0 ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '1.3.0' );
}
function comments_number( $zero = false, $one = false, $more = false, $post_id = 0 ) {
echo get_comments_number_text( $zero, $one, $more, $post_id );
}