diff options
Diffstat (limited to 'src')
522 files changed, 6818 insertions, 5463 deletions
diff --git a/src/index.php b/src/index.php index 9e8f9ec856..c1be8ac3b0 100644 --- a/src/index.php +++ b/src/index.php @@ -29,7 +29,7 @@ require_once( ABSPATH . WPINC . '/version.php' ); wp_check_php_mysql_versions(); wp_load_translations_early(); -// Die with an error message +// Die with an error message. $die = sprintf( '<p>%s</p>', __( 'You are running WordPress without JavaScript and CSS files. These need to be built.' ) diff --git a/src/js/_enqueues/admin/comment.js b/src/js/_enqueues/admin/comment.js index f1fd2213a0..fd347d448b 100644 --- a/src/js/_enqueues/admin/comment.js +++ b/src/js/_enqueues/admin/comment.js @@ -70,7 +70,7 @@ jQuery(document).ready( function($) { * @param {Event} event The event object. * @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(), newD = new Date( aa, mm - 1, jj, hh, mn ); diff --git a/src/js/_enqueues/admin/common.js b/src/js/_enqueues/admin/common.js index 0541c8d0f2..75c77b3bac 100644 --- a/src/js/_enqueues/admin/common.js +++ b/src/js/_enqueues/admin/common.js @@ -168,7 +168,7 @@ window.validateForm = function( form ) { .length; }; -// stub for doing better warnings +// Stub for doing better warnings. /** * 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') ) return false; - // Links + // Links. $('.contextual-help-tabs .active').removeClass('active'); link.parent('li').addClass('active'); panel = $( link.attr('href') ); - // Panels + // Panels. $('.help-tab-content').not( panel ).removeClass('active').hide(); panel.addClass('active').show(); }); @@ -517,7 +517,7 @@ $document.ready( function() { $( '#collapse-button' ).on( 'click.collapse-menu', function() { 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', ''); if ( viewportWidth < 960 ) { @@ -582,12 +582,12 @@ $document.ready( function() { menutop = $menuItem.offset().top; 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 - pageHeight = $wpwrap.height(); // Height of the entire page + bottomOffset = menutop + $submenu.height() + 1; // Bottom offset of the menu. + pageHeight = $wpwrap.height(); // Height of the entire page. adjustment = 60 + bottomOffset - pageHeight; - theFold = $window.height() + wintop - 50; // The fold + theFold = $window.height() + wintop - 50; // The fold. if ( theFold < ( bottomOffset - adjustment ) ) { adjustment = bottomOffset - theFold; @@ -604,8 +604,8 @@ $document.ready( function() { } } - if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // touch screen device - // iOS Safari works with touchstart, the rest work with click + if ( 'ontouchstart' in window || /IEMobile\/[1-9]/.test(navigator.userAgent) ) { // Touch screen device. + // iOS Safari works with touchstart, the rest work with click. mobileEvent = isIOS ? 'touchstart' : 'click'; /** @@ -639,9 +639,11 @@ $document.ready( function() { return; } - // Show the sub instead of following the link if: - // - the submenu is not open - // - the submenu is not shown inline or the menu is not folded + /* + * Show the sub instead of following the link if: + * - 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 ) ) { event.preventDefault(); adjustSubmenu( $menuItem ); @@ -664,12 +666,12 @@ $document.ready( function() { $submenu = $menuItem.find( '.wp-submenu' ), 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; } if ( $adminmenu.data( 'wp-responsive' ) ) { - // The menu is in responsive mode, bail + // The menu is in responsive mode, bail. return; } @@ -685,7 +687,7 @@ $document.ready( function() { */ out: function(){ if ( $adminmenu.data( 'wp-responsive' ) ) { - // The menu is in responsive mode, bail + // The menu is in responsive mode, bail. return; } @@ -705,7 +707,7 @@ $document.ready( function() { */ $adminmenu.on( 'focus.adminmenu', '.wp-submenu a', function( event ) { if ( $adminmenu.data( 'wp-responsive' ) ) { - // The menu is in responsive mode, bail + // The menu is in responsive mode, bail. return; } @@ -759,7 +761,7 @@ $document.ready( function() { $button = $( '<button type="button" class="notice-dismiss"><span class="screen-reader-text"></span></button>' ), btnText = commonL10n.dismiss || ''; - // Ensure plain text + // Ensure plain text. $button.find( '.screen-reader-text' ).text( btnText ); $button.on( 'click.wp-dismiss-notice', function( event ) { 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 ); - // Init screen meta + // Init screen meta. screenMeta.init(); /** @@ -902,7 +904,7 @@ $document.ready( function() { } }, '.has-row-actions' ); - // Toggle list table rows on small screens + // Toggle list table rows on small screens. $( 'tbody' ).on( 'click', '.toggle-row', function() { $( 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. 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(); $(el).data('tab-out', true); return; @@ -1276,7 +1278,7 @@ $document.ready( function() { 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() { self.activate(); }).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 ) { event.preventDefault(); - // close any open toolbar submenus. + // Close any open toolbar submenus. $adminbar.find( '.hover' ).removeClass( 'hover' ); $wpwrap.toggleClass( 'wp-responsive-open' ); diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js index 4391d50fef..1a64268b6a 100644 --- a/src/js/_enqueues/admin/edit-comments.js +++ b/src/js/_enqueues/admin/edit-comments.js @@ -192,7 +192,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved, var newTitle, regExMatch, titleCount, commentFrag; 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 />' ); newTitle = adminTitle; @@ -256,7 +256,7 @@ var getCount, updateCount, updateCountText, updatePending, updateApproved, return; } - // cache selectors to not get dupes + // Cache selectors to not get dupes. pending = $( 'span.' + pendingClass, postSelector ); noPending = $( 'span.' + noClass, postSelector ); @@ -444,7 +444,7 @@ window.setCommentsList = function() { a.click(function( e ){ e.preventDefault(); - e.stopPropagation(); // ticket #35904 + e.stopPropagation(); // Ticket #35904. list.wpList.del(this); $('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){ $(this).remove(); @@ -491,17 +491,19 @@ window.setCommentsList = function() { unapproved = commentRow.hasClass( 'unapproved' ), spammed = commentRow.hasClass( 'spam' ), trashed = commentRow.hasClass( 'trash' ), - undoing = false; // ticket #35904 + undoing = false; // Ticket #35904. updateDashboardText( newTotal ); updateInModerationText( newTotal ); - // the order of these checks is important - // .unspam can also have .approve or .unapprove - // .untrash can also have .approve or .unapprove + /* + * The order of these checks is important. + * .unspam can also have .approve or .unapprove. + * .untrash can also have .approve or .unapprove. + */ if ( targetParent.is( 'span.undo' ) ) { - // the comment was spammed + // The comment was spammed. if ( targetParent.hasClass( 'unspam' ) ) { spamDiff = -1; @@ -513,7 +515,7 @@ window.setCommentsList = function() { pendingDiff = 1; } - // the comment was trashed + // The comment was trashed. } else if ( targetParent.hasClass( 'untrash' ) ) { trashDiff = -1; @@ -528,32 +530,32 @@ window.setCommentsList = function() { undoing = true; - // user clicked "Spam" + // User clicked "Spam". } else if ( targetParent.is( 'span.spam' ) ) { - // the comment is currently approved + // The comment is currently approved. if ( approved ) { approvedDiff = -1; - // the comment is currently pending + // The comment is currently pending. } else if ( unapproved ) { pendingDiff = -1; - // the comment was in the trash + // The comment was in the trash. } else if ( trashed ) { trashDiff = -1; } - // you can't spam an item on the spam screen + // You can't spam an item on the Spam screen. spamDiff = 1; - // user clicked "Unspam" + // User clicked "Unspam". } else if ( targetParent.is( 'span.unspam' ) ) { if ( approved ) { pendingDiff = 1; } else if ( unapproved ) { approvedDiff = 1; } else if ( trashed ) { - // the comment was previously approved + // The comment was previously approved. if ( targetParent.hasClass( 'approve' ) ) { approvedDiff = 1; - // the comment was previously pending + // The comment was previously pending. } else if ( targetParent.hasClass( 'unapprove' ) ) { pendingDiff = 1; } @@ -565,23 +567,23 @@ window.setCommentsList = function() { pendingDiff = 1; } } - // you can Unspam an item on the spam screen + // You can unspam an item on the Spam screen. spamDiff = -1; - // user clicked "Trash" + // User clicked "Trash". } else if ( targetParent.is( 'span.trash' ) ) { if ( approved ) { approvedDiff = -1; } else if ( unapproved ) { pendingDiff = -1; - // the comment was in the spam queue + // The comment was in the spam queue. } else if ( spammed ) { spamDiff = -1; } - // you can't trash an item on the trash screen + // You can't trash an item on the Trash screen. trashDiff = 1; - // user clicked "Restore" + // User clicked "Restore". } else if ( targetParent.is( 'span.untrash' ) ) { if ( approved ) { pendingDiff = 1; @@ -594,21 +596,21 @@ window.setCommentsList = function() { pendingDiff = 1; } } - // you can't go from trash to spam - // you can untrash on the trash screen + // You can't go from Trash to Spam. + // You can untrash on the Trash screen. trashDiff = -1; - // User clicked "Approve" + // User clicked "Approve". } else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) { approvedDiff = 1; pendingDiff = -1; - // User clicked "Unapprove" + // User clicked "Unapprove". } else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) { approvedDiff = -1; pendingDiff = 1; - // User clicked "Delete Permanently" + // User clicked "Delete Permanently". } else if ( targetParent.is( 'span.delete' ) ) { if ( spammed ) { spamDiff = -1; @@ -713,17 +715,17 @@ window.setCommentsList = function() { if (ev) { 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 { 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.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 ) args.comment_type = ''; @@ -781,9 +783,9 @@ window.commentReply = { /** * Initializes the comment reply functionality. * - * @memberof commentReply - * * @since 2.7.0 + * + * @memberof commentReply */ init : function() { var row = $('#replyrow'); @@ -798,7 +800,7 @@ window.commentReply = { } }); - // add events + // Add events. $('#the-comment-list .column-comment > p').dblclick(function(){ commentReply.toggle($(this).parent()); }); @@ -911,7 +913,7 @@ window.commentReply = { .focus(); } - // reset the Quicktags buttons + // Reset the Quicktags buttons. if ( typeof QTags != 'undefined' ) QTags.closeAllTags('replycontent'); @@ -1029,7 +1031,7 @@ window.commentReply = { $('#replycontent').focus().keyup(function(e){ if ( e.which == 27 ) - commentReply.revert(); // close on Escape + commentReply.revert(); // Close on Escape. }); }, 600); @@ -1130,7 +1132,7 @@ window.commentReply = { updateCountText( 'span.all-count', 1 ); } - c = $.trim(r.data); // Trim leading whitespaces + c = $.trim(r.data); // Trim leading whitespaces. $(c).hide(); $('#replyrow').after(c); diff --git a/src/js/_enqueues/admin/inline-edit-post.js b/src/js/_enqueues/admin/inline-edit-post.js index 85cc742844..70a57e1200 100644 --- a/src/js/_enqueues/admin/inline-edit-post.js +++ b/src/js/_enqueues/admin/inline-edit-post.js @@ -29,41 +29,42 @@ window.wp = window.wp || {}; /** * 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 * editing. Adds event handler to bulk edit. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @return {void} */ init : function(){ var t = this, qeRow = $('#inline-edit'), bulkRow = $('#bulk-edit'); t.type = $('table.widefat').hasClass('pages') ? 'page' : 'post'; - // Post id prefix. + // Post ID prefix. 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. */ qeRow.keyup(function(e){ - // Revert changes if escape key is pressed. + // Revert changes if Escape key is pressed. if ( e.which === 27 ) { 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. */ bulkRow.keyup(function(e){ - // Revert changes if escape key is pressed. + // Revert changes if Escape key is pressed. if ( e.which === 27 ) { 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. */ @@ -157,9 +158,10 @@ window.wp = window.wp || {}; * Toggles the quick edit window, hiding it when it's active and showing it when * inactive. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @param {Object} el Element within a post table row. */ toggle : function(el){ @@ -170,8 +172,9 @@ window.wp = window.wp || {}; /** * Creates the bulk editor row to edit multiple posts at once. * - * @memberof inlineEditPost * @since 2.7.0 + * + * @memberof inlineEditPost */ setBulk : function(){ 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. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @param {number|Object} id The id of the clicked post or an element within a post * table row. * @return {boolean} Always returns false at the end of execution. @@ -409,7 +413,7 @@ window.wp = window.wp || {}; fields = $('#edit-'+id).find(':input').serialize(); params = fields + '&' + $.param(params); - // Make ajax request. + // Make Ajax request. $.post( ajaxurl, params, function(r) { 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. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @return {boolean} Always returns false. */ 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 * edit table. * - * @memberof inlineEditPost * @since 2.7.0 * + * @memberof inlineEditPost + * * @param {Object} o DOM row object to get the id for. * @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() { - // Set the heartbeat interval to 15 sec. + // Set the heartbeat interval to 15 seconds. if ( typeof wp !== 'undefined' && wp.heartbeat ) { wp.heartbeat.interval( 15 ); } diff --git a/src/js/_enqueues/admin/inline-edit-tax.js b/src/js/_enqueues/admin/inline-edit-tax.js index dcaa8d2bdc..5a3cad885c 100644 --- a/src/js/_enqueues/admin/inline-edit-tax.js +++ b/src/js/_enqueues/admin/inline-edit-tax.js @@ -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. */ row.keyup( function( e ) { - // 27 = [escape] + // 27 = [Escape]. if ( e.which === 27 ) { 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 ) { - // 13 = [enter] + // 13 = [Enter]. if ( e.which === 13 ) { return inlineEditTax.save( this ); } @@ -184,7 +184,7 @@ window.inlineEditTax = { fields = $('#edit-'+id).find(':input').serialize(); 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, /** * Handles the response from the server diff --git a/src/js/_enqueues/admin/link.js b/src/js/_enqueues/admin/link.js index 076d07c44f..02698e5eea 100644 --- a/src/js/_enqueues/admin/link.js +++ b/src/js/_enqueues/admin/link.js @@ -9,7 +9,7 @@ jQuery(document).ready( function($) { var newCat, noSyncChecks = false, syncChecks, catAddAfter; $('#link_name').focus(); - // postboxes + // Postboxes. postboxes.add_postbox_toggles('link'); /** @@ -33,7 +33,7 @@ jQuery(document).ready( function($) { if ( getUserSetting('cats') ) $('#category-tabs a[href="#categories-pop"]').click(); - // Ajax Cat + // Ajax Cat. newCat = $('#newcat').one( 'focus', function() { $(this).val( '' ).removeClass( 'form-input-tip' ); } ); /** diff --git a/src/js/_enqueues/admin/media-upload.js b/src/js/_enqueues/admin/media-upload.js index 3f45e2ef80..1a28f36d04 100644 --- a/src/js/_enqueues/admin/media-upload.js +++ b/src/js/_enqueues/admin/media-upload.js @@ -43,16 +43,16 @@ window.send_to_editor = function( html ) { editor = tinymce.get( wpActiveEditor ); } - // If the editor is set and not hidden, insert the HTML into the content of the - // editor. + // If the editor is set and not hidden, + // insert the HTML into the content of the editor. if ( editor && ! editor.isHidden() ) { editor.execCommand( 'mceInsertContent', false, html ); } else if ( hasQuicktags ) { // If quick tags are available, insert the HTML into its content. QTags.insertContent( html ); } else { - // If neither the TinyMCE editor and the quick tags are available, add the HTML - // to the current active editor. + // If neither the TinyMCE editor and the quick tags are available, + // add the HTML to the current active editor. document.getElementById( wpActiveEditor ).value += html; } diff --git a/src/js/_enqueues/admin/plugin-install.js b/src/js/_enqueues/admin/plugin-install.js index b6cd1d74e4..f9c2be395d 100644 --- a/src/js/_enqueues/admin/plugin-install.js +++ b/src/js/_enqueues/admin/plugin-install.js @@ -183,11 +183,12 @@ jQuery( document ).ready( function( $ ) { var tab = $( this ).attr( 'name' ); event.preventDefault(); - // Flip the tab + // Flip the tab. $( '#plugin-information-tabs a.current' ).removeClass( '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 ) { $( '#plugin-information-content' ).find( '.fyi' ).hide(); } else { diff --git a/src/js/_enqueues/admin/post.js b/src/js/_enqueues/admin/post.js index d2e956b4e4..cc7cab1a72 100644 --- a/src/js/_enqueues/admin/post.js +++ b/src/js/_enqueues/admin/post.js @@ -91,9 +91,9 @@ window.wp = window.wp || {}; /** * Load the next batch of comments. * - * @param {int} total Total number of comments to load. - * * @memberof commentsBox + * + * @param {int} total Total number of comments to load. */ load: function(total){ this.st = jQuery('#the-comment-list tr.comment:visible').length; @@ -309,24 +309,24 @@ jQuery(document).ready( function($) { // Post locks: contain focus inside the dialog. If the dialog is shown, focus the first item. $('#post-lock-dialog .notification-dialog').on( 'keydown', function(e) { - // Don't do anything when [tab] is pressed. + // Don't do anything when [Tab] is pressed. if ( e.which != 9 ) return; var target = $(e.target); - // [shift] + [tab] on first tab cycles back to last tab. + // [Shift] + [Tab] on first tab cycles back to last tab. if ( target.hasClass('wp-tab-first') && e.shiftKey ) { $(this).find('.wp-tab-last').focus(); e.preventDefault(); - // [tab] on last tab cycles back to first tab. + // [Tab] on last tab cycles back to first tab. } else if ( target.hasClass('wp-tab-last') && ! e.shiftKey ) { $(this).find('.wp-tab-first').focus(); e.preventDefault(); } }).filter(':visible').find('.wp-tab-first').focus(); - // Set the heartbeat interval to 15 sec. if post lock dialogs are enabled. + // Set the heartbeat interval to 15 seconds if post lock dialogs are enabled. if ( wp.heartbeat && $('#post-lock-dialog').length ) { wp.heartbeat.interval( 15 ); } @@ -385,7 +385,7 @@ jQuery(document).ready( function($) { }); }); - // Submit the form saving a draft or an autosave, and show a preview in a new tab + // Submit the form saving a draft or an autosave, and show a preview in a new tab. $('#post-preview').on( 'click.post-preview', function( event ) { var $this = $(this), $form = $('form#post'), @@ -534,7 +534,7 @@ jQuery(document).ready( function($) { }); }); - // Multiple Taxonomies. + // Multiple taxonomies. if ( $('#tagsdiv-post_tag').length ) { window.tagBox && window.tagBox.init(); } else { @@ -559,7 +559,7 @@ jQuery(document).ready( function($) { settingName = 'cats'; } - // TODO: move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js + // @todo Move to jQuery 1.3+, support for multiple hierarchical taxonomies, see wp-lists.js. $('a', '#' + taxonomy + '-tabs').click( function( e ) { e.preventDefault(); var t = $(this).attr('href'); @@ -581,7 +581,7 @@ jQuery(document).ready( function($) { $( this ).val( '' ).removeClass( 'form-input-tip' ); }); - // On [enter] submit the taxonomy. + // On [Enter] submit the taxonomy. $('#new' + taxonomy).keypress( function(event){ if( 13 === event.keyCode ) { event.preventDefault(); @@ -654,7 +654,7 @@ jQuery(document).ready( function($) { $('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c ); }); - }); // end cats + }); // End cats. // Custom Fields postbox. if ( $('#postcustom').length ) { @@ -796,7 +796,8 @@ jQuery(document).ready( function($) { // Update "Status:" to currently selected status. $('#post-status-display').text( - wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() ) // Remove any potential tags from post status text. + // Remove any potential tags from post status text. + wp.sanitize.stripTagsAndEncodeText( $('option:selected', postStatus).text() ) ); // Show or hide the "Save Draft" button. @@ -838,7 +839,7 @@ jQuery(document).ready( function($) { }); // Set the selected visibility as current. - $postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // crazyhorse - multiple ok cancels + $postVisibilitySelect.find('.save-post-visibility').click( function( event ) { // Crazyhorse - multiple OK cancels. $postVisibilitySelect.slideUp('fast'); $('#visibility .edit-visibility').show().focus(); updateText(); @@ -886,7 +887,7 @@ jQuery(document).ready( function($) { }); // Save the changed timestamp. - $timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels + $timestampdiv.find('.save-timestamp').click( function( event ) { // Crazyhorse - multiple OK cancels. if ( updateText() ) { $timestampdiv.slideUp('fast'); $timestampdiv.siblings('a.edit-timestamp').show().focus(); @@ -1023,12 +1024,12 @@ jQuery(document).ready( function($) { $el.html( '<input type="text" id="new-post-slug" value="' + slug_value + '" autocomplete="off" />' ).children( 'input' ).keydown( function( e ) { var key = e.which; - // On [enter], just save the new slug, don't save the post. + // On [Enter], just save the new slug, don't save the post. if ( 13 === key ) { e.preventDefault(); buttons.children( '.save' ).click(); } - // On [esc] cancel the editing. + // On [Esc] cancel the editing. if ( 27 === key ) { buttons.children( '.cancel' ).click(); } @@ -1173,7 +1174,7 @@ jQuery(document).ready( function($) { } }); - // When changing page template, change the editor body class + // When changing page template, change the editor body class. $( '#page_template' ).on( 'change.set-editor-class', function() { var editor, body, pageTemplate = $( this ).val() || ''; @@ -1191,9 +1192,9 @@ jQuery(document).ready( function($) { } - // Save on pressing [ctrl]/[command] + [s] in the Text editor. + // Save on pressing [Ctrl]/[Command] + [S] in the Text editor. $textarea.on( 'keydown.wp-autosave', function( event ) { - // Key [s] has code 83. + // Key [S] has code 83. if ( event.which === 83 ) { if ( event.shiftKey || event.altKey || ( isMac && ( ! event.metaKey || event.ctrlKey ) ) || ( ! isMac && ! event.ctrlKey ) ) { return; diff --git a/src/js/_enqueues/admin/postbox.js b/src/js/_enqueues/admin/postbox.js index 9789518b65..ff144777f9 100644 --- a/src/js/_enqueues/admin/postbox.js +++ b/src/js/_enqueues/admin/postbox.js @@ -32,7 +32,9 @@ * if the postbox has been closed. * * @since 4.4.0 + * * @memberof postboxes + * * @fires postboxes#postbox-toggled * * @return {void} @@ -90,6 +92,7 @@ * Adds event handlers to all postboxes and screen option on the current page. * * @since 2.7.0 + * * @memberof postboxes * * @param {string} page The page we are currently on. @@ -190,6 +193,7 @@ * Initializes all the postboxes, mainly their sortable behaviour. * * @since 2.7.0 + * * @memberof postboxes * * @param {string} page The page we are currently on. @@ -272,6 +276,7 @@ * hidden postboxes. * * @since 2.7.0 + * * @memberof postboxes * * @param {string} page The page we are currently on. @@ -303,6 +308,7 @@ * Sends a list of all postboxes inside a sortable area to the server. * * @since 2.8.0 + * * @memberof postboxes * * @param {string} page The page we are currently on. @@ -333,9 +339,10 @@ * present. * * @since 3.3.0 - * @memberof postboxes * @access private * + * @memberof postboxes + * * @return {void} */ _mark_area : function() { @@ -365,9 +372,11 @@ * Changes the amount of columns on the post edit page. * * @since 3.3.0 + * @access private + * * @memberof postboxes + * * @fires postboxes#postboxes-columnchange - * @access private * * @param {number} n The amount of columns to divide the post edit page in. * @return {void} @@ -395,9 +404,10 @@ * orientation of the browser. * * @since 3.3.0 - * @memberof postboxes * @access private * + * @memberof postboxes + * * @return {void} */ _pb_change : function() { @@ -425,19 +435,20 @@ /** * @since 2.7.0 - * @memberof postboxes * @access public + * * @property {Function|boolean} pbshow A callback that is called when a postbox * is opened. + * @memberof postboxes */ pbshow : false, /** * @since 2.7.0 - * @memberof postboxes * @access public * @property {Function|boolean} pbhide A callback that is called when a postbox * is closed. + * @memberof postboxes */ pbhide : false }; diff --git a/src/js/_enqueues/admin/privacy-tools.js b/src/js/_enqueues/admin/privacy-tools.js index 802ec88f4b..90b3a49233 100644 --- a/src/js/_enqueues/admin/privacy-tools.js +++ b/src/js/_enqueues/admin/privacy-tools.js @@ -4,7 +4,7 @@ * @output wp-admin/js/privacy-tools.js */ -// Privacy request action handling +// Privacy request action handling. jQuery( document ).ready( function( $ ) { var strings = window.privacyToolsL10n || {}; @@ -111,7 +111,7 @@ jQuery( document ).ready( function( $ ) { if ( ! response.success ) { - // e.g. invalid request ID + // e.g. invalid request ID. onExportFailure( response.data ); return; } @@ -127,12 +127,12 @@ jQuery( document ).ready( function( $ ) { } }).fail( function( jqxhr, textStatus, error ) { - // e.g. Nonce failure + // e.g. Nonce failure. onExportFailure( error ); }); } - // And now, let's begin + // And now, let's begin. setActionState( $action, 'export-personal-data-processing' ); doNextExport( 1, 1 ); }); @@ -224,7 +224,7 @@ jQuery( document ).ready( function( $ ) { }); } - // And now, let's begin + // And now, let's begin. setActionState( $action, 'remove-personal-data-processing' ); doNextErasure( 1, 1 ); diff --git a/src/js/_enqueues/admin/site-health.js b/src/js/_enqueues/admin/site-health.js index 015b06c5ec..b0f24c7121 100644 --- a/src/js/_enqueues/admin/site-health.js +++ b/src/js/_enqueues/admin/site-health.js @@ -259,9 +259,11 @@ jQuery( document ).ready( function( $ ) { RecalculateProgression(); if ( delay > 3000 ) { - // We have announced that we're waiting. - // Announce that we're ready after giving at least 3 seconds for the first announcement - // to be read out, or the two may collide. + /* + * We have announced that we're waiting. + * Announce that we're ready after giving at least 3 seconds + * for the first announcement to be read out, or the two may collide. + */ if ( delay > 6000 ) { delay = 0; } else { diff --git a/src/js/_enqueues/admin/tags-box.js b/src/js/_enqueues/admin/tags-box.js index c4676f263e..40105e2d38 100644 --- a/src/js/_enqueues/admin/tags-box.js +++ b/src/js/_enqueues/admin/tags-box.js @@ -52,6 +52,7 @@ * Cleans up tags by removing redundant characters. * * @since 2.9.0 + * * @memberOf tagBox * * @param {string} tags Comma separated tags that need to be cleaned up. @@ -76,6 +77,7 @@ * Parses tags and makes them editable. * * @since 2.9.0 + * * @memberOf tagBox * * @param {Object} el The tag element to retrieve the ID from. @@ -110,6 +112,7 @@ * Creates clickable links, buttons and fields for adding or editing tags. * * @since 2.9.0 + * * @memberOf tagBox * * @param {Object} el The container HTML element. @@ -134,6 +137,7 @@ * Creates a delete button if tag editing is enabled, before adding it to the tag list. * * @since 2.5.0 + * * @memberOf tagBox * * @param {string} key The index of the current tag. @@ -209,6 +213,7 @@ * Also ensures that the quick links are properly generated. * * @since 2.9.0 + * * @memberOf tagBox * * @param {Object} el The container HTML element. @@ -262,6 +267,7 @@ * tagcloud. Clicking a tag will add it. * * @since 2.9.0 + * * @memberOf tagBox * * @param {string} id The ID to extract the taxonomy from. @@ -350,6 +356,7 @@ * retrieval of tag suggestions. * * @since 2.9.0 + * * @memberOf tagBox * * @return {void} diff --git a/src/js/_enqueues/admin/tags-suggest.js b/src/js/_enqueues/admin/tags-suggest.js index 50075a654b..c5ccf16eaf 100644 --- a/src/js/_enqueues/admin/tags-suggest.js +++ b/src/js/_enqueues/admin/tags-suggest.js @@ -89,8 +89,8 @@ focus: function( event, ui ) { $element.attr( 'aria-activedescendant', 'wp-tags-autocomplete-' + ui.item.id ); - // Don't empty the input field when using the arrow keys to - // highlight items. See api.jqueryui.com/autocomplete/#event-focus + // Don't empty the input field when using the arrow keys + // to highlight items. See api.jqueryui.com/autocomplete/#event-focus event.preventDefault(); }, select: function( event, ui ) { @@ -113,7 +113,7 @@ window.tagBox.flushTags( $( this ).closest( '.tagsdiv' ) ); } - // Do not close Quick Edit / Bulk Edit + // Do not close Quick Edit / Bulk Edit. event.preventDefault(); event.stopPropagation(); } @@ -175,14 +175,16 @@ .attr( 'role', 'listbox' ) .removeAttr( 'tabindex' ) // Remove the `tabindex=0` attribute added by jQuery UI. - // Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301. - // The `menufocus` and `menublur` events are the same events used to add and remove - // the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget. + /* + * Looks like Safari and VoiceOver need an `aria-selected` attribute. See ticket #33301. + * The `menufocus` and `menublur` events are the same events used to add and remove + * the `ui-state-focus` CSS class on the menu items. See jQuery UI Menu Widget. + */ .on( 'menufocus', function( event, ui ) { ui.item.attr( 'aria-selected', 'true' ); }) .on( 'menublur', function() { - // The `menublur` event returns an object where the item is `null` + // The `menublur` event returns an object where the item is `null`, // so we need to find the active item with other means. $( this ).find( '[aria-selected="true"]' ).removeAttr( 'aria-selected' ); }); diff --git a/src/js/_enqueues/admin/tags.js b/src/js/_enqueues/admin/tags.js index df5b3f7e5d..d87b98174b 100644 --- a/src/js/_enqueues/admin/tags.js +++ b/src/js/_enqueues/admin/tags.js @@ -132,10 +132,14 @@ jQuery(document).ready(function($) { parent = form.find( 'select#parent' ).val(); - if ( parent > 0 && $('#tag-' + parent ).length > 0 ) // If the parent exists on this page, insert it below. Else insert it at the top of the list. - $( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents ); // As the parent exists, Insert the version with - - - prefixed - else - $( '.tags' ).prepend( res.responses[0].supplemental.parents ); // As the parent is not visible, Insert the version with Parent - Child - ThisTerm + // If the parent exists on this page, insert it below. Else insert it at the top of the list. + if ( parent > 0 && $('#tag-' + parent ).length > 0 ) { + // As the parent exists, insert the version with - - - prefixed. + $( '.tags #tag-' + parent ).after( res.responses[0].supplemental.noparents ); + } else { + // As the parent is not visible, insert the version with Parent - Child - ThisTerm. + $( '.tags' ).prepend( res.responses[0].supplemental.parents ); + } $('.tags .no-items').remove(); @@ -143,7 +147,7 @@ jQuery(document).ready(function($) { // Parents field exists, Add new term to the list. term = res.responses[1].supplemental; - // Create an indent for the Parent field + // Create an indent for the Parent field. indent = ''; for ( i = 0; i < res.responses[1].position; i++ ) indent += ' '; diff --git a/src/js/_enqueues/admin/user-profile.js b/src/js/_enqueues/admin/user-profile.js index f737dde255..ff4830242c 100644 --- a/src/js/_enqueues/admin/user-profile.js +++ b/src/js/_enqueues/admin/user-profile.js @@ -196,7 +196,7 @@ resetToggle( false ); if ( $pass1Row.closest( 'form' ).is( '#your-profile' ) ) { - // Clear password field to prevent update + // Clear password field to prevent update. $pass1.val( '' ).trigger( 'pwupdate' ); $submitButtons.prop( 'disabled', false ); } @@ -342,7 +342,7 @@ $this.siblings( '.selected' ).removeClass( 'selected' ); $this.addClass( 'selected' ).find( 'input[type="radio"]' ).prop( 'checked', true ); - // Set color scheme + // Set color scheme. if ( user_id === current_user_id ) { // Load the colors stylesheet. // The default color scheme won't have one, so we'll need to create an element. @@ -351,7 +351,7 @@ } $stylesheet.attr( 'href', $this.children( '.css_url' ).val() ); - // repaint icons + // Repaint icons. if ( typeof wp !== 'undefined' && wp.svgPainter ) { try { colors = $.parseJSON( $this.children( '.icon_colors' ).val() ); @@ -363,7 +363,7 @@ } } - // update user option + // Update user option. $.post( ajaxurl, { action: 'save-user-color-scheme', color_scheme: $this.children( 'input[name="admin_color"]' ).val(), diff --git a/src/js/_enqueues/admin/widgets.js b/src/js/_enqueues/admin/widgets.js index 00ae62dbae..3d72db74e2 100644 --- a/src/js/_enqueues/admin/widgets.js +++ b/src/js/_enqueues/admin/widgets.js @@ -222,9 +222,9 @@ window.wpWidgets = { the_id = this.id; if ( chooser.length ) { - // Hide the chooser and move it out of the widget + // Hide the chooser and move it out of the widget. $( '#wpbody-content' ).append( chooser.hide() ); - // Delete the cloned chooser from the drag helper + // Delete the cloned chooser from the drag helper. ui.helper.find('.widgets-chooser').remove(); self.clearWidgetSelection(); } @@ -321,7 +321,7 @@ window.wpWidgets = { wpWidgets.hoveredSidebar = null; if ( $widget.hasClass('deleting') ) { - wpWidgets.save( $widget, 1, 0, 1 ); // delete widget + wpWidgets.save( $widget, 1, 0, 1 ); // Delete widget. $widget.remove(); return; } @@ -363,7 +363,7 @@ window.wpWidgets = { $children = $sidebar.children('.widget'); - // Make sure the dropped widget is at the top + // Make sure the dropped widget is at the top. if ( $children.length > 1 ) { child = $children.get(0); item = $widget.get(0); @@ -386,14 +386,14 @@ window.wpWidgets = { }, deactivate: function() { - // Remove all min-height added on "start" + // Remove all min-height added on "start". $(this).css( 'min-height', '' ).parent().removeClass( 'widget-hover' ); }, receive: function( event, ui ) { var $sender = $( ui.sender ); - // Don't add more widgets to orphaned sidebars + // Don't add more widgets to orphaned sidebars. if ( this.id.indexOf('orphaned_widgets') > -1 ) { $sender.sortable('cancel'); return; @@ -431,7 +431,7 @@ window.wpWidgets = { } }); - // Area Chooser + // Area Chooser. $( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) { var $element = $( element ), name = $element.find( '.sidebar-name h2' ).text(), @@ -465,7 +465,7 @@ window.wpWidgets = { toggleButton.attr( 'aria-expanded', 'false' ); self.closeChooser(); } else { - // Open the chooser + // Open the chooser. self.clearWidgetSelection(); $( '#widgets-left' ).addClass( 'chooser' ); // Add CSS class and insert the chooser after the widget description. @@ -486,7 +486,7 @@ window.wpWidgets = { } }); - // Add event handlers + // Add event handlers. chooser.on( 'click.widgets-chooser', function( event ) { var $target = $( event.target ); @@ -662,7 +662,7 @@ window.wpWidgets = { add = widget.find( 'input.add_new' ).val(); n = widget.find( 'input.multi_number' ).val(); - // Remove the cloned chooser from the widget + // Remove the cloned chooser from the widget. widget.find('.widgets-chooser').remove(); if ( 'multi' === add ) { @@ -689,7 +689,7 @@ window.wpWidgets = { sidebar.sortable('refresh'); wpWidgets.save( widget, 0, 0, 1 ); - // No longer "new" widget + // No longer "new" widget. widget.find( 'input.add_new' ).val(''); $document.trigger( 'widget-added', [ widget ] ); diff --git a/src/js/_enqueues/lib/accordion.js b/src/js/_enqueues/lib/accordion.js index 0bec1ce514..7eacbec966 100644 --- a/src/js/_enqueues/lib/accordion.js +++ b/src/js/_enqueues/lib/accordion.js @@ -35,11 +35,11 @@ // Expand/Collapse accordion sections on click. $( '.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; } - e.preventDefault(); // Keep this AFTER the key filter above + e.preventDefault(); // Keep this AFTER the key filter above. accordionSwitch( $( this ) ); }); @@ -80,7 +80,7 @@ section.toggleClass( 'open' ); } - // We have to wait for the animations to finish + // We have to wait for the animations to finish. setTimeout(function(){ container.removeClass( 'opening' ); }, 150); diff --git a/src/js/_enqueues/lib/admin-bar.js b/src/js/_enqueues/lib/admin-bar.js index 3e4292f36a..537df2d98f 100644 --- a/src/js/_enqueues/lib/admin-bar.js +++ b/src/js/_enqueues/lib/admin-bar.js @@ -264,7 +264,7 @@ return; } - // (Old) IE doesn't support preventDefault, and does support returnValue + // (Old) IE doesn't support preventDefault, and does support returnValue. if ( event.preventDefault ) { event.preventDefault(); } @@ -451,7 +451,7 @@ }; } - // Get the closest matching elent + // Get the closest matching elent. for ( ; el && el !== document; el = el.parentNode ) { if ( el.matches( selector ) ) { return el; diff --git a/src/js/_enqueues/lib/ajax-response.js b/src/js/_enqueues/lib/ajax-response.js index fd71ff3702..f2eedf3732 100644 --- a/src/js/_enqueues/lib/ajax-response.js +++ b/src/js/_enqueues/lib/ajax-response.js @@ -17,7 +17,7 @@ window.wpAjax = jQuery.extend( { } return r; }, - parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission + parseAjaxResponse: function( x, r, e ) { // 1 = good, 0 = strange (bad data?), -1 = you lack permission. var parsed = {}, re = jQuery('#' + r).empty(), err = ''; if ( x && typeof x == 'object' && x.getElementsByTagName('wp_ajax') ) { @@ -64,7 +64,7 @@ window.wpAjax = jQuery.extend( { } }, wpAjax || { noPerm: 'Sorry, you are not allowed to do that.', broken: 'Something went wrong.' } ); -// Basic form validation +// Basic form validation. jQuery(document).ready( function($){ $('form.validate').submit( function() { return wpAjax.validateForm( $(this) ); } ); }); diff --git a/src/js/_enqueues/lib/auth-check.js b/src/js/_enqueues/lib/auth-check.js index 158b6e1750..ef6d861de0 100644 --- a/src/js/_enqueues/lib/auth-check.js +++ b/src/js/_enqueues/lib/auth-check.js @@ -51,8 +51,8 @@ else parent.css( 'max-height', height + 40 + 'px' ); } else if ( ! body || ! body.length ) { - // Catch "silent" iframe origin exceptions in WebKit after another page is - // loaded in the iframe. + // Catch "silent" iframe origin exceptions in WebKit + // after another page is loaded in the iframe. wrap.addClass('fallback'); parent.css( 'max-height', '' ); form.remove(); @@ -68,9 +68,11 @@ if ( frame ) { frame.focus(); - // WebKit doesn't throw an error if the iframe fails to load because of - // "X-Frame-Options: DENY" header. - // Wait for 10 sec. and switch to the fallback text. + /* + * WebKit doesn't throw an error if the iframe fails to load + * because of "X-Frame-Options: DENY" header. + * Wait for 10 seconds and switch to the fallback text. + */ setTimeout( function() { if ( ! loaded ) { wrap.addClass('fallback'); @@ -92,8 +94,8 @@ function hide() { $(window).off( 'beforeunload.wp-auth-check' ); - // When on the Edit Post screen, speed up heartbeat after the user logs in to - // quickly refresh nonces. + // When on the Edit Post screen, speed up heartbeat + // after the user logs in to quickly refresh nonces. if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) && typeof wp !== 'undefined' && wp.heartbeat ) { diff --git a/src/js/_enqueues/lib/color-picker.js b/src/js/_enqueues/lib/color-picker.js index 0a99ae00cc..18f2bc26dc 100644 --- a/src/js/_enqueues/lib/color-picker.js +++ b/src/js/_enqueues/lib/color-picker.js @@ -36,7 +36,6 @@ * Creates a color picker that only allows you to adjust the hue. * * @since 3.5.0 - * * @access private * * @return {void} @@ -80,7 +79,6 @@ * Creates the color picker, sets default values, css classes and wraps it all in HTML. * * @since 3.5.0 - * * @access private * * @return {void} @@ -209,7 +207,6 @@ * Binds event listeners to the color picker. * * @since 3.5.0 - * * @access private * * @return {void} diff --git a/src/js/_enqueues/lib/comment-reply.js b/src/js/_enqueues/lib/comment-reply.js index ea973f41e8..1ba9498f11 100644 --- a/src/js/_enqueues/lib/comment-reply.js +++ b/src/js/_enqueues/lib/comment-reply.js @@ -95,7 +95,7 @@ window.addComment = ( function( window ) { cancelElement.addEventListener( 'touchstart', cancelEvent ); cancelElement.addEventListener( 'click', cancelEvent ); - // Submit the comment form when the user types CTRL or CMD + 'Enter'. + // Submit the comment form when the user types [Ctrl] or [Cmd] + [Enter]. var submitFormHandler = function( e ) { if ( ( e.metaKey || e.ctrlKey ) && e.keyCode === 13 ) { commentFormElement.removeEventListener( 'keydown', submitFormHandler ); diff --git a/src/js/_enqueues/lib/cookies.js b/src/js/_enqueues/lib/cookies.js index ac74bdb3a8..66d920affa 100644 --- a/src/js/_enqueues/lib/cookies.js +++ b/src/js/_enqueues/lib/cookies.js @@ -115,7 +115,7 @@ window.wpCookies = { if ( typeof( expires ) === 'object' && expires.toGMTString ) { expires = expires.toGMTString(); } else if ( parseInt( expires, 10 ) ) { - d.setTime( d.getTime() + ( parseInt( expires, 10 ) * 1000 ) ); // time must be in milliseconds + d.setTime( d.getTime() + ( parseInt( expires, 10 ) * 1000 ) ); // Time must be in milliseconds. expires = d.toGMTString(); } else { expires = ''; @@ -153,9 +153,11 @@ window.getUserSetting = function( name, def ) { return ''; }; -// Both name and value must be only ASCII letters, numbers or underscore -// and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text. -// The value is converted and stored as string. +/* + * Both name and value must be only ASCII letters, numbers or underscore + * and the shorter, the better (cookies can store maximum 4KB). Not suitable to store text. + * The value is converted and stored as string. + */ window.setUserSetting = function( name, value, _del ) { if ( 'object' !== typeof userSettings ) { return false; @@ -192,7 +194,7 @@ window.deleteUserSetting = function( name ) { return setUserSetting( name, '', 1 ); }; -// Returns all settings as js object. +// Returns all settings as JS object. window.getAllUserSettings = function() { if ( 'object' !== typeof userSettings ) { return {}; diff --git a/src/js/_enqueues/lib/gallery.js b/src/js/_enqueues/lib/gallery.js index 36cb08636b..dda3e33408 100644 --- a/src/js/_enqueues/lib/gallery.js +++ b/src/js/_enqueues/lib/gallery.js @@ -15,7 +15,7 @@ jQuery(document).ready(function($) { distance: 2, handle: 'div.filename', 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; $.each(all, function(i, id) { var order = desc ? (len - i) : (1 + i); @@ -71,7 +71,7 @@ jQuery(document).ready(function($) { $('img.pinkynail').toggle(true); }); - // initialize sortable + // Initialize sortable. gallerySortableInit(); 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 */ window.tinymce = null; @@ -122,7 +122,7 @@ window.wpgallery = { document.domain = q.mce_rdomain; } - // Find window & API + // Find window & API. window.tinymce = w.tinymce; window.tinyMCE = w.tinyMCE; t.editor = tinymce.EditorManager.activeEditor; diff --git a/src/js/_enqueues/lib/image-edit.js b/src/js/_enqueues/lib/image-edit.js index 756d2e4da1..d2b0139bc1 100644 --- a/src/js/_enqueues/lib/image-edit.js +++ b/src/js/_enqueues/lib/image-edit.js @@ -48,8 +48,9 @@ /** * Converts a value to an integer. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @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. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {jQuery} el The element that should be modified. * @param {bool|number} s The state for the element. If set to true @@ -95,8 +97,9 @@ /** * Initializes the image editor. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -121,12 +124,12 @@ $('input[type="text"]', '#imgedit-panel-' + postid).keypress(function(e) { 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 ) { $(this).blur(); } - // The key code 13 is the enter key. + // The key code 13 is the Enter key. if ( 13 === k ) { e.preventDefault(); e.stopPropagation(); @@ -138,8 +141,9 @@ /** * Toggles the wait/load icon in the editor. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @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. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @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 * have to be applied to. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -198,8 +204,9 @@ * * If the original image size is exceeded a red exclamation mark is shown. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The current post id. * @param {number} x Is 0 when it applies the y-axis @@ -234,8 +241,9 @@ /** * Gets the selected aspect ratio. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -261,8 +269,9 @@ * Removes the last action from the image edit history. * The history consist of (edit) actions performed on the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {number} setSize 0 or 1, when 1 the image resets to its original size. @@ -295,13 +304,13 @@ // Restore original 'o'. 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; if ( o ) { - // fw = Full image width + // fw = Full image width. this.hold.w = o.fw; - // fh = Full image height + // fh = Full image height. this.hold.h = o.fh; } } @@ -326,8 +335,9 @@ * * When the image source is reloaded the image will be reloaded. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce to verify the request. @@ -371,7 +381,7 @@ 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 ); max2 = Math.max( $(img).width(), $(img).height() ); t.hold.sizer = max1 > max2 ? max2 / max1 : 1; @@ -399,8 +409,9 @@ /** * Performs an image edit action. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce to verify the request. @@ -456,7 +467,7 @@ $.post(ajaxurl, data, function(r) { $('#image-editor-' + postid).empty().append(r); t.toggleEditor(postid, 0); - // refresh the attachment model so that changes propagate + // Refresh the attachment model so that changes propagate. if ( t._view ) { t._view.refresh(); } @@ -466,8 +477,9 @@ /** * Stores the changes that are made to the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id to get the image from the database. * @param {string} nonce The nonce to verify the request. @@ -531,8 +543,9 @@ /** * Creates the image edit window. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id for the image. * @param {string} nonce The nonce to verify the request. @@ -588,8 +601,9 @@ /** * Initializes the cropping tool and sets a default cropping selection. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -614,8 +628,9 @@ /** * Initializes the cropping tool. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {HTMLElement} image The preview image. @@ -645,8 +660,8 @@ * @param {jQuery} img The preview image. */ onInit: function( img ) { - // Ensure that the imgAreaSelect wrapper elements are position:absolute. - // (even if we're in a position:fixed modal) + // Ensure that the imgAreaSelect wrapper elements are position:absolute + // (even if we're in a position:fixed modal). $img = $( img ); $img.next().css( 'position', 'absolute' ) .nextAll( '.imgareaselect-outer' ).css( 'position', 'absolute' ); @@ -715,8 +730,9 @@ /** * Stores the current crop selection. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {object} c The selection. @@ -746,8 +762,9 @@ /** * Closes the image editor. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {bool} warn Warning message. @@ -764,13 +781,14 @@ this.iasapi = {}; this.hold = {}; - // If we've loaded the editor in the context of a Media Modal, then switch to the previous view, - // whatever that might have been. + // If we've loaded the editor in the context of a Media Modal, + // then switch to the previous view, whatever that might have been. if ( this._view ){ 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 { $('#image-editor-' + postid).fadeOut('fast', function() { $( '#media-head-' + postid ).fadeIn( 'fast', function() { @@ -787,8 +805,9 @@ /** * Checks if the image edit history is saved. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @@ -811,8 +830,9 @@ /** * Adds an image edit action to the history. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {object} op The original position. * @param {number} postid The post id. @@ -830,7 +850,7 @@ history.pop(); pop--; } - undone.val(0); // reset + undone.val(0); // Reset. history.push(op); elem.val( JSON.stringify(history) ); @@ -844,8 +864,9 @@ /** * Rotates the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {string} angle The angle the image is rotated with. * @param {number} postid The post id. @@ -865,8 +886,9 @@ /** * Flips the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} axis The axle the image is flipped on. * @param {number} postid The post id. @@ -886,8 +908,9 @@ /** * Crops the image. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce. @@ -915,8 +938,9 @@ /** * Undoes an image edit action. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce. @@ -948,8 +972,9 @@ /** * Reverts a undo action. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {string} nonce The nonce. @@ -978,8 +1003,9 @@ /** * Sets the selection for the height and width in pixels. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {jQuery} el The element containing the values. @@ -1035,8 +1061,9 @@ /** * Rounds a number to a whole. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} num The number. * @@ -1064,8 +1091,9 @@ /** * Sets a locked aspect ratio for the selection. * + * @since 2.9.0 + * * @memberof imageEdit - * @since 2.9.0 * * @param {number} postid The post id. * @param {number} n The ratio to set. @@ -1108,8 +1136,9 @@ /** * Validates if a value in a jQuery.HTMLElement is numeric. * + * @since 4.6.0 + * * @memberof imageEdit - * @since 4.6 * * @param {jQuery} el The html element. * diff --git a/src/js/_enqueues/lib/link.js b/src/js/_enqueues/lib/link.js index 954d211131..1dfc1204e1 100644 --- a/src/js/_enqueues/lib/link.js +++ b/src/js/_enqueues/lib/link.js @@ -36,24 +36,24 @@ inputs.submit = $( '#wp-link-submit' ); inputs.close = $( '#wp-link-close' ); - // Input + // Input. inputs.text = $( '#wp-link-text' ); inputs.url = $( '#wp-link-url' ); inputs.nonce = $( '#_ajax_linking_nonce' ); inputs.openInNewTab = $( '#wp-link-target' ); inputs.search = $( '#wp-link-search' ); - // Build Rivers + // Build rivers. rivers.search = new River( $( '#search-results' ) ); rivers.recent = new River( $( '#most-recent-results' ) ); rivers.elements = inputs.dialog.find( '.query-results' ); - // Get search notice text + // Get search notice text. inputs.queryNotice = $( '#query-notice-message' ); inputs.queryNoticeTextDefault = inputs.queryNotice.find( '.query-notice-default' ); inputs.queryNoticeTextHint = inputs.queryNotice.find( '.query-notice-hint' ); - // Bind event handlers + // Bind event handlers. inputs.dialog.keydown( wpLink.keydown ); inputs.dialog.keyup( wpLink.keyup ); inputs.submit.click( function( event ) { @@ -68,7 +68,7 @@ rivers.elements.on( 'river-select', wpLink.updateFields ); - // Display 'hint' message when search field or 'query-results' box are focused + // Display 'hint' message when search field or 'query-results' box are focused. inputs.search.on( 'focus.wplink', function() { inputs.queryNoticeTextDefault.hide(); inputs.queryNoticeTextHint.removeClass( 'screen-reader-text' ).show(); @@ -91,7 +91,7 @@ inputs.url.on( 'blur', wpLink.correctURL ); }, - // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http:// + // If URL wasn't corrected last time and doesn't start with http:, https:, ? # or /, prepend http://. correctURL: function () { var url = $.trim( inputs.url.val() ); @@ -154,24 +154,24 @@ refresh: function( url, text ) { var linkText = ''; - // Refresh rivers (clear links, check visibility) + // Refresh rivers (clear links, check visibility). rivers.search.refresh(); rivers.recent.refresh(); if ( wpLink.isMCE() ) { wpLink.mceRefresh( url, text ); } else { - // For the Text editor the "Link text" field is always shown + // For the Text editor the "Link text" field is always shown. if ( ! inputs.wrap.hasClass( 'has-text-field' ) ) { inputs.wrap.addClass( 'has-text-field' ); } if ( document.selection ) { - // Old IE + // Old IE. linkText = document.selection.createRange().text || text || ''; } else if ( typeof this.textarea.selectionStart !== 'undefined' && ( this.textarea.selectionStart !== this.textarea.selectionEnd ) ) { - // W3C + // W3C. text = this.textarea.value.substring( this.textarea.selectionStart, this.textarea.selectionEnd ) || text || ''; } @@ -180,12 +180,14 @@ } if ( isTouch ) { - // Close the onscreen keyboard + // Close the onscreen keyboard. inputs.url.focus().blur(); } else { - // Focus the URL field and highlight its contents. - // If this is moved above the selection changes, - // IE will show a flashing cursor over the dialog. + /* + * Focus the URL field and highlight its contents. + * If this is moved above the selection changes, + * IE will show a flashing cursor over the dialog. + */ window.setTimeout( function() { inputs.url[0].select(); inputs.url.focus(); @@ -203,7 +205,7 @@ hasSelectedText: function( linkNode ) { var node, nodes, i, html = editor.selection.getContent(); - // Partial html and not a fully selected anchor element + // Partial html and not a fully selected anchor element. if ( /</.test( html ) && ( ! /^<a [^>]+>[^<]+<\/a>$/.test( html ) || html.indexOf('href=') === -1 ) ) { return false; } @@ -259,7 +261,7 @@ inputs.search.val( '' ); } - // Always reset the search + // Always reset the search. window.setTimeout( function() { wpLink.searchInternalLinks(); } ); @@ -358,11 +360,11 @@ html = wpLink.buildHtml(attrs); - // Insert HTML + // Insert HTML. if ( document.selection && wpLink.range ) { - // IE + // IE. // Note: If no text is selected, IE will not place the cursor - // inside the closing tag. + // inside the closing tag. textarea.focus(); wpLink.range.text = html + ( text || wpLink.range.text ) + '</a>'; wpLink.range.moveToBookmark( wpLink.range.getBookmark() ); @@ -370,7 +372,7 @@ wpLink.range = null; } else if ( typeof textarea.selectionStart !== 'undefined' ) { - // W3C + // W3C. begin = textarea.selectionStart; end = textarea.selectionEnd; selection = text || textarea.value.substring( begin, end ); @@ -388,7 +390,7 @@ textarea.value.substring( end, textarea.value.length ) ); - // Update cursor position + // Update cursor position. textarea.selectionStart = textarea.selectionEnd = cursor; } @@ -484,10 +486,10 @@ selection = $.trim( selection ); if ( selection && emailRegexp.test( selection ) ) { - // Selection is email address + // Selection is email address. return 'mailto:' + selection; } else if ( selection && urlRegexp.test( selection ) ) { - // Selection is URL + // Selection is URL. return selection.replace( /&|�?38;/gi, '&' ); } @@ -553,7 +555,7 @@ id = event.target.id; // wp-link-submit must always be the last focusable element in the dialog. - // following focusable elements will be skipped on keyboard navigation. + // Following focusable elements will be skipped on keyboard navigation. if ( id === 'wp-link-submit' && ! event.shiftKey ) { inputs.close.focus(); event.preventDefault(); @@ -656,18 +658,18 @@ this.deselect(); this.selected = li.addClass( 'selected' ); - // Make sure the element is visible + // Make sure the element is visible. liHeight = li.outerHeight(); elHeight = this.element.height(); liTop = li.position().top; elTop = this.element.scrollTop(); - if ( liTop < 0 ) // Make first visible element + if ( liTop < 0 ) // Make first visible element. this.element.scrollTop( elTop + liTop ); - else if ( liTop + liHeight > elHeight ) // Make last visible element + else if ( liTop + liHeight > elHeight ) // Make last visible element. this.element.scrollTop( elTop + liTop - elHeight + liHeight ); - // Trigger the river-select event + // Trigger the river-select event. this.element.trigger( 'river-select', [ li, event, this ] ); }, deselect: function() { diff --git a/src/js/_enqueues/lib/nav-menu.js b/src/js/_enqueues/lib/nav-menu.js index 95b66c1a42..3a0bd642ef 100644 --- a/src/js/_enqueues/lib/nav-menu.js +++ b/src/js/_enqueues/lib/nav-menu.js @@ -69,7 +69,7 @@ }, jQueryExtensions : function() { - // jQuery extensions + // jQuery extensions. $.fn.extend({ menuItemDepth : function() { var margin = api.isRTL ? this.eq(0).css('margin-right') : this.eq(0).css('margin-left'); @@ -114,7 +114,7 @@ depth = t.menuItemDepth(), newDepth = depth + dir; - // Change .menu-item-depth-n class + // Change .menu-item-depth-n class. t.moveHorizontally( newDepth, depth ); }); }, @@ -125,10 +125,10 @@ diff = newDepth - depth, subItemText = t.find('.is-submenu'); - // Change .menu-item-depth-n class + // Change .menu-item-depth-n class. t.updateDepthClass( newDepth, depth ).updateParentMenuItemDBId(); - // If it has children, move those too + // If it has children, move those too. if ( children ) { children.each(function() { var t = $(this), @@ -138,7 +138,7 @@ }); } - // Show "Sub item" helper text + // Show "Sub item" helper text. if (0 === newDepth) subItemText.hide(); else @@ -153,7 +153,7 @@ parentDepth = depth - 1, 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); } else { // Find the parent item, and retrieve its object id. input.val( parent.find( '.menu-item-data-db-id' ).val() ); @@ -191,10 +191,10 @@ if ( !checkboxes.length ) return false; - // Show the ajax spinner + // Show the Ajax spinner. t.find( '.button-controls .spinner' ).addClass( 'is-active' ); - // Retrieve menu item data + // Retrieve menu item data. $(checkboxes).each(function(){ var t = $(this), listItemDBIDMatch = re.exec( t.attr('name') ), @@ -205,9 +205,9 @@ menuItems[listItemDBID] = t.closest('li').getItemData( 'add-menu-item', listItemDBID ); }); - // Add the items + // Add the items. 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 ); t.find( '.button-controls .select-all' ).prop( 'checked', false ); t.find( '.button-controls .spinner' ).removeClass( 'is-active' ); @@ -312,22 +312,22 @@ case 'up': newItemPosition = thisItemPosition - 1; - // Already at top + // Already at top. if ( 0 === thisItemPosition ) 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 ) 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 ) thisItem.moveHorizontally( prevItemDepth, thisItemDepth ); // Does this item have sub items? if ( thisItemChildren ) { items = thisItem.add( thisItemChildren ); - // Move the entire block + // Move the entire block. items.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId(); } else { thisItem.detach().insertBefore( menuItems.eq( newItemPosition ) ).updateParentMenuItemDBId(); @@ -351,40 +351,40 @@ items.detach().insertAfter( menuItems.eq( thisItemPosition + items.length ) ).updateParentMenuItemDBId(); } else { - // If next item has sub items, shift depth + // If next item has sub items, shift depth. if ( 0 !== nextItemChildren.length ) thisItem.moveHorizontally( nextItemDepth, thisItemDepth ); - // Have we reached the bottom + // Have we reached the bottom? if ( menuItemsCount === thisItemPosition + 1 ) break; thisItem.detach().insertAfter( menuItems.eq( thisItemPosition + 1 ) ).updateParentMenuItemDBId(); } break; case 'top': - // Already at top + // Already at top. if ( 0 === thisItemPosition ) break; // Does this item have sub items? if ( thisItemChildren ) { items = thisItem.add( thisItemChildren ); - // Move the entire block + // Move the entire block. items.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId(); } else { thisItem.detach().insertBefore( menuItems.eq( 0 ) ).updateParentMenuItemDBId(); } break; case 'left': - // As far left as possible + // As far left as possible. if ( 0 === thisItemDepth ) break; thisItem.shiftHorizontally( -1 ); break; case 'right': - // Can't be sub item at top + // Can't be sub item at top. if ( 0 === thisItemPosition ) break; - // Already sub item of prevItem + // Already sub item of prevItem. if ( thisItemData['menu-item-parent-id'] === prevItemId ) break; thisItem.shiftHorizontally( 1 ); @@ -402,7 +402,7 @@ api.refreshKeyboardAccessibility(); 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(){ api.refreshAdvancedAccessibilityOfItem( $( this ).find( 'a.item-edit' ) ); } ); @@ -412,7 +412,7 @@ api.refreshAdvancedAccessibilityOfItem( $( this ) ); } ); - // Links for moving items + // Links for moving items. menu.on( 'click', '.menus-move', function () { var $this = $( this ), dir = $this.data( 'dir' ); @@ -433,7 +433,7 @@ */ refreshAdvancedAccessibilityOfItem : function( itemToRefresh ) { - // Only refresh accessibility when necessary + // Only refresh accessibility when necessary. if ( true !== $( itemToRefresh ).data( 'needs_accessibility_refresh' ) ) { return; } @@ -494,7 +494,7 @@ itemPosition = primaryItems.index( menuItem ) + 1, 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 ); } else { 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 + '"]' ), 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 ); } $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 ); }, @@ -523,10 +523,10 @@ // Hide all the move buttons by default. $( '.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 ); - // 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() { api.refreshAdvancedAccessibilityOfItem( this ); } ); @@ -541,18 +541,18 @@ thisItem = $this.parents( 'li.menu-item' ), 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 ) return; - // Avoid multiple keydown events + // Avoid multiple keydown events. $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 ) return; - // If RTL, swap left/right arrows + // If RTL, swap left/right arrows. arrows = { '38': 'up', '40': 'down', '37': 'left', '39': 'right' }; if ( $('body').hasClass('rtl') ) arrows = { '38' : 'up', '40' : 'down', '39' : 'left', '37' : 'right' }; @@ -571,7 +571,7 @@ api.moveMenuItem( $this, 'right' ); break; } - // Put focus back on same menu item + // Put focus back on same menu item. $( '#edit-' + thisItemData['menu-item-db-id'] ).focus(); return false; }); @@ -594,10 +594,10 @@ }, initToggles : function() { - // init postboxes + // Init postboxes. postboxes.add_postbox_toggles('nav-menus'); - // adjust columns functions for menus UI + // Adjust columns functions for menus UI. columns.useCheckboxesForHidden(); columns.checked = function(field) { $('.field-' + field).removeClass('hidden-field'); @@ -605,7 +605,7 @@ columns.unchecked = function(field) { $('.field-' + field).addClass('hidden-field'); }; - // hide fields + // Hide fields. api.menuList.hideAdvancedMenuItemFields(); $('.hide-postbox-tog').click(function () { @@ -639,7 +639,7 @@ start: function(e, ui) { var height, width, parent, children, tempHolder; - // handle placement for rtl orientation + // Handle placement for RTL orientation. if ( api.isRTL ) ui.item[0].style.right = 'auto'; @@ -649,19 +649,19 @@ originalDepth = ui.item.menuItemDepth(); updateCurrentDepth(ui, originalDepth); - // Attach child elements to parent - // Skip the placeholder + // Attach child elements to parent. + // Skip the placeholder. parent = ( ui.item.next()[0] == ui.placeholder[0] ) ? ui.item.next() : ui.item; children = parent.childMenuItems(); transport.append( children ); // Update the height of the placeholder to match the moving item. 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 += ui.helper.outerHeight(); helperHeight = height; - height -= 2; // Subtract 2 for borders + height -= 2; // Subtract 2 for borders. ui.placeholder.height(height); // Update the width of the placeholder to match the moving item. @@ -670,18 +670,18 @@ var depth = $(this).menuItemDepth(); maxChildDepth = (depth > maxChildDepth) ? depth : maxChildDepth; }); - width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width - width += api.depthToPx(maxChildDepth - originalDepth); // Account for children - width -= 2; // Subtract 2 for borders + width = ui.helper.find('.menu-item-handle').outerWidth(); // Get original width. + width += api.depthToPx(maxChildDepth - originalDepth); // Account for children. + width -= 2; // Subtract 2 for borders. ui.placeholder.width(width); // Update the list of menu items. tempHolder = ui.placeholder.next( '.menu-item' ); - 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 - $(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQ UI know. - ui.item.after( ui.placeholder ); // reattach the placeholder. - tempHolder.css('margin-top', 0); // reset the margin + 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. + $(this).sortable( 'refresh' ); // The children aren't sortable. We should let jQuery UI know. + ui.item.after( ui.placeholder ); // Reattach the placeholder. + tempHolder.css('margin-top', 0); // Reset the margin. // Now that the element is complete, we can update... updateSharedVars(ui); @@ -690,31 +690,31 @@ var children, subMenuTitle, depthChange = currentDepth - originalDepth; - // Return child elements to the list + // Return child elements to the list. children = transport.children().insertAfter(ui.item); - // Add "sub menu" description + // Add "sub menu" description. subMenuTitle = ui.item.find( '.item-title .is-submenu' ); if ( 0 < currentDepth ) subMenuTitle.show(); else subMenuTitle.hide(); - // Update depth classes + // Update depth classes. if ( 0 !== depthChange ) { ui.item.updateDepthClass( currentDepth ); children.shiftDepthClass( depthChange ); updateMenuMaxDepth( depthChange ); } - // Register a change + // Register a change. api.registerChange(); // Update the item data. 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; - // handle drop placement for rtl orientation + // Handle drop placement for rtl orientation. if ( api.isRTL ) { ui.item[0].style.left = 'auto'; ui.item[0].style.right = 0; @@ -736,9 +736,11 @@ edge = api.isRTL ? offset.left + ui.helper.width() : offset.left, 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 - // an item, shift the placeholder to a child position. + /* + * Check and correct if depth is not within range. + * 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 ) ) { depth = maxDepth; } else if ( depth < minDepth ) { @@ -748,7 +750,7 @@ if( depth != currentDepth ) 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 ) { next.after( ui.placeholder ); updateSharedVars( ui ); @@ -955,12 +957,12 @@ return false; } - // Show the ajax spinner + // Show the Ajax spinner. $( '.customlinkdiv .spinner' ).addClass( 'is-active' ); this.addLinkToMenu( url, label, processMethod, function() { - // Remove the ajax spinner + // Remove the Ajax spinner. $( '.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-url' ).val( '' ).attr( 'placeholder', 'https://' ); }); @@ -997,10 +999,10 @@ $.post( ajaxurl, params, function(menuMarkup) { var ins = $('#menu-instructions'); - menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces + menuMarkup = $.trim( menuMarkup ); // Trim leading whitespaces. 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'); $( '.drag-instructions' ).show(); if( ! ins.hasClass( 'menu-instructions-inactive' ) && ins.siblings().length ) @@ -1051,7 +1053,7 @@ return navMenuL10n.saveAlert; }; } 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' ); } }, @@ -1071,7 +1073,7 @@ 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 ); $('.tabs-panel-active', wrapper).removeClass('tabs-panel-active').addClass('tabs-panel-inactive'); @@ -1080,7 +1082,7 @@ $('.tabs', wrapper).removeClass('tabs'); target.parent().addClass('tabs'); - // select the search bar + // Select the search bar. $('.quick-search', wrapper).focus(); // Hide controls in the search tab if no items found. @@ -1193,17 +1195,17 @@ var locs = '', menuName = $('#menu-name'), menuNameVal = menuName.val(); - // Cancel and warn if invalid menu name + // Cancel and warn if invalid menu name. if ( ! menuNameVal || ! menuNameVal.replace( /\s+/, '' ) ) { menuName.parent().addClass( 'form-invalid' ); return false; } - // Copy menu theme locations + // Copy menu theme locations. $('#nav-menu-theme-locations select').each(function() { locs += '<input type="hidden" name="' + this.name + '" value="' + $(this).val() + '" />'; }); $('#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; } ); window.onbeforeunload = null; @@ -1211,7 +1213,7 @@ }, eventOnClickMenuDelete : function() { - // Delete warning AYS + // Delete warning AYS. if ( window.confirm( navMenuL10n.warnDeleteMenu ) ) { window.onbeforeunload = null; return true; @@ -1253,7 +1255,7 @@ $items.each(function(){ $item = $(this); - // make a unique DB ID number + // Make a unique DB ID number. matched = pattern.exec($item.html()); if ( matched && matched[1] ) { diff --git a/src/js/_enqueues/lib/pointer.js b/src/js/_enqueues/lib/pointer.js index f841f82308..52524922c1 100644 --- a/src/js/_enqueues/lib/pointer.js +++ b/src/js/_enqueues/lib/pointer.js @@ -90,11 +90,11 @@ var o = this.options, tip = this.pointer; - // Handle document transfer + // Handle document transfer. if ( key === 'document' && value !== o.document ) { tip.detach().appendTo( value.body ); - // Handle class change + // Handle class change. } else if ( key === 'pointerClass' ) { tip.removeClass( o.pointerClass ).addClass( value ); } @@ -102,11 +102,11 @@ // Call super method. $.Widget.prototype._setOption.apply( this, arguments ); - // Reposition automatically + // Reposition automatically. if ( key === 'position' ) { this.reposition(); - // Update content automatically if pointer is open + // Update content automatically if pointer is open. } else if ( key === 'content' && this.active ) { this.update(); } @@ -234,7 +234,7 @@ }).show().position($.extend({ of: this.element, collision: 'fit none' - }, position )); // the object comes before this.options.position so the user can override position.of. + }, position )); // The object comes before this.options.position so the user can override position.of. this.repoint(); }, diff --git a/src/js/_enqueues/lib/quicktags.js b/src/js/_enqueues/lib/quicktags.js index f7bc488691..2224cbed84 100644 --- a/src/js/_enqueues/lib/quicktags.js +++ b/src/js/_enqueues/lib/quicktags.js @@ -20,7 +20,7 @@ * @output wp-includes/js/quicktags.js */ -// new edit toolbar used with permission +// New edit toolbar used with permission // by Alex King // http://www.alexking.org/ @@ -52,7 +52,7 @@ window.edToolbar = function(){}; /* jshint ignore:end */ (function(){ - // private stuff is prefixed with an underscore + // Private stuff is prefixed with an underscore. var _domReady = function(func) { var t, i, DOMContentLoaded, _tryReady; @@ -150,7 +150,7 @@ window.edToolbar = function(){}; t.settings = settings; if ( id === 'content' && typeof(adminpage) === 'string' && ( adminpage === 'post-new-php' || adminpage === 'post-php' ) ) { - // back compat hack :-( + // Back compat hack :-( window.edCanvas = canvas; toolbar_id = 'ed_toolbar'; } else { @@ -168,19 +168,19 @@ window.edToolbar = function(){}; canvas.parentNode.insertBefore(tb, canvas); t.toolbar = tb; - // listen for click events + // Listen for click events. onclick = function(e) { e = e || window.event; var target = e.target || e.srcElement, visible = target.clientWidth || target.offsetWidth, i; - // don't call the callback on pressing the accesskey when the button is not visible + // Don't call the callback on pressing the accesskey when the button is not visible. if ( !visible ) { return; } - // as long as it has the class ed_button, execute the callback + // As long as it has the class ed_button, execute the callback. if ( / ed_button /.test(' ' + target.className + ' ') ) { - // we have to reassign canvas here + // We have to reassign canvas here. t.canvas = canvas = document.getElementById(id); i = target.id.replace(name + '_', ''); @@ -261,7 +261,7 @@ window.edToolbar = function(){}; theButtons = {}; use = ''; - // set buttons + // Set buttons. if ( settings.buttons ) { use = ','+settings.buttons+','; } @@ -361,7 +361,7 @@ window.edToolbar = function(){}; return; } - if ( priority === -1 ) { // back-compat + if ( priority === -1 ) { // Back-compat. return btn; } @@ -376,7 +376,7 @@ window.edToolbar = function(){}; } if ( this.buttonsInitDone ) { - this._buttonsInit(); // add the button HTML to all instances toolbars if addButton() was called too late + this._buttonsInit(); // Add the button HTML to all instances toolbars if addButton() was called too late. } }; @@ -387,12 +387,12 @@ window.edToolbar = function(){}; return false; } - if ( document.selection ) { //IE + if ( document.selection ) { // IE. canvas.focus(); sel = document.selection.createRange(); sel.text = content; canvas.focus(); - } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera + } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera. text = canvas.value; startPos = canvas.selectionStart; endPos = canvas.selectionEnd; @@ -420,7 +420,7 @@ window.edToolbar = function(){}; return true; }; - // a plain, dumb button + // A plain, dumb button. qt.Button = function( id, display, access, title, instance, attr ) { this.id = id; this.display = display; @@ -450,7 +450,7 @@ window.edToolbar = function(){}; }; qt.Button.prototype.callback = function(){}; - // a button that inserts HTML tag + // A button that inserts HTML tag. qt.TagButton = function( id, display, tagStart, tagEnd, access, title, instance, attr ) { var t = this; qt.Button.call( t, id, display, access, title, instance, attr ); @@ -485,7 +485,7 @@ window.edToolbar = function(){}; element.setAttribute( 'aria-label', this.attr.ariaLabel ); } }; - // whether a tag is open or not. Returns false if not open, or current open depth of the tag + // Whether a tag is open or not. Returns false if not open, or current open depth of the tag. qt.TagButton.prototype.isOpen = function (ed) { var t = this, i = 0, ret = false; if ( ed.openTags ) { @@ -501,7 +501,7 @@ window.edToolbar = function(){}; qt.TagButton.prototype.callback = function(element, canvas, ed) { var t = this, startPos, endPos, cursorPos, scrollTop, v = canvas.value, l, r, i, sel, endTag = v ? t.tagEnd : '', event; - if ( document.selection ) { // IE + if ( document.selection ) { // IE. canvas.focus(); sel = document.selection.createRange(); if ( sel.text.length > 0 ) { @@ -522,7 +522,7 @@ window.edToolbar = function(){}; } } canvas.focus(); - } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera + } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera. startPos = canvas.selectionStart; endPos = canvas.selectionEnd; @@ -532,12 +532,12 @@ window.edToolbar = function(){}; cursorPos = endPos; scrollTop = canvas.scrollTop; - l = v.substring(0, startPos); // left of the selection - r = v.substring(endPos, v.length); // right of the selection - i = v.substring(startPos, endPos); // inside the selection + l = v.substring(0, startPos); // Left of the selection. + r = v.substring(endPos, v.length); // Right of the selection. + i = v.substring(startPos, endPos); // Inside the selection. if ( startPos !== endPos ) { if ( !t.tagEnd ) { - canvas.value = l + i + t.tagStart + r; // insert self closing tags after the selection + canvas.value = l + i + t.tagStart + r; // Insert self-closing tags after the selection. cursorPos += t.tagStart.length; } else { canvas.value = l + t.tagStart + i + endTag + r; @@ -562,7 +562,7 @@ window.edToolbar = function(){}; canvas.selectionEnd = cursorPos; canvas.scrollTop = scrollTop; canvas.focus(); - } else { // other browsers? + } else { // Other browsers? if ( !endTag ) { canvas.value += t.tagStart; } else if ( t.isOpen(ed) !== false ) { @@ -584,10 +584,10 @@ window.edToolbar = function(){}; } }; - // removed + // Removed. qt.SpellButton = function() {}; - // the close tags button + // The close tags button. qt.CloseButton = function() { qt.Button.call( this, 'close', quicktagsL10n.closeTags, '', quicktagsL10n.closeAllOpenTags ); }; @@ -621,7 +621,7 @@ window.edToolbar = function(){}; } }; - // the link button + // The link button. qt.LinkButton = function() { var attr = { ariaLabel: quicktagsL10n.link @@ -653,7 +653,7 @@ window.edToolbar = function(){}; } }; - // the img button + // The img button. qt.ImgButton = function() { var attr = { ariaLabel: quicktagsL10n.image @@ -704,14 +704,14 @@ window.edToolbar = function(){}; c.focus(); }; - // ensure backward compatibility + // Ensure backward compatibility. edButtons[10] = new qt.TagButton( 'strong', 'b', '<strong>', '</strong>', '', '', '', { ariaLabel: quicktagsL10n.strong, ariaLabelClose: quicktagsL10n.strongClose } ); edButtons[20] = new qt.TagButton( 'em', 'i', '<em>', '</em>', '', '', '', { ariaLabel: quicktagsL10n.em, ariaLabelClose: quicktagsL10n.emClose } ); - edButtons[30] = new qt.LinkButton(); // special case + edButtons[30] = new qt.LinkButton(); // Special case. edButtons[40] = new qt.TagButton( 'block', 'b-quote', '\n\n<blockquote>', '</blockquote>\n\n', '', '', '', { ariaLabel: quicktagsL10n.blockquote, ariaLabelClose: quicktagsL10n.blockquoteClose } ); edButtons[50] = new qt.TagButton( 'del', 'del', '<del datetime="' + _datetime + '">', '</del>', '', '', '', { ariaLabel: quicktagsL10n.del, ariaLabelClose: quicktagsL10n.delClose } ); edButtons[60] = new qt.TagButton( 'ins', 'ins', '<ins datetime="' + _datetime + '">', '</ins>', '', '', '', { ariaLabel: quicktagsL10n.ins, ariaLabelClose: quicktagsL10n.insClose } ); - edButtons[70] = new qt.ImgButton(); // special case + edButtons[70] = new qt.ImgButton(); // Special case. edButtons[80] = new qt.TagButton( 'ul', 'ul', '<ul>\n', '</ul>\n\n', '', '', '', { ariaLabel: quicktagsL10n.ul, ariaLabelClose: quicktagsL10n.ulClose } ); edButtons[90] = new qt.TagButton( 'ol', 'ol', '<ol>\n', '</ol>\n\n', '', '', '', { ariaLabel: quicktagsL10n.ol, ariaLabelClose: quicktagsL10n.olClose } ); edButtons[100] = new qt.TagButton( 'li', 'li', '\t<li>', '</li>\n', '', '', '', { ariaLabel: quicktagsL10n.li, ariaLabelClose: quicktagsL10n.liClose } ); diff --git a/src/js/_enqueues/vendor/plupload/handlers.js b/src/js/_enqueues/vendor/plupload/handlers.js index 9116a64eac..9ed2cc687d 100644 --- a/src/js/_enqueues/vendor/plupload/handlers.js +++ b/src/js/_enqueues/vendor/plupload/handlers.js @@ -1,18 +1,18 @@ /* global plupload, pluploadL10n, ajaxurl, post_id, wpUploaderInit, deleteUserSetting, setUserSetting, getUserSetting, shortform */ var topWin = window.dialogArguments || opener || parent || top, uploader, uploader_init; -// progress and success handlers for media multi uploads +// Progress and success handlers for media multi uploads. function fileQueued( fileObj ) { - // Get rid of unused form + // Get rid of unused form. jQuery( '.media-blank' ).remove(); var items = jQuery( '#media-items' ).children(), postid = post_id || 0; - // Collapse a single item + // Collapse a single item. if ( items.length == 1 ) { items.removeClass( 'open' ).find( '.slidetoggle' ).slideUp( 200 ); } - // Create a progress bar containing the filename + // Create a progress bar containing the filename. jQuery( '<div class="media-item">' ) .attr( 'id', 'media-item-' + fileObj.id ) .addClass( 'child-of-' + postid ) @@ -20,7 +20,7 @@ function fileQueued( fileObj ) { jQuery( '<div class="filename original">' ).text( ' ' + fileObj.name ) ) .appendTo( jQuery( '#media-items' ) ); - // Disable submit + // Disable submit. jQuery( '#insert-gallery' ).prop( 'disabled', true ); } @@ -40,27 +40,27 @@ function uploadProgress( up, file ) { jQuery( '.percent', item ).html( file.percent + '%' ); } -// check to see if a large file failed to upload +// Check to see if a large file failed to upload. function fileUploading( up, file ) { var hundredmb = 100 * 1024 * 1024, max = parseInt( up.settings.max_file_size, 10 ); if ( max > hundredmb && file.size > hundredmb ) { setTimeout( function() { - if ( file.status < 3 && file.loaded === 0 ) { // not uploading + if ( file.status < 3 && file.loaded === 0 ) { // Not uploading. wpFileError( file, pluploadL10n.big_upload_failed.replace( '%1$s', '<a class="uploader-html" href="#">' ).replace( '%2$s', '</a>' ) ); - up.stop(); // stops the whole queue + up.stop(); // Stop the whole queue. up.removeFile( file ); - up.start(); // restart the queue + up.start(); // Restart the queue. } - }, 10000 ); // wait for 10 sec. for the file to start uploading + }, 10000 ); // Wait for 10 seconds for the file to start uploading. } } function updateMediaForm() { var items = jQuery( '#media-items' ).children(); - // Just one file, no need for collapsible part + // Just one file, no need for collapsible part. if ( items.length == 1 ) { items.addClass( 'open' ).find( '.slidetoggle' ).show(); jQuery( '.insert-gallery' ).hide(); @@ -80,11 +80,12 @@ function updateMediaForm() { function uploadSuccess( fileObj, serverData ) { var item = jQuery( '#media-item-' + fileObj.id ); - // on success serverData should be numeric, fix bug in html4 runtime returning the serverData wrapped in a <pre> tag + // On success serverData should be numeric, + // fix bug in html4 runtime returning the serverData wrapped in a <pre> tag. if ( typeof serverData === 'string' ) { serverData = serverData.replace( /^<pre>(\d+)<\/pre>$/, '$1' ); - // if async-upload returned an error message, place it in the media item div and return + // If async-upload returned an error message, place it in the media item div and return. if ( /media-upload-error|error-div/.test( serverData ) ) { item.html( serverData ); return; @@ -129,25 +130,27 @@ function prepareMediaItem( fileObj, serverData ) { topWin.jQuery( '#TB_overlay' ).click( topWin.tb_remove ); } catch( e ){} - if ( isNaN( serverData ) || !serverData ) { // Old style: Append the HTML returned by the server -- thumbnail and form inputs + if ( isNaN( serverData ) || !serverData ) { + // Old style: Append the HTML returned by the server -- thumbnail and form inputs. item.append( serverData ); prepareMediaItemInit( fileObj ); - } else { // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server + } else { + // New style: server data is just the attachment ID, fetch the thumbnail and form html from the server. item.load( 'async-upload.php', {attachment_id:serverData, fetch:f}, function(){prepareMediaItemInit( fileObj );updateMediaForm();}); } } function prepareMediaItemInit( fileObj ) { var item = jQuery( '#media-item-' + fileObj.id ); - // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename + // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename. jQuery( '.thumbnail', item ).clone().attr( 'class', 'pinkynail toggle' ).prependTo( item ); - // Replace the original filename with the new (unique) one assigned during upload + // Replace the original filename with the new (unique) one assigned during upload. jQuery( '.filename.original', item ).replaceWith( jQuery( '.filename.new', item ) ); - // Bind AJAX to the new Delete button + // Bind AJAX to the new Delete button. jQuery( 'a.delete', item ).click( function(){ - // Tell the server to delete it. TODO: handle exceptions + // Tell the server to delete it. TODO: Handle exceptions. jQuery.ajax({ url: ajaxurl, type: 'post', @@ -163,9 +166,9 @@ function prepareMediaItemInit( fileObj ) { return false; }); - // Bind AJAX to the new Undo button + // Bind AJAX to the new Undo button. jQuery( 'a.undo', item ).click( function(){ - // Tell the server to untrash it. TODO: handle exceptions + // Tell the server to untrash it. TODO: Handle exceptions. jQuery.ajax({ url: ajaxurl, type: 'post', @@ -195,16 +198,16 @@ function prepareMediaItemInit( fileObj ) { return false; }); - // Open this item if it says to start open (e.g. to display an error) + // Open this item if it says to start open (e.g. to display an error). jQuery( '#media-item-' + fileObj.id + '.startopen' ).removeClass( 'startopen' ).addClass( 'open' ).find( 'slidetoggle' ).fadeIn(); } -// generic error message +// Generic error message. function wpQueueError( message ) { jQuery( '#media-upload-error' ).show().html( '<div class="error"><p>' + message + '</p></div>' ); } -// file-specific error messages +// File-specific error messages. function wpFileError( fileObj, message ) { itemAjaxError( fileObj.id, message ); } @@ -212,7 +215,7 @@ function wpFileError( fileObj, message ) { function itemAjaxError( id, message ) { var item = jQuery( '#media-item-' + id ), filename = item.find( '.filename' ).text(), last_err = item.data( 'last-err' ); - if ( last_err == id ) // prevent firing an error for the same file twice + if ( last_err == id ) // Prevent firing an error for the same file twice. return; item.html( '<div class="error-div">' + @@ -274,7 +277,7 @@ function switchUploader( s ) { if ( typeof( uploader ) == 'object' ) uploader.refresh(); } else { - setUserSetting( 'uploader', '1' ); // 1 == html uploader + setUserSetting( 'uploader', '1' ); // 1 == html uploader. jQuery( '.media-upload-form' ).addClass( 'html-uploader' ); } } @@ -365,7 +368,7 @@ jQuery( document ).ready( function( $ ) { $( '.media-upload-form' ).bind( 'click.uploader', function( e ) { var target = $( e.target ), tr, c; - if ( target.is( 'input[type="radio"]' ) ) { // remember the last used image size and alignment + if ( target.is( 'input[type="radio"]' ) ) { // Remember the last used image size and alignment. tr = target.closest( 'tr' ); if ( tr.hasClass( 'align' ) ) @@ -373,7 +376,7 @@ jQuery( document ).ready( function( $ ) { else if ( tr.hasClass( 'image-size' ) ) setUserSetting( 'imgsize', target.val() ); - } else if ( target.is( 'button.button' ) ) { // remember the last used image link url + } else if ( target.is( 'button.button' ) ) { // Remember the last used image link url. c = e.target.className || ''; c = c.match( /url([^ '"]+)/ ); @@ -385,15 +388,15 @@ jQuery( document ).ready( function( $ ) { target.parents( '.media-item' ).fadeOut( 200, function() { $( this ).remove(); } ); - } else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // switch uploader to html4 + } else if ( target.is( '.upload-flash-bypass a' ) || target.is( 'a.uploader-html' ) ) { // Switch uploader to html4. $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', 'none' ); switchUploader( 0 ); e.preventDefault(); - } else if ( target.is( '.upload-html-bypass a' ) ) { // switch uploader to multi-file + } else if ( target.is( '.upload-html-bypass a' ) ) { // Switch uploader to multi-file. $( '#media-items, p.submit, span.big-file-warning' ).css( 'display', '' ); switchUploader( 1 ); e.preventDefault(); - } else if ( target.is( 'a.describe-toggle-on' ) ) { // Show + } else if ( target.is( 'a.describe-toggle-on' ) ) { // Show. target.parent().addClass( 'open' ); target.siblings( '.slidetoggle' ).fadeIn( 250, function() { var S = $( window ).scrollTop(), @@ -417,7 +420,7 @@ jQuery( document ).ready( function( $ ) { } ); e.preventDefault(); - } else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide + } else if ( target.is( 'a.describe-toggle-off' ) ) { // Hide. target.siblings( '.slidetoggle' ).fadeOut( 250, function() { target.parent().removeClass( 'open' ); } ); @@ -450,9 +453,11 @@ jQuery( document ).ready( function( $ ) { times = tryAgainCount[ file.id ]; if ( times && times > 4 ) { - // The file may have been uploaded and attachment post created, - // but post-processing and resizing failed... - // Do a cleanup then tell the user to scale down the image and upload it again. + /* + * The file may have been uploaded and attachment post created, + * but post-processing and resizing failed... + * Do a cleanup then tell the user to scale down the image and upload it again. + */ $.ajax({ type: 'post', url: ajaxurl, @@ -514,7 +519,7 @@ jQuery( document ).ready( function( $ ) { }); } - // init and set the uploader + // Init and set the uploader. uploader_init = function() { uploader = new plupload.Uploader( wpUploaderInit ); diff --git a/src/js/_enqueues/vendor/plupload/wp-plupload.js b/src/js/_enqueues/vendor/plupload/wp-plupload.js index ea32444c7e..e42288fbe4 100644 --- a/src/js/_enqueues/vendor/plupload/wp-plupload.js +++ b/src/js/_enqueues/vendor/plupload/wp-plupload.js @@ -33,7 +33,7 @@ window.wp = window.wp || {}; */ Uploader = function( options ) { var self = this, - isIE, // not used, back-compat + isIE, // Not used, back-compat. elements = { container: 'container', browser: 'browse_button', @@ -60,10 +60,12 @@ window.wp = window.wp || {}; this.plupload = $.extend( true, { multipart_params: {} }, Uploader.defaults ); this.container = document.body; // Set default container. - // Extend the instance with options. - // - // Use deep extend to allow options.plupload to override individual - // default plupload keys. + /* + * Extend the instance with options. + * + * Use deep extend to allow options.plupload to override individual + * default plupload keys. + */ $.extend( true, this, options ); // Proxy all methods so this always refers to the current instance. @@ -138,9 +140,11 @@ window.wp = window.wp || {}; times = tryAgainCount[ file.id ]; if ( times && times > 4 ) { - // The file may have been uploaded and attachment post created, - // but post-processing and resizing failed... - // Do a cleanup then tell the user to scale down the image and upload it again. + /* + * The file may have been uploaded and attachment post created, + * but post-processing and resizing failed... + * Do a cleanup then tell the user to scale down the image and upload it again. + */ $.ajax({ type: 'post', url: ajaxurl, @@ -238,7 +242,7 @@ window.wp = window.wp || {}; fileUploaded = function( up, file, response ) { var complete; - // Remove the "uploading" UI elements + // Remove the "uploading" UI elements. _.each( ['file','loaded','size','percent'], function( key ) { file.attachment.unset( key ); } ); @@ -295,11 +299,13 @@ window.wp = window.wp || {}; }); dropzone.bind('dragleave.wp-uploader, drop.wp-uploader', function() { - // Using an instant timer prevents the drag-over class from - // being quickly removed and re-added when elements inside the - // dropzone are repositioned. - // - // @see https://core.trac.wordpress.org/ticket/21705 + /* + * Using an instant timer prevents the drag-over class + * from being quickly removed and re-added when elements + * inside the dropzone are repositioned. + * + * @see https://core.trac.wordpress.org/ticket/21705 + */ timer = setTimeout( function() { active = false; dropzone.trigger('dropzone:leave').removeClass('drag-over'); @@ -513,9 +519,11 @@ window.wp = window.wp || {}; node = node.parentNode; } - // If the browser node is not attached to the DOM, use a - // temporary container to house it, as the browser button - // shims require the button to exist in the DOM at all times. + /* + * If the browser node is not attached to the DOM, + * use a temporary container to house it, as the browser button shims + * require the button to exist in the DOM at all times. + */ if ( ! attached ) { id = 'wp-uploader-browser-' + this.uploader.id; diff --git a/src/js/_enqueues/vendor/tinymce/plugins/compat3x/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/compat3x/plugin.js index 92d433edcd..9be24f3e1a 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/compat3x/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/compat3x/plugin.js @@ -44,7 +44,7 @@ this.add = function (callback, scope, prepend) { log('<target>.on' + newEventName + ".add(..)"); - // Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2) + // Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2). function patchedEventCallback(e) { var callbackArgs = []; diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js index b7848cd987..cbb320b146 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wordpress/plugin.js @@ -1,6 +1,6 @@ /* global getUserSetting, setUserSetting */ ( function( tinymce ) { -// Set the minimum value for the modals z-index higher than #wpadminbar (100000) +// Set the minimum value for the modals z-index higher than #wpadminbar (100000). if ( ! tinymce.ui.FloatPanel.zIndex || tinymce.ui.FloatPanel.zIndex < 100100 ) { tinymce.ui.FloatPanel.zIndex = 100100; } @@ -88,7 +88,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Hide the toolbars after loading + // Hide the toolbars after loading. editor.on( 'PostRender', function() { if ( editor.getParam( 'wordpress_adv_hidden', true ) && getUserSetting( 'hidetb', '0' ) === '0' ) { toggleToolbars( 'hide' ); @@ -191,7 +191,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Display the tag name instead of img in element path + // Display the tag name instead of img in element path. editor.on( 'ResolveName', function( event ) { var attr; @@ -200,7 +200,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Register commands + // Register commands. editor.addCommand( 'WP_More', function( tag ) { var parent, html, title, classname = 'wp-more-tag', @@ -215,13 +215,13 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { html = '<img src="' + tinymce.Env.transparentSrc + '" alt="" title="' + title + '" class="' + classname + '" ' + 'data-wp-more="' + tag + '" data-mce-resize="false" data-mce-placeholder="1" />'; - // Most common case + // Most common case. if ( node === rootNode || ( node.nodeName === 'P' && node.parentNode === rootNode ) ) { editor.insertContent( html ); return; } - // Get the top level parent node + // Get the top level parent node. parent = dom.getParent( node, function( found ) { if ( found.parentNode && found.parentNode === rootNode ) { return true; @@ -328,7 +328,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { html = '<div class="wp-editor-help">'; - // Main section, default and additional shortcuts + // Main section, default and additional shortcuts. html = html + '<h2>' + __( 'Default shortcuts,' ) + ' ' + meta + '</h2>' + '<table class="wp-help-th-center fixed">' + @@ -342,7 +342,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { '</table>'; if ( editor.plugins.wptextpattern && ( ! tinymce.Env.ie || tinymce.Env.ie > 8 ) ) { - // Text pattern section + // Text pattern section. html = html + '<h2>' + __( 'When starting a new paragraph with one of these formatting shortcuts followed by a space, the formatting will be applied automatically. Press Backspace or Escape to undo.' ) + '</h2>' + '<table class="wp-help-th-center fixed">' + @@ -363,7 +363,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { '</table>'; } - // Focus management section + // Focus management section. html = html + '<h2>' + __( 'Focus shortcuts:' ) + '</h2>' + '<table class="wp-help-single">' + @@ -413,7 +413,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Register buttons + // Register buttons. editor.addButton( 'wp_more', { tooltip: 'Insert Read More tag', onclick: function() { @@ -439,7 +439,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { stateSelector: 'code' }); - // Insert->Add Media + // Insert->Add Media. if ( wp && wp.media && wp.media.editor ) { editor.addButton( 'wp_add_media', { tooltip: 'Add Media', @@ -455,7 +455,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { }); } - // Insert "Read More..." + // Insert "Read More...". editor.addMenuItem( 'wp_more', { text: 'Insert Read More tag', icon: 'wp_more', @@ -465,7 +465,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Insert "Next Page" + // Insert "Next Page". editor.addMenuItem( 'wp_page', { text: 'Page break', icon: 'wp_page', @@ -496,7 +496,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { editor.on( 'init', function() { var env = tinymce.Env, - bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css... + bodyClass = ['mceContentBody'], // Back-compat for themes that use this in editor-style.css... doc = editor.getDoc(), dom = editor.dom; @@ -531,7 +531,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } }); - // Remove invalid parent paragraphs when inserting HTML + // Remove invalid parent paragraphs when inserting HTML. editor.on( 'BeforeSetContent', function( event ) { if ( event.content ) { event.content = event.content.replace( /<p>\s*<(p|div|ul|ol|dl|table|blockquote|h[1-6]|fieldset|pre)( [^>]*)?>/gi, '<$1$2>' ) @@ -554,21 +554,21 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { if ( editor.getParam( 'wp_paste_filters', true ) ) { editor.on( 'PastePreProcess', function( event ) { - // Remove trailing <br> added by WebKit browsers to the clipboard + // Remove trailing <br> added by WebKit browsers to the clipboard. event.content = event.content.replace( /<br class="?Apple-interchange-newline"?>/gi, '' ); - // In WebKit this is handled by removeWebKitStyles() + // In WebKit this is handled by removeWebKitStyles(). if ( ! tinymce.Env.webkit ) { - // Remove all inline styles + // Remove all inline styles. event.content = event.content.replace( /(<[^>]+) style="[^"]*"([^>]*>)/gi, '$1$2' ); - // Put back the internal styles + // Put back the internal styles. event.content = event.content.replace(/(<[^>]+) data-mce-style=([^>]+>)/gi, '$1 style=$2' ); } }); editor.on( 'PastePostProcess', function( event ) { - // Remove empty paragraphs + // Remove empty paragraphs. editor.$( 'p', event.node ).each( function( i, node ) { if ( dom.isEmpty( node ) ) { dom.remove( node ); @@ -585,7 +585,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { }); editor.on( 'SaveContent', function( event ) { - // If editor is hidden, we just want the textarea's value to be saved + // If editor is hidden, we just want the textarea's value to be saved. if ( ! editor.inline && editor.isHidden() ) { event.content = event.element.value; return; @@ -700,7 +700,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { wpTooltips = {}; - // For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325 + // For MacOS: ctrl = \u2303, cmd = \u2318, alt = \u2325. if ( tinymce.Env.mac ) { access = '\u2303\u2325'; meta = '\u2318'; @@ -761,7 +761,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { } function addShortcutsToListbox() { - // listbox for the "blocks" drop-down + // listbox for the "blocks" drop-down. each( editor.theme.panel.find( 'listbox' ), function( listbox ) { if ( listbox && listbox.settings.text === 'Paragraph' ) { each( listbox.settings.values, function( item ) { @@ -1118,9 +1118,11 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { event.type === 'resize' || event.type === 'scroll' ) && ! activeToolbar.blockHide ) { - // Showing a tooltip may trigger a `resize` event in Chromium browsers. - // That results in a flicketing inline menu; tooltips are shown on hovering over a button, - // which then hides the toolbar on `resize`, then it repeats as soon as the toolbar is shown again. + /* + * Showing a tooltip may trigger a `resize` event in Chromium browsers. + * That results in a flicketing inline menu; tooltips are shown on hovering over a button, + * which then hides the toolbar on `resize`, then it repeats as soon as the toolbar is shown again. + */ if ( event.type === 'resize' || event.type === 'resizewindow' ) { win = editor.getWin(); size = win.innerHeight + win.innerWidth; @@ -1187,7 +1189,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) { function noop() {} - // Expose some functions (back-compat) + // Expose some functions (back-compat). return { _showButtons: noop, _hideButtons: noop, diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpautoresize/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpautoresize/plugin.js index 98905f6478..6e0a1a8d82 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpautoresize/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpautoresize/plugin.js @@ -61,13 +61,13 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { if ( ! body || ( e && e.type === 'setcontent' && e.initial ) || isFullscreen() ) { if ( body && docElm ) { body.style.overflowY = 'auto'; - docElm.style.overflowY = 'auto'; // Old IE + docElm.style.overflowY = 'auto'; // Old IE. } return; } - // Calculate outer height of the body element using CSS styles + // Calculate outer height of the body element using CSS styles. marginTop = editor.dom.getStyle( body, 'margin-top', true ); marginBottom = editor.dom.getStyle( body, 'margin-bottom', true ); paddingTop = editor.dom.getStyle( body, 'padding-top', true ); @@ -83,36 +83,36 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { myHeight = docElm.offsetHeight; } - // Make sure we have a valid height + // Make sure we have a valid height. if ( isNaN( myHeight ) || myHeight <= 0 ) { - // Get height differently depending on the browser used + // Get height differently depending on the browser used. myHeight = tinymce.Env.ie ? body.scrollHeight : ( tinymce.Env.webkit && body.clientHeight === 0 ? 0 : body.offsetHeight ); } - // Don't make it smaller than the minimum height + // Don't make it smaller than the minimum height. if ( myHeight > settings.autoresize_min_height ) { resizeHeight = myHeight; } - // If a maximum height has been defined don't exceed this height + // If a maximum height has been defined don't exceed this height. if ( settings.autoresize_max_height && myHeight > settings.autoresize_max_height ) { resizeHeight = settings.autoresize_max_height; body.style.overflowY = 'auto'; - docElm.style.overflowY = 'auto'; // Old IE + docElm.style.overflowY = 'auto'; // Old IE. } else { body.style.overflowY = 'hidden'; - docElm.style.overflowY = 'hidden'; // Old IE + docElm.style.overflowY = 'hidden'; // Old IE. body.scrollTop = 0; } - // Resize content element + // Resize content element. if (resizeHeight !== oldSize) { deltaSize = resizeHeight - oldSize; DOM.setStyle( editor.iframeElement, 'height', resizeHeight + 'px' ); oldSize = resizeHeight; - // WebKit doesn't decrease the size of the body element until the iframe gets resized - // So we need to continue to resize the iframe down until the size gets fixed + // WebKit doesn't decrease the size of the body element until the iframe gets resized. + // So we need to continue to resize the iframe down until the size gets fixed. if ( tinymce.isWebKit && deltaSize < 0 ) { resize( e ); } @@ -137,17 +137,17 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { }, interval ); } - // Define minimum height + // Define minimum height. settings.autoresize_min_height = parseInt(editor.getParam( 'autoresize_min_height', editor.getElement().offsetHeight), 10 ); - // Define maximum height + // Define maximum height. settings.autoresize_max_height = parseInt(editor.getParam( 'autoresize_max_height', 0), 10 ); function on() { if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) { isActive = true; editor.dom.addClass( editor.getBody(), 'wp-autoresize' ); - // Add appropriate listeners for resizing the content area + // Add appropriate listeners for resizing the content area. editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize ); resize(); } @@ -156,20 +156,20 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { function off() { var doc; - // Don't turn off if the setting is 'on' + // Don't turn off if the setting is 'on'. if ( ! settings.wp_autoresize_on ) { isActive = false; doc = editor.getDoc(); editor.dom.removeClass( editor.getBody(), 'wp-autoresize' ); editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize ); doc.body.style.overflowY = 'auto'; - doc.documentElement.style.overflowY = 'auto'; // Old IE + doc.documentElement.style.overflowY = 'auto'; // Old IE. oldSize = 0; } } if ( settings.wp_autoresize_on ) { - // Turn resizing on when the editor loads + // Turn resizing on when the editor loads. isActive = true; editor.on( 'init', function() { @@ -184,24 +184,24 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) { if ( editor.getParam( 'autoresize_on_init', true ) ) { editor.on( 'init', function() { - // Hit it 10 times in 200 ms intervals + // Hit it 10 times in 200 ms intervals. wait( 10, 200, function() { - // Hit it 5 times in 1 sec intervals + // Hit it 5 times in 1 sec intervals. wait( 5, 1000 ); }); }); } } - // Reset the stored size + // Reset the stored size. editor.on( 'show', function() { oldSize = 0; }); - // Register the command + // Register the command. editor.addCommand( 'wpAutoResize', resize ); - // On/off + // On/off. editor.addCommand( 'wpAutoResizeOn', on ); editor.addCommand( 'wpAutoResizeOff', off ); }); diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpdialogs/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpdialogs/plugin.js index 8b9229fdbc..11c8d5fdc4 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpdialogs/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpdialogs/plugin.js @@ -30,7 +30,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { } if ( typeof jQuery === 'undefined' || ! jQuery.wp || ! jQuery.wp.wpdialog ) { - // wpdialog.js is not loaded + // wpdialog.js is not loaded. if ( window.console && window.console.error ) { window.console.error('wpdialog.js is not loaded. Please set "wpdialogs" as dependency for your script when calling wp_enqueue_script(). You may also want to enqueue the "wp-jquery-ui-dialog" stylesheet.'); } @@ -54,7 +54,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { // Store selection. Takes a snapshot in the FocusManager of the selection before focus is moved to the dialog. editor.nodeChanged(); - // Create the dialog if necessary + // Create the dialog if necessary. if ( ! $element.data('wpdialog') ) { $element.wpdialog({ title: args.title, @@ -85,7 +85,7 @@ tinymce.WPWindowManager = tinymce.InlineWindowManager = function( editor ) { }; tinymce.PluginManager.add( 'wpdialogs', function( editor ) { - // Replace window manager + // Replace window manager. editor.on( 'init', function() { editor.windowManager = new tinymce.WPWindowManager( editor ); }); diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js index 9142ed5717..ac6c83b427 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpeditimage/plugin.js @@ -18,7 +18,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } ); editor.addButton( 'wp_img_edit', { - tooltip: 'Edit|button', // '|button' is not displayed, only used for context + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', onclick: function() { editImage( editor.selection.getNode() ); @@ -146,7 +146,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { caption = trim( img[2] ); img = trim( img[1] ); } else { - // old captions shortcode style + // Old captions shortcode style. caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' ); img = c; } @@ -214,18 +214,18 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) { - // no line breaks inside HTML tags + // No line breaks inside HTML tags. return a.replace( /[\r\n\t]+/, ' ' ); }); - // convert remaining line breaks to <br> + // Convert remaining line breaks to <br>. caption = caption.replace( /\s*\n\s*/g, '<br />' ); return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]'; }); if ( out.indexOf('[caption') === -1 ) { - // the caption html seems broken, try to find the image that may be wrapped in a link + // The caption html seems broken, try to find the image that may be wrapped in a link // and may be followed by <p> with the caption text. out = dl.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' ); } @@ -240,7 +240,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { dom = editor.dom, isIntRegExp = /^\d+$/; - // default attributes + // Default attributes. metadata = { attachment_id: false, size: 'custom', @@ -292,7 +292,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { metadata.extraClasses = extraClasses.join( ' ' ); - // Extract caption + // Extract caption. captionBlock = dom.getParents( imageNode, '.wp-caption' ); if ( captionBlock.length ) { @@ -318,7 +318,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } } - // Extract linkTo + // Extract linkTo. if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) { link = imageNode.parentNode; metadata.linkUrl = dom.getAttrib( link, 'href' ); @@ -334,7 +334,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { return node && !! ( node.textContent || node.innerText ).replace( /\ufeff/g, '' ); } - // Verify HTML in captions + // Verify HTML in captions. function verifyHTML( caption ) { if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) { return caption; @@ -404,7 +404,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { }; if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) { - // Update or remove an existing link wrapped around the image + // Update or remove an existing link wrapped around the image. if ( imageData.linkUrl ) { dom.setAttribs( imageNode.parentNode, linkAttrs ); } else { @@ -413,11 +413,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } else if ( imageData.linkUrl ) { if ( linkNode = dom.getParent( imageNode, 'a' ) ) { // The image is inside a link together with other nodes, - // or is nested in another node, move it out + // or is nested in another node, move it out. dom.insertAfter( imageNode, linkNode ); } - // Add link wrapped around the image + // Add link wrapped around the image. linkNode = dom.create( 'a', linkAttrs ); imageNode.parentNode.insertBefore( linkNode, imageNode ); linkNode.appendChild( imageNode ); @@ -467,7 +467,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } else { id = id ? 'id="'+ id +'" ' : ''; - // should create a new function for generating the caption markup + // Should create a new function for generating the caption markup. html = '<dl ' + id + 'class="' + className +'" style="width: '+ width +'px">' + '<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>'; @@ -486,7 +486,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } } } else if ( captionNode ) { - // Remove the caption wrapper and place the image in new paragraph + // Remove the caption wrapper and place the image in new paragraph. parent = dom.create( 'p' ); captionNode.parentNode.insertBefore( parent, captionNode ); parent.appendChild( node ); @@ -530,7 +530,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { // Mark the image node so we can select it later. editor.$( img ).attr( 'data-wp-editing', 1 ); - // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal + // Manipulate the metadata by reference that is fed into the PostImage model used in the media modal. wp.media.events.trigger( 'editor:image-edit', { editor: editor, metadata: metadata, @@ -558,9 +558,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { editor.focus(); frame.detach(); - // `close` fires first... - // To be able to update the image node, we need to find it here, - // and use it in the callback. + /* + * `close` fires first... + * To be able to update the image node, we need to find it here, + * and use it in the callback. + */ imageNode = editor.$( 'img[data-wp-editing]' ) imageNode.removeAttr( 'data-wp-editing' ); }); @@ -600,12 +602,12 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { dom.addClass( editor.getBody(), captionClass ); - // Prevent IE11 from making dl.wp-caption resizable + // Prevent IE11 from making dl.wp-caption resizable. if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) { - // The 'mscontrolselect' event is supported only in IE11+ + // The 'mscontrolselect' event is supported only in IE11+. dom.bind( editor.getBody(), 'mscontrolselect', function( event ) { if ( event.target.nodeName === 'IMG' && dom.getParent( event.target, '.wp-caption' ) ) { - // Hide the thick border with resize handles around dl.wp-caption + // Hide the thick border with resize handles around dl.wp-caption. editor.getBody().focus(); // :( } else if ( event.target.nodeName === 'DL' && dom.hasClass( event.target, 'wp-caption' ) ) { // Trigger the thick border with resize handles... @@ -688,25 +690,31 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { if ( cmd === 'mceInsertContent' ) { if ( pasteInCaption ) { pasteInCaption = false; - // We are in the caption element, and in 'paste' context, - // and the pasted HTML was cleaned up on 'pastePostProcess' above. - // Let it be pasted in the caption. + /* + * We are in the caption element, and in 'paste' context, + * and the pasted HTML was cleaned up on 'pastePostProcess' above. + * Let it be pasted in the caption. + */ return; } - // The paste is somewhere else in the caption DL element. - // Prevent pasting in there as it will break the caption. - // Make new paragraph under the caption DL and move the caret there. + /* + * The paste is somewhere else in the caption DL element. + * Prevent pasting in there as it will break the caption. + * Make new paragraph under the caption DL and move the caret there. + */ p = dom.create( 'p' ); dom.insertAfter( p, captionParent ); editor.selection.setCursorLocation( p, 0 ); - // If the image is selected and the user pastes "over" it, - // replace both the image and the caption elements with the pasted content. - // This matches the behavior when pasting over non-caption images. + /* + * If the image is selected and the user pastes "over" it, + * replace both the image and the caption elements with the pasted content. + * This matches the behavior when pasting over non-caption images. + */ if ( node.nodeName === 'IMG' ) { - editor.$( captionParent ).remove(); - } + editor.$( captionParent ).remove(); + } editor.nodeChanged(); } else { @@ -759,7 +767,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { VK = tinymce.util.VK; if ( keyCode === VK.ENTER ) { - // When pressing Enter inside a caption move the caret to a new parapraph under it + // When pressing Enter inside a caption move the caret to a new parapraph under it. node = selection.getNode(); wrap = dom.getParent( node, 'div.mceTemp' ); @@ -802,9 +810,11 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } }); - // After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS. - // This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places. - // Collapse the selection to remove the resize handles. + /* + * After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS. + * This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places. + * Collapse the selection to remove the resize handles. + */ if ( tinymce.Env.gecko ) { editor.on( 'undo redo', function() { if ( editor.selection.getNode().nodeName === 'IMG' ) { @@ -878,7 +888,7 @@ tinymce.PluginManager.add( 'wpeditimage', function( editor ) { } ); } )(); - // Add to editor.wp + // Add to editor.wp. editor.wp = editor.wp || {}; editor.wp.isPlaceholder = isPlaceholder; diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpemoji/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpemoji/plugin.js index 7d3e4baaef..84de774d70 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpemoji/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpemoji/plugin.js @@ -56,18 +56,22 @@ } if ( isWin8 ) { - // Windows 8+ emoji can be "typed" with the onscreen keyboard. - // That triggers the normal keyboard events, but not the 'input' event. - // Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji. + /* + * Windows 8+ emoji can be "typed" with the onscreen keyboard. + * That triggers the normal keyboard events, but not the 'input' event. + * Thankfully it sets keyCode 231 when the onscreen keyboard inserts any emoji. + */ editor.on( 'keyup', function( event ) { if ( event.keyCode === 231 ) { parseNode( editor.selection.getNode() ); } } ); } else if ( ! isWin ) { - // In MacOS inserting emoji doesn't trigger the stanradr keyboard events. - // Thankfully it triggers the 'input' event. - // This works in Android and iOS as well. + /* + * In MacOS inserting emoji doesn't trigger the stanradr keyboard events. + * Thankfully it triggers the 'input' event. + * This works in Android and iOS as well. + */ editor.on( 'keydown keyup', function( event ) { typing = ( event.type === 'keydown' ); } ); diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpgallery/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpgallery/plugin.js index d9723f2db5..54245efaa5 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpgallery/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpgallery/plugin.js @@ -57,7 +57,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { } } - // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'); + // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'). editor.addCommand( 'WP_Gallery', function() { editMedia( editor.selection.getNode() ); }); @@ -71,7 +71,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { } if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) { - // Don't trigger on right-click + // Don't trigger on right-click. if ( event.button !== 2 ) { if ( dom.hasClass( node, 'wp-media-selected' ) ) { editMedia( node ); @@ -85,7 +85,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { } }); - // Display gallery, audio or video instead of img in the element path + // Display gallery, audio or video instead of img in the element path. editor.on( 'ResolveName', function( event ) { var dom = editor.dom, node = event.target; @@ -98,7 +98,7 @@ tinymce.PluginManager.add('wpgallery', function( editor ) { }); editor.on( 'BeforeSetContent', function( event ) { - // 'wpview' handles the gallery shortcode when present + // 'wpview' handles the gallery shortcode when present. if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) { event.content = replaceGalleryShortcodes( event.content ); } diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js index 890ebe86c2..29f98a128f 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wplink/plugin.js @@ -37,9 +37,9 @@ url = this.url; } - // If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with ... + // If the URL is longer that 40 chars, concatenate the beginning (after the domain) and ending with '...'. if ( url.length > 40 && ( index = url.indexOf( '/' ) ) !== -1 && ( lastIndex = url.lastIndexOf( '/' ) ) !== -1 && lastIndex !== index ) { - // If the beginning + ending are shorter that 40 chars, show more of the ending + // If the beginning + ending are shorter that 40 chars, show more of the ending. if ( index + url.length - lastIndex < 40 ) { lastIndex = -( 40 - ( index + 1 ) ); } @@ -297,10 +297,10 @@ editor.execCommand( 'wp_link_cancel' ); } ); - // WP default shortcuts + // WP default shortcuts. editor.addShortcut( 'access+a', '', 'WP_Link' ); editor.addShortcut( 'access+s', '', 'wp_unlink' ); - // The "de-facto standard" shortcut, see #27305 + // The "de-facto standard" shortcut, see #27305. editor.addShortcut( 'meta+k', '', 'WP_Link' ); editor.addButton( 'link', { @@ -565,7 +565,7 @@ } ); editor.addButton( 'wp_link_edit', { - tooltip: 'Edit|button', // '|button' is not displayed, only used for context + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', cmd: 'WP_Link' } ); diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wptextpattern/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wptextpattern/plugin.js index 236775034c..a11515acb1 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wptextpattern/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wptextpattern/plugin.js @@ -149,9 +149,9 @@ var before = string.charAt( startOffset - 1 ); var after = string.charAt( startOffset + p.delimiter.length ); - // test*test* => format applied - // test *test* => applied - // test* test* => not applied + // test*test* => format applied. + // test *test* => applied. + // test* test* => not applied. if ( startOffset && /\S/.test( before ) ) { if ( /\s/.test( after ) || before === delimiterFirstChar ) { return; diff --git a/src/js/_enqueues/vendor/tinymce/plugins/wpview/plugin.js b/src/js/_enqueues/vendor/tinymce/plugins/wpview/plugin.js index 573ecb4167..1c21854786 100644 --- a/src/js/_enqueues/vendor/tinymce/plugins/wpview/plugin.js +++ b/src/js/_enqueues/vendor/tinymce/plugins/wpview/plugin.js @@ -52,7 +52,7 @@ var className = editor.getBody().className; editor.$( 'iframe[class="wpview-sandbox"]' ).each( function( i, iframe ) { - // Make sure it is a local iframe + // Make sure it is a local iframe. // jshint scripturl: true if ( ! iframe.src || iframe.src === 'javascript:""' ) { try { @@ -79,11 +79,11 @@ node = editor.selection.getNode(); if ( node && node !== editor.getBody() && /^\s*https?:\/\/\S+\s*$/i.test( event.content ) ) { - // When a url is pasted or inserted, only try to embed it when it is in an empty paragrapgh. + // When a url is pasted or inserted, only try to embed it when it is in an empty paragraph. node = editor.dom.getParent( node, 'p' ); if ( node && /^[\s\uFEFF\u00A0]*$/.test( editor.$( node ).text() || '' ) ) { - // Make sure there are no empty inline elements in the <p> + // Make sure there are no empty inline elements in the <p>. node.innerHTML = ''; } else { return; @@ -178,7 +178,7 @@ } ); editor.addButton( 'wp_view_edit', { - tooltip: 'Edit|button', // '|button' is not displayed, only used for context + tooltip: 'Edit|button', // '|button' is not displayed, only used for context. icon: 'dashicon dashicons-edit', onclick: function() { var node = editor.selection.getNode(); diff --git a/src/js/_enqueues/vendor/tinymce/wp-tinymce.php b/src/js/_enqueues/vendor/tinymce/wp-tinymce.php index 3d7b2347f6..213e9327b5 100644 --- a/src/js/_enqueues/vendor/tinymce/wp-tinymce.php +++ b/src/js/_enqueues/vendor/tinymce/wp-tinymce.php @@ -26,10 +26,10 @@ function get_file( $path ) { return @file_get_contents( $path ); } -$expires_offset = 31536000; // 1 year +$expires_offset = 31536000; // 1 year. header( 'Content-Type: application/javascript; charset=UTF-8' ); -header( 'Vary: Accept-Encoding' ); // Handle proxies +header( 'Vary: Accept-Encoding' ); // Handle proxies. header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expires_offset ) . ' GMT' ); header( "Cache-Control: public, max-age=$expires_offset" ); diff --git a/src/js/_enqueues/wp/api-request.js b/src/js/_enqueues/wp/api-request.js index 3ed1c68695..51df7f6f64 100644 --- a/src/js/_enqueues/wp/api-request.js +++ b/src/js/_enqueues/wp/api-request.js @@ -8,7 +8,7 @@ * - Sends the REST API nonce as a request header. * - Allows specifying only an endpoint namespace/path instead of a full URL. * - * @since 4.9.0 + * @since 4.9.0 * @output wp-includes/js/api-request.js */ @@ -42,8 +42,8 @@ apiRoot = wpApiSettings.root; path = path.replace( /^\//, '' ); - // API root may already include query parameter prefix if site is - // configured to use plain permalinks. + // API root may already include query parameter prefix + // if site is configured to use plain permalinks. if ( 'string' === typeof apiRoot && -1 !== apiRoot.indexOf( '?' ) ) { path = path.replace( '?', '&' ); } diff --git a/src/js/_enqueues/wp/api.js b/src/js/_enqueues/wp/api.js index cbd3d4bc6b..8233e4a52c 100644 --- a/src/js/_enqueues/wp/api.js +++ b/src/js/_enqueues/wp/api.js @@ -107,9 +107,11 @@ minutesOffset = 0, numericKeys = [ 1, 4, 5, 6, 7, 10, 11 ]; - // ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string - // before falling back to any implementation-specific date parsing, so that’s what we do, even if native - // implementations could be faster. + /* + * ES5 §15.9.4.2 states that the string should attempt to be parsed as a Date Time String Format string + * before falling back to any implementation-specific date parsing, so that’s what we do, even if native + * implementations could be faster. + */ // 1 YYYY 2 MM 3 DD 4 HH 5 mm 6 ss 7 msec 8 Z 9 ± 10 tzHH 11 tzmm if ( ( struct = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec( date ) ) ) { @@ -855,7 +857,7 @@ if ( _.isFunction( model.nonce ) && ! _.isEmpty( model.nonce() ) ) { beforeSend = options.beforeSend; - // @todo enable option for jsonp endpoints + // @todo Enable option for jsonp endpoints. // options.dataType = 'jsonp'; // Include the nonce with requests. @@ -1340,7 +1342,7 @@ } ); } else { - // This is a model without a parent in its route + // This is a model without a parent in its route. modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName ); modelClassName = mapping.models[ modelClassName ] || modelClassName; loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( { @@ -1514,7 +1516,7 @@ if ( ! initializedDeferreds[ attributes.apiRoot + attributes.versionString ] ) { - // Look for an existing copy of this endpoint + // Look for an existing copy of this endpoint. endpoint = wp.api.endpoints.findWhere( { 'apiRoot': attributes.apiRoot, 'versionString': attributes.versionString } ); if ( ! endpoint ) { endpoint = new Endpoint( attributes ); diff --git a/src/js/_enqueues/wp/autosave.js b/src/js/_enqueues/wp/autosave.js index a96ea97bf9..33c7e2d3b6 100644 --- a/src/js/_enqueues/wp/autosave.js +++ b/src/js/_enqueues/wp/autosave.js @@ -3,7 +3,7 @@ */ /* global tinymce, wpCookies, autosaveL10n, switchEditors */ -// Back-compat +// Back-compat. window.autosave = function() { return true; }; @@ -209,7 +209,7 @@ window.autosave = function() { */ function getStorage() { var stored_obj = false; - // Separate local storage containers for each blog_id + // Separate local storage containers for each blog_id. if ( hasStorage && blog_id ) { stored_obj = sessionStorage.getItem( 'wp-autosave-' + blog_id ); @@ -314,7 +314,7 @@ window.autosave = function() { /** * Saves post data for the current post. * - * Runs on a 15 sec. interval, saves when there are differences in the post title or content. + * Runs on a 15 seconds interval, saves when there are differences in the post title or content. * When the optional data is provided, updates the last saved post data. * * @since 3.9.0 @@ -378,9 +378,11 @@ window.autosave = function() { // Check if the local post data is different than the loaded post data. if ( $( '#wp-content-wrap' ).hasClass( 'tmce-active' ) ) { - // If TinyMCE loads first, check the post 1.5 sec. after it is ready. - // By this time the content has been loaded in the editor and 'saved' to the textarea. - // This prevents false positives. + /* + * If TinyMCE loads first, check the post 1.5 seconds after it is ready. + * By this time the content has been loaded in the editor and 'saved' to the textarea. + * This prevents false positives. + */ $document.on( 'tinymce-editor-init.autosave', function() { window.setTimeout( function() { checkPost(); @@ -390,7 +392,7 @@ window.autosave = function() { checkPost(); } - // Save every 15 sec. + // Save every 15 seconds. intervalTimer = window.setInterval( save, 15000 ); $( 'form#post' ).on( 'submit.autosave-local', function() { @@ -456,7 +458,7 @@ window.autosave = function() { if ( cookie === post_id + '-saved' ) { wpCookies.remove( 'wp-saving-post' ); - // The post was saved properly, remove old data and bail + // The post was saved properly, remove old data and bail. setData( false ); return; } @@ -519,7 +521,7 @@ window.autosave = function() { var editor; if ( postData ) { - // Set the last saved data + // Set the last saved data. lastCompareString = getCompareString( postData ); if ( $( '#title' ).val() !== postData.post_title ) { @@ -534,14 +536,14 @@ window.autosave = function() { postData.content = switchEditors.wpautop( postData.content ); } - // Make sure there's an undo level in the editor + // Make sure there's an undo level in the editor. editor.undoManager.transact( function() { editor.setContent( postData.content || '' ); editor.nodeChanged(); }); } else { - // Make sure the Text editor is selected + // Make sure the Text editor is selected. $( '#content-html' ).click(); $( '#content' ).focus(); @@ -558,9 +560,11 @@ window.autosave = function() { blog_id = typeof window.autosaveL10n !== 'undefined' && window.autosaveL10n.blog_id; - // Check if the browser supports sessionStorage and it's not disabled, - // then initialize and run checkPost(). - // Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'. + /* + * Check if the browser supports sessionStorage and it's not disabled, + * then initialize and run checkPost(). + * Don't run if the post type supports neither 'editor' (textarea#content) nor 'excerpt'. + */ if ( checkStorage() && blog_id && ( $('#content').length || $('#excerpt').length ) ) { $document.ready( run ); } @@ -652,7 +656,7 @@ window.autosave = function() { enableButtons(); if ( data.success ) { - // No longer an auto-draft + // No longer an auto-draft. $( '#auto_draft' ).val(''); } } @@ -698,7 +702,7 @@ window.autosave = function() { function save() { var postData, compareString; - // window.autosave() used for back-compat + // window.autosave() used for back-compat. if ( isSuspended || _blockSave || ! window.autosave() ) { return false; } @@ -710,12 +714,12 @@ window.autosave = function() { postData = getPostData(); compareString = getCompareString( postData ); - // First check + // First check. if ( typeof lastCompareString === 'undefined' ) { lastCompareString = initialCompareString; } - // No change + // No change. if ( compareString === lastCompareString ) { return false; } @@ -836,7 +840,7 @@ window.autosave = function() { } }).ready( function() { - // Set the initial compare string in case TinyMCE is not used or not loaded first + // Set the initial compare string in case TinyMCE is not used or not loaded first. initialCompareString = getCompareString(); }); diff --git a/src/js/_enqueues/wp/code-editor.js b/src/js/_enqueues/wp/code-editor.js index 15906ff55b..dd0feca956 100644 --- a/src/js/_enqueues/wp/code-editor.js +++ b/src/js/_enqueues/wp/code-editor.js @@ -79,7 +79,11 @@ if ( 'undefined' === typeof window.wp.codeEditor ) { 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 ) { options.options = {}; } diff --git a/src/js/_enqueues/wp/custom-header.js b/src/js/_enqueues/wp/custom-header.js index 1c405990de..1f2c56f96e 100644 --- a/src/js/_enqueues/wp/custom-header.js +++ b/src/js/_enqueues/wp/custom-header.js @@ -79,7 +79,7 @@ * @return {boolean} */ supportsVideo: function() { - // Don't load video on small screens. @todo: consider bandwidth and other factors. + // Don't load video on small screens. @todo Consider bandwidth and other factors. if ( window.innerWidth < settings.minWidth || window.innerHeight < settings.minHeight ) { return false; } diff --git a/src/js/_enqueues/wp/customize/base.js b/src/js/_enqueues/wp/customize/base.js index 183b731ace..1d38d9b0dc 100644 --- a/src/js/_enqueues/wp/customize/base.js +++ b/src/js/_enqueues/wp/customize/base.js @@ -25,17 +25,21 @@ window.wp = window.wp || {}; inherits = function( parent, protoProps, staticProps ) { var child; - // The constructor function for the new subclass is either defined by you - // (the "constructor" property in your `extend` definition), or defaulted - // by us to simply call `super()`. + /* + * The constructor function for the new subclass is either defined by you + * (the "constructor" property in your `extend` definition), or defaulted + * by us to simply call `super()`. + */ if ( protoProps && protoProps.hasOwnProperty( 'constructor' ) ) { child = protoProps.constructor; } else { child = function() { - // Storing the result `super()` before returning the value - // prevents a bug in Opera where, if the constructor returns - // a function, Opera will reject the return value in favor of - // the original object. This causes all sorts of trouble. + /* + * Storing the result `super()` before returning the value + * prevents a bug in Opera where, if the constructor returns + * a function, Opera will reject the return value in favor of + * the original object. This causes all sorts of trouble. + */ var result = parent.apply( this, arguments ); return result; }; @@ -44,8 +48,8 @@ window.wp = window.wp || {}; // Inherit class (static) properties from parent. $.extend( child, parent ); - // Set the prototype chain to inherit from `parent`, without calling - // `parent`'s constructor function. + // Set the prototype chain to inherit from `parent`, + // without calling `parent`'s constructor function. ctor.prototype = parent.prototype; child.prototype = new ctor(); @@ -187,7 +191,7 @@ window.wp = window.wp || {}; * @param {object} options */ initialize: function( initial, options ) { - this._value = initial; // @todo: potentially change this to a this.set() call. + this._value = initial; // @todo Potentially change this to a this.set() call. this.callbacks = $.Callbacks(); this._dirty = false; @@ -496,7 +500,7 @@ window.wp = window.wp || {}; ids = slice.call( arguments ), dfd = $.Deferred(); - // If the last argument is a callback, bind it to .done() + // If the last argument is a callback, bind it to .done(). if ( $.isFunction( ids[ ids.length - 1 ] ) ) { dfd.done( ids.pop() ); } @@ -699,7 +703,7 @@ window.wp = window.wp || {}; return urlParser.protocol + '//' + urlParser.host.replace( /:(80|443)$/, '' ); }); - // first add with no value + // First add with no value. this.add( 'targetWindow', null ); // This avoids SecurityErrors when setting a window object in x-origin iframe'd scenarios. this.targetWindow.set = function( to ) { @@ -719,15 +723,17 @@ window.wp = window.wp || {}; return this; }; - // now set it + // Now set it. this.targetWindow( params.targetWindow || defaultTarget ); - // Since we want jQuery to treat the receive function as unique - // to this instance, we give the function a new guid. - // - // This will prevent every Messenger's receive function from being - // unbound when calling $.off( 'message', this.receive ); + /* + * Since we want jQuery to treat the receive function as unique + * to this instance, we give the function a new guid. + * + * This will prevent every Messenger's receive function from being + * unbound when calling $.off( 'message', this.receive ); + */ this.receive = $.proxy( this.receive, this ); this.receive.guid = $.guid++; diff --git a/src/js/_enqueues/wp/customize/controls.js b/src/js/_enqueues/wp/customize/controls.js index 6c92362410..8b8c1fd67e 100644 --- a/src/js/_enqueues/wp/customize/controls.js +++ b/src/js/_enqueues/wp/customize/controls.js @@ -578,7 +578,8 @@ 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 ) { return deferred.reject( { code: 'illegal_status_in_changeset_update' } ).promise(); } @@ -772,13 +773,13 @@ */ api.utils.areElementListsEqual = function ( listA, listB ) { var 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? - _.zip( listA, listB ), // pair up each element between the two lists + 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? + _.zip( listA, listB ), // Pair up each element between the two lists. 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; }; @@ -1128,7 +1129,8 @@ } 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 ); if ( args.completeCallback ) { args.completeCallback(); @@ -1479,7 +1481,7 @@ }); } ); } 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 ); if ( ! section.headContainer.parent().is( parentContainer ) ) { parentContainer.append( section.headContainer ); @@ -1511,7 +1513,7 @@ if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. if ( section.expanded() ) { section.collapse(); @@ -1718,12 +1720,12 @@ var inject, section = this; - // Watch for changes to the panel state + // Watch for changes to the panel state. inject = function( panelId ) { var parentContainer; 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() { parentContainer = panel.contentContainer; if ( ! section.headContainer.parent().is( parentContainer ) ) { @@ -1737,7 +1739,7 @@ } ); }; 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; } - // Pressing the right arrow key fires a theme:next event + // Pressing the right arrow key fires a theme:next event. if ( 39 === event.keyCode ) { 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 ) { 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 ( section.$body.hasClass( 'modal-open' ) ) { @@ -1818,7 +1820,7 @@ if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. section.collapse(); }); @@ -1957,11 +1959,11 @@ */ onChangeExpanded: function ( expanded, args ) { - // Note: there is a second argument 'args' passed + // Note: there is a second argument 'args' passed. var section = this, 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.completeCallback ) { args.completeCallback(); @@ -1976,7 +1978,7 @@ section.loadThemes(); } - // Collapse any sibling sections/panels + // Collapse any sibling sections/panels. api.section.each( function ( otherSection ) { var searchTerm; @@ -2123,7 +2125,8 @@ _.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; } } else { @@ -2202,7 +2205,9 @@ container = section.container.closest( '.customize-themes-full-container' ); 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 ) { section.loadThemes(); @@ -2614,15 +2619,15 @@ el.on( 'keydown', function( event ) { // 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 ) { return; } - // uses jQuery UI to get the tabbable elements + // Uses jQuery UI to get the tabbable elements. tabbables = $( ':tabbable', el ); - // Keep focus within the overlay + // Keep focus within the overlay. if ( tabbables.last()[0] === event.target && ! event.shiftKey ) { tabbables.first().focus(); return false; @@ -2797,7 +2802,7 @@ embed: function () { var panel = this, 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 ) ) { parentContainer.append( panel.headContainer ); @@ -2821,7 +2826,7 @@ if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. if ( ! panel.expanded() ) { panel.expand(); @@ -2833,7 +2838,7 @@ if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; } - event.preventDefault(); // Keep this AFTER the key filter above + event.preventDefault(); // Keep this AFTER the key filter above. if ( panel.expanded() ) { panel.collapse(); @@ -2908,7 +2913,7 @@ */ 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.completeCallback ) { args.completeCallback(); @@ -2916,7 +2921,7 @@ return; } - // Note: there is a second argument 'args' passed + // Note: there is a second argument 'args' passed. var panel = this, accordionSection = panel.contentContainer, overlay = accordionSection.closest( '.wp-full-overlay' ), @@ -2927,7 +2932,7 @@ skipTransition; if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) { - // Collapse any sibling sections/panels + // Collapse any sibling sections/panels. api.section.each( function ( section ) { if ( panel.id !== section.panel() ) { section.collapse( { duration: 0 } ); @@ -3067,7 +3072,7 @@ // Attach regular panel events. 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 ) { panel.notifications.add( new api.Notification( 'theme_install_unavailable', { message: api.l10n.themeInstallUnavailable, @@ -3140,7 +3145,7 @@ // Expand/collapse the panel normally. 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.completeCallback ) { args.completeCallback(); @@ -3682,15 +3687,15 @@ var control = this, inject; - // Watch for changes to the section state + // Watch for changes to the section state. inject = function ( sectionId ) { 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; } - // Wait for the section to be registered + // Wait for the section to be registered. 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 () { parentContainer = ( section.contentContainer.is( 'ul' ) ) ? section.contentContainer : section.contentContainer.find( 'ul:first' ); if ( ! control.container.parent().is( parentContainer ) ) { @@ -3724,7 +3729,7 @@ control.addNewPage(); }); control.container.on( 'keydown', '.create-item-input', function( e ) { - if ( 13 === e.which ) { // Enter + if ( 13 === e.which ) { // Enter. control.addNewPage(); } }); @@ -3909,7 +3914,7 @@ } 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 ); if ( 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 ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; @@ -3973,7 +3978,7 @@ 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; setTimeout(function () { toggleFreeze = false; @@ -4017,7 +4022,8 @@ 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' && _.contains( standardTypes, control.params.type ) && ! document.getElementById( 'tmpl-' + templateId ) && @@ -4047,6 +4053,7 @@ * * @since 4.7.0 * @access private + * * @return {void} */ addNewPage: function () { @@ -4070,7 +4077,8 @@ input.removeClass( 'invalid' ); 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( { post_title: title, post_type: 'page' @@ -4199,7 +4207,7 @@ control.container.on( 'click keydown', '.remove-button', control.removeFile ); 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 .on( 'expanded', function() { if ( control.player ) { @@ -5128,7 +5136,7 @@ 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.showDetails( control.params.theme, function() { @@ -5196,7 +5204,7 @@ control.params.priority = 101 - matchCount; // Sort results by match count. return true; } else { - control.deactivate(); // Hide control + control.deactivate(); // Hide control. control.params.priority = 101; return false; } @@ -6498,13 +6506,15 @@ urlParser.href = previewer.origin(); previewer.add( 'scheme', urlParser.protocol.replace( /:$/, '' ) ); - // 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 - // insecure content warnings. This is not attempted if the admin and front end - // are on different domains to avoid the case where the front end doesn't have - // ssl certs. + /* + * 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 + * insecure content warnings. This is not attempted if the admin and front end + * 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 ) { var result = null, urlParser, queryParams, parsedAllowedUrl, parsedCandidateUrls = []; @@ -6735,12 +6745,13 @@ * * @since 3.4.0 * @access public + * * @return {void} */ refresh: function() { var previewer = this, onSettingChange; - // Display loading indicator + // Display loading indicator. previewer.send( 'loading-initiated' ); previewer.abort(); @@ -7013,7 +7024,7 @@ activeElement = $( document.activeElement ); } - // Sort the sections within each panel + // Sort the sections within each panel. api.panel.each( function ( panel ) { if ( 'themes' === panel.id ) { 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 ) { var controls = section.controls(), 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 ); 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() ) ) { _( rootNodes ).each( function ( rootNode ) { appendContainer.append( rootNode.headContainer ); @@ -7058,7 +7069,7 @@ 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 ) { var value = panel.active(); panel.active.callbacks.fireWith( panel.active, [ value, value ] ); @@ -7068,7 +7079,7 @@ 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 ) { activeElement.focus(); } @@ -7208,9 +7219,11 @@ cancelScheduleButtonReminder = api.utils.highlightButton( btnWrapper, { delay: 1000, - // Only abort the reminder when the save button is focused. - // If the user clicks the settings button to toggle the - // settings closed, we'll still remind them. + /* + * Only abort the reminder when the save button is focused. + * If the user clicks the settings button to toggle the + * settings closed, we'll still remind them. + */ focusTarget: saveBtn } ); } @@ -7579,7 +7592,7 @@ if ( '0' === response ) { response = 'not_logged_in'; } 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'; } @@ -7812,7 +7825,7 @@ api.previewer.send( 'nonce-refresh', nonce ); }); - // Create Settings + // Create Settings. $.each( api.settings.settings, function( id, data ) { var Constructor = api.settingConstructor[ data.type ] || api.Setting; api.add( new Constructor( id, data.value, { @@ -7822,28 +7835,31 @@ } ) ); }); - // Create Panels + // Create Panels. $.each( api.settings.panels, function ( id, data ) { 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 ) ); }); - // Create Sections + // Create Sections. $.each( api.settings.sections, function ( id, data ) { 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 ) ); }); - // Create Controls + // Create Controls. $.each( api.settings.controls, function( id, data ) { 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 ) ); }); - // Focus the autofocused element + // Focus the autofocused element. _.each( [ 'panel', 'section', 'control' ], function( type ) { var id = api.settings.autofocus[ type ]; if ( ! id ) { @@ -7896,7 +7912,7 @@ api.notifications.render(); }); - // Save and activated states + // Save and activated states. (function( state ) { var saved = state.instance( 'saved' ), 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' ); // Set the default device. @@ -8797,7 +8814,7 @@ api.state( 'selectedChangesetStatus' ).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() { if ( ! isCleanState() && ! api.state( 'changesetLocked' ).get() ) { setTimeout( function() { @@ -8882,7 +8899,7 @@ }); } ); - // Pass titles to the parent + // Pass titles to the parent. api.bind( 'title', function( newTitle ) { parent.send( 'title', newTitle ); }); @@ -8894,7 +8911,7 @@ // Initialize the connection with the parent frame. parent.send( 'ready' ); - // Control visibility for default controls + // Control visibility for default controls. $.each({ 'background_image': { controls: [ 'background_preset', 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], @@ -8926,7 +8943,7 @@ api.control( 'background_preset', function( control ) { var visibility, defaultValues, values, toggleVisibility, updateSettings, preset; - visibility = { // position, size, repeat, attachment + visibility = { // position, size, repeat, attachment. 'default': [ false, false, false, false ], 'fill': [ true, false, false, false ], 'fit': [ true, false, true, false ], @@ -8942,14 +8959,15 @@ _wpCustomizeBackground.defaults['default-attachment'] ]; - values = { // position_x, position_y, size, repeat, attachment + values = { // position_x, position_y, size, repeat, attachment. 'default': defaultValues, 'fill': [ 'left', 'top', 'cover', 'no-repeat', 'fixed' ], 'fit': [ 'left', 'top', 'contain', 'no-repeat', 'fixed' ], '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 ) { _.each( [ 'background_position', 'background_size', 'background_repeat', 'background_attachment' ], function( controlId, i ) { 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 ) { var last = ''; diff --git a/src/js/_enqueues/wp/customize/loader.js b/src/js/_enqueues/wp/customize/loader.js index e27f1bc9c5..239d36824f 100644 --- a/src/js/_enqueues/wp/customize/loader.js +++ b/src/js/_enqueues/wp/customize/loader.js @@ -119,7 +119,7 @@ window.wp = window.wp || {}; return window.location = src; } - // Store the document title prior to opening the Live Preview + // Store the document title prior to opening the Live Preview. this.originalDocumentTitle = document.title; this.active = true; @@ -170,7 +170,7 @@ window.wp = window.wp || {}; } }); - // Prompt AYS dialog when navigating away + // Prompt AYS dialog when navigating away. $( window ).on( 'beforeunload', this.beforeunload ); this.messenger.bind( 'saved', function () { @@ -223,13 +223,13 @@ window.wp = window.wp || {}; self.active = false; self.trigger( 'close' ); - // Restore document title prior to opening the Live Preview + // Restore document title prior to opening the Live Preview. if ( self.originalDocumentTitle ) { document.title = self.originalDocumentTitle; } } else { - // Go forward since Customizer is exited by history.back() + // Go forward since Customizer is exited by history.back(). history.forward(); } self.messenger.unbind( 'confirmed-close', onConfirmClose ); @@ -286,6 +286,6 @@ window.wp = window.wp || {}; Loader.initialize(); }); - // Expose the API publicly on window.wp.customize.Loader + // Expose the API publicly on window.wp.customize.Loader. api.Loader = Loader; })( wp, jQuery ); diff --git a/src/js/_enqueues/wp/customize/models.js b/src/js/_enqueues/wp/customize/models.js index f11b3d04b8..0a8bca7f47 100644 --- a/src/js/_enqueues/wp/customize/models.js +++ b/src/js/_enqueues/wp/customize/models.js @@ -53,8 +53,8 @@ var data = this.get('header'), curr = api.HeaderTool.currentHeader.get('header').attachment_id; - // If the image we're removing is also the current header, unset - // the latter + // If the image we're removing is also the current header, + // unset the latter. if (curr && data.attachment_id === curr) { api.HeaderTool.currentHeader.trigger('hide'); } @@ -142,7 +142,7 @@ api.HeaderTool.ChoiceList = Backbone.Collection.extend({ model: api.HeaderTool.ImageModel, - // Ordered from most recently used to least + // Ordered from most recently used to least. comparator: function(model) { return -model.get('header').timestamp; }, @@ -151,18 +151,18 @@ var current = api.HeaderTool.currentHeader.get('choice').replace(/^https?:\/\//, ''), isRandom = this.isRandomChoice(api.get().header_image); - // Overridable by an extending class + // Overridable by an extending class. if (!this.type) { this.type = 'uploaded'; } - // Overridable by an extending class + // Overridable by an extending class. if (typeof this.data === 'undefined') { this.data = _wpCustomizeHeader.uploads; } if (isRandom) { - // So that when adding data we don't hide regular images + // So that when adding data we don't hide regular images. current = api.get().header_image; } diff --git a/src/js/_enqueues/wp/customize/nav-menus.js b/src/js/_enqueues/wp/customize/nav-menus.js index 309785d54c..7ca17acbe1 100644 --- a/src/js/_enqueues/wp/customize/nav-menus.js +++ b/src/js/_enqueues/wp/customize/nav-menus.js @@ -203,9 +203,11 @@ _.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 - // available menu items panel. Also close on back button click. + /* + * If the available menu items panel is open and the customize controls + * 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 ) { var isDeleteBtn = $( e.target ).is( '.item-delete, .item-delete *' ), 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 ); self.delegateEvents(); @@ -496,7 +498,7 @@ // Submit handler for keypress and click on menu item. _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 ) ) { return; } @@ -717,7 +719,7 @@ this.$search.focus(); }, - // Closes the panel + // Closes the panel. close: function( options ) { options = options || {}; @@ -741,7 +743,7 @@ isBackTab = ( 9 === event.which && event.shiftKey ), 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() ) { return; } @@ -781,7 +783,7 @@ } event.preventDefault(); - // Hide description + // Hide description. if ( content.not( ':hidden' ) ) { content.slideUp( 'fast' ); help.attr( 'aria-expanded', 'false' ); @@ -802,7 +804,7 @@ return false; } ); - // Help toggle + // Help toggle. help.on( 'click keydown', function( event ) { if ( api.utils.isKeydownButNotEnterEvent( event ) ) { return; @@ -1062,7 +1064,7 @@ menuAutoAddControl.active.set( true ); } - // Add the control for deleting the menu + // Add the control for deleting the menu. menuDeleteControlId = section.id + '[delete]'; menuDeleteControl = api.control( menuDeleteControlId ); if ( ! menuDeleteControl ) { @@ -1126,7 +1128,7 @@ wpNavMenu.menuList = section.contentContainer; wpNavMenu.targetList = wpNavMenu.menuList; - // Add attributes needed by wpNavMenu + // Add attributes needed by wpNavMenu. $( '#menu-to-edit' ).removeAttr( 'id' ); wpNavMenu.menuList.attr( 'id', 'menu-to-edit' ).addClass( 'menu' ); @@ -1145,7 +1147,8 @@ wpNavMenu.initSortables(); // Depends on menu-to-edit ID being set above. 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(); } if ( _.isFunction( completeCallback ) ) { @@ -1415,7 +1418,7 @@ navMenuLocationSetting = api( 'nav_menu_locations[' + checkbox.data( 'location-id' ) + ']' ); navMenuLocationSetting.set( menuSection.params.menu_id ); - // Reset state for next new menu + // Reset state for next new menu. checkbox.prop( 'checked', false ); } } ); @@ -1698,7 +1701,8 @@ 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.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 ) { element.bind(function( value ) { @@ -1790,7 +1794,7 @@ $removeBtn = control.container.find( '.item-delete' ); $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; if ( ! $( 'body' ).hasClass( 'adding-menu-items' ) ) { @@ -1811,7 +1815,7 @@ control.container.slideUp( function() { control.setting.set( false ); wp.a11y.speak( api.Menus.data.l10n.itemDeleted ); - $adjacentFocusTarget.focus(); // keyboard accessibility + $adjacentFocusTarget.focus(); // Keyboard accessibility. } ); control.setting.set( false ); @@ -2778,13 +2782,13 @@ action = sectionTitle.find( '.customize-action' ), name = displayNavMenuName( menu.name ); - // Update the control title + // Update the control title. controlTitle.text( name ); if ( location.length ) { location.appendTo( controlTitle ); } - // Update the section title + // Update the section title. sectionTitle.text( name ); if ( action.length ) { action.prependTo( sectionTitle ); @@ -2981,7 +2985,7 @@ position: position } ); - delete item.id; // only used by Backbone + delete item.id; // Only used by Backbone. placeholderId = api.Menus.generatePlaceholderAutoIncrementId(); customizeId = 'nav_menu_item[' + String( placeholderId ) + ']'; diff --git a/src/js/_enqueues/wp/customize/preview-widgets.js b/src/js/_enqueues/wp/customize/preview-widgets.js index f46456b28f..e00982d963 100644 --- a/src/js/_enqueues/wp/customize/preview-widgets.js +++ b/src/js/_enqueues/wp/customize/preview-widgets.js @@ -672,7 +672,7 @@ wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function( self.preview.send( 'highlight-widget-control', $( this ).prop( 'id' ) ); }); - // Open expand the widget control when shift+clicking the widget element + // Open expand the widget control when shift+clicking the widget element. $( document ).on( 'click', selector, function( e ) { if ( ! e.shiftKey ) { return; diff --git a/src/js/_enqueues/wp/customize/preview.js b/src/js/_enqueues/wp/customize/preview.js index 12c641c080..9e048dd0f6 100644 --- a/src/js/_enqueues/wp/customize/preview.js +++ b/src/js/_enqueues/wp/customize/preview.js @@ -232,8 +232,8 @@ * * @since 4.7.0 * @access protected - * * @access private + * * @return {void} */ api.addLinkPreviewing = function addLinkPreviewing() { @@ -337,7 +337,7 @@ api.prepareLinkPreview = function prepareLinkPreview( element ) { var queryParams, $element = $( element ); - // Skip elements with no href attribute. Check first to avoid more expensive checks down the road + // Skip elements with no href attribute. Check first to avoid more expensive checks down the road. if ( ! element.hasAttribute( 'href' ) ) { return; } @@ -357,7 +357,7 @@ element.protocol = 'https:'; } - // Ignore links with class wp-playlist-caption + // Ignore links with class wp-playlist-caption. if ( $element.hasClass( 'wp-playlist-caption' ) ) { return; } diff --git a/src/js/_enqueues/wp/customize/selective-refresh.js b/src/js/_enqueues/wp/customize/selective-refresh.js index ae9f9ffaf2..9fee9690d0 100644 --- a/src/js/_enqueues/wp/customize/selective-refresh.js +++ b/src/js/_enqueues/wp/customize/selective-refresh.js @@ -442,7 +442,7 @@ wp.customize.selectiveRefresh = ( function( $, api ) { if ( partial.params.containerInclusive ) { - // Note that content may be an empty string, and in this case jQuery will just remove the oldContainer + // Note that content may be an empty string, and in this case jQuery will just remove the oldContainer. newContainerElement = $( content ); // Merge the new context on top of the old context. diff --git a/src/js/_enqueues/wp/customize/widgets.js b/src/js/_enqueues/wp/customize/widgets.js index a2b800db72..8738c13b73 100644 --- a/src/js/_enqueues/wp/customize/widgets.js +++ b/src/js/_enqueues/wp/customize/widgets.js @@ -17,7 +17,7 @@ api.Widgets = api.Widgets || {}; api.Widgets.savedWidgetIds = {}; - // Link settings + // Link settings. api.Widgets.data = _wpCustomizeWidgetsSettings || {}; l10n = api.Widgets.data.l10n; @@ -59,16 +59,16 @@ model: api.Widgets.WidgetModel, // Controls searching on the current widget collection - // and triggers an update event + // and triggers an update event. doSearch: function( value ) { - // Don't do anything if we've already done this search - // Useful because the search handler fires multiple times per keystroke + // Don't do anything if we've already done this search. + // Useful because the search handler fires multiple times per keystroke. if ( this.terms === value ) { return; } - // Updates terms with the value passed + // Updates terms with the value passed. this.terms = value; // 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 search: function( term ) { var match, haystack; - // Escape the term string for RegExp meta characters + // Escape the term string for RegExp meta characters. term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' ); // 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, ')(?=.*' ); match = new RegExp( '^(?=.*' + term + ').+', 'i' ); @@ -150,10 +150,10 @@ 'keydown' : 'keyboardAccessible' }, - // Cache current selected widget + // Cache current selected widget. selected: null, - // Cache sidebar control which has opened panel + // Cache sidebar control which has opened panel. currentSidebarControl: null, $search: null, $clearResults: null, @@ -181,9 +181,11 @@ // Set the initial search count to the number of available widgets. 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 - // available widgets panel. Also close on back button click. + /* + * If the available widgets panel is open and the customize controls + * 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 ) { var isAddNewBtn = $( e.target ).is( '.add-new-widget, .add-new-widget *' ); if ( $( 'body' ).hasClass( 'adding-widget' ) && ! isAddNewBtn ) { @@ -197,7 +199,7 @@ 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 ); }, @@ -213,19 +215,19 @@ // Announce how many search results. 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' ) ) { this.selected.removeClass( 'selected' ); 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 ) { this.selected.removeClass( 'selected' ); 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 ) { firstVisible = this.$el.find( '> .widget-tpl:visible:first' ); if ( firstVisible.length ) { @@ -301,7 +303,7 @@ * Handles submit for keypress and click on widget. */ _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 ) ) { return; } @@ -345,7 +347,7 @@ open: function( 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 ) { if ( control.params.is_wide ) { control.collapseForm(); @@ -360,7 +362,7 @@ this.$el.find( '.selected' ).removeClass( 'selected' ); - // Reset search + // Reset search. this.collection.doSearch( '' ); if ( ! api.settings.browser.mobile ) { @@ -428,7 +430,7 @@ 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() ) { return; } @@ -602,7 +604,7 @@ _setupModel: function() { 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() { api.Widgets.savedWidgetIds[self.params.widget_id] = true; }; @@ -613,7 +615,7 @@ this.isWidgetUpdating = false; this.liveUpdateMode = true; - // Update widget whenever model changes + // Update widget whenever model changes. this.setting.bind( function( to, from ) { if ( ! _( from ).isEqual( to ) && ! self.isWidgetUpdating ) { self.updateWidget( { instance: to } ); @@ -658,10 +660,10 @@ top; $widgetInside.css( 'max-height', windowHeight ); top = Math.max( - 0, // prevent top from going off screen + 0, // Prevent top from going off screen. Math.min( - Math.max( offsetTop, 0 ), // distance widget in panel is from top of screen - windowHeight - formHeight // flush up against bottom of screen + Math.max( offsetTop, 0 ), // Distance widget in panel is from top of screen. + windowHeight - formHeight // Flush up against bottom of screen. ) ); $widgetInside.css( 'top', top ); @@ -680,7 +682,7 @@ $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 ) { if ( 0 === setting.id.indexOf( 'sidebars_widgets[' ) ) { setting.bind( function() { @@ -711,7 +713,7 @@ $closeBtn = this.container.find( '.widget-control-close' ); $closeBtn.on( 'click', function() { 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 ); } - $( this ).focus(); // re-focus after the container was moved + $( this ).focus(); // Re-focus after the container was moved. } } ); @@ -886,12 +888,12 @@ _setupHighlightEffects: function() { 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() { 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() { self.setting.previewer.send( 'highlight-widget', self.params.widget_id ); } ); @@ -907,7 +909,7 @@ $widgetRoot = this.container.find( '.widget:first' ); $widgetContent = $widgetRoot.find( '.widget-content:first' ); - // Configure update button + // Configure update button. $saveBtn = this.container.find( '.widget-control-save' ); $saveBtn.val( l10n.saveBtnLabel ); $saveBtn.attr( 'title', l10n.saveBtnTooltip ); @@ -921,15 +923,15 @@ self.updateWidget(); }, 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 ) { - if ( 13 === e.which ) { // Enter + if ( 13 === e.which ) { // Enter. e.preventDefault(); self.updateWidget( { ignoreActiveElement: true } ); } } ); - // Handle widgets that support live previews + // Handle widgets that support live previews. $widgetContent.on( 'change input propertychange', ':input', function( e ) { if ( ! self.liveUpdateMode ) { 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() { self.container.removeClass( 'previewer-loading' ); } ); @@ -972,7 +974,7 @@ * @param {function} args.completeCallback */ 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 ); if ( args.completeCallback ) { args.completeCallback(); @@ -985,10 +987,10 @@ _setupRemoveUI: function() { var self = this, $removeBtn, replaceDeleteWithRemove; - // Configure remove button + // Configure remove button. $removeBtn = this.container.find( '.widget-control-remove' ); $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; if ( self.container.next().is( '.customize-control-widget_form' ) ) { $adjacentFocusTarget = self.container.next().find( '.widget-action:first' ); @@ -1015,12 +1017,12 @@ sidebarWidgetIds.splice( i, 1 ); sidebarsWidgetsControl.setting( sidebarWidgetIds ); - $adjacentFocusTarget.focus(); // keyboard accessibility + $adjacentFocusTarget.focus(); // Keyboard accessibility. } ); } ); 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 ); }; @@ -1105,7 +1107,7 @@ if ( ! $.isArray( state ) ) { state = []; } 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 ) { return String( value ); } ); @@ -1169,7 +1171,7 @@ $widgetRoot = this.container.find( '.widget:first' ); $widgetContent = $widgetRoot.find( '.widget-content:first' ); - // Remove a previous error message + // Remove a previous error message. $widgetContent.find( '.widget-error' ).remove(); this.container.addClass( 'widget-form-loading' ); @@ -1191,9 +1193,11 @@ data = $.param( params ); $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, - // then we do not need to touch the UI and mess up the user's ongoing editing. + /* + * 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, + * then we do not need to touch the UI and mess up the user's ongoing editing. + */ $inputs.each( function() { $( this ).data( 'state' + updateNumber, self._getInputState( this ) ); } ); @@ -1236,14 +1240,14 @@ $sanitizedInputs = self._getInputs( sanitizedForm ); 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 ) { self.liveUpdateMode = true; self.container.removeClass( 'widget-form-disabled' ); 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 ) { $inputs.each( function( i ) { var $input = $( this ), @@ -1262,13 +1266,13 @@ $( 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 ) { self.liveUpdateMode = false; self.container.find( 'input[name="savewidget"]' ).show(); isLiveUpdateAborted = true; - // Otherwise, replace existing form with the sanitized form + // Otherwise, replace existing form with the sanitized form. } else { $widgetContent.html( r.data.form ); @@ -1284,11 +1288,11 @@ */ isChanged = ! isLiveUpdateAborted && ! _( self.setting() ).isEqual( r.data.instance ); if ( isChanged ) { - self.isWidgetUpdating = true; // suppress triggering another updateWidget + self.isWidgetUpdating = true; // Suppress triggering another updateWidget. self.setting( r.data.instance ); self.isWidgetUpdating = false; } 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' ); } @@ -1296,7 +1300,7 @@ completeCallback.call( self, null, { noChange: ! isChanged, ajaxFinished: true } ); } } else { - // General error message + // General error message. message = l10n.error; if ( r.data && r.data.message ) { @@ -1406,7 +1410,7 @@ 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 ( expanded ) { api.Control.prototype.expand.call( self, { @@ -1422,7 +1426,7 @@ 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 ) { if ( self.params.type === otherControl.params.type && self !== otherControl ) { otherControl.collapse(); @@ -1535,7 +1539,7 @@ i = this.getWidgetSidebarPosition(); sidebarWidgetsSetting = this.getSidebarWidgetsControl().setting; - sidebarWidgetIds = Array.prototype.slice.call( sidebarWidgetsSetting() ); // clone + sidebarWidgetIds = Array.prototype.slice.call( sidebarWidgetsSetting() ); // Clone. adjacentWidgetId = sidebarWidgetIds[i + offset]; sidebarWidgetIds[i + offset] = this.params.widget_id; sidebarWidgetIds[i] = adjacentWidgetId; @@ -1558,7 +1562,7 @@ } if ( showOrHide ) { - // reset the selected sidebar + // Reset the selected sidebar. $moveWidgetArea.find( '.selected' ).removeClass( 'selected' ); $moveWidgetArea.find( 'li' ).filter( function() { @@ -1781,7 +1785,7 @@ 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 ) { var parsedWidgetId = parseWidgetId( newWidgetId ); @@ -1798,7 +1802,7 @@ return widgetFormControl; } ); - // Sort widget controls to their new positions + // Sort widget controls to their new positions. widgetFormControls.sort( function( a, b ) { var aIndex = _.indexOf( newWidgetIds, a.params.widget_id ), bIndex = _.indexOf( newWidgetIds, b.params.widget_id ); @@ -1811,25 +1815,26 @@ control.section( self.section() ); 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(); - // 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 ) { widgetFormControl.params.sidebar_id = self.params.sidebar_id; } ); - // Cleanup after widget removal + // Cleanup after widget removal. _( 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() { var removedControl, wasDraggedToAnotherSidebar, inactiveWidgets, removedIdBase, widget, isPresentInAnotherSidebar = false; - // Check if the widget is in another sidebar + // Check if the widget is in another sidebar. api.each( function( otherSetting ) { if ( otherSetting.id === self.setting.id || 0 !== otherSetting.id.indexOf( 'sidebars_widgets[' ) || otherSetting.id === 'sidebars_widgets[wp_inactive_widgets]' ) { return; @@ -1850,24 +1855,24 @@ 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] ); - // Delete any widget form controls for removed widgets + // Delete any widget form controls for removed widgets. if ( removedControl && ! wasDraggedToAnotherSidebar ) { api.control.remove( removedControl.id ); removedControl.container.remove(); } - // 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 + // 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. if ( api.Widgets.savedWidgetIds[removedWidgetId] ) { inactiveWidgets = api.value( 'sidebars_widgets[wp_inactive_widgets]' )().slice(); inactiveWidgets.push( removedWidgetId ); 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; widget = api.Widgets.availableWidgets.findWhere( { id_base: removedIdBase } ); if ( widget && ! widget.get( 'is_multi' ) ) { @@ -1916,9 +1921,9 @@ over: function() { var section = api.section( self.section.get() ); 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 () { - // @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 ) { if ( otherSection.container.find( '.customize-control-sidebar_widgets' ).length ) { otherSection.container.find( '.accordion-section-content:first' ).sortable( 'refreshPositions' ); @@ -2079,7 +2084,7 @@ return false; } - // Set up new multi widget + // Set up new multi widget. if ( widget.get( 'is_multi' ) && ! widgetNumber ) { widget.set( 'multi_number', widget.get( 'multi_number' ) + 1 ); widgetNumber = widget.get( 'multi_number' ); @@ -2091,7 +2096,7 @@ return m.replace( /__i__|%i%/g, widgetNumber ); } ); } 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 ); @@ -2101,7 +2106,7 @@ .addClass( 'customize-control-' + controlType ) .append( $widget ); - // Remove icon which is visible inside the panel + // Remove icon which is visible inside the panel. controlContainer.find( '> .widget-icon' ).remove(); if ( widget.get( 'is_multi' ) ) { @@ -2111,7 +2116,7 @@ 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' ); if ( widget.get( 'is_multi' ) ) { @@ -2119,7 +2124,7 @@ } 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 ); if ( ! isExistingWidget ) { settingArgs = { @@ -2127,7 +2132,7 @@ previewer: this.setting.previewer }; setting = api.create( settingId, settingId, '', settingArgs ); - setting.set( {} ); // mark dirty, changing from '' to {} + setting.set( {} ); // Mark dirty, changing from '' to {}. } controlConstructor = api.controlConstructor[controlType]; @@ -2147,7 +2152,7 @@ } ); 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 ) { if ( otherSetting.id === self.setting.id ) { return; @@ -2166,7 +2171,7 @@ } } ); - // Add widget to this sidebar + // Add widget to this sidebar. sidebarWidgets = this.setting().slice(); if ( -1 === _.indexOf( sidebarWidgets, 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, { widgets: api.Widgets.WidgetsPanel }); @@ -2201,15 +2206,15 @@ * Init Customizer for widgets. */ api.bind( 'ready', function() { - // Set up the widgets panel + // Set up the widgets panel. api.Widgets.availableWidgetsPanel = new api.Widgets.AvailableWidgetsPanelView({ collection: api.Widgets.availableWidgets }); - // Highlight widget control + // Highlight widget control. 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 ); } ); @@ -2247,7 +2252,7 @@ api.Widgets.getSidebarWidgetControlContainingWidget = function( widgetId ) { 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 ) { if ( control.params.type === 'sidebar_widgets' && -1 !== _.indexOf( control.setting(), widgetId ) ) { foundControl = control; @@ -2266,7 +2271,7 @@ api.Widgets.getWidgetFormControlForWidget = function( widgetId ) { var foundControl = null; - // @todo We can just use widgetIdToSettingId() here + // @todo We can just use widgetIdToSettingId() here. api.control.each( function( control ) { if ( control.params.type === 'widget_form' && control.params.widget_id === widgetId ) { foundControl = control; @@ -2343,7 +2348,7 @@ parsed.id_base = matches[1]; parsed.number = parseInt( matches[2], 10 ); } else { - // likely an old single widget + // Likely an old single widget. parsed.id_base = widgetId; } diff --git a/src/js/_enqueues/wp/editor/base.js b/src/js/_enqueues/wp/editor/base.js index 6159467b9c..602fad7355 100644 --- a/src/js/_enqueues/wp/editor/base.js +++ b/src/js/_enqueues/wp/editor/base.js @@ -112,7 +112,7 @@ window.wp = window.wp || {}; } if ( keepSelection ) { - // Save the selection + // Save the selection. addHTMLBookmarkInTextAreaContent( $textarea ); } @@ -131,7 +131,7 @@ window.wp = window.wp || {}; } if ( editor.getParam( 'wp_keep_scroll_position' ) ) { - // Restore the selection + // Restore the selection. focusHTMLBookmarkInVisualEditor( editor ); } } else { @@ -149,7 +149,8 @@ window.wp = window.wp || {}; } 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 ) { iframe = editor.iframeElement; editorHeight = iframe ? parseInt( iframe.style.height, 10 ) : 0; @@ -177,7 +178,8 @@ window.wp = window.wp || {}; selectTextInTextArea( editor, selectionRange ); } } 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': '' }); } @@ -209,7 +211,7 @@ window.wp = window.wp || {}; lastGtPos = content.lastIndexOf( '>', cursorPosition ); if ( lastLtPos > lastGtPos || content.substr( cursorPosition, 1 ) === '>' ) { - // find what the tag is + // Find what the tag is. var tagContent = content.substr( lastLtPos ), tagMatch = tagContent.match( /<\s*(\/)?(\w+|\!-{2}.*-{2})/ ); @@ -222,7 +224,7 @@ window.wp = window.wp || {}; return { 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, isClosingTag: !! tagMatch[1] }; @@ -248,7 +250,7 @@ window.wp = window.wp || {}; * @param {number} cursorPosition The cursor position to check. * * @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 ) { var contentShortcodes = getShortCodePositionsInText( content ); @@ -403,7 +405,7 @@ window.wp = window.wp || {}; var cursorStart = cursorPositions.cursorStart, 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 ); if ( isCursorStartInTag ) { @@ -506,11 +508,11 @@ window.wp = window.wp || {}; } textArea.value = [ - textArea.value.slice( 0, htmlModeCursorStartPosition ), // text until the cursor/selection position - cursorMarkerSkeleton.clone() // cursor/selection start marker + textArea.value.slice( 0, htmlModeCursorStartPosition ), // Text until the cursor/selection position. + cursorMarkerSkeleton.clone() // Cursor/selection start marker. .addClass( 'mce_SELRES_start' )[0].outerHTML, - selectedText, // selected text with end cursor/position marker - textArea.value.slice( htmlModeCursorEndPosition ) // text from last cursor/selection position to end + selectedText, // Selected text with end cursor/position marker. + textArea.value.slice( htmlModeCursorEndPosition ) // Text from last cursor/selection position to end. ].join( '' ); } @@ -804,7 +806,7 @@ window.wp = window.wp || {}; 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; } @@ -826,7 +828,7 @@ window.wp = window.wp || {}; * @param {Object} selection Selection data. */ 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 ) { return; } @@ -836,11 +838,11 @@ window.wp = window.wp || {}; end = selection.end || selection.start; 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() { textArea.setSelectionRange( start, end ); if ( textArea.blur ) { - // defocus before focusing + // Defocus before focusing. textArea.blur(); } textArea.focus(); @@ -1249,7 +1251,7 @@ window.wp = window.wp || {}; defaults = wp.editor.getDefaultSettings(); - // Initialize TinyMCE by default + // Initialize TinyMCE by default. if ( ! settings ) { settings = { tinymce: true diff --git a/src/js/_enqueues/wp/editor/dfw.js b/src/js/_enqueues/wp/editor/dfw.js index 53ec6f594e..2fc580c1fe 100644 --- a/src/js/_enqueues/wp/editor/dfw.js +++ b/src/js/_enqueues/wp/editor/dfw.js @@ -246,10 +246,11 @@ function mceKeyup( event ) { 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 ) ) { 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 ) { return; } @@ -516,7 +517,7 @@ * 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. */ - canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding + canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding. canPin = editorHeight > ( canPin + 5 ); if ( ! canPin ) { @@ -910,7 +911,7 @@ // Adjust when entering or exiting fullscreen mode. 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 ) { element && element.attr( 'style', '' ); }); @@ -1179,15 +1180,15 @@ // 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 && ( - // 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 ) || - // Windows keys + // Windows keys. ( key >= 91 && key <= 93 ) || - // F keys + // F keys. ( key >= 112 && key <= 135 ) || - // Num Lock, Scroll Lock, OEM + // Num Lock, Scroll Lock, OEM. ( key >= 144 && key <= 150 ) || - // OEM or non-printable + // OEM or non-printable. key >= 224 ) ) ) ) { return; diff --git a/src/js/_enqueues/wp/emoji.js b/src/js/_enqueues/wp/emoji.js index 27882d1e27..c737bb17bf 100644 --- a/src/js/_enqueues/wp/emoji.js +++ b/src/js/_enqueues/wp/emoji.js @@ -9,8 +9,8 @@ /** * Replaces emoji with images when browsers don't support emoji. * - * @since 4.2.0 - * @access private + * @since 4.2.0 + * @access private * * @class * @@ -22,10 +22,10 @@ function wpEmoji() { var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, - // Compression and maintain local scope + // Compression and maintain local scope. document = window.document, - // Private + // Private. twemoji, timer, loaded = false, count = 0, @@ -69,7 +69,7 @@ // Ensure twemoji is available on the global window before proceeding. if ( typeof window.twemoji === 'undefined' ) { - // Break if waiting for longer than 30 sec. + // Break if waiting for longer than 30 seconds. if ( count > 600 ) { return; } @@ -245,8 +245,8 @@ } if ( settings.supports.everythingExceptFlag && - ! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags - ! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon ) // Rainbow and pirate flags + ! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags. + ! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon ) // Rainbow and pirate flags. ) { return false; } diff --git a/src/js/_enqueues/wp/heartbeat.js b/src/js/_enqueues/wp/heartbeat.js index 98cba71c54..f55d2f87ca 100644 --- a/src/js/_enqueues/wp/heartbeat.js +++ b/src/js/_enqueues/wp/heartbeat.js @@ -62,7 +62,7 @@ // Connect interval (in seconds). mainInterval: 60, - // Used when the interval is set to 5 sec. temporarily. + // Used when the interval is set to 5 seconds temporarily. tempInterval: 0, // Used when the interval is reset. @@ -89,7 +89,7 @@ // Whether the current browser window is in focus and the user is active. hasFocus: true, - // Timestamp, last time the user was active. Checked every 30 sec. + // Timestamp, last time the user was active. Checked every 30 seconds. userActivity: 0, // Flag whether events tracking user activity were set. @@ -106,9 +106,8 @@ /** * Sets local variables and events, then starts the heartbeat. * - * @access private - * * @since 3.8.0 + * @access private * * @return {void} */ @@ -133,9 +132,8 @@ } /* - * The interval can be from 15 to 120 sec. and can be set temporarily to 5 sec. - * It can be set in the initial options or changed later through JS and/or - * through PHP. + * The interval can be from 15 to 120 seconds and can be set temporarily to 5 seconds. + * It can be set in the initial options or changed later through JS and/or through PHP. */ if ( options.interval ) { settings.mainInterval = options.interval; @@ -148,12 +146,12 @@ } /* - * Used to limit the number of AJAX requests. Overrides all other intervals if - * they are shorter. Needed for some hosts that cannot handle frequent requests - * and the user may exceed the allocated server CPU time, etc. The minimal - * interval can be up to 600 sec. however setting it to longer than 120 sec. - * will limit or disable some of the functionality (like post locks). Once set - * at initialization, minimalInterval cannot be changed/overridden. + * Used to limit the number of AJAX requests. Overrides all other intervals + * if they are shorter. Needed for some hosts that cannot handle frequent requests + * and the user may exceed the allocated server CPU time, etc. The minimal interval + * can be up to 600 seconds, however setting it to longer than 120 seconds + * will limit or disable some of the functionality (like post locks). + * Once set at initialization, minimalInterval cannot be changed/overridden. */ if ( options.minimalInterval ) { options.minimalInterval = parseInt( options.minimalInterval, 10 ); @@ -189,11 +187,11 @@ hidden = 'hidden'; visibilitychange = 'visibilitychange'; visibilityState = 'visibilityState'; - } else if ( typeof document.msHidden !== 'undefined' ) { // IE10 + } else if ( typeof document.msHidden !== 'undefined' ) { // IE10. hidden = 'msHidden'; visibilitychange = 'msvisibilitychange'; visibilityState = 'msVisibilityState'; - } else if ( typeof document.webkitHidden !== 'undefined' ) { // Android + } else if ( typeof document.webkitHidden !== 'undefined' ) { // Android. hidden = 'webkitHidden'; visibilitychange = 'webkitvisibilitychange'; visibilityState = 'webkitVisibilityState'; @@ -245,9 +243,8 @@ /** * Returns the current time according to the browser. * - * @access private - * * @since 3.6.0 + * @access private * * @return {number} Returns the current time. */ @@ -258,9 +255,8 @@ /** * Checks if the iframe is from the same origin. * - * @access private - * * @since 3.6.0 + * @access private * * @return {boolean} Returns whether or not the iframe is from the same origin. */ @@ -291,9 +287,8 @@ /** * Checks if the document's focus has changed. * - * @access private - * * @since 4.1.0 + * @access private * * @return {void} */ @@ -308,9 +303,8 @@ /** * Sets error state and fires an event on XHR errors or timeout. * - * @access private - * * @since 3.8.0 + * @access private * * @param {string} error The error type passed from the XHR. * @param {number} status The HTTP status code passed from jqXHR @@ -327,7 +321,7 @@ // Do nothing. break; case 'timeout': - // No response for 30 sec. + // No response for 30 seconds. trigger = true; break; case 'error': @@ -359,9 +353,8 @@ /** * Clears the error state and fires an event if there is a connection error. * - * @access private - * * @since 3.8.0 + * @access private * * @return {void} */ @@ -380,9 +373,8 @@ /** * Gathers the data and connects to the server. * - * @access private - * * @since 3.6.0 + * @access private * * @return {void} */ @@ -421,7 +413,7 @@ settings.xhr = $.ajax({ url: settings.url, type: 'post', - timeout: 30000, // throw an error if not completed after 30 sec. + timeout: 30000, // Throw an error if not completed after 30 seconds. data: ajaxData, dataType: 'json' }).always( function() { @@ -442,7 +434,7 @@ wp.hooks.doAction( 'heartbeat.nonces-expired' ); } - // Change the interval from PHP + // Change the interval from PHP. if ( response.heartbeat_interval ) { newInterval = response.heartbeat_interval; delete response.heartbeat_interval; @@ -464,7 +456,7 @@ $document.trigger( 'heartbeat-tick', [response, textStatus, jqXHR] ); wp.hooks.doAction( 'heartbeat.tick', response, textStatus, jqXHR ); - // Do this last. Can trigger the next XHR if connection time > 5 sec. and newInterval == 'fast'. + // Do this last. Can trigger the next XHR if connection time > 5 seconds and newInterval == 'fast'. if ( newInterval ) { interval( newInterval ); } @@ -480,9 +472,8 @@ * * Fires immediately if the connection time is longer than the interval. * - * @access private - * * @since 3.8.0 + * @access private * * @return {void} */ @@ -495,7 +486,7 @@ } if ( ! settings.hasFocus ) { - interval = 120000; // 120 sec. Post locks expire after 150 sec. + interval = 120000; // 120 seconds. Post locks expire after 150 seconds. } else if ( settings.countdown > 0 && settings.tempInterval ) { interval = settings.tempInterval; settings.countdown--; @@ -526,9 +517,8 @@ /** * Sets the internal state when the browser window becomes hidden or loses focus. * - * @access private - * * @since 3.6.0 + * @access private * * @return {void} */ @@ -539,16 +529,15 @@ /** * Sets the internal state when the browser window becomes visible or is in focus. * - * @access private - * * @since 3.6.0 + * @access private * * @return {void} */ function focused() { settings.userActivity = time(); - // Resume if suspended + // Resume if suspended. settings.suspend = false; if ( ! settings.hasFocus ) { @@ -560,9 +549,8 @@ /** * Runs when the user becomes active after a period of inactivity. * - * @access private - * * @since 3.6.0 + * @access private * * @return {void} */ @@ -582,26 +570,25 @@ /** * Checks for user activity. * - * Runs every 30 sec. Sets 'hasFocus = true' if user is active and the window is - * in the background. Sets 'hasFocus = false' if the user has been inactive - * (no mouse or keyboard activity) for 5 min. even when the window has focus. - * - * @access private + * Runs every 30 seconds. Sets 'hasFocus = true' if user is active and the window + * is in the background. Sets 'hasFocus = false' if the user has been inactive + * (no mouse or keyboard activity) for 5 minutes even when the window has focus. * * @since 3.8.0 + * @access private * * @return {void} */ function checkUserActivity() { var lastActive = settings.userActivity ? time() - settings.userActivity : 0; - // Throttle down when no mouse or keyboard activity for 5 min. + // Throttle down when no mouse or keyboard activity for 5 minutes. if ( lastActive > 300000 && settings.hasFocus ) { blurred(); } - // Suspend after 10 min. of inactivity when suspending is enabled. - // Always suspend after 60 min. of inactivity. This will release the post lock, etc. + // Suspend after 10 minutes of inactivity when suspending is enabled. + // Always suspend after 60 minutes of inactivity. This will release the post lock, etc. if ( ( settings.suspendEnabled && lastActive > 600000 ) || lastActive > 3600000 ) { settings.suspend = true; } @@ -672,9 +659,9 @@ * Disables suspending. * * Should be used only when Heartbeat is performing critical tasks like - * autosave, post-locking, etc. Using this on many screens may overload the - * user's hosting account if several browser windows/tabs are left open for a - * long time. + * autosave, post-locking, etc. Using this on many screens may overload + * the user's hosting account if several browser windows/tabs are left open + * for a long time. * * @since 3.8.0 * @@ -691,15 +678,15 @@ * * When setting to 'fast' or 5, the interval is 5 seconds for the next 30 ticks * (for 2 minutes and 30 seconds) by default. In this case the number of 'ticks' - * can be passed as second argument. If the window doesn't have focus, the - * interval slows down to 2 min. + * can be passed as second argument. If the window doesn't have focus, + * the interval slows down to 2 minutes. * * @since 3.6.0 * * @memberOf wp.heartbeat.prototype * - * @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120. Fast - * equals 5. + * @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120. + * Fast equals 5. * @param {string} ticks Tells how many ticks before the interval reverts * back. Used with speed = 'fast' or 5. * @@ -728,7 +715,7 @@ newInterval = 120000; break; case 'long-polling': - // Allow long polling, (experimental) + // Allow long polling (experimental). settings.mainInterval = 0; return 0; default: @@ -751,9 +738,11 @@ settings.mainInterval = newInterval; } - // Change the next connection time if new interval has been set. - // Will connect immediately if the time since the last connection - // is greater than the new interval. + /* + * Change the next connection time if new interval has been set. + * Will connect immediately if the time since the last connection + * is greater than the new interval. + */ if ( newInterval !== oldInterval ) { scheduleNextTick(); } diff --git a/src/js/_enqueues/wp/mce-view.js b/src/js/_enqueues/wp/mce-view.js index e0439c41c7..1fca3d6d35 100644 --- a/src/js/_enqueues/wp/mce-view.js +++ b/src/js/_enqueues/wp/mce-view.js @@ -565,10 +565,12 @@ dom.add( node, 'span', { 'class': 'wpview-end' } ); } ); - // Bail if the iframe node is not attached to the DOM. - // Happens when the view is dragged in the editor. - // There is a browser restriction when iframes are moved in the DOM. They get emptied. - // The iframe will be rerendered after dropping the view node at the new location. + /* + * Bail if the iframe node is not attached to the DOM. + * Happens when the view is dragged in the editor. + * There is a browser restriction when iframes are moved in the DOM. They get emptied. + * The iframe will be rerendered after dropping the view node at the new location. + */ if ( ! iframe.contentWindow ) { return; } diff --git a/src/js/_enqueues/wp/media/audiovideo.js b/src/js/_enqueues/wp/media/audiovideo.js index 75eee00d52..f0127cc507 100644 --- a/src/js/_enqueues/wp/media/audiovideo.js +++ b/src/js/_enqueues/wp/media/audiovideo.js @@ -53,7 +53,7 @@ wp.media.mixin = { return; } - // invoke features cleanup + // Invoke features cleanup. for ( featureIndex in t.options.features ) { feature = t.options.features[featureIndex]; if ( t['clean' + feature] ) { diff --git a/src/js/_enqueues/wp/media/editor.js b/src/js/_enqueues/wp/media/editor.js index 380dbe2ce2..a02ecf9376 100644 --- a/src/js/_enqueues/wp/media/editor.js +++ b/src/js/_enqueues/wp/media/editor.js @@ -430,9 +430,11 @@ _.extend( attrs, attachments[this.tag].toJSON() ); } - // Convert all gallery shortcodes to use the `ids` property. - // Ignore `post__in` and `post__not_in`; the attachments in - // the collection will already reflect those properties. + /* + * Convert all gallery shortcodes to use the `ids` property. + * Ignore `post__in` and `post__not_in`; the attachments in + * the collection will already reflect those properties. + */ attrs.ids = attachments.pluck('id'); // Copy the `uploadedTo` post ID. @@ -670,7 +672,7 @@ this.content.set( view ); - // after bringing in the frame, load the actual editor via an ajax call + // After bringing in the frame, load the actual editor via an Ajax call. view.loadEditor(); }, this._frame ); @@ -733,9 +735,11 @@ wpActiveEditor = window.wpActiveEditor; } - // Delegate to the global `send_to_editor` if it exists. - // This attempts to play nice with any themes/plugins that have - // overridden the insert functionality. + /* + * Delegate to the global `send_to_editor` if it exists. + * This attempts to play nice with any themes/plugins + * that have overridden the insert functionality. + */ if ( window.send_to_editor ) { return window.send_to_editor.apply( this, arguments ); } @@ -780,7 +784,7 @@ add: function( id, options ) { var workflow = this.get( id ); - // only add once: if exists return existing + // Only add once: if exists return existing. if ( workflow ) { return workflow; } @@ -1016,7 +1020,7 @@ workflow = this.get( id ); - // Redo workflow if state has changed + // Redo workflow if state has changed. if ( ! workflow || ( workflow.options && options.state !== workflow.options.state ) ) { workflow = this.add( id, options ); } diff --git a/src/js/_enqueues/wp/media/models.js b/src/js/_enqueues/wp/media/models.js index 308aea41c0..205616c36c 100644 --- a/src/js/_enqueues/wp/media/models.js +++ b/src/js/_enqueues/wp/media/models.js @@ -147,9 +147,11 @@ _.extend( media, /** @lends wp.media */{ maxHeight = dimensions.maxHeight, constraint; - // Compare ratios between the two values to determine which - // max to constrain by. If a max value doesn't exist, then the - // opposite side is the constraint. + /* + * Compare ratios between the two values to determine + * which max to constrain by. If a max value doesn't exist, + * then the opposite side is the constraint. + */ if ( ! _.isUndefined( maxWidth ) && ! _.isUndefined( maxHeight ) ) { constraint = ( width / height > maxWidth / maxHeight ) ? 'width' : 'height'; } else if ( _.isUndefined( maxHeight ) ) { @@ -236,7 +238,7 @@ media.query = function( props ) { }); }; -// Clean up. Prevents mobile browsers caching +// Clean up. Prevents mobile browsers caching. $(window).on('unload', function(){ window.wp = null; }); diff --git a/src/js/_enqueues/wp/media/views.js b/src/js/_enqueues/wp/media/views.js index d2c35078e6..2f98e029f5 100644 --- a/src/js/_enqueues/wp/media/views.js +++ b/src/js/_enqueues/wp/media/views.js @@ -18,7 +18,7 @@ delete l10n.settings; // Copy the `post` setting over to the model settings. media.model.settings.post = media.view.settings.post; -// Check if the browser supports CSS 3.0 transitions +// Check if the browser supports CSS 3.0 transitions. $.support.transition = (function(){ var style = document.documentElement.style, transitions = { diff --git a/src/js/_enqueues/wp/shortcode.js b/src/js/_enqueues/wp/shortcode.js index bf3e1e21a0..1818d20c51 100644 --- a/src/js/_enqueues/wp/shortcode.js +++ b/src/js/_enqueues/wp/shortcode.js @@ -13,13 +13,15 @@ window.wp = window.wp || {}; (function(){ wp.shortcode = { - // ### Find the next matching shortcode - // - // Given a shortcode `tag`, a block of `text`, and an optional starting - // `index`, returns the next matching shortcode or `undefined`. - // - // Shortcodes are formatted as an object that contains the match - // `content`, the matching `index`, and the parsed `shortcode` object. + /* + * ### Find the next matching shortcode. + * + * Given a shortcode `tag`, a block of `text`, and an optional starting + * `index`, returns the next matching shortcode or `undefined`. + * + * Shortcodes are formatted as an object that contains the match + * `content`, the matching `index`, and the parsed `shortcode` object. + */ next: function( tag, text, index ) { var re = wp.shortcode.regexp( tag ), match, result; @@ -57,15 +59,17 @@ window.wp = window.wp || {}; return result; }, - // ### Replace matching shortcodes in a block of text - // - // Accepts a shortcode `tag`, content `text` to scan, and a `callback` - // to process the shortcode matches and return a replacement string. - // Returns the `text` with all shortcodes replaced. - // - // Shortcode matches are objects that contain the shortcode `tag`, - // a shortcode `attrs` object, the `content` between shortcode tags, - // and a boolean flag to indicate if the match was a `single` tag. + /* + * ### Replace matching shortcodes in a block of text. + * + * Accepts a shortcode `tag`, content `text` to scan, and a `callback` + * to process the shortcode matches and return a replacement string. + * Returns the `text` with all shortcodes replaced. + * + * Shortcode matches are objects that contain the shortcode `tag`, + * a shortcode `attrs` object, the `content` between shortcode tags, + * and a boolean flag to indicate if the match was a `single` tag. + */ replace: function( tag, text, callback ) { return text.replace( wp.shortcode.regexp( tag ), function( match, left, tag, attrs, slash, content, closing, right ) { // If both extra brackets exist, the shortcode has been @@ -83,67 +87,75 @@ window.wp = window.wp || {}; }); }, - // ### Generate a string from shortcode parameters - // - // Creates a `wp.shortcode` instance and returns a string. - // - // Accepts the same `options` as the `wp.shortcode()` constructor, - // containing a `tag` string, a string or object of `attrs`, a boolean - // indicating whether to format the shortcode using a `single` tag, and a - // `content` string. + /* + * ### Generate a string from shortcode parameters. + * + * Creates a `wp.shortcode` instance and returns a string. + * + * Accepts the same `options` as the `wp.shortcode()` constructor, + * containing a `tag` string, a string or object of `attrs`, a boolean + * indicating whether to format the shortcode using a `single` tag, and a + * `content` string. + */ string: function( options ) { return new wp.shortcode( options ).string(); }, - // ### Generate a RegExp to identify a shortcode - // - // The base regex is functionally equivalent to the one found in - // `get_shortcode_regex()` in `wp-includes/shortcodes.php`. - // - // Capture groups: - // - // 1. An extra `[` to allow for escaping shortcodes with double `[[]]` - // 2. The shortcode name - // 3. The shortcode argument list - // 4. The self closing `/` - // 5. The content of a shortcode when it wraps some content. - // 6. The closing tag. - // 7. An extra `]` to allow for escaping shortcodes with double `[[]]` + /* + * ### Generate a RegExp to identify a shortcode. + * + * The base regex is functionally equivalent to the one found in + * `get_shortcode_regex()` in `wp-includes/shortcodes.php`. + * + * Capture groups: + * + * 1. An extra `[` to allow for escaping shortcodes with double `[[]]`. + * 2. The shortcode name. + * 3. The shortcode argument list. + * 4. The self closing `/`. + * 5. The content of a shortcode when it wraps some content. + * 6. The closing tag. + * 7. An extra `]` to allow for escaping shortcodes with double `[[]]`. + */ regexp: _.memoize( function( tag ) { return new RegExp( '\\[(\\[?)(' + tag + ')(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)', 'g' ); }), - // ### Parse shortcode attributes - // - // Shortcodes accept many types of attributes. These can chiefly be - // divided into named and numeric attributes: - // - // Named attributes are assigned on a key/value basis, while numeric - // attributes are treated as an array. - // - // Named attributes can be formatted as either `name="value"`, - // `name='value'`, or `name=value`. Numeric attributes can be formatted - // as `"value"` or just `value`. + /* + * ### Parse shortcode attributes. + * + * Shortcodes accept many types of attributes. These can chiefly be + * divided into named and numeric attributes: + * + * Named attributes are assigned on a key/value basis, while numeric + * attributes are treated as an array. + * + * Named attributes can be formatted as either `name="value"`, + * `name='value'`, or `name=value`. Numeric attributes can be formatted + * as `"value"` or just `value`. + */ attrs: _.memoize( function( text ) { var named = {}, numeric = [], pattern, match; - // This regular expression is reused from `shortcode_parse_atts()` - // in `wp-includes/shortcodes.php`. - // - // Capture groups: - // - // 1. An attribute name, that corresponds to... - // 2. a value in double quotes. - // 3. An attribute name, that corresponds to... - // 4. a value in single quotes. - // 5. An attribute name, that corresponds to... - // 6. an unquoted value. - // 7. A numeric attribute in double quotes. - // 8. A numeric attribute in single quotes. - // 9. An unquoted numeric attribute. + /* + * This regular expression is reused from `shortcode_parse_atts()` + * in `wp-includes/shortcodes.php`. + * + * Capture groups: + * + * 1. An attribute name, that corresponds to... + * 2. a value in double quotes. + * 3. An attribute name, that corresponds to... + * 4. a value in single quotes. + * 5. An attribute name, that corresponds to... + * 6. an unquoted value. + * 7. A numeric attribute in double quotes. + * 8. A numeric attribute in single quotes. + * 9. An unquoted numeric attribute. + */ pattern = /([\w-]+)\s*=\s*"([^"]*)"(?:\s|$)|([\w-]+)\s*=\s*'([^']*)'(?:\s|$)|([\w-]+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|'([^']*)'(?:\s|$)|(\S+)(?:\s|$)/g; // Map zero-width spaces to actual spaces. @@ -172,10 +184,13 @@ window.wp = window.wp || {}; }; }), - // ### Generate a Shortcode Object from a RegExp match - // Accepts a `match` object from calling `regexp.exec()` on a `RegExp` - // generated by `wp.shortcode.regexp()`. `match` can also be set to the - // `arguments` from a callback passed to `regexp.replace()`. + /* + * ### Generate a Shortcode Object from a RegExp match. + * + * Accepts a `match` object from calling `regexp.exec()` on a `RegExp` + * generated by `wp.shortcode.regexp()`. `match` can also be set + * to the `arguments` from a callback passed to `regexp.replace()`. + */ fromMatch: function( match ) { var type; @@ -197,16 +212,18 @@ window.wp = window.wp || {}; }; - // Shortcode Objects - // ----------------- - // - // Shortcode objects are generated automatically when using the main - // `wp.shortcode` methods: `next()`, `replace()`, and `string()`. - // - // To access a raw representation of a shortcode, pass an `options` object, - // containing a `tag` string, a string or object of `attrs`, a string - // indicating the `type` of the shortcode ('single', 'self-closing', or - // 'closed'), and a `content` string. + /* + * Shortcode Objects + * ----------------- + * + * Shortcode objects are generated automatically when using the main + * `wp.shortcode` methods: `next()`, `replace()`, and `string()`. + * + * To access a raw representation of a shortcode, pass an `options` object, + * containing a `tag` string, a string or object of `attrs`, a string + * indicating the `type` of the shortcode ('single', 'self-closing', + * or 'closed'), and a `content` string. + */ wp.shortcode = _.extend( function( options ) { _.extend( this, _.pick( options || {}, 'tag', 'attrs', 'type', 'content' ) ); @@ -239,24 +256,28 @@ window.wp = window.wp || {}; }, wp.shortcode ); _.extend( wp.shortcode.prototype, { - // ### Get a shortcode attribute - // - // Automatically detects whether `attr` is named or numeric and routes - // it accordingly. + /* + * ### Get a shortcode attribute. + * + * Automatically detects whether `attr` is named or numeric and routes + * it accordingly. + */ get: function( attr ) { return this.attrs[ _.isNumber( attr ) ? 'numeric' : 'named' ][ attr ]; }, - // ### Set a shortcode attribute - // - // Automatically detects whether `attr` is named or numeric and routes - // it accordingly. + /* + * ### Set a shortcode attribute. + * + * Automatically detects whether `attr` is named or numeric and routes + * it accordingly. + */ set: function( attr, value ) { this.attrs[ _.isNumber( attr ) ? 'numeric' : 'named' ][ attr ] = value; return this; }, - // ### Transform the shortcode match into a string + // ### Transform the shortcode match into a string. string: function() { var text = '[' + this.tag; @@ -293,20 +314,24 @@ window.wp = window.wp || {}; }); }()); -// HTML utility functions -// ---------------------- -// -// Experimental. These functions may change or be removed in the future. +/* + * HTML utility functions + * ---------------------- + * + * Experimental. These functions may change or be removed in the future. + */ (function(){ wp.html = _.extend( wp.html || {}, { - // ### Parse HTML attributes. - // - // Converts `content` to a set of parsed HTML attributes. - // Utilizes `wp.shortcode.attrs( content )`, which is a valid superset of - // the HTML attribute specification. Reformats the attributes into an - // object that contains the `attrs` with `key:value` mapping, and a record - // of the attributes that were entered using `empty` attribute syntax (i.e. - // with no value). + /* + * ### Parse HTML attributes. + * + * Converts `content` to a set of parsed HTML attributes. + * Utilizes `wp.shortcode.attrs( content )`, which is a valid superset of + * the HTML attribute specification. Reformats the attributes into an + * object that contains the `attrs` with `key:value` mapping, and a record + * of the attributes that were entered using `empty` attribute syntax (i.e. + * with no value). + */ attrs: function( content ) { var result, attrs; diff --git a/src/js/_enqueues/wp/svg-painter.js b/src/js/_enqueues/wp/svg-painter.js index e0277f13f2..e697a0df28 100644 --- a/src/js/_enqueues/wp/svg-painter.js +++ b/src/js/_enqueues/wp/svg-painter.js @@ -13,7 +13,7 @@ wp.svgPainter = ( function( $, window, document, undefined ) { elements = []; $(document).ready( function() { - // detection for browser SVG capability + // Detection for browser SVG capability. if ( document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) { $( document.body ).removeClass( 'no-svg' ).addClass( 'svg' ); wp.svgPainter.init(); @@ -148,24 +148,24 @@ wp.svgPainter = ( function( $, window, document, undefined ) { }, paint: function() { - // loop through all elements + // Loop through all elements. $.each( elements, function( index, $element ) { var $menuitem = $element.parent().parent(); if ( $menuitem.hasClass( 'current' ) || $menuitem.hasClass( 'wp-has-current-submenu' ) ) { - // paint icon in 'current' color + // Paint icon in 'current' color. painter.paintElement( $element, 'current' ); } else { - // paint icon in base color + // Paint icon in base color. painter.paintElement( $element, 'base' ); - // set hover callbacks + // Set hover callbacks. $menuitem.hover( function() { painter.paintElement( $element, 'focus' ); }, function() { - // Match the delay from hoverIntent + // Match the delay from hoverIntent. window.setTimeout( function() { painter.paintElement( $element, 'base' ); }, 100 ); @@ -184,7 +184,7 @@ wp.svgPainter = ( function( $, window, document, undefined ) { color = colorscheme[ colorType ]; - // only accept hex colors: #101 or #101010 + // Only accept hex colors: #101 or #101010. if ( ! color.match( /^(#[0-9a-f]{3}|#[0-9a-f]{6})$/i ) ) { return; } @@ -212,13 +212,13 @@ wp.svgPainter = ( function( $, window, document, undefined ) { } catch ( error ) {} if ( xml ) { - // replace `fill` attributes + // Replace `fill` attributes. xml = xml.replace( /fill="(.+?)"/g, 'fill="' + color + '"'); - // replace `style` attributes + // Replace `style` attributes. xml = xml.replace( /style="(.+?)"/g, 'style="fill:' + color + '"'); - // replace `fill` properties in `<style>` tags + // Replace `fill` properties in `<style>` tags. xml = xml.replace( /fill:.*?;/g, 'fill: ' + color + ';'); if ( 'btoa' in window ) { diff --git a/src/js/_enqueues/wp/theme-plugin-editor.js b/src/js/_enqueues/wp/theme-plugin-editor.js index 6ddb9dff47..84695dfefa 100644 --- a/src/js/_enqueues/wp/theme-plugin-editor.js +++ b/src/js/_enqueues/wp/theme-plugin-editor.js @@ -491,7 +491,7 @@ wp.themePluginEditor = (function( $ ) { var TreeitemLink = function (node, treeObj, group) { - // Check whether node is a DOM element + // Check whether node is a DOM element. if (typeof node !== 'object') { return; } @@ -696,7 +696,7 @@ wp.themePluginEditor = (function( $ ) { TreeitemLink.prototype.handleClick = function (event) { - // only process click events that directly happened on this treeitem + // Only process click events that directly happened on this treeitem. if (event.target !== this.domNode && event.target !== this.domNode.firstElementChild) { return; } @@ -773,7 +773,7 @@ wp.themePluginEditor = (function( $ ) { */ var TreeLinks = function (node) { - // Check whether node is a DOM element + // Check whether node is a DOM element. if (typeof node !== 'object') { return; } @@ -812,7 +812,7 @@ wp.themePluginEditor = (function( $ ) { } } - // initialize pop up menus + // Initialize pop up menus. if (!this.domNode.getAttribute('role')) { this.domNode.setAttribute('role', 'tree'); } @@ -964,16 +964,16 @@ wp.themePluginEditor = (function( $ ) { var start, index; _char = _char.toLowerCase(); - // Get start index for search based on position of currentItem + // Get start index for search based on position of currentItem. start = this.treeitems.indexOf(currentItem) + 1; if (start === this.treeitems.length) { start = 0; } - // Check remaining slots in the menu + // Check remaining slots in the menu. index = this.getIndexFirstChars(start, _char); - // If not found in remaining slots, check from beginning + // If not found in remaining slots, check from beginning. if (index === -1) { index = this.getIndexFirstChars(0, _char); } diff --git a/src/js/_enqueues/wp/theme.js b/src/js/_enqueues/wp/theme.js index 0d29fe8876..7f7f0ce1fb 100644 --- a/src/js/_enqueues/wp/theme.js +++ b/src/js/_enqueues/wp/theme.js @@ -11,20 +11,20 @@ window.wp = window.wp || {}; var themes, l10n; themes = wp.themes = wp.themes || {}; -// Store the theme data and settings for organized and quick access -// themes.data.settings, themes.data.themes, themes.data.l10n +// Store the theme data and settings for organized and quick access. +// themes.data.settings, themes.data.themes, themes.data.l10n. themes.data = _wpThemeSettings; l10n = themes.data.l10n; -// Shortcut for isInstall check +// Shortcut for isInstall check. themes.isInstall = !! themes.data.settings.isInstall; -// Setup app structure +// Setup app structure. _.extend( themes, { model: {}, view: {}, routes: {}, router: {}, template: wp.template }); themes.Model = Backbone.Model.extend({ - // Adds attributes to the default data coming through the .org themes api - // Map `id` to `slug` for shared code + // Adds attributes to the default data coming through the .org themes api. + // Map `id` to `slug` for shared code. initialize: function() { var description; @@ -33,14 +33,14 @@ themes.Model = Backbone.Model.extend({ this.set({ installed: true }); } - // Set the attributes + // Set the attributes. this.set({ - // slug is for installation, id is for existing. + // `slug` is for installation, `id` is for existing. id: this.get( 'slug' ) || this.get( 'id' ) }); // Map `section.description` to `description` - // as the API sometimes returns it differently + // as the API sometimes returns it differently. if ( this.has( 'sections' ) ) { description = this.get( 'sections' ).description; this.set({ description: description }); @@ -48,31 +48,31 @@ themes.Model = Backbone.Model.extend({ } }); -// Main view controller for themes.php -// Unifies and renders all available views +// Main view controller for themes.php. +// Unifies and renders all available views. themes.view.Appearance = wp.Backbone.View.extend({ el: '#wpbody-content .wrap .theme-browser', window: $( window ), - // Pagination instance + // Pagination instance. page: 0, - // Sets up a throttler for binding to 'scroll' + // Sets up a throttler for binding to 'scroll'. initialize: function( options ) { - // Scroller checks how far the scroll position is + // Scroller checks how far the scroll position is. _.bindAll( this, 'scroller' ); this.SearchView = options.SearchView ? options.SearchView : themes.view.Search; // Bind to the scroll event and throttle - // the results from this.scroller + // the results from this.scroller. this.window.bind( 'scroll', _.throttle( this.scroller, 300 ) ); }, - // Main render control + // Main render control. render: function() { // Setup the main theme view - // with the current theme collection + // with the current theme collection. this.view = new themes.view.Themes({ collection: this.collection, parent: this @@ -83,21 +83,21 @@ themes.view.Appearance = wp.Backbone.View.extend({ this.$el.removeClass( 'search-loading' ); - // Render and append + // Render and append. this.view.render(); this.$el.empty().append( this.view.el ).addClass( 'rendered' ); }, - // Defines search element container + // Defines search element container. searchContainer: $( '.search-form' ), // Search input and view - // for current theme collection + // for current theme collection. search: function() { var view, self = this; - // Don't render the search if there is only one theme + // Don't render the search if there is only one theme. if ( themes.data.themes.length === 1 ) { return; } @@ -108,7 +108,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ }); self.SearchView = view; - // Render and append after screen title + // Render and append after screen title. view.render(); this.searchContainer .append( $.parseHTML( '<label class="screen-reader-text" for="wp-filter-search-input">' + l10n.search + '</label>' ) ) @@ -119,7 +119,7 @@ themes.view.Appearance = wp.Backbone.View.extend({ }, // Checks when the user gets close to the bottom - // of the mage and triggers a theme:scroll event + // of the mage and triggers a theme:scroll event. scroller: function() { var self = this, bottom, threshold; @@ -134,26 +134,26 @@ themes.view.Appearance = wp.Backbone.View.extend({ } }); -// Set up the Collection for our theme data +// Set up the Collection for our theme data. // @has 'id' 'name' 'screenshot' 'author' 'authorURI' 'version' 'active' ... themes.Collection = Backbone.Collection.extend({ model: themes.Model, - // Search terms + // Search terms. terms: '', // Controls searching on the current theme collection - // and triggers an update event + // and triggers an update event. doSearch: function( value ) { - // Don't do anything if we've already done this search - // Useful because the Search handler fires multiple times per keystroke + // Don't do anything if we've already done this search. + // Useful because the Search handler fires multiple times per keystroke. if ( this.terms === value ) { return; } - // Updates terms with the value passed + // Updates terms with the value passed. this.terms = value; // If we have terms, run a search... @@ -161,38 +161,41 @@ themes.Collection = Backbone.Collection.extend({ this.search( this.terms ); } - // If search is blank, show all themes - // Useful for resetting the views when you clean the input + // If search is blank, show all themes. + // Useful for resetting the views when you clean the input. if ( this.terms === '' ) { this.reset( themes.data.themes ); $( 'body' ).removeClass( 'no-results' ); } - // Trigger a 'themes:update' event + // Trigger a 'themes:update' event. this.trigger( 'themes:update' ); }, - // Performs a search within the collection - // @uses RegExp + /** + * Performs a search within the collection. + * + * @uses RegExp + */ search: function( term ) { var match, results, haystack, name, description, author; - // Start with a full collection + // Start with a full collection. this.reset( themes.data.themes, { silent: true } ); - // Trim the term + // Trim the term. term = term.trim(); - // Escape the term string for RegExp meta characters + // Escape the term string for RegExp meta characters. term = term.replace( /[-\/\\^$*+?.()|[\]{}]/g, '\\$&' ); // 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, ')(?=.*' ); match = new RegExp( '^(?=.*' + term + ').+', 'i' ); - // Find results - // _.filter and .test + // Find results. + // _.filter() and .test(). results = this.filter( function( data ) { name = data.get( 'name' ).replace( /(<([^>]+)>)/ig, '' ); description = data.get( 'description' ).replace( /(<([^>]+)>)/ig, '' ); @@ -217,12 +220,12 @@ themes.Collection = Backbone.Collection.extend({ }, // Paginates the collection with a helper method - // that slices the collection + // that slices the collection. paginate: function( instance ) { var collection = this; instance = instance || 0; - // Themes per instance are set at 20 + // Themes per instance are set at 20. collection = _( collection.rest( 20 * instance ) ); collection = _( collection.first( 20 ) ); @@ -231,11 +234,13 @@ themes.Collection = Backbone.Collection.extend({ count: false, - // Handles requests for more themes - // and caches results - // - // When we are missing a cache object we fire an apiCall() - // which triggers events of `query:success` or `query:fail` + /* + * Handles requests for more themes and caches results. + * + * + * When we are missing a cache object we fire an apiCall() + * which triggers events of `query:success` or `query:fail`. + */ query: function( request ) { /** * @static @@ -246,7 +251,7 @@ themes.Collection = Backbone.Collection.extend({ query, isPaginated, count; // Store current query request args - // for later use with the event `theme:end` + // for later use with the event `theme:end`. this.currentQuery.request = request; // Search the query cache for matches. @@ -271,7 +276,7 @@ themes.Collection = Backbone.Collection.extend({ if ( data.themes ) { self.reset( data.themes ); count = data.info.results; - // Store the results and the query request + // Store the results and the query request. queries.push( { themes: data.themes, request: request, total: count } ); } @@ -291,8 +296,8 @@ themes.Collection = Backbone.Collection.extend({ // If it's a paginated request we need to fetch more themes... if ( isPaginated ) { return this.apiCall( request, isPaginated ).done( function( data ) { - // Add the new themes to the current collection - // @todo update counter + // Add the new themes to the current collection. + // @todo Update counter. self.add( data.themes ); self.trigger( 'query:success' ); @@ -311,7 +316,7 @@ themes.Collection = Backbone.Collection.extend({ } // Only trigger an update event since we already have the themes - // on our cached object + // on our cached object. if ( _.isNumber( query.total ) ) { this.count = query.total; } @@ -326,20 +331,20 @@ themes.Collection = Backbone.Collection.extend({ } }, - // Local cache array for API queries + // Local cache array for API queries. queries: [], - // Keep track of current query so we can handle pagination + // Keep track of current query so we can handle pagination. currentQuery: { page: 1, request: {} }, - // Send request to api.wordpress.org/themes + // Send request to api.wordpress.org/themes. apiCall: function( request, paginated ) { return wp.ajax.send( 'query-themes', { data: { - // Request data + // Request data. request: _.extend({ per_page: 100 }, request) @@ -347,7 +352,7 @@ themes.Collection = Backbone.Collection.extend({ beforeSend: function() { if ( ! paginated ) { - // Spin it + // Spin it. $( 'body' ).addClass( 'loading-content' ).removeClass( 'no-results' ); } } @@ -359,17 +364,17 @@ themes.Collection = Backbone.Collection.extend({ }); // This is the view that controls each theme item -// that will be displayed on the screen +// that will be displayed on the screen. themes.view.Theme = wp.Backbone.View.extend({ - // Wrap theme data on a div.theme element + // Wrap theme data on a div.theme element. className: 'theme', - // Reflects which theme view we have - // 'grid' (default) or 'detail' + // Reflects which theme view we have. + // 'grid' (default) or 'detail'. state: 'grid', - // The HTML template for each element to be rendered + // The HTML template for each element to be rendered. html: themes.template( 'theme' ), events: { @@ -391,14 +396,14 @@ themes.view.Theme = wp.Backbone.View.extend({ render: function() { var data = this.model.toJSON(); - // Render themes using the html template + // Render themes using the html template. this.$el.html( this.html( data ) ).attr({ tabindex: 0, 'aria-describedby' : data.id + '-action ' + data.id + '-name', 'data-slug': data.id }); - // Renders active theme styles + // Renders active theme styles. this.activeTheme(); if ( this.model.get( 'displayAuthor' ) ) { @@ -407,7 +412,7 @@ themes.view.Theme = wp.Backbone.View.extend({ }, // Adds a class to the currently active theme - // and to the overlay in detailed view mode + // and to the overlay in detailed view mode. activeTheme: function() { if ( this.model.get( 'active' ) ) { this.$el.addClass( 'active' ); @@ -422,25 +427,25 @@ themes.view.Theme = wp.Backbone.View.extend({ $themeToFocus.addClass('focus'); }, - // Single theme overlay screen - // It's shown when clicking a theme + // Single theme overlay screen. + // It's shown when clicking a theme. expand: function( event ) { var self = this; event = event || window.event; - // 'enter' and 'space' keys expand the details view when a theme is :focused + // 'Enter' and 'Space' keys expand the details view when a theme is :focused. if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) { return; } - // Bail if the user scrolled on a touch device + // Bail if the user scrolled on a touch device. if ( this.touchDrag === true ) { return this.touchDrag = false; } // Prevent the modal from showing when the user clicks - // one of the direct action buttons + // one of the direct action buttons. if ( $( event.target ).is( '.theme-actions a' ) ) { return; } @@ -450,7 +455,7 @@ themes.view.Theme = wp.Backbone.View.extend({ return; } - // Set focused theme to current element + // Set focused theme to current element. themes.focusedTheme = this.$el; this.trigger( 'theme:expand', self.model.cid ); @@ -466,7 +471,7 @@ themes.view.Theme = wp.Backbone.View.extend({ event = event || window.event; - // Bail if the user scrolled on a touch device + // Bail if the user scrolled on a touch device. if ( this.touchDrag === true ) { return this.touchDrag = false; } @@ -476,12 +481,12 @@ themes.view.Theme = wp.Backbone.View.extend({ return; } - // 'enter' and 'space' keys expand the details view when a theme is :focused + // 'Enter' and 'Space' keys expand the details view when a theme is :focused. if ( event.type === 'keydown' && ( event.which !== 13 && event.which !== 32 ) ) { return; } - // pressing enter while focused on the buttons shouldn't open the preview + // Pressing Enter while focused on the buttons shouldn't open the preview. if ( event.type === 'keydown' && event.which !== 13 && $( ':focus' ).hasClass( 'button' ) ) { return; } @@ -502,14 +507,14 @@ themes.view.Theme = wp.Backbone.View.extend({ preview.render(); this.setNavButtonsState(); - // Hide previous/next navigation if there is only one theme + // Hide previous/next navigation if there is only one theme. if ( this.model.collection.length === 1 ) { preview.$el.addClass( 'no-navigation' ); } else { preview.$el.removeClass( 'no-navigation' ); } - // Append preview + // Append preview. $( 'div.wrap' ).append( preview.el ); // Listen to our preview object @@ -545,7 +550,7 @@ themes.view.Theme = wp.Backbone.View.extend({ // Keep track of current theme model. current = self.model; - // Bail early if we are at the beginning of the collection + // Bail early if we are at the beginning of the collection. if ( self.model.collection.indexOf( self.current ) === 0 ) { return; } @@ -577,14 +582,14 @@ themes.view.Theme = wp.Backbone.View.extend({ }, - // Handles .disabled classes for previous/next buttons in theme installer preview + // Handles .disabled classes for previous/next buttons in theme installer preview. setNavButtonsState: function() { var $themeInstaller = $( '.theme-install-overlay' ), current = _.isUndefined( this.current ) ? this.model : this.current, previousThemeButton = $themeInstaller.find( '.previous-theme' ), nextThemeButton = $themeInstaller.find( '.next-theme' ); - // Disable previous at the zero position + // Disable previous at the zero position. if ( 0 === this.model.collection.indexOf( current ) ) { previousThemeButton .addClass( 'disabled' ) @@ -593,7 +598,7 @@ themes.view.Theme = wp.Backbone.View.extend({ nextThemeButton.focus(); } - // Disable next if the next model is undefined + // Disable next if the next model is undefined. if ( _.isUndefined( this.model.collection.at( this.model.collection.indexOf( current ) + 1 ) ) ) { nextThemeButton .addClass( 'disabled' ) @@ -649,11 +654,11 @@ themes.view.Theme = wp.Backbone.View.extend({ } }); -// Theme Details view -// Set ups a modal overlay with the expanded theme data +// Theme Details view. +// Sets up a modal overlay with the expanded theme data. themes.view.Details = wp.Backbone.View.extend({ - // Wrap theme data on a div.theme element + // Wrap theme data on a div.theme element. className: 'theme-overlay', events: { @@ -664,26 +669,26 @@ themes.view.Details = wp.Backbone.View.extend({ 'click #update-theme': 'updateTheme' }, - // The HTML template for the theme overlay + // The HTML template for the theme overlay. html: themes.template( 'theme-single' ), render: function() { var data = this.model.toJSON(); this.$el.html( this.html( data ) ); - // Renders active theme styles + // Renders active theme styles. this.activeTheme(); - // Set up navigation events + // Set up navigation events. this.navigation(); - // Checks screenshot size + // Checks screenshot size. this.screenshotCheck( this.$el ); - // Contain "tabbing" inside the overlay + // Contain "tabbing" inside the overlay. this.containFocus( this.$el ); }, // Adds a class to the currently active theme - // and to the overlay in detailed view mode + // and to the overlay in detailed view mode. activeTheme: function() { - // Check the model has the active property + // Check the model has the active property. this.$el.toggleClass( 'active', this.model.get( 'active' ) ); }, @@ -713,44 +718,43 @@ themes.view.Details = wp.Backbone.View.extend({ }); }, - // Single theme overlay screen - // It's shown when clicking a theme + // Single theme overlay screen. + // It's shown when clicking a theme. collapse: function( event ) { var self = this, scroll; event = event || window.event; - // Prevent collapsing detailed view when there is only one theme available + // Prevent collapsing detailed view when there is only one theme available. if ( themes.data.themes.length === 1 ) { return; } - // Detect if the click is inside the overlay - // and don't close it unless the target was - // the div.back button + // Detect if the click is inside the overlay and don't close it + // unless the target was the div.back button. if ( $( event.target ).is( '.theme-backdrop' ) || $( event.target ).is( '.close' ) || event.keyCode === 27 ) { - // Add a temporary closing class while overlay fades out + // Add a temporary closing class while overlay fades out. $( 'body' ).addClass( 'closing-overlay' ); - // With a quick fade out animation + // With a quick fade out animation. this.$el.fadeOut( 130, function() { - // Clicking outside the modal box closes the overlay + // Clicking outside the modal box closes the overlay. $( 'body' ).removeClass( 'closing-overlay' ); - // Handle event cleanup + // Handle event cleanup. self.closeOverlay(); - // Get scroll position to avoid jumping to the top + // Get scroll position to avoid jumping to the top. scroll = document.body.scrollTop; - // Clean the url structure + // Clean the URL structure. themes.router.navigate( themes.router.baseUrl( '' ) ); - // Restore scroll position + // Restore scroll position. document.body.scrollTop = scroll; - // Return focus to the theme div + // Return focus to the theme div. if ( themes.focusedTheme ) { themes.focusedTheme.focus(); } @@ -758,10 +762,10 @@ themes.view.Details = wp.Backbone.View.extend({ } }, - // Handles .disabled classes for next/previous buttons + // Handles .disabled classes for next/previous buttons. navigation: function() { - // Disable Left/Right when at the start or end of the collection + // Disable Left/Right when at the start or end of the collection. if ( this.model.cid === this.model.collection.at(0).cid ) { this.$el.find( '.left' ) .addClass( 'disabled' ) @@ -775,7 +779,7 @@ themes.view.Details = wp.Backbone.View.extend({ }, // Performs the actions to effectively close - // the theme details overlay + // the theme details overlay. closeOverlay: function() { $( 'body' ).removeClass( 'modal-open' ); this.remove(); @@ -848,7 +852,7 @@ themes.view.Details = wp.Backbone.View.extend({ }, // Checks if the theme screenshot is the old 300px width version - // and adds a corresponding class if it's true + // and adds a corresponding class if it's true. screenshotCheck: function( el ) { var screenshot, image; @@ -856,15 +860,15 @@ themes.view.Details = wp.Backbone.View.extend({ image = new Image(); image.src = screenshot.attr( 'src' ); - // Width check + // Width check. if ( image.width && image.width <= 300 ) { el.addClass( 'small-screenshot' ); } } }); -// Theme Preview view -// Set ups a modal overlay with the expanded theme data +// Theme Preview view. +// Sets up a modal overlay with the expanded theme data. themes.view.Preview = themes.view.Details.extend({ className: 'wp-full-overlay expanded', @@ -880,7 +884,7 @@ themes.view.Preview = themes.view.Details.extend({ 'click .theme-install': 'installTheme' }, - // The HTML template for the theme preview + // The HTML template for the theme preview. html: themes.template( 'theme-preview' ), render: function() { @@ -918,7 +922,7 @@ themes.view.Preview = themes.view.Details.extend({ this.$el.fadeOut( 200, function() { $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ); - // Return focus to the theme div + // Return focus to the theme div. if ( themes.focusedTheme ) { themes.focusedTheme.focus(); } @@ -973,17 +977,17 @@ themes.view.Preview = themes.view.Details.extend({ }, keyEvent: function( event ) { - // The escape key closes the preview + // The escape key closes the preview. if ( event.keyCode === 27 ) { this.undelegateEvents(); this.close(); } - // The right arrow key, next theme + // The right arrow key, next theme. if ( event.keyCode === 39 ) { _.once( this.nextTheme() ); } - // The left arrow key, previous theme + // The left arrow key, previous theme. if ( event.keyCode === 37 ) { this.previousTheme(); } @@ -1011,32 +1015,32 @@ themes.view.Preview = themes.view.Details.extend({ }); // Controls the rendering of div.themes, -// a wrapper that will hold all the theme elements +// a wrapper that will hold all the theme elements. themes.view.Themes = wp.Backbone.View.extend({ className: 'themes wp-clearfix', $overlay: $( 'div.theme-overlay' ), // Number to keep track of scroll position - // while in theme-overlay mode + // while in theme-overlay mode. index: 0, - // The theme count element + // The theme count element. count: $( '.wrap .theme-count' ), - // The live themes count + // The live themes count. liveThemeCount: 0, initialize: function( options ) { var self = this; - // Set up parent + // Set up parent. this.parent = options.parent; - // Set current view to [grid] + // Set current view to [grid]. this.setView( 'grid' ); - // Move the active theme to the beginning of the collection + // Move the active theme to the beginning of the collection. self.currentTheme(); // When the collection is updated by user input... @@ -1082,17 +1086,17 @@ themes.view.Themes = wp.Backbone.View.extend({ return; } - // Pressing the right arrow key fires a theme:next event + // Pressing the right arrow key fires a theme:next event. if ( event.keyCode === 39 ) { self.overlay.nextTheme(); } - // Pressing the left arrow key fires a theme:previous event + // Pressing the left arrow key fires a theme:previous event. if ( event.keyCode === 37 ) { self.overlay.previousTheme(); } - // Pressing the escape key fires a theme:collapse event + // Pressing the escape key fires a theme:collapse event. if ( event.keyCode === 27 ) { self.overlay.collapse( event ); } @@ -1100,35 +1104,33 @@ themes.view.Themes = wp.Backbone.View.extend({ }, // Manages rendering of theme pages - // and keeping theme count in sync + // and keeping theme count in sync. render: function() { - // Clear the DOM, please + // Clear the DOM, please. this.$el.empty(); - // If the user doesn't have switch capabilities - // or there is only one theme in the collection - // render the detailed view of the active theme + // If the user doesn't have switch capabilities or there is only one theme + // in the collection, render the detailed view of the active theme. if ( themes.data.themes.length === 1 ) { - // Constructs the view + // Constructs the view. this.singleTheme = new themes.view.Details({ model: this.collection.models[0] }); - // Render and apply a 'single-theme' class to our container + // Render and apply a 'single-theme' class to our container. this.singleTheme.render(); this.$el.addClass( 'single-theme' ); this.$el.append( this.singleTheme.el ); } - // Generate the themes - // Using page instance - // While checking the collection has items + // Generate the themes using page instance + // while checking the collection has items. if ( this.options.collection.size() > 0 ) { this.renderThemes( this.parent.page ); } - // Display a live theme count for the collection + // Display a live theme count for the collection. this.liveThemeCount = this.collection.count ? this.collection.count : this.collection.length; this.count.text( this.liveThemeCount ); @@ -1142,25 +1144,25 @@ themes.view.Themes = wp.Backbone.View.extend({ }, // Iterates through each instance of the collection - // and renders each theme module + // and renders each theme module. renderThemes: function( page ) { var self = this; self.instance = self.collection.paginate( page ); - // If we have no more themes bail + // If we have no more themes, bail. if ( self.instance.size() === 0 ) { // Fire a no-more-themes event. this.parent.trigger( 'theme:end' ); return; } - // Make sure the add-new stays at the end + // Make sure the add-new stays at the end. if ( ! themes.isInstall && page >= 1 ) { $( '.add-new-theme' ).remove(); } - // Loop through the themes and setup each theme view + // Loop through the themes and setup each theme view. self.instance.each( function( theme ) { self.theme = new themes.view.Theme({ model: theme, @@ -1169,15 +1171,15 @@ themes.view.Themes = wp.Backbone.View.extend({ // Render the views... self.theme.render(); - // and append them to div.themes + // ...and append them to div.themes. self.$el.append( self.theme.el ); // Binds to theme:expand to show the modal box - // with the theme details + // with the theme details. self.listenTo( self.theme, 'theme:expand', self.expand, self ); }); - // 'Add new theme' element shown at the end of the grid + // 'Add new theme' element shown at the end of the grid. if ( ! themes.isInstall && themes.data.settings.canInstall ) { this.$el.append( '<div class="theme add-new-theme"><a href="' + themes.data.settings.installURI + '"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">' + l10n.addNew + '</h2></a></div>' ); } @@ -1185,41 +1187,41 @@ themes.view.Themes = wp.Backbone.View.extend({ this.parent.page++; }, - // Grabs current theme and puts it at the beginning of the collection + // Grabs current theme and puts it at the beginning of the collection. currentTheme: function() { var self = this, current; current = self.collection.findWhere({ active: true }); - // Move the active theme to the beginning of the collection + // Move the active theme to the beginning of the collection. if ( current ) { self.collection.remove( current ); self.collection.add( current, { at:0 } ); } }, - // Sets current view + // Sets current view. setView: function( view ) { return view; }, - // Renders the overlay with the ThemeDetails view - // Uses the current model data + // Renders the overlay with the ThemeDetails view. + // Uses the current model data. expand: function( id ) { var self = this, $card, $modal; - // Set the current theme model + // Set the current theme model. this.model = self.collection.get( id ); - // Trigger a route update for the current model + // Trigger a route update for the current model. themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.id ) ); - // Sets this.view to 'detail' + // Sets this.view to 'detail'. this.setView( 'detail' ); $( 'body' ).addClass( 'modal-open' ); - // Set up the theme details view + // Set up the theme details view. this.overlay = new themes.view.Details({ model: self.model }); @@ -1243,72 +1245,75 @@ themes.view.Themes = wp.Backbone.View.extend({ this.$overlay.html( this.overlay.el ); - // Bind to theme:next and theme:previous - // triggered by the arrow keys - // - // Keep track of the current model so we - // can infer an index position + // Bind to theme:next and theme:previous triggered by the arrow keys. + // Keep track of the current model so we can infer an index position. this.listenTo( this.overlay, 'theme:next', function() { - // Renders the next theme on the overlay + // Renders the next theme on the overlay. self.next( [ self.model.cid ] ); }) .listenTo( this.overlay, 'theme:previous', function() { - // Renders the previous theme on the overlay + // Renders the previous theme on the overlay. self.previous( [ self.model.cid ] ); }); }, - // This method renders the next theme on the overlay modal - // based on the current position in the collection - // @params [model cid] + /* + * This method renders the next theme on the overlay modal + * based on the current position in the collection. + * + * @params [model cid] + */ next: function( args ) { var self = this, model, nextModel; - // Get the current theme + // Get the current theme. model = self.collection.get( args[0] ); - // Find the next model within the collection + // Find the next model within the collection. nextModel = self.collection.at( self.collection.indexOf( model ) + 1 ); - // Sanity check which also serves as a boundary test + // Sanity check which also serves as a boundary test. if ( nextModel !== undefined ) { // We have a new theme... - // Close the overlay + // Close the overlay. this.overlay.closeOverlay(); - // Trigger a route update for the current model + // Trigger a route update for the current model. self.theme.trigger( 'theme:expand', nextModel.cid ); } }, - // This method renders the previous theme on the overlay modal - // based on the current position in the collection - // @params [model cid] + /* + * This method renders the previous theme on the overlay modal + * based on the current position in the collection. + * + * @params [model cid] + */ previous: function( args ) { var self = this, model, previousModel; - // Get the current theme + // Get the current theme. model = self.collection.get( args[0] ); - // Find the previous model within the collection + // Find the previous model within the collection. previousModel = self.collection.at( self.collection.indexOf( model ) - 1 ); if ( previousModel !== undefined ) { // We have a new theme... - // Close the overlay + // Close the overlay. this.overlay.closeOverlay(); - // Trigger a route update for the current model + // Trigger a route update for the current model. self.theme.trigger( 'theme:expand', previousModel.cid ); } }, - // Dispatch audible search results feedback message + // Dispatch audible search results feedback message. announceSearchResults: function( count ) { if ( 0 === count ) { wp.a11y.speak( l10n.noThemesFound ); @@ -1364,14 +1369,14 @@ themes.view.Search = wp.Backbone.View.extend({ this.collection.doSearch( event.target.value.replace( /\+/g, ' ' ) ); - // if search is initiated and key is not return + // if search is initiated and key is not return. if ( this.searching && event.which !== 13 ) { options.replace = true; } else { this.searching = true; } - // Update the URL hash + // Update the URL hash. if ( event.target.value ) { themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + event.target.value ), options ); } else { @@ -1408,8 +1413,8 @@ function navigateRouter( url, state ) { } } -// Sets up the routes events for relevant url queries -// Listens to [theme] and [search] params +// Sets up the routes events for relevant url queries. +// Listens to [theme] and [search] params. themes.Router = Backbone.Router.extend({ routes: { @@ -1439,14 +1444,14 @@ themes.Router = Backbone.Router.extend({ }); -// Execute and setup the application +// Execute and setup the application. themes.Run = { init: function() { - // Initializes the blog's theme library view - // Create a new collection with data + // Initializes the blog's theme library view. + // Create a new collection with data. this.themes = new themes.Collection( themes.data.themes ); - // Set up the view + // Set up the view. this.view = new themes.view.Appearance({ collection: this.themes }); @@ -1459,7 +1464,7 @@ themes.Run = { render: function() { - // Render results + // Render results. this.view.render(); this.routes(); @@ -1476,10 +1481,10 @@ themes.Run = { routes: function() { var self = this; // Bind to our global thx object - // so that the object is available to sub-views + // so that the object is available to sub-views. themes.router = new themes.Router(); - // Handles theme details route event + // Handles theme details route event. themes.router.on( 'route:theme', function( slug ) { self.view.view.expand( slug ); }); @@ -1489,7 +1494,7 @@ themes.Run = { self.view.trigger( 'theme:close' ); }); - // Handles search route event + // Handles search route event. themes.router.on( 'route:search', function() { $( '.wp-filter-search' ).trigger( 'keyup' ); }); @@ -1502,7 +1507,7 @@ themes.Run = { } }; -// Extend the main Search view +// Extend the main Search view. themes.view.InstallerSearch = themes.view.Search.extend({ events: { @@ -1512,10 +1517,10 @@ themes.view.InstallerSearch = themes.view.Search.extend({ terms: '', - // Handles Ajax request for searching through themes in public repo + // Handles Ajax request for searching through themes in public repo. search: function( event ) { - // Tabbing or reverse tabbing into the search input shouldn't trigger a search + // Tabbing or reverse tabbing into the search input shouldn't trigger a search. if ( event.type === 'keyup' && ( event.which === 9 || event.which === 16 ) ) { return; } @@ -1543,19 +1548,23 @@ themes.view.InstallerSearch = themes.view.Search.extend({ request.search = value; - // Intercept an [author] search. - // - // If input value starts with `author:` send a request - // for `author` instead of a regular `search` + /* + * Intercept an [author] search. + * + * If input value starts with `author:` send a request + * for `author` instead of a regular `search`. + */ if ( value.substring( 0, 7 ) === 'author:' ) { request.search = ''; request.author = value.slice( 7 ); } - // Intercept a [tag] search. - // - // If input value starts with `tag:` send a request - // for `tag` instead of a regular `search` + /* + * Intercept a [tag] search. + * + * If input value starts with `tag:` send a request + * for `tag` instead of a regular `search`. + */ if ( value.substring( 0, 4 ) === 'tag:' ) { request.search = ''; request.tag = [ value.slice( 4 ) ]; @@ -1569,10 +1578,10 @@ themes.view.InstallerSearch = themes.view.Search.extend({ $( '.drawer-toggle' ).attr( 'aria-expanded', 'false' ); // Get the themes by sending Ajax POST request to api.wordpress.org/themes - // or searching the local cache + // or searching the local cache. this.collection.query( request ); - // Set route + // Set route. themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + encodeURIComponent( value ) ), { replace: true } ); } }); @@ -1581,7 +1590,7 @@ themes.view.Installer = themes.view.Appearance.extend({ el: '#wpbody-content .wrap', - // Register events for sorting and filters in theme-navigation + // Register events for sorting and filters in theme-navigation. events: { 'click .filter-links li > a': 'onSort', 'click .theme-filter': 'onFilter', @@ -1594,7 +1603,7 @@ themes.view.Installer = themes.view.Appearance.extend({ 'keyup #wporg-username-input': 'saveUsername' }, - // Initial render method + // Initial render method. render: function() { var self = this; @@ -1606,7 +1615,7 @@ themes.view.Installer = themes.view.Appearance.extend({ // Bump `collection.currentQuery.page` and request more themes if we hit the end of the page. this.listenTo( this, 'theme:end', function() { - // Make sure we are not already loading + // Make sure we are not already loading. if ( self.collection.loadingThemes ) { return; } @@ -1639,29 +1648,29 @@ themes.view.Installer = themes.view.Appearance.extend({ this.view.remove(); } - // Set ups the view and passes the section argument + // Sets up the view and passes the section argument. this.view = new themes.view.Themes({ collection: this.collection, parent: this }); - // Reset pagination every time the install view handler is run + // Reset pagination every time the install view handler is run. this.page = 0; - // Render and append + // Render and append. this.$el.find( '.themes' ).remove(); this.view.render(); this.$el.find( '.theme-browser' ).append( this.view.el ).addClass( 'rendered' ); }, - // Handles all the rendering of the public theme directory + // Handles all the rendering of the public theme directory. browse: function( section ) { // Create a new collection with the proper theme data - // for each section + // for each section. this.collection.query( { browse: section } ); }, - // Sorting navigation + // Sorting navigation. onSort: function( event ) { var $el = $( event.target ), sort = $el.data( 'sort' ); @@ -1671,14 +1680,14 @@ themes.view.Installer = themes.view.Appearance.extend({ $( 'body' ).removeClass( 'filters-applied show-filters' ); $( '.drawer-toggle' ).attr( 'aria-expanded', 'false' ); - // Bail if this is already active + // Bail if this is already active. if ( $el.hasClass( this.activeClass ) ) { return; } this.sort( sort ); - // Trigger a router.naviagte update + // Trigger a router.navigate update. themes.router.navigate( themes.router.baseUrl( themes.router.browsePath + sort ) ); }, @@ -1705,13 +1714,13 @@ themes.view.Installer = themes.view.Appearance.extend({ this.browse( sort ); }, - // Filters and Tags + // Filters and Tags. onFilter: function( event ) { var request, $el = $( event.target ), filter = $el.data( 'filter' ); - // Bail if this is already active + // Bail if this is already active. if ( $el.hasClass( this.activeClass ) ) { return; } @@ -1728,21 +1737,21 @@ themes.view.Installer = themes.view.Appearance.extend({ } // Construct the filter request - // using the default values + // using the default values. filter = _.union( [ filter, this.filtersChecked() ] ); request = { tag: [ filter ] }; // Get the themes by sending Ajax POST request to api.wordpress.org/themes - // or searching the local cache + // or searching the local cache. this.collection.query( request ); }, - // Clicking on a checkbox to add another filter to the request + // Clicking on a checkbox to add another filter to the request. addFilter: function() { this.filtersChecked(); }, - // Applying filters triggers a tag request + // Applying filters triggers a tag request. applyFilters: function( event ) { var name, tags = this.filtersChecked(), @@ -1771,7 +1780,7 @@ themes.view.Installer = themes.view.Appearance.extend({ }); // Get the themes by sending Ajax POST request to api.wordpress.org/themes - // or searching the local cache + // or searching the local cache. this.collection.query( request ); }, @@ -1786,7 +1795,7 @@ themes.view.Installer = themes.view.Appearance.extend({ event.preventDefault(); } - // save username on enter + // Save username on enter. if ( event.type === 'keyup' && event.which !== 13 ) { return; } @@ -1798,14 +1807,17 @@ themes.view.Installer = themes.view.Appearance.extend({ }, success: function () { // Get the themes by sending Ajax POST request to api.wordpress.org/themes - // or searching the local cache + // or searching the local cache. that.collection.query( request ); } } ); }, - // Get the checked filters - // @return {array} of tags or false + /** + * Get the checked filters. + * + * @return {array} of tags or false + */ filtersChecked: function() { var items = $( '.filter-group' ).find( ':checkbox' ), tags = []; @@ -1814,7 +1826,7 @@ themes.view.Installer = themes.view.Appearance.extend({ tags.push( $( item ).prop( 'value' ) ); }); - // When no filters are checked, restore initial state and return + // When no filters are checked, restore initial state and return. if ( tags.length === 0 ) { $( '.filter-drawer .apply-filters' ).find( 'span' ).text( '' ); $( '.filter-drawer .clear-filters' ).hide(); @@ -1830,7 +1842,7 @@ themes.view.Installer = themes.view.Appearance.extend({ activeClass: 'current', - /* + /** * When users press the "Upload Theme" button, show the upload form in place. */ uploader: function() { @@ -1845,7 +1857,7 @@ themes.view.Installer = themes.view.Appearance.extend({ }); }, - // Toggle the full filters navigation + // Toggle the full filters navigation. moreFilters: function( event ) { var $body = $( 'body' ), $toggleButton = $( '.drawer-toggle' ); @@ -1865,8 +1877,11 @@ themes.view.Installer = themes.view.Appearance.extend({ $toggleButton.attr( 'aria-expanded', $body.hasClass( 'show-filters' ) ); }, - // Clears all the checked filters - // @uses filtersChecked() + /** + * Clears all the checked filters. + * + * @uses filtersChecked() + */ clearFilters: function( event ) { var items = $( '.filter-group' ).find( ':checkbox' ), self = this; @@ -1919,14 +1934,14 @@ themes.InstallerRouter = Backbone.Router.extend({ themes.RunInstaller = { init: function() { - // Set up the view - // Passes the default 'section' as an option + // Set up the view. + // Passes the default 'section' as an option. this.view = new themes.view.Installer({ section: 'featured', SearchView: themes.view.InstallerSearch }); - // Render results + // Render results. this.render(); // Start debouncing user searches after Backbone.history.start(). @@ -1935,7 +1950,7 @@ themes.RunInstaller = { render: function() { - // Render results + // Render results. this.view.render(); this.routes(); @@ -1954,11 +1969,11 @@ themes.RunInstaller = { request = {}; // Bind to our global `wp.themes` object - // so that the router is available to sub-views + // so that the router is available to sub-views. themes.router = new themes.InstallerRouter(); - // Handles `theme` route event - // Queries the API for the passed theme slug + // Handles `theme` route event. + // Queries the API for the passed theme slug. themes.router.on( 'route:preview', function( slug ) { // Remove existing handlers. @@ -1986,9 +2001,11 @@ themes.RunInstaller = { } }); - // Handles sorting / browsing routes - // Also handles the root URL triggering a sort request - // for `featured`, the default view + /* + * Handles sorting / browsing routes. + * Also handles the root URL triggering a sort request + * for `featured`, the default view. + */ themes.router.on( 'route:sort', function( sort ) { if ( ! sort ) { sort = 'featured'; @@ -2043,7 +2060,7 @@ $( document ).ready(function() { })( jQuery ); -// Align theme browser thickbox +// Align theme browser thickbox. jQuery(document).ready( function($) { window.tb_position = function() { var tbWindow = $('#TB_window'), diff --git a/src/js/_enqueues/wp/util.js b/src/js/_enqueues/wp/util.js index 836d0016f2..5bb0a6b3ae 100644 --- a/src/js/_enqueues/wp/util.js +++ b/src/js/_enqueues/wp/util.js @@ -41,11 +41,13 @@ window.wp = window.wp || {}; }; }); - // wp.ajax - // ------ - // - // Tools for sending ajax requests with JSON responses and built in error handling. - // Mirrors and wraps jQuery's ajax APIs. + /* + * wp.ajax + * ------ + * + * Tools for sending ajax requests with JSON responses and built in error handling. + * Mirrors and wraps jQuery's ajax APIs. + */ wp.ajax = { settings: settings.ajax || {}, @@ -105,7 +107,7 @@ window.wp = window.wp || {}; delete options.success; delete options.error; - // Use with PHP's wp_send_json_success() and wp_send_json_error() + // Use with PHP's wp_send_json_success() and wp_send_json_error(). deferred.jqXHR = $.ajax( options ).done( function( response ) { // Treat a response of 1 as successful for backward compatibility with existing handlers. if ( response === '1' || response === 1 ) { diff --git a/src/js/_enqueues/wp/utils/word-count.js b/src/js/_enqueues/wp/utils/word-count.js index 41a052b572..a0454512bd 100644 --- a/src/js/_enqueues/wp/utils/word-count.js +++ b/src/js/_enqueues/wp/utils/word-count.js @@ -3,7 +3,8 @@ * provided text string. * * @namespace wp.utils - * @since 2.6.0 + * + * @since 2.6.0 * @output wp-admin/js/word-count.js */ @@ -73,17 +74,17 @@ spaceRegExp: / | /gi, HTMLEntityRegExp: /&\S+?;/g, - // \u2014 = em-dash + // \u2014 = em-dash. connectorRegExp: /--|\u2014/g, // Characters to be removed from input text. removeRegExp: new RegExp( [ '[', - // Basic Latin (extract) + // Basic Latin (extract). '\u0021-\u0040\u005B-\u0060\u007B-\u007E', - // Latin-1 Supplement (extract) + // Latin-1 Supplement (extract). '\u0080-\u00BF\u00D7\u00F7', /* @@ -115,7 +116,7 @@ */ '\u2000-\u2BFF', - // Supplemental Punctuation + // Supplemental Punctuation. '\u2E00-\u2E7F', ']' ].join( '' ), 'g' ), @@ -143,7 +144,8 @@ /** * Counts the number of words (or other specified type) in the specified text. * - * @since 2.6.0 + * @since 2.6.0 + * * @memberof wp.utils.wordcounter * * @param {String} text Text to count elements in. diff --git a/src/js/media/controllers/collection-add.js b/src/js/media/controllers/collection-add.js index fedcb308b7..aab6bb03e3 100644 --- a/src/js/media/controllers/collection-add.js +++ b/src/js/media/controllers/collection-add.js @@ -15,8 +15,8 @@ var Selection = wp.media.model.Selection, * @augments Backbone.Model * * @param {object} [attributes] The attributes hash passed to the state. - * @param {string} [attributes.id=library] Unique identifier. - * @param {string} attributes.title Title for the state. Displays in the frame's title region. + * @param {string} [attributes.id=library] Unique identifier. + * @param {string} attributes.title Title for the state. Displays in the frame's title region. * @param {boolean} [attributes.multiple=add] Whether multi-select is enabled. @todo 'add' doesn't seem do anything special, and gets used as a boolean. * @param {wp.media.model.Attachments} [attributes.library] The attachments collection to browse. * If one is not supplied, a collection of attachments of the specified type will be created. @@ -34,8 +34,8 @@ var Selection = wp.media.model.Selection, * @param {int} [attributes.priority=100] The priority for the state link in the media menu. * @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state. * Defaults to false because for this state, because the library of the Edit Gallery state is the selection. - * @param {string} attributes.type The collection's media type. (e.g. 'video'). - * @param {string} attributes.collectionType The collection type. (e.g. 'playlist'). + * @param {string} attributes.type The collection's media type. (e.g. 'video'). + * @param {string} attributes.collectionType The collection type. (e.g. 'playlist'). */ CollectionAdd = Library.extend(/** @lends wp.media.controller.CollectionAdd.prototype */{ defaults: _.defaults( { @@ -87,9 +87,11 @@ CollectionAdd = Library.extend(/** @lends wp.media.controller.CollectionAdd.prot return !! this.mirroring.get( attachment.cid ) && ! edit.get( attachment.cid ) && Selection.prototype.validator.apply( this, arguments ); }; - // Reset the library to ensure that all attachments are re-added - // to the collection. Do so silently, as calling `observe` will - // trigger the `reset` event. + /* + * Reset the library to ensure that all attachments are re-added + * to the collection. Do so silently, as calling `observe` will + * trigger the `reset` event. + */ library.reset( library.mirroring.models, { silent: true }); library.observe( edit ); this.set('editLibrary', edit); diff --git a/src/js/media/controllers/embed.js b/src/js/media/controllers/embed.js index 2b271dcd0a..d6614ed24d 100644 --- a/src/js/media/controllers/embed.js +++ b/src/js/media/controllers/embed.js @@ -63,9 +63,11 @@ Embed = wp.media.controller.State.extend(/** @lends wp.media.controller.Embed.pr scanners: [] }; - // Scan is triggered with the list of `attributes` to set on the - // state, useful for the 'type' attribute and 'scanners' attribute, - // an array of promise objects for asynchronous scan operations. + /* + * Scan is triggered with the list of `attributes` to set on the + * state, useful for the 'type' attribute and 'scanners' attribute, + * an array of promise objects for asynchronous scan operations. + */ if ( this.props.get('url') ) { this.trigger( 'scan', attributes ); } diff --git a/src/js/media/controllers/state.js b/src/js/media/controllers/state.js index 666efe58f4..62e8c545ef 100644 --- a/src/js/media/controllers/state.js +++ b/src/js/media/controllers/state.js @@ -71,24 +71,24 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype reset: function() {}, /** - * @access private * @since 3.5.0 + * @access private */ _ready: function() { this._updateMenu(); }, /** - * @access private * @since 3.5.0 + * @access private */ _preActivate: function() { this.active = true; }, /** - * @access private * @since 3.5.0 + * @access private */ _postActivate: function() { this.on( 'change:menu', this._menu, this ); @@ -106,8 +106,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype }, /** - * @access private * @since 3.5.0 + * @access private */ _deactivate: function() { this.active = false; @@ -121,24 +121,24 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype }, /** - * @access private * @since 3.5.0 + * @access private */ _title: function() { this.frame.title.render( this.get('titleMode') || 'default' ); }, /** - * @access private * @since 3.5.0 + * @access private */ _renderTitle: function( view ) { view.$el.text( this.get('title') || '' ); }, /** - * @access private * @since 3.5.0 + * @access private */ _router: function() { var router = this.frame.router, @@ -159,8 +159,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype }, /** - * @access private * @since 3.5.0 + * @access private */ _menu: function() { var menu = this.frame.menu, @@ -181,8 +181,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype }, /** - * @access private * @since 3.5.0 + * @access private */ _updateMenu: function() { var previous = this.previous('menu'), @@ -200,8 +200,8 @@ var State = Backbone.Model.extend(/** @lends wp.media.controller.State.prototype /** * Create a view in the media menu for the state. * - * @access private * @since 3.5.0 + * @access private * * @param {media.view.Menu} view The menu view. */ diff --git a/src/js/media/models/attachments.js b/src/js/media/models/attachments.js index ed46588189..ac967bda56 100644 --- a/src/js/media/models/attachments.js +++ b/src/js/media/models/attachments.js @@ -133,9 +133,8 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen return; } - // If no `Attachments` model is provided to source the searches - // from, then automatically generate a source from the existing - // models. + // If no `Attachments` model is provided to source the searches from, + // then automatically generate a source from the existing models. if ( ! this._source ) { this._source = new Attachments( this.models ); } @@ -326,10 +325,12 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen if ( ! mirroring || ! mirroring.more ) { return deferred.resolveWith( this ).promise(); } - // If we're mirroring another collection, forward `more` to - // the mirrored collection. Account for a race condition by - // checking if we're still mirroring that collection when - // the request resolves. + /* + * If we're mirroring another collection, forward `more` to + * the mirrored collection. Account for a race condition by + * checking if we're still mirroring that collection when + * the request resolves. + */ mirroring.more( options ).done( function() { if ( this === attachments.mirroring ) { deferred.resolveWith( this ); @@ -412,9 +413,11 @@ var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachmen return; } - // Removes any uploading attachments, updates each attachment's - // menu order, and returns an object with an { id: menuOrder } - // mapping to pass to the request. + /* + * Removes any uploading attachments, updates each attachment's + * menu order, and returns an object with an { id: menuOrder } + * mapping to pass to the request. + */ var attachments = this.chain().filter( function( attachment ) { return ! _.isUndefined( attachment.id ); }).map( function( attachment, index ) { diff --git a/src/js/media/models/post-image.js b/src/js/media/models/post-image.js index f1ff867e48..1642f42e2a 100644 --- a/src/js/media/models/post-image.js +++ b/src/js/media/models/post-image.js @@ -30,7 +30,7 @@ var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.protot this.bindAttachmentListeners(); } - // keep url in sync with changes to the type of link + // Keep URL in sync with changes to the type of link. this.on( 'change:link', this.updateLinkUrl, this ); this.on( 'change:size', this.updateSize, this ); @@ -70,7 +70,7 @@ var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.protot return; } - // default to custom if there is a linkUrl + // Default to custom if there is a linkUrl. type = 'custom'; if ( this.attachment ) { diff --git a/src/js/media/models/query.js b/src/js/media/models/query.js index 90e36e6cc7..a9d01c43a4 100644 --- a/src/js/media/models/query.js +++ b/src/js/media/models/query.js @@ -43,15 +43,19 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ return true; } - // We want any items that can be placed before the last - // item in the set. If we add any items after the last - // item, then we can't guarantee the set is complete. + /* + * We want any items that can be placed before the last + * item in the set. If we add any items after the last + * item, then we can't guarantee the set is complete. + */ if ( this.length ) { return 1 !== this.comparator( attachment, this.last(), { ties: true }); - // Handle the case where there are no items yet and - // we're sorting for recent items. In that case, we want - // changes that occurred after we created the query. + /* + * Handle the case where there are no items yet and + * we're sorting for recent items. In that case, we want + * changes that occurred after we created the query. + */ } else if ( 'DESC' === order && ( 'date' === orderby || 'modified' === orderby ) ) { return attachment.get( orderby ) >= this.created; @@ -65,12 +69,14 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ return false; }; - // Observe the central `wp.Uploader.queue` collection to watch for - // new matches for the query. - // - // Only observe when a limited number of query args are set. There - // are no filters for other properties, so observing will result in - // false positives in those queries. + /* + * Observe the central `wp.Uploader.queue` collection to watch for + * new matches for the query. + * + * Only observe when a limited number of query args are set. There + * are no filters for other properties, so observing will result in + * false positives in those queries. + */ allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent', 'author' ]; if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) { this.observe( wp.Uploader.queue ); @@ -144,7 +150,7 @@ Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{ options.data.query = args; return wp.media.ajax( options ); - // Otherwise, fall back to Backbone.sync() + // Otherwise, fall back to `Backbone.sync()`. } else { /** * Call wp.media.model.Attachments.sync or Backbone.sync diff --git a/src/js/media/routers/manage.js b/src/js/media/routers/manage.js index d058078773..5e0cb21b3d 100644 --- a/src/js/media/routers/manage.js +++ b/src/js/media/routers/manage.js @@ -16,7 +16,7 @@ var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.R 'upload.php': 'reset' }, - // Map routes against the page URL + // Map routes against the page URL. baseUrl: function( url ) { return 'upload.php' + url; }, @@ -29,19 +29,19 @@ var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.R } }, - // Respond to the search route by filling the search field and trigggering the input event + // Respond to the search route by filling the search field and trigggering the input event. search: function( query ) { jQuery( '#media-search-input' ).val( query ).trigger( 'input' ); }, - // Show the modal with a specific item + // Show the modal with a specific item. showItem: function( query ) { var media = wp.media, frame = media.frames.browse, library = frame.state().get('library'), item; - // Trigger the media frame to open the correct item + // Trigger the media frame to open the correct item. item = library.findWhere( { id: parseInt( query, 10 ) } ); item.set( 'skipHistory', true ); diff --git a/src/js/media/utils/selection-sync.js b/src/js/media/utils/selection-sync.js index fd2a872e1d..73cbed002a 100644 --- a/src/js/media/utils/selection-sync.js +++ b/src/js/media/utils/selection-sync.js @@ -22,10 +22,12 @@ var selectionSync = { return; } - // If the selection supports multiple items, validate the stored - // attachments based on the new selection's conditions. Record - // the attachments that are not included; we'll maintain a - // reference to those. Other attachments are considered in flux. + /* + * If the selection supports multiple items, validate the stored + * attachments based on the new selection's conditions. Record + * the attachments that are not included; we'll maintain a + * reference to those. Other attachments are considered in flux. + */ if ( selection.multiple ) { selection.reset( [], { silent: true }); selection.validateAll( manager.attachments ); diff --git a/src/js/media/views/attachment.js b/src/js/media/views/attachment.js index 36ea814fe1..543c75adee 100644 --- a/src/js/media/views/attachment.js +++ b/src/js/media/views/attachment.js @@ -167,13 +167,13 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ return; } - // Catch arrow events + // Catch arrow events. if ( 37 === event.keyCode || 38 === event.keyCode || 39 === event.keyCode || 40 === event.keyCode ) { this.controller.trigger( 'attachment:keydown:arrow', event ); return; } - // Catch enter and space events + // Catch enter and space events. if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) { return; } @@ -183,7 +183,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ // In the grid view, bubble up an edit:attachment event to the controller. if ( this.controller.isModeActive( 'grid' ) ) { if ( this.controller.isModeActive( 'edit' ) ) { - // Pass the current target to restore focus when closing + // Pass the current target to restore focus when closing. this.controller.trigger( 'edit:attachment', this.model, event.currentTarget ); return; } @@ -255,7 +255,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ return; } - // Fixes bug that loses focus when selecting a featured image + // Fixes bug that loses focus when selecting a featured image. if ( ! method ) { method = 'add'; } @@ -265,14 +265,18 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ } if ( this.selected() ) { - // If the model is the single model, remove it. - // If it is not the same as the single model, - // it now becomes the single model. + /* + * If the model is the single model, remove it. + * If it is not the same as the single model, + * it now becomes the single model. + */ selection[ single === model ? 'remove' : 'single' ]( model ); } else { - // If the model is not selected, run the `method` on the - // selection. By default, we `reset` the selection, but the - // `method` can be set to `add` the model to the selection. + /* + * If the model is not selected, run the `method` on the + * selection. By default, we `reset` the selection, but the + * `method` can be set to `add` the model to the selection. + */ selection[ method ]( model ); selection.single( model ); } @@ -298,9 +302,11 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ var selection = this.options.selection, controller = this.controller; - // Check if a selection exists and if it's the collection provided. - // If they're not the same collection, bail; we're in another - // selection's event loop. + /* + * Check if a selection exists and if it's the collection provided. + * If they're not the same collection, bail; we're in another + * selection's event loop. + */ if ( ! selection || ( collection && collection !== selection ) ) { return; } @@ -324,9 +330,11 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ deselect: function( model, collection ) { var selection = this.options.selection; - // Check if a selection exists and if it's the collection provided. - // If they're not the same collection, bail; we're in another - // selection's event loop. + /* + * Check if a selection exists and if it's the collection provided. + * If they're not the same collection, bail; we're in another + * selection's event loop. + */ if ( ! selection || ( collection && collection !== selection ) ) { return; } @@ -478,7 +486,7 @@ Attachment = View.extend(/** @lends wp.media.view.Attachment.prototype */{ * @param {Object} event */ removeFromLibrary: function( event ) { - // Catch enter and space events + // Catch enter and space events. if ( 'keydown' === event.type && 13 !== event.keyCode && 32 !== event.keyCode ) { return; } @@ -565,10 +573,12 @@ _.each({ return this; } - // If the updated value is in sync with the value in the DOM, there - // is no need to re-render. If we're currently editing the value, - // it will automatically be in sync, suppressing the re-render for - // the view we're editing, while updating any others. + /* + * If the updated value is in sync with the value in the DOM, there + * is no need to re-render. If we're currently editing the value, + * it will automatically be in sync, suppressing the re-render for + * the view we're editing, while updating any others. + */ if ( value === $setting.find('input, textarea, select, [value]').val() ) { return this; } diff --git a/src/js/media/views/attachment/details.js b/src/js/media/views/attachment/details.js index 5f80220088..b406818683 100644 --- a/src/js/media/views/attachment/details.js +++ b/src/js/media/views/attachment/details.js @@ -146,10 +146,10 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp this.model.save().done( function() { library._requery( true ); /* - * @todo: We need to move focus back to the previous, next, or first - * attachment but the library gets re-queried and refreshed. Thus, - * the references to the previous attachments are lost. We need an - * alternate method. + * @todo We need to move focus back to the previous, next, or first + * attachment but the library gets re-queried and refreshed. + * Thus, the references to the previous attachments are lost. + * We need an alternate method. */ self.moveFocusToLastFallback(); } ); diff --git a/src/js/media/views/attachments.js b/src/js/media/views/attachments.js index c36f7f681b..cb81ea3072 100644 --- a/src/js/media/views/attachments.js +++ b/src/js/media/views/attachments.js @@ -131,11 +131,11 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ */ attachmentFocus: function() { /* - * @todo: when uploading new attachments, this tries to move focus to the - * attachmentz grid. Actually, a progress bar gets initially displayed + * @todo When uploading new attachments, this tries to move focus to + * the attachments grid. Actually, a progress bar gets initially displayed * and then updated when uploading completes, so focus is lost. - * Additionally: this view is used for both the attachments list and the - * list of selected attachments in the bottom media toolbar. Thus, when + * Additionally: this view is used for both the attachments list and + * the list of selected attachments in the bottom media toolbar. Thus, when * uploading attachments, it is called twice and returns two different `this`. * `this.columns` is truthy within the modal. */ @@ -257,8 +257,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ /** * Initializes jQuery sortable on the attachment list. * - * Fails gracefully if jQuery sortable doesn't exist or isn't passed in the - * options. + * Fails gracefully if jQuery sortable doesn't exist or isn't passed + * in the options. * * @since 3.5.0 * @@ -278,8 +278,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ disabled: !! collection.comparator, /* - * Change the position of the attachment as soon as the mouse pointer overlaps a - * thumbnail. + * Change the position of the attachment as soon as the mouse pointer + * overlaps a thumbnail. */ tolerance: 'pointer', @@ -321,8 +321,8 @@ Attachments = View.extend(/** @lends wp.media.view.Attachments.prototype */{ }, this.options.sortable ) ); /* - * If the `orderby` property is changed on the `collection`, check to see if we - * have a `comparator`. If so, disable sorting. + * If the `orderby` property is changed on the `collection`, + * check to see if we have a `comparator`. If so, disable sorting. */ collection.props.on( 'change:orderby', function() { this.$el.sortable( 'option', 'disabled', !! collection.comparator ); diff --git a/src/js/media/views/attachments/browser.js b/src/js/media/views/attachments/browser.js index a4a880f842..4a4289149d 100644 --- a/src/js/media/views/attachments/browser.js +++ b/src/js/media/views/attachments/browser.js @@ -194,9 +194,11 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro } } - // Feels odd to bring the global media library switcher into the Attachment - // browser view. Is this a use case for doAction( 'add:toolbar-items:attachments-browser', this.toolbar ); - // which the controller can tap into and add this view? + /* + * Feels odd to bring the global media library switcher into the Attachment browser view. + * Is this a use case for doAction( 'add:toolbar-items:attachments-browser', this.toolbar ); + * which the controller can tap into and add this view? + */ if ( this.controller.isModeActive( 'grid' ) ) { LibraryViewSwitcher = View.extend({ className: 'view-switch media-grid-view-switch', @@ -222,7 +224,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro priority: -75 }).render() ); - // BulkSelection is a <div> with subviews, including screen reader text + // BulkSelection is a <div> with subviews, including screen reader text. this.toolbar.set( 'selectModeToggleButton', new wp.media.view.SelectModeToggleButton({ text: l10n.bulkSelect, controller: this.controller, @@ -437,7 +439,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro AttachmentView: this.options.AttachmentView }); - // Add keydown listener to the instance of the Attachments view + // Add keydown listener to the instance of the Attachments view. this.controller.on( 'attachment:keydown:arrow', _.bind( this.attachments.arrowEvent, this.attachments ) ); this.controller.on( 'attachment:details:shift-tab', _.bind( this.attachments.restoreFocus, this.attachments ) ); @@ -516,7 +518,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro }) ); } - // Show the sidebar on mobile + // Show the sidebar on mobile. if ( this.model.id === 'insert' ) { sidebar.$el.addClass( 'visible' ); } @@ -527,7 +529,7 @@ AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.pro sidebar.unset('details'); sidebar.unset('compat'); sidebar.unset('display'); - // Hide the sidebar on mobile + // Hide the sidebar on mobile. sidebar.$el.removeClass( 'visible' ); } }); diff --git a/src/js/media/views/button/select-mode-toggle.js b/src/js/media/views/button/select-mode-toggle.js index dbe662653e..2c2335bcd5 100644 --- a/src/js/media/views/button/select-mode-toggle.js +++ b/src/js/media/views/button/select-mode-toggle.js @@ -49,7 +49,7 @@ SelectModeToggle = Button.extend(/** @lends wp.media.view.SelectModeToggle.proto children = toolbar.$( '.media-toolbar-secondary > *, .media-toolbar-primary > *' ); - // TODO: the Frame should be doing all of this. + // @todo The Frame should be doing all of this. if ( this.controller.isModeActive( 'select' ) ) { this.model.set( { size: 'large', diff --git a/src/js/media/views/embed/link.js b/src/js/media/views/embed/link.js index ade3ae8ce5..f42d494558 100644 --- a/src/js/media/views/embed/link.js +++ b/src/js/media/views/embed/link.js @@ -23,11 +23,11 @@ EmbedLink = wp.media.view.Settings.extend(/** @lends wp.media.view.EmbedLink.pro updateoEmbed: _.debounce( function() { var url = this.model.get( 'url' ); - // clear out previous results + // Clear out previous results. this.$('.embed-container').hide().find('.embed-preview').empty(); this.$( '.setting' ).hide(); - // only proceed with embed if the field contains more than 11 characters + // Only proceed with embed if the field contains more than 11 characters. // Example: http://a.io is 11 chars if ( url && ( url.length < 11 || ! url.match(/^http(s)?:\/\//) ) ) { return; @@ -39,7 +39,7 @@ EmbedLink = wp.media.view.Settings.extend(/** @lends wp.media.view.EmbedLink.pro fetch: function() { var url = this.model.get( 'url' ), re, youTubeEmbedMatch; - // check if they haven't typed in 500 ms + // Check if they haven't typed in 500 ms. if ( $('#embed-url-field').val() !== url ) { return; } diff --git a/src/js/media/views/focus-manager.js b/src/js/media/views/focus-manager.js index ba2db72511..414b7a5418 100644 --- a/src/js/media/views/focus-manager.js +++ b/src/js/media/views/focus-manager.js @@ -91,7 +91,7 @@ var FocusManager = wp.media.View.extend(/** @lends wp.media.view.FocusManager.pr tabbables = this.getTabbables(); - // Keep tab focus within media modal while it's open + // Keep tab focus within media modal while it's open. if ( tabbables.last()[0] === event.target && ! event.shiftKey ) { tabbables.first().focus(); return false; diff --git a/src/js/media/views/frame/edit-attachments.js b/src/js/media/views/frame/edit-attachments.js index 249329f396..a2e1749dc1 100644 --- a/src/js/media/views/frame/edit-attachments.js +++ b/src/js/media/views/frame/edit-attachments.js @@ -255,11 +255,11 @@ EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAtta return; } - // The right arrow key + // The right arrow key. if ( 39 === event.keyCode ) { this.nextMediaItem(); } - // The left arrow key + // The left arrow key. if ( 37 === event.keyCode ) { this.previousMediaItem(); } diff --git a/src/js/media/views/frame/image-details.js b/src/js/media/views/frame/image-details.js index a270df8875..7ad1ecbe30 100644 --- a/src/js/media/views/frame/image-details.js +++ b/src/js/media/views/frame/image-details.js @@ -43,7 +43,7 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr this.on( 'content:create:image-details', this.imageDetailsContent, this ); this.on( 'content:render:edit-image', this.editImageContent, this ); this.on( 'toolbar:render:image-details', this.renderImageDetailsToolbar, this ); - // override the select toolbar + // Override the select toolbar. this.on( 'toolbar:render:replace', this.renderReplaceImageToolbar, this ); }, @@ -91,7 +91,7 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr this.content.set( view ); - // after bringing in the frame, load the actual editor via an ajax call + // After bringing in the frame, load the actual editor via an Ajax call. view.loadEditor(); }, @@ -111,8 +111,8 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr controller.close(); - // not sure if we want to use wp.media.string.image which will create a shortcode or - // perhaps wp.html.string to at least to build the <img /> + // Not sure if we want to use wp.media.string.image which will create a shortcode or + // perhaps wp.html.string to at least to build the <img />. state.trigger( 'update', controller.image.toJSON() ); // Restore and reset the default state. @@ -160,8 +160,8 @@ ImageDetails = Select.extend(/** @lends wp.media.view.MediaFrame.ImageDetails.pr controller.image.changeAttachment( attachment, state.display( attachment ) ); - // not sure if we want to use wp.media.string.image which will create a shortcode or - // perhaps wp.html.string to at least to build the <img /> + // Not sure if we want to use wp.media.string.image which will create a shortcode or + // perhaps wp.html.string to at least to build the <img />. state.trigger( 'replace', controller.image.toJSON() ); // Restore and reset the default state. diff --git a/src/js/media/views/frame/manage.js b/src/js/media/views/frame/manage.js index 4c244120a2..bed774a2e2 100644 --- a/src/js/media/views/frame/manage.js +++ b/src/js/media/views/frame/manage.js @@ -102,7 +102,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype } }, 1000 ); - // Update the URL when entering search string (at most once per second) + // Update the URL when entering search string (at most once per second). search.on( 'input', _.bind( input, this ) ); this.gridRouter @@ -183,7 +183,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype $browser = this.$('.attachments-browser'); $toolbar = $browser.find('.media-toolbar'); - // Offset doesn't appear to take top margin into account, hence +16 + // Offset doesn't appear to take top margin into account, hence +16. if ( ( $browser.offset().top + 16 ) < this.$window.scrollTop() + this.$adminBar.height() ) { $browser.addClass( 'fixed' ); $toolbar.css('width', $browser.width() + 'px'); @@ -271,7 +271,7 @@ Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype }, startHistory: function() { - // Verify pushState support and activate + // Verify pushState support and activate. if ( window.history && window.history.pushState ) { if ( Backbone.History.started ) { Backbone.history.stop(); diff --git a/src/js/media/views/frame/post.js b/src/js/media/views/frame/post.js index dbf550d0ec..064c024cf4 100644 --- a/src/js/media/views/frame/post.js +++ b/src/js/media/views/frame/post.js @@ -180,7 +180,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ this.on( 'activate', this.activate, this ); - // Only bother checking media type counts if one of the counts is zero + // Only bother checking media type counts if one of the counts is zero. checkCounts = _.find( this.counts, function( type ) { return type.count === 0; } ); @@ -235,7 +235,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ }, activate: function() { - // Hide menu items for states tied to particular media types if there are no items + // Hide menu items for states tied to particular media types if there are no items. _.each( this.counts, function( type ) { if ( type.count < 1 ) { this.menuItemVisibility( type.state, 'hide' ); @@ -250,7 +250,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ } }, - // Menus + // Menus. /** * @param {wp.Backbone.View} view */ @@ -358,7 +358,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ }); }, - // Content + // Content. embedContent: function() { var view = new wp.media.view.Embed({ controller: this, @@ -400,7 +400,7 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ // Browse our library of attachments. this.content.set( view ); - // Trigger the controller to set focus + // Trigger the controller to set focus. this.trigger( 'edit:selection', this ); }, @@ -410,12 +410,12 @@ Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{ this.content.set( view ); - // after creating the wrapper view, load the actual editor via an ajax call + // After creating the wrapper view, load the actual editor via an Ajax call. view.loadEditor(); }, - // Toolbars + // Toolbars. /** * @param {wp.Backbone.View} view diff --git a/src/js/media/views/frame/select.js b/src/js/media/views/frame/select.js index acb58906c9..3f3c0642ee 100644 --- a/src/js/media/views/frame/select.js +++ b/src/js/media/views/frame/select.js @@ -64,7 +64,7 @@ Select = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Select.prototype this.content.set( view ); - // after creating the wrapper view, load the actual editor via an ajax call + // After creating the wrapper view, load the actual editor via an Ajax call. view.loadEditor(); }, diff --git a/src/js/media/views/image-details.js b/src/js/media/views/image-details.js index cbd62e306d..db3597a4f9 100644 --- a/src/js/media/views/image-details.js +++ b/src/js/media/views/image-details.js @@ -27,7 +27,7 @@ ImageDetails = AttachmentDisplay.extend(/** @lends wp.media.view.ImageDetails.pr 'keyup [data-setting="customHeight"]': 'onCustomSize' } ), initialize: function() { - // used in AttachmentDisplay.prototype.updateLinkTo + // Used in AttachmentDisplay.prototype.updateLinkTo. this.options.attachment = this.model.attachment; this.listenTo( this.model, 'change:url', this.updateUrl ); this.listenTo( this.model, 'change:link', this.toggleLinkSettings ); @@ -109,7 +109,7 @@ ImageDetails = AttachmentDisplay.extend(/** @lends wp.media.view.ImageDetails.pr num = $( event.target ).val(), value; - // Ignore bogus input + // Ignore bogus input. if ( ! /^\d+/.test( num ) || parseInt( num, 10 ) < 1 ) { event.preventDefault(); return; diff --git a/src/js/media/views/menu-item.js b/src/js/media/views/menu-item.js index b492b4eae3..6acb5c361b 100644 --- a/src/js/media/views/menu-item.js +++ b/src/js/media/views/menu-item.js @@ -42,7 +42,7 @@ MenuItem = wp.media.View.extend(/** @lends wp.media.view.MenuItem.prototype */{ if ( state ) { this.controller.setState( state ); // Toggle the menu visibility in the responsive view. - this.views.parent.$el.removeClass( 'visible' ); // TODO: or hide on any click, see below + this.views.parent.$el.removeClass( 'visible' ); // @todo Or hide on any click, see below. } }, diff --git a/src/js/media/views/modal.js b/src/js/media/views/modal.js index 7927c0777b..d06bf9b599 100644 --- a/src/js/media/views/modal.js +++ b/src/js/media/views/modal.js @@ -102,7 +102,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ $el.show(); - // Try to close the onscreen keyboard + // Try to close the onscreen keyboard. if ( 'ontouchend' in document ) { if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) { mceEditor.iframeElement.focus(); @@ -135,7 +135,7 @@ Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ // Enable page scrolling. $( 'body' ).removeClass( 'modal-open' ); - // Hide modal and remove restricted media modal tab focus once it's closed + // Hide modal and remove restricted media modal tab focus once it's closed. this.$el.hide().undelegate( 'keydown' ); /* diff --git a/src/js/media/views/toolbar.js b/src/js/media/views/toolbar.js index 4cd6ee2d8f..1beb428fe6 100644 --- a/src/js/media/views/toolbar.js +++ b/src/js/media/views/toolbar.js @@ -142,7 +142,7 @@ Toolbar = View.extend(/** @lends wp.media.view.Toolbar.prototype */{ var requires = button.options.requires, disabled = false; - // Prevent insertion of attachments if any of them are still uploading + // Prevent insertion of attachments if any of them are still uploading. if ( selection && selection.models ) { disabled = _.some( selection.models, function( attachment ) { return attachment.get('uploading') === true; diff --git a/src/js/media/views/uploader/inline.js b/src/js/media/views/uploader/inline.js index 4cb80e1e0e..bd2cff0dcc 100644 --- a/src/js/media/views/uploader/inline.js +++ b/src/js/media/views/uploader/inline.js @@ -70,9 +70,11 @@ UploaderInline = View.extend(/** @lends wp.media.view.UploaderInline.prototype * return View.prototype.dispose.apply( this, arguments ); } - // Run remove on `dispose`, so we can be sure to refresh the - // uploader with a view-less DOM. Track whether we're disposing - // so we don't trigger an infinite loop. + /* + * Run remove on `dispose`, so we can be sure to refresh the + * uploader with a view-less DOM. Track whether we're disposing + * so we don't trigger an infinite loop. + */ this.disposing = true; return this.remove(); }, diff --git a/src/js/media/views/view.js b/src/js/media/views/view.js index 19b16e5c8f..e8a4b3621a 100644 --- a/src/js/media/views/view.js +++ b/src/js/media/views/view.js @@ -31,9 +31,11 @@ var View = wp.Backbone.View.extend(/** @lends wp.media.View.prototype */{ * @return {wp.media.View} Returns itself to allow chaining. */ dispose: function() { - // Undelegating events, removing events from the model, and - // removing events from the controller mirror the code for - // `Backbone.View.dispose` in Backbone 0.9.8 development. + /* + * Undelegating events, removing events from the model, and + * removing events from the controller mirror the code for + * `Backbone.View.dispose` in Backbone 0.9.8 development. + */ this.undelegateEvents(); if ( this.model && this.model.off ) { diff --git a/src/wp-activate.php b/src/wp-activate.php index 0349f3fa37..5949372fe7 100644 --- a/src/wp-activate.php +++ b/src/wp-activate.php @@ -68,7 +68,7 @@ if ( is_object( $wp_object_cache ) ) { $wp_object_cache->cache_enabled = false; } -// Fix for page title +// Fix for page title. $wp_query->is_404 = false; /** diff --git a/src/wp-admin/_index.php b/src/wp-admin/_index.php index 9389409e88..7dcf45c481 100644 --- a/src/wp-admin/_index.php +++ b/src/wp-admin/_index.php @@ -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>' . __( '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'; $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' ) ); if ( $hide ) { $classes .= ' hidden'; diff --git a/src/wp-admin/admin-ajax.php b/src/wp-admin/admin-ajax.php index deea44152c..57d33f4f54 100644 --- a/src/wp-admin/admin-ajax.php +++ b/src/wp-admin/admin-ajax.php @@ -27,7 +27,7 @@ send_origin_headers(); header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) ); header( 'X-Robots-Tag: noindex' ); -// Require an action parameter +// Require an action parameter. if ( empty( $_REQUEST['action'] ) ) { wp_die( '0', 400 ); } @@ -141,7 +141,7 @@ $core_actions_post = array( '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 = array_merge( $core_actions_post, $core_actions_post_deprecated ); @@ -189,5 +189,5 @@ if ( is_user_logged_in() ) { */ do_action( "wp_ajax_nopriv_{$action}" ); } -// Default status +// Default status. wp_die( '0' ); diff --git a/src/wp-admin/admin-footer.php b/src/wp-admin/admin-footer.php index 4c4c40a081..099b45dfe0 100644 --- a/src/wp-admin/admin-footer.php +++ b/src/wp-admin/admin-footer.php @@ -6,7 +6,7 @@ * @subpackage Administration */ -// don't load directly +// Don't load directly. if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } @@ -104,7 +104,7 @@ do_action( 'admin_print_footer_scripts' ); */ 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 ( false === get_site_option( 'can_compress_scripts' ) ) { compression_test(); diff --git a/src/wp-admin/admin.php b/src/wp-admin/admin.php index 5f8916ed41..14014b04f3 100644 --- a/src/wp-admin/admin.php +++ b/src/wp-admin/admin.php @@ -93,12 +93,12 @@ require_once( ABSPATH . 'wp-admin/includes/admin.php' ); auth_redirect(); -// Schedule trash collection +// Schedule trash collection. if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) { wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' ); } -// Schedule Transient cleanup. +// Schedule transient cleanup. if ( ! wp_next_scheduled( 'delete_expired_transients' ) && ! wp_installing() ) { wp_schedule_event( time(), 'daily', 'delete_expired_transients' ); } @@ -182,7 +182,7 @@ if ( isset( $plugin_page ) ) { // Back-compat for plugins using add_management_page(). 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'] ) ) { $query_string = $_SERVER['QUERY_STRING']; } else { @@ -347,7 +347,7 @@ if ( isset( $plugin_page ) ) { include( ABSPATH . 'wp-admin/admin-footer.php' ); - // Make sure rules are flushed + // Make sure rules are flushed. flush_rewrite_rules( false ); exit(); diff --git a/src/wp-admin/async-upload.php b/src/wp-admin/async-upload.php index 4d37f7f644..349335ec0a 100644 --- a/src/wp-admin/async-upload.php +++ b/src/wp-admin/async-upload.php @@ -38,7 +38,7 @@ if ( ! current_user_can( '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'] ) { $id = intval( $_REQUEST['attachment_id'] ); $post = get_post( $id ); @@ -112,7 +112,7 @@ if ( $_REQUEST['short'] ) { // Short form response - attachment ID only. echo $id; } else { - // Long form response - big chunk of html. + // Long form response - big chunk of HTML. $type = $_REQUEST['type']; /** diff --git a/src/wp-admin/comment.php b/src/wp-admin/comment.php index 145cd7a5ea..7678a83d92 100644 --- a/src/wp-admin/comment.php +++ b/src/wp-admin/comment.php @@ -137,7 +137,7 @@ switch ( $action ) { break; } - if ( $comment->comment_approved != '0' ) { // if not unapproved + if ( $comment->comment_approved != '0' ) { // If not unapproved. $message = ''; switch ( $comment->comment_approved ) { case '1': @@ -355,6 +355,6 @@ switch ( $action ) { default: wp_die( __( 'Unknown action.' ) ); -} // end switch +} // End switch. include( ABSPATH . 'wp-admin/admin-footer.php' ); diff --git a/src/wp-admin/credits.php b/src/wp-admin/credits.php index af4792d2b4..e6e66564ed 100644 --- a/src/wp-admin/credits.php +++ b/src/wp-admin/credits.php @@ -133,7 +133,7 @@ include( ABSPATH . 'wp-admin/admin-footer.php' ); 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' ); /* translators: %s: The current WordPress version number. */ __( 'Core Contributors to WordPress %s' ); diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index b159c0a179..a03fd00e59 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -52,7 +52,7 @@ if ( $doaction ) { 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 ) ) { continue; } diff --git a/src/wp-admin/edit-form-advanced.php b/src/wp-admin/edit-form-advanced.php index e7127fbcb2..20b62af216 100644 --- a/src/wp-admin/edit-form-advanced.php +++ b/src/wp-admin/edit-form-advanced.php @@ -6,7 +6,7 @@ * @subpackage Administration */ -// don't load directly +// Don't load directly. if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } @@ -95,7 +95,7 @@ if ( $thumbnail_support ) { 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' ); /* @@ -242,7 +242,7 @@ $form_action = 'editpost'; $nonce_action = 'update-post_' . $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 ) ) { foreach ( _wp_post_revision_fields( $post ) as $autosave_field => $_autosave_field ) { if ( normalize_whitespace( $autosave->$autosave_field ) != normalize_whitespace( $post->$autosave_field ) ) { diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index dcec9faaab..274325ae74 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -8,7 +8,7 @@ * @subpackage Administration */ -// don't load directly +// Don't load directly. if ( ! defined( 'ABSPATH' ) ) { 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 ); -// Get all available templates for the post/page attributes meta-box. -// The "Default template" array element should only be added if the array is -// not empty so we do not trigger the template select element without any options -// besides the default value. +/* + * Get all available templates for the post/page attributes meta-box. + * The "Default template" array element should only be added if the array is + * 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 = ! empty( $available_templates ) ? array_merge( array( diff --git a/src/wp-admin/edit-form-comment.php b/src/wp-admin/edit-form-comment.php index aaed1f9fa4..43b568a0aa 100644 --- a/src/wp-admin/edit-form-comment.php +++ b/src/wp-admin/edit-form-comment.php @@ -6,7 +6,7 @@ * @subpackage Administration */ -// don't load directly +// Don't load directly. if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } diff --git a/src/wp-admin/edit-link-form.php b/src/wp-admin/edit-link-form.php index 05c3751f72..13cc68ae05 100644 --- a/src/wp-admin/edit-link-form.php +++ b/src/wp-admin/edit-link-form.php @@ -6,7 +6,7 @@ * @subpackage Administration */ -// don't load directly +// Don't load directly. if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } diff --git a/src/wp-admin/edit-tag-form.php b/src/wp-admin/edit-tag-form.php index a56ee93ff7..42350b709a 100644 --- a/src/wp-admin/edit-tag-form.php +++ b/src/wp-admin/edit-tag-form.php @@ -6,12 +6,12 @@ * @subpackage Administration */ -// don't load directly +// Don't load directly. if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } -// Back compat hooks +// Back compat hooks. if ( 'category' == $taxonomy ) { /** * 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> </tr> <?php - // Back compat hooks + // Back compat hooks. if ( 'category' == $taxonomy ) { /** * Fires after the Edit Category form fields are displayed. @@ -238,7 +238,7 @@ if ( isset( $tag->name ) ) { ?> </table> <?php -// Back compat hooks +// Back compat hooks. if ( 'category' == $taxonomy ) { /** This action is documented in wp-admin/edit-tags.php */ do_action_deprecated( 'edit_category_form', array( $tag ), '3.0.0', '{$taxonomy}_add_form' ); diff --git a/src/wp-admin/edit-tags.php b/src/wp-admin/edit-tags.php index 580c70dc7a..de1dc624c9 100644 --- a/src/wp-admin/edit-tags.php +++ b/src/wp-admin/edit-tags.php @@ -204,7 +204,7 @@ switch ( $wp_list_table->current_action() ) { $tags = (array) $_REQUEST['delete_tags']; /** 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; } diff --git a/src/wp-admin/edit.php b/src/wp-admin/edit.php index 5c818f4e4c..0584e7fe6d 100644 --- a/src/wp-admin/edit.php +++ b/src/wp-admin/edit.php @@ -47,7 +47,7 @@ if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) { $wp_list_table = _get_list_table( 'WP_Posts_List_Table' ); $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 ) { if ( ! empty( $_REQUEST[ $_redirect ] ) ) { wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) ); diff --git a/src/wp-admin/import.php b/src/wp-admin/import.php index d10f60bde7..cc4246d65c 100644 --- a/src/wp-admin/import.php +++ b/src/wp-admin/import.php @@ -39,7 +39,7 @@ if ( current_user_can( 'install_plugins' ) ) { $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'] ] ) ) { $importer_id = $popular_importers[ $_GET['invalid'] ]['importer-id']; if ( $importer_id != $_GET['invalid'] ) { // Prevent redirect loops. @@ -93,7 +93,7 @@ foreach ( $popular_importers as $pop_importer => $pop_data ) { } 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 { uasort( $importers, '_usort_by_first_member' ); ?> diff --git a/src/wp-admin/includes/admin-filters.php b/src/wp-admin/includes/admin-filters.php index c080fd0f24..4e66b28bb8 100644 --- a/src/wp-admin/includes/admin-filters.php +++ b/src/wp-admin/includes/admin-filters.php @@ -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_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_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 ); diff --git a/src/wp-admin/includes/admin.php b/src/wp-admin/includes/admin.php index 8c3a3eb156..43f0014eb2 100644 --- a/src/wp-admin/includes/admin.php +++ b/src/wp-admin/includes/admin.php @@ -74,7 +74,7 @@ require_once( ABSPATH . 'wp-admin/includes/theme.php' ); require_once( ABSPATH . 'wp-admin/includes/privacy-tools.php' ); /** 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-data-export-requests-list-table.php' ); require_once( ABSPATH . 'wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php' ); diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index 495693c313..f230290bb9 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -22,7 +22,7 @@ function wp_ajax_nopriv_heartbeat() { $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'] ) ) { $screen_id = sanitize_key( $_POST['screen_id'] ); } else { @@ -272,23 +272,23 @@ function wp_ajax_autocomplete_user() { $return = array(); - // Check the type of request - // Current allowed values are `add` and `search` + // Check the type of request. + // Current allowed values are `add` and `search`. if ( isset( $_REQUEST['autocomplete_type'] ) && 'search' === $_REQUEST['autocomplete_type'] ) { $type = $_REQUEST['autocomplete_type']; } else { $type = 'add'; } - // Check the desired field for value - // Current allowed values are `user_email` and `user_login` + // Check the desired field for value. + // Current allowed values are `user_email` and `user_login`. if ( isset( $_REQUEST['autocomplete_field'] ) && 'user_email' === $_REQUEST['autocomplete_field'] ) { $field = $_REQUEST['autocomplete_field']; } else { $field = 'user_login'; } - // Exclude current users of this blog + // Exclude current users of this blog. if ( isset( $_REQUEST['site_id'] ) ) { $id = absint( $_REQUEST['site_id'] ); } else { @@ -433,7 +433,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { $page = isset( $_POST['_page'] ) ? (int) $_POST['_page'] : 0; $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 ) { $time = time(); $comment = get_comment( $comment_id ); @@ -482,7 +482,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { $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 ) ) { $post_id = 0; // What type of comment count are we looking for? @@ -600,7 +600,7 @@ function _wp_ajax_add_hierarchical_term() { $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; } @@ -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 ); $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 ); if ( is_wp_error( $parent ) ) { break; @@ -716,7 +716,8 @@ function wp_ajax_delete_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; } } elseif ( isset( $_POST['spam'] ) && 1 == $_POST['spam'] ) { @@ -732,7 +733,8 @@ function wp_ajax_delete_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; } } elseif ( isset( $_POST['delete'] ) && 1 == $_POST['delete'] ) { @@ -741,7 +743,8 @@ function wp_ajax_delete_comment() { 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 ); } @@ -989,7 +992,7 @@ function wp_ajax_dim_comment() { $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_die( 0 ); } @@ -1161,7 +1164,7 @@ function wp_ajax_get_tagcloud() { $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( $tags, array( @@ -1288,8 +1291,8 @@ function wp_ajax_replyto_comment( $action ) { } if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) { - kses_remove_filters(); // start with a clean slate - kses_init_filters(); // set up the filters + kses_remove_filters(); // Start with a clean slate. + kses_init_filters(); // Set up the filters. remove_filter( 'pre_comment_content', 'wp_filter_post_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_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; } @@ -1498,7 +1501,7 @@ function wp_ajax_add_menu_item() { if ( ! empty( $menu_obj->ID ) ) { $menu_obj = wp_setup_nav_menu_item( $menu_obj ); $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; } } @@ -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 ( $post->post_status == 'auto-draft' ) { $post_data = array(); - $post_data['action'] = 'draft'; // Warning fix + $post_data['action'] = 'draft'; // Warning fix. $post_data['post_ID'] = $pid; $post_data['post_type'] = $post->post_type; $post_data['post_status'] = 'draft'; @@ -1608,7 +1611,7 @@ function wp_ajax_add_meta() { $meta = get_metadata_by_mid( 'post', $mid ); if ( ! $meta ) { - wp_die( 0 ); // if meta doesn't exist + wp_die( 0 ); // If meta doesn't exist. } if ( @@ -1731,7 +1734,8 @@ function wp_ajax_closed_postboxes() { } 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 ); } @@ -2620,7 +2624,7 @@ function wp_ajax_image_editor() { * @since 3.1.0 */ 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'] ); if ( ! current_user_can( 'edit_post', $post_ID ) ) { @@ -3226,7 +3230,7 @@ function wp_ajax_send_attachment_to_editor() { $html = stripslashes_deep( $_POST['html'] ); } else { $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 ) ) { $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 ); if ( $check_embed !== $fallback ) { - // TinyMCE view for [embed] will parse this + // TinyMCE view for [embed] will parse this. $html = '[embed]' . $src . '[/embed]'; } elseif ( $link_text ) { $html = '<a href="' . esc_url( $src ) . '">' . $link_text . '</a>'; @@ -3327,7 +3331,7 @@ function wp_ajax_heartbeat() { $data = array(); $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'] ) ) { $screen_id = sanitize_key( $_POST['screen_id'] ); } else { @@ -3392,7 +3396,7 @@ function wp_ajax_heartbeat() { */ 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(); wp_send_json( $response ); @@ -3735,7 +3739,7 @@ function wp_ajax_parse_media_shortcode() { $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 ( 'embed' === $shortcode ) { wp_send_json_error(); diff --git a/src/wp-admin/includes/class-automatic-upgrader-skin.php b/src/wp-admin/includes/class-automatic-upgrader-skin.php index e3cc207776..9875c6dee5 100644 --- a/src/wp-admin/includes/class-automatic-upgrader-skin.php +++ b/src/wp-admin/includes/class-automatic-upgrader-skin.php @@ -41,8 +41,10 @@ class Automatic_Upgrader_Skin extends WP_Upgrader_Skin { if ( $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(); $result = parent::request_filesystem_credentials( $error, $context, $allow_relaxed_file_ownership ); ob_end_clean(); diff --git a/src/wp-admin/includes/class-core-upgrader.php b/src/wp-admin/includes/class-core-upgrader.php index dd3f540dda..328c91de15 100644 --- a/src/wp-admin/includes/class-core-upgrader.php +++ b/src/wp-admin/includes/class-core-upgrader.php @@ -115,7 +115,7 @@ class Core_Upgrader extends WP_Upgrader { $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 ); if ( ! $lock ) { 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' ); if ( ! $parsed_args['do_rollback'] ) { @@ -272,8 +272,9 @@ class Core_Upgrader extends WP_Upgrader { public static function should_update_to_version( $offered_ver ) { include( ABSPATH . WPINC . '/version.php' ); // $wp_version; // x.y.z - $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 + $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 + $current_is_development_version = (bool) strpos( $wp_version, '-' ); // Defaults: @@ -284,17 +285,17 @@ class Core_Upgrader extends WP_Upgrader { // WP_AUTO_UPDATE_CORE = true (all), 'minor', false. if ( defined( '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_minor = false; $upgrade_major = false; } elseif ( true === WP_AUTO_UPDATE_CORE ) { - // ALL updates for core + // ALL updates for core. $upgrade_dev = true; $upgrade_minor = true; $upgrade_major = true; } elseif ( 'minor' === WP_AUTO_UPDATE_CORE ) { - // Only minor updates for core + // Only minor updates for core. $upgrade_dev = false; $upgrade_minor = true; $upgrade_major = false; @@ -306,7 +307,7 @@ class Core_Upgrader extends WP_Upgrader { 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, '>' ) ) { return false; } @@ -323,15 +324,17 @@ class Core_Upgrader extends WP_Upgrader { 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. - // 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. + /* + * 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. + * 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'] ) { 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 ) { /** @@ -348,7 +351,7 @@ class Core_Upgrader extends WP_Upgrader { // 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 ) { /** @@ -361,7 +364,7 @@ class Core_Upgrader extends WP_Upgrader { 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, '>' ) ) { /** @@ -374,7 +377,7 @@ class Core_Upgrader extends WP_Upgrader { 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; } @@ -398,7 +401,7 @@ class Core_Upgrader extends WP_Upgrader { } foreach ( $checksums as $file => $checksum ) { - // Skip files which get updated + // Skip files which get updated. if ( 'wp-content' == substr( $file, 0, 10 ) ) { continue; } diff --git a/src/wp-admin/includes/class-custom-background.php b/src/wp-admin/includes/class-custom-background.php index ea74ef420c..30a05bf607 100644 --- a/src/wp-admin/includes/class-custom-background.php +++ b/src/wp-admin/includes/class-custom-background.php @@ -124,7 +124,7 @@ class Custom_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' ); set_theme_mod( 'background_image', '' ); set_theme_mod( 'background_image_thumb', '' ); @@ -284,7 +284,7 @@ class Custom_Background { . " 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 ) { ?> <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="" /> @@ -503,7 +503,7 @@ class Custom_Background { $file = $file['file']; $filename = wp_basename( $file ); - // Construct the object array + // Construct the object array. $object = array( 'post_title' => $filename, 'post_content' => $url, @@ -512,10 +512,10 @@ class Custom_Background { 'context' => 'custom-background', ); - // Save the data + // Save the data. $id = wp_insert_attachment( $object, $file ); - // Add the meta-data + // Add the metadata. wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 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] ) ); /** 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; } diff --git a/src/wp-admin/includes/class-custom-image-header.php b/src/wp-admin/includes/class-custom-image-header.php index 12d307d6d4..4f3eb75786 100644 --- a/src/wp-admin/includes/class-custom-image-header.php +++ b/src/wp-admin/includes/class-custom-image-header.php @@ -800,7 +800,7 @@ endif; } $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' ) ) { $max_width = 1500; } @@ -810,10 +810,10 @@ endif; } $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' ) && $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 ) ) { 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 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(); } elseif ( $width > $max_width ) { @@ -839,7 +839,7 @@ endif; } /** 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 ); $width = $width / $oitar; @@ -910,7 +910,7 @@ endif; $file = $file['file']; $filename = wp_basename( $file ); - // Construct the object array + // Construct the object array. $object = array( 'post_title' => $filename, 'post_content' => $url, @@ -919,7 +919,7 @@ endif; 'context' => 'custom-header', ); - // Save the data + // Save the data. $attachment_id = wp_insert_attachment( $object, $file ); 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 */ - $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 ); @@ -990,7 +990,7 @@ endif; unset( $object['ID'] ); } - // Update the attachment + // Update the attachment. $attachment_id = $this->insert_attachment( $object, $cropped ); $url = wp_get_attachment_url( $attachment_id ); @@ -1180,7 +1180,7 @@ endif; '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 ) { $max_width = 1500; } @@ -1318,7 +1318,7 @@ endif; } /** 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 ); @@ -1434,8 +1434,8 @@ endif; // Get the default image if there is one. $default = get_theme_support( 'custom-header', 'default-image' ); - if ( ! $default ) { // If not, - return $this->default_headers; // easy peasy. + if ( ! $default ) { // If not, easy peasy. + return $this->default_headers; } $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); diff --git a/src/wp-admin/includes/class-file-upload-upgrader.php b/src/wp-admin/includes/class-file-upload-upgrader.php index 52e103cc79..3bdae332c8 100644 --- a/src/wp-admin/includes/class-file-upload-upgrader.php +++ b/src/wp-admin/includes/class-file-upload-upgrader.php @@ -56,7 +56,7 @@ class File_Upload_Upgrader { 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 ) ) { $overrides = array( 'test_form' => false, @@ -71,7 +71,7 @@ class File_Upload_Upgrader { $this->filename = $_FILES[ $form ]['name']; $this->package = $file['file']; - // Construct the object array + // Construct the object array. $object = array( 'post_title' => $this->filename, 'post_content' => $file['url'], diff --git a/src/wp-admin/includes/class-language-pack-upgrader.php b/src/wp-admin/includes/class-language-pack-upgrader.php index 72a86bb32f..0ae18d9e50 100644 --- a/src/wp-admin/includes/class-language-pack-upgrader.php +++ b/src/wp-admin/includes/class-language-pack-upgrader.php @@ -192,7 +192,7 @@ class Language_Pack_Upgrader extends WP_Upgrader { $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_clear_destination' ); remove_all_filters( 'upgrader_post_install' ); @@ -202,7 +202,7 @@ class Language_Pack_Upgrader extends WP_Upgrader { $this->skin->header(); - // Connect to the Filesystem first. + // Connect to the filesystem first. $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) ); if ( ! $res ) { $this->skin->footer(); @@ -369,7 +369,7 @@ class Language_Pack_Upgrader extends WP_Upgrader { public function get_name_for_update( $update ) { switch ( $update->type ) { case 'core': - return 'WordPress'; // Not translated + return 'WordPress'; // Not translated. case 'theme': $theme = wp_get_theme( $update->slug ); diff --git a/src/wp-admin/includes/class-plugin-upgrader.php b/src/wp-admin/includes/class-plugin-upgrader.php index e4b6f54baa..28523e9db8 100644 --- a/src/wp-admin/includes/class-plugin-upgrader.php +++ b/src/wp-admin/includes/class-plugin-upgrader.php @@ -123,7 +123,7 @@ class Plugin_Upgrader extends WP_Upgrader { return $this->result; } - // Force refresh of plugin update information + // Force refresh of plugin update information. wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); return true; @@ -163,12 +163,13 @@ class Plugin_Upgrader extends WP_Upgrader { return false; } - // Get the URL to the zip file + // Get the URL to the zip file. $r = $current->response[ $plugin ]; 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 ); - //'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'] ) { // Clear cache so wp_update_plugins() knows about the new plugin. add_action( 'upgrader_process_complete', 'wp_clean_plugins_cache', 9, 0 ); @@ -197,7 +198,7 @@ class Plugin_Upgrader extends WP_Upgrader { return $this->result; } - // Force refresh of plugin update information + // Force refresh of plugin update information. wp_clean_plugins_cache( $parsed_args['clear_update_cache'] ); return true; @@ -234,7 +235,7 @@ class Plugin_Upgrader extends WP_Upgrader { $this->skin->header(); - // Connect to the Filesystem first. + // Connect to the filesystem first. $res = $this->fs_connect( array( WP_CONTENT_DIR, WP_PLUGIN_DIR ) ); if ( ! $res ) { $this->skin->footer(); @@ -247,7 +248,7 @@ class Plugin_Upgrader extends WP_Upgrader { * Only start maintenance mode if: * - running Multisite and there are one or more plugins specified, OR * - 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 ) ); foreach ( $plugins as $plugin ) { @@ -294,11 +295,11 @@ class Plugin_Upgrader extends WP_Upgrader { $results[ $plugin ] = $this->result; - // Prevent credentials auth screen from displaying multiple times + // Prevent credentials auth screen from displaying multiple times. if ( false === $result ) { break; } - } //end foreach $plugins + } // End foreach $plugins. $this->maintenance_mode( false ); @@ -353,7 +354,7 @@ class Plugin_Upgrader extends WP_Upgrader { return $source; } - // Check the folder contains at least 1 valid plugin. + // Check that the folder contains at least 1 valid plugin. $plugins_found = false; $files = glob( $working_directory . '*.php' ); if ( $files ) { @@ -390,12 +391,14 @@ class Plugin_Upgrader extends WP_Upgrader { 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 ) ) { 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]; } @@ -414,11 +417,11 @@ class Plugin_Upgrader extends WP_Upgrader { */ public function deactivate_plugin_before_upgrade( $return, $plugin ) { - if ( is_wp_error( $return ) ) { //Bypass. + if ( is_wp_error( $return ) ) { // Bypass. 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() ) { return $return; } @@ -429,7 +432,7 @@ class Plugin_Upgrader extends WP_Upgrader { } 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 ); } @@ -456,7 +459,7 @@ class Plugin_Upgrader extends WP_Upgrader { global $wp_filesystem; if ( is_wp_error( $removed ) ) { - return $removed; //Pass errors through. + return $removed; // Pass errors through. } $plugin = isset( $plugin['plugin'] ) ? $plugin['plugin'] : ''; @@ -467,12 +470,13 @@ class Plugin_Upgrader extends WP_Upgrader { $plugins_dir = $wp_filesystem->wp_plugins_dir(); $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; } // 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 ); } else { $deleted = $wp_filesystem->delete( $plugins_dir . $plugin ); diff --git a/src/wp-admin/includes/class-theme-upgrader.php b/src/wp-admin/includes/class-theme-upgrader.php index 5abf380324..ec177a249e 100644 --- a/src/wp-admin/includes/class-theme-upgrader.php +++ b/src/wp-admin/includes/class-theme-upgrader.php @@ -94,7 +94,7 @@ class Theme_Upgrader extends WP_Upgrader { * @return bool */ 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(); if ( ! $theme_info->parent() ) { @@ -119,11 +119,11 @@ class Theme_Upgrader extends WP_Upgrader { 'tags' => false, ), ) - ); //Save on a bit of bandwidth. + ); // Save on a bit of bandwidth. if ( ! $api || is_wp_error( $api ) ) { $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' ) ); return $install_result; } @@ -132,20 +132,21 @@ class Theme_Upgrader extends WP_Upgrader { $child_api = $this->skin->api; $child_success_message = $this->strings['process_success']; - // Override them - $this->skin->api = $api; - $this->strings['process_success_specific'] = $this->strings['parent_theme_install_success'];//, $api->name, $api->version); + // Override them. + $this->skin->api = $api; + + $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 ); 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( array( 'package' => $api->download_link, 'destination' => get_theme_root(), - 'clear_destination' => false, //Do not overwrite files. + 'clear_destination' => false, // Do not overwrite files. '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' ) ); } - // Start cleaning up after the parents installation + // Start cleaning up after the parent's installation. 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->skin->api = $child_api; $this->strings['process_success'] = $child_success_message; @@ -219,7 +220,7 @@ class Theme_Upgrader extends WP_Upgrader { array( 'package' => $package, 'destination' => get_theme_root(), - 'clear_destination' => false, //Do not overwrite files. + 'clear_destination' => false, // Do not overwrite files. 'clear_working' => true, 'hook_extra' => array( 'type' => 'theme', @@ -236,7 +237,7 @@ class Theme_Upgrader extends WP_Upgrader { return $this->result; } - // Refresh the Theme Update information + // Refresh the Theme Update information. wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); return true; @@ -349,7 +350,7 @@ class Theme_Upgrader extends WP_Upgrader { $this->skin->header(); - // Connect to the Filesystem first. + // Connect to the filesystem first. $res = $this->fs_connect( array( WP_CONTENT_DIR ) ); if ( ! $res ) { $this->skin->footer(); @@ -358,10 +359,12 @@ class Theme_Upgrader extends WP_Upgrader { $this->skin->bulk_header(); - // Only start maintenance mode if: - // - running Multisite and there are one or more themes specified, OR - // - 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. + /* + * Only start maintenance mode if: + * - running Multisite and there are one or more themes specified, OR + * - 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 ) ); foreach ( $themes as $theme ) { $maintenance = $maintenance || $theme == get_stylesheet() || $theme == get_template(); @@ -388,7 +391,7 @@ class Theme_Upgrader extends WP_Upgrader { continue; } - // Get the URL to the zip file + // Get the URL to the zip file. $r = $current->response[ $theme ]; $result = $this->run( @@ -406,15 +409,15 @@ class Theme_Upgrader extends WP_Upgrader { $results[ $theme ] = $this->result; - // Prevent credentials auth screen from displaying multiple times + // Prevent credentials auth screen from displaying multiple times. if ( false === $result ) { break; } - } //end foreach $plugins + } // End foreach $themes. $this->maintenance_mode( false ); - // Refresh the Theme Update information + // Refresh the Theme Update information. wp_clean_themes_cache( $parsed_args['clear_update_cache'] ); /** This action is documented in wp-admin/includes/class-wp-upgrader.php */ @@ -462,13 +465,13 @@ class Theme_Upgrader extends WP_Upgrader { 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 ); if ( ! is_dir( $working_directory ) ) { // Sanity check, if the above fails, let's not prevent installation. 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' ) ) { return new WP_Error( 'incompatible_archive_theme_no_style', @@ -536,10 +539,11 @@ class Theme_Upgrader extends WP_Upgrader { $theme = isset( $theme['theme'] ) ? $theme['theme'] : ''; - if ( $theme != get_stylesheet() ) { //If not current + if ( $theme != get_stylesheet() ) { // If not current. return $return; } - //Change to maintenance mode now. + + // Change to maintenance mode now. if ( ! $this->bulk ) { $this->maintenance_mode( true ); } @@ -566,7 +570,7 @@ class Theme_Upgrader extends WP_Upgrader { $theme = isset( $theme['theme'] ) ? $theme['theme'] : ''; - if ( $theme != get_stylesheet() ) { // If not current + if ( $theme != get_stylesheet() ) { // If not current. return $return; } @@ -577,7 +581,7 @@ class Theme_Upgrader extends WP_Upgrader { switch_theme( $stylesheet ); } - //Time to remove maintenance mode + // Time to remove maintenance mode. if ( ! $this->bulk ) { $this->maintenance_mode( false ); } diff --git a/src/wp-admin/includes/class-walker-category-checklist.php b/src/wp-admin/includes/class-walker-category-checklist.php index 76c4f2bcbd..553494d165 100644 --- a/src/wp-admin/includes/class-walker-category-checklist.php +++ b/src/wp-admin/includes/class-walker-category-checklist.php @@ -21,7 +21,7 @@ class Walker_Category_Checklist extends Walker { public $db_fields = array( 'parent' => 'parent', 'id' => 'term_id', - ); //TODO: decouple this + ); // TODO: Decouple this. /** * Starts the list before the elements are added. diff --git a/src/wp-admin/includes/class-walker-nav-menu-checklist.php b/src/wp-admin/includes/class-walker-nav-menu-checklist.php index 6cacf1874a..ea4b362bb3 100644 --- a/src/wp-admin/includes/class-walker-nav-menu-checklist.php +++ b/src/wp-admin/includes/class-walker-nav-menu-checklist.php @@ -106,7 +106,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu { $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-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 ) . '" />'; @@ -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 ) . '" />'; } -} // Walker_Nav_Menu_Checklist +} diff --git a/src/wp-admin/includes/class-walker-nav-menu-edit.php b/src/wp-admin/includes/class-walker-nav-menu-edit.php index fdb247f065..3c984950b0 100644 --- a/src/wp-admin/includes/class-walker-nav-menu-edit.php +++ b/src/wp-admin/includes/class-walker-nav-menu-edit.php @@ -295,4 +295,4 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu { $output .= ob_get_clean(); } -} // Walker_Nav_Menu_Edit +} diff --git a/src/wp-admin/includes/class-wp-automatic-updater.php b/src/wp-admin/includes/class-wp-automatic-updater.php index fe0142dc7a..cf37ca0e4a 100644 --- a/src/wp-admin/includes/class-wp-automatic-updater.php +++ b/src/wp-admin/includes/class-wp-automatic-updater.php @@ -141,7 +141,7 @@ class WP_Automatic_Updater { 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; if ( 'core' == $type && isset( $item->new_files ) && ! $item->new_files ) { $allow_relaxed_file_ownership = true; @@ -283,7 +283,7 @@ class WP_Automatic_Updater { break; case 'plugin': $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; case 'theme': $upgrader = new Theme_Upgrader( $skin ); @@ -357,7 +357,7 @@ class WP_Automatic_Updater { 'pre_check_md5' => false, // Only available for core updates. '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, ) ); @@ -409,51 +409,51 @@ class WP_Automatic_Updater { 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', 'wp_version_check' ); remove_action( 'upgrader_process_complete', 'wp_update_plugins' ); remove_action( 'upgrader_process_complete', 'wp_update_themes' ); - // Next, Plugins - wp_update_plugins(); // Check for Plugin updates + // Next, plugins. + wp_update_plugins(); // Check for plugin updates. $plugin_updates = get_site_transient( 'update_plugins' ); if ( $plugin_updates && ! empty( $plugin_updates->response ) ) { foreach ( $plugin_updates->response as $plugin ) { $this->update( 'plugin', $plugin ); } - // Force refresh of plugin update information + // Force refresh of plugin update information. wp_clean_plugins_cache(); } - // Next, those themes we all love - wp_update_themes(); // Check for Theme updates + // Next, those themes we all love. + wp_update_themes(); // Check for theme updates. $theme_updates = get_site_transient( 'update_themes' ); if ( $theme_updates && ! empty( $theme_updates->response ) ) { foreach ( $theme_updates->response as $theme ) { $this->update( 'theme', (object) $theme ); } - // Force refresh of theme update information + // Force refresh of theme update information. wp_clean_themes_cache(); } - // Next, Process any core update - wp_version_check(); // Check for Core updates + // Next, process any core update. + wp_version_check(); // Check for core updates. $core_update = find_core_auto_update(); if ( $core_update ) { $this->update( 'core', $core_update ); } - // Clean up, and check for any pending translations - // (Core_Upgrader checks for core updates) + // Clean up, and check for any pending translations. + // (Core_Upgrader checks for core updates.) $theme_stats = array(); if ( isset( $this->update_results['theme'] ) ) { foreach ( $this->update_results['theme'] as $upgrade ) { $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(); if ( isset( $this->update_results['plugin'] ) ) { @@ -461,21 +461,21 @@ class WP_Automatic_Updater { $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(); if ( $language_updates ) { foreach ( $language_updates as $update ) { $this->update( 'translation', $update ); } - // Clear existing caches + // Clear existing caches. wp_clean_update_cache(); - wp_version_check(); // check for Core updates - wp_update_themes(); // Check for Theme updates - wp_update_plugins(); // Check for Plugin updates + wp_version_check(); // Check for core updates. + wp_update_themes(); // Check for theme updates. + wp_update_plugins(); // Check for plugin updates. } // 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(); - // 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 ) { $next_user_core_update = $core_update; } @@ -860,7 +860,7 @@ class WP_Automatic_Updater { /* translators: %s: Network home URL. */ $body[] = sprintf( __( 'WordPress site: %s' ), network_home_url( '/' ) ); - // Core + // Core. if ( isset( $this->update_results['core'] ) ) { $result = $this->update_results['core'][0]; if ( $result->result && ! is_wp_error( $result->result ) ) { @@ -874,7 +874,7 @@ class WP_Automatic_Updater { $body[] = ''; } - // Plugins, Themes, Translations + // Plugins, Themes, Translations. foreach ( array( 'plugin', 'theme', 'translation' ) as $type ) { if ( ! isset( $this->update_results[ $type ] ) ) { continue; @@ -894,7 +894,7 @@ class WP_Automatic_Updater { } } if ( $success_items != $this->update_results[ $type ] ) { - // Failed updates + // Failed updates. $messages = array( 'plugin' => __( 'The following plugins failed to update:' ), 'theme' => __( 'The following themes failed to update:' ), diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index a11eefc873..b0ad3494f4 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -100,7 +100,7 @@ class WP_Comments_List_Table extends WP_List_Table { if ( isset( $_REQUEST['number'] ) ) { $number = (int) $_REQUEST['number']; } 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(); @@ -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>', 'comments' - ), // singular not used + ), // Singular not used. /* translators: %s: Number of comments. */ 'mine' => _nx_noop( @@ -746,7 +746,7 @@ class WP_Comments_List_Table extends WP_List_Table { ++$i; ( ( ( '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() ) { $action .= ' hide-if-no-js'; } elseif ( ( $action === 'untrash' && $the_comment_status === 'trash' ) || ( $action === 'unspam' && $the_comment_status === 'spam' ) ) { diff --git a/src/wp-admin/includes/class-wp-community-events.php b/src/wp-admin/includes/class-wp-community-events.php index 776d72f2f2..8b7acc04ab 100644 --- a/src/wp-admin/includes/class-wp-community-events.php +++ b/src/wp-admin/includes/class-wp-community-events.php @@ -92,7 +92,7 @@ class WP_Community_Events { return $cached_events; } - // include an unmodified $wp_version + // Include an unmodified $wp_version. include( ABSPATH . WPINC . '/version.php' ); $api_url = 'http://api.wordpress.org/events/1.0/'; diff --git a/src/wp-admin/includes/class-wp-debug-data.php b/src/wp-admin/includes/class-wp-debug-data.php index 0e7cbcbf34..23aa3678e4 100644 --- a/src/wp-admin/includes/class-wp-debug-data.php +++ b/src/wp-admin/includes/class-wp-debug-data.php @@ -580,7 +580,7 @@ class WP_Debug_Data { if ( function_exists( 'phpversion' ) ) { $php_version_debug = phpversion(); - // Whether PHP supports 64bit + // Whether PHP supports 64-bit. $php64bit = ( PHP_INT_SIZE * 8 === 64 ); $php_version = sprintf( @@ -677,7 +677,7 @@ class WP_Debug_Data { ); } - // SUHOSIN + // SUHOSIN. $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) ); $info['wp-server']['fields']['suhosin'] = array( @@ -686,7 +686,7 @@ class WP_Debug_Data { 'debug' => $suhosin_loaded, ); - // Imagick + // Imagick. $imagick_loaded = extension_loaded( 'imagick' ); $info['wp-server']['fields']['imagick_availability'] = array( @@ -1012,7 +1012,7 @@ class WP_Debug_Data { $theme_version = $theme->version; $theme_author = $theme->author; - // Sanitize + // Sanitize. $theme_author = wp_kses( $theme_author, array() ); $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 ) ) { $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR ); diff --git a/src/wp-admin/includes/class-wp-filesystem-base.php b/src/wp-admin/includes/class-wp-filesystem-base.php index fe8f4b27b6..d9459b31df 100644 --- a/src/wp-admin/includes/class-wp-filesystem-base.php +++ b/src/wp-admin/includes/class-wp-filesystem-base.php @@ -55,7 +55,8 @@ class WP_Filesystem_Base { */ public function abspath() { $folder = $this->find_folder( ABSPATH ); - // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. + // Perhaps the FTP folder is rooted at the WordPress install. + // Check for wp-includes folder in root. Could have some false positives, but rare. if ( ! $folder && $this->is_dir( '/' . WPINC ) ) { $folder = '/'; } @@ -96,7 +97,7 @@ class WP_Filesystem_Base { public function wp_themes_dir( $theme = false ) { $theme_root = get_theme_root( $theme ); - // Account for relative theme roots + // Account for relative theme roots. if ( '/themes' == $theme_root || ! is_dir( $theme_root ) ) { $theme_root = WP_CONTENT_DIR . $theme_root; } @@ -182,7 +183,7 @@ class WP_Filesystem_Base { 'FTP_LANG_DIR' => WP_LANG_DIR, ); - // Direct matches ( folder = CONSTANT/ ) + // Direct matches ( folder = CONSTANT/ ). foreach ( $constant_overrides as $constant => $dir ) { if ( ! defined( $constant ) ) { 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 ) { if ( ! defined( $constant ) ) { 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 = trailingslashit( $potential_folder ); @@ -208,12 +209,12 @@ class WP_Filesystem_Base { } } } elseif ( 'direct' == $this->method ) { - $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation + $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation. return trailingslashit( $folder ); } - $folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out windows drive letter if it's there. - $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation + $folder = preg_replace( '|^([a-z]{1}):|i', '', $folder ); // Strip out Windows drive letter if it's there. + $folder = str_replace( '\\', '/', $folder ); // Windows path sanitisation. if ( isset( $this->cache[ $folder ] ) ) { return $this->cache[ $folder ]; @@ -240,7 +241,7 @@ class WP_Filesystem_Base { * * @param string $folder The folder to locate. * @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. */ public function search_for_folder( $folder, $base = '.', $loop = false ) { @@ -303,7 +304,7 @@ class WP_Filesystem_Base { } // 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 ) { return false; } @@ -328,39 +329,39 @@ class WP_Filesystem_Base { */ public function gethchmod( $file ) { $perms = intval( $this->getchmod( $file ), 8 ); - if ( ( $perms & 0xC000 ) == 0xC000 ) { // Socket + if ( ( $perms & 0xC000 ) == 0xC000 ) { // Socket. $info = 's'; - } elseif ( ( $perms & 0xA000 ) == 0xA000 ) { // Symbolic Link + } elseif ( ( $perms & 0xA000 ) == 0xA000 ) { // Symbolic Link. $info = 'l'; - } elseif ( ( $perms & 0x8000 ) == 0x8000 ) { // Regular + } elseif ( ( $perms & 0x8000 ) == 0x8000 ) { // Regular. $info = '-'; - } elseif ( ( $perms & 0x6000 ) == 0x6000 ) { // Block special + } elseif ( ( $perms & 0x6000 ) == 0x6000 ) { // Block special. $info = 'b'; - } elseif ( ( $perms & 0x4000 ) == 0x4000 ) { // Directory + } elseif ( ( $perms & 0x4000 ) == 0x4000 ) { // Directory. $info = 'd'; - } elseif ( ( $perms & 0x2000 ) == 0x2000 ) { // Character special + } elseif ( ( $perms & 0x2000 ) == 0x2000 ) { // Character special. $info = 'c'; - } elseif ( ( $perms & 0x1000 ) == 0x1000 ) { // FIFO pipe + } elseif ( ( $perms & 0x1000 ) == 0x1000 ) { // FIFO pipe. $info = 'p'; - } else { // Unknown + } else { // Unknown. $info = 'u'; } - // Owner + // Owner. $info .= ( ( $perms & 0x0100 ) ? 'r' : '-' ); $info .= ( ( $perms & 0x0080 ) ? 'w' : '-' ); $info .= ( ( $perms & 0x0040 ) ? ( ( $perms & 0x0800 ) ? 's' : 'x' ) : ( ( $perms & 0x0800 ) ? 'S' : '-' ) ); - // Group + // Group. $info .= ( ( $perms & 0x0020 ) ? 'r' : '-' ); $info .= ( ( $perms & 0x0010 ) ? 'w' : '-' ); $info .= ( ( $perms & 0x0008 ) ? ( ( $perms & 0x0400 ) ? 's' : 'x' ) : ( ( $perms & 0x0400 ) ? 'S' : '-' ) ); - // World + // World. $info .= ( ( $perms & 0x0004 ) ? 'r' : '-' ); $info .= ( ( $perms & 0x0002 ) ? 'w' : '-' ); $info .= ( ( $perms & 0x0001 ) ? @@ -827,4 +828,4 @@ class WP_Filesystem_Base { return false; } -} // WP_Filesystem_Base +} diff --git a/src/wp-admin/includes/class-wp-filesystem-direct.php b/src/wp-admin/includes/class-wp-filesystem-direct.php index d71bcbd777..11999a4e70 100644 --- a/src/wp-admin/includes/class-wp-filesystem-direct.php +++ b/src/wp-admin/includes/class-wp-filesystem-direct.php @@ -131,7 +131,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { if ( ! $this->is_dir( $file ) ) { return chgrp( $file, $group ); } - // Is a directory, and we want recursive + // Is a directory, and we want recursive. $file = trailingslashit( $file ); $filelist = $this->dirlist( $file ); foreach ( $filelist as $filename ) { @@ -167,7 +167,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { if ( ! $recursive || ! $this->is_dir( $file ) ) { return chmod( $file, $mode ); } - // Is a directory, and we want recursive + // Is a directory, and we want recursive. $file = trailingslashit( $file ); $filelist = $this->dirlist( $file ); foreach ( (array) $filelist as $filename => $filemeta ) { @@ -198,7 +198,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { if ( ! $this->is_dir( $file ) ) { return chown( $file, $owner ); } - // Is a directory, and we want recursive + // Is a directory, and we want recursive. $filelist = $this->dirlist( $file ); foreach ( $filelist as $filename ) { $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. */ 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; } - $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 ) ) { return @unlink( $file ); @@ -339,7 +340,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base { 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 ); $filelist = $this->dirlist( $file, true ); diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php index 1209ef4d28..ac897046be 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -38,8 +38,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { 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' ) ) { define( 'FS_TIMEOUT', 240 ); } @@ -113,7 +112,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { return false; } - // Set the Connection to use Passive FTP + // Set the connection to use Passive FTP. ftp_pasv( $this->link, true ); if ( @ftp_get_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; } - 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 = ''; while ( ! feof( $temp ) ) { @@ -203,7 +202,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { 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 ); @@ -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' ) ) { 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 ! 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 ) { $lucifer[3] += 2000; } else { - $lucifer[3] += 1900; // 4digit year fix + $lucifer[3] += 1900; // 4-digit year fix. } $b['isdir'] = ( $lucifer[7] == '<DIR>' ); if ( $b['isdir'] ) { @@ -593,7 +592,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { } elseif ( ! $is_windows ) { $lucifer = preg_split( '/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY ); if ( $lucifer ) { - //echo $line."\n"; + // echo $line."\n"; $lcount = count( $lucifer ); if ( $lcount < 8 ) { 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'] ) { $b['name'] = preg_replace( '/(\s*->\s*.*)$/', '', $b['name'] ); } diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php index 49ed4af139..01cbc9ceac 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php @@ -150,12 +150,12 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { 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(); - 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 = ''; while ( ! feof( $temphandle ) ) { @@ -198,7 +198,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { 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(); $bytes_written = fwrite( $temphandle, $contents ); @@ -211,7 +211,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { 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 ); @@ -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 ); } @@ -408,7 +408,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { 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. } @@ -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'] ) { $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'] ); $ret[ $struc['name'] ] = $struc; diff --git a/src/wp-admin/includes/class-wp-filesystem-ssh2.php b/src/wp-admin/includes/class-wp-filesystem-ssh2.php index 6468caf72b..51a0dff86c 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ssh2.php +++ b/src/wp-admin/includes/class-wp-filesystem-ssh2.php @@ -64,7 +64,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { $this->method = 'ssh2'; $this->errors = new WP_Error(); - //Check if possible to use ssh2 functions. + // Check if possible to use ssh2 functions. if ( ! extension_loaded( 'ssh2' ) ) { $this->errors->add( 'no_ssh2_ext', __( 'The ssh2 PHP extension is not available' ) ); return; @@ -582,7 +582,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { * @return bool Whether $file is writable. */ 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; } @@ -737,7 +737,7 @@ class WP_Filesystem_SSH2 extends WP_Filesystem_Base { $struc['name'] = $entry; 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] ) { diff --git a/src/wp-admin/includes/class-wp-importer.php b/src/wp-admin/includes/class-wp-importer.php index 43a2038d03..5639f1eb36 100644 --- a/src/wp-admin/includes/class-wp-importer.php +++ b/src/wp-admin/includes/class-wp-importer.php @@ -25,18 +25,18 @@ class WP_Importer { $limit = 100; $offset = 0; - // Grab all posts in chunks + // Grab all posts in chunks. do { $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 ); $results = $wpdb->get_results( $sql ); - // Increment offset + // Increment offset. $offset = ( $limit + $offset ); if ( ! empty( $results ) ) { foreach ( $results as $r ) { - // Set permalinks into array + // Set permalinks into array. $hashtable[ $r->meta_value ] = intval( $r->post_id ); } } @@ -62,7 +62,7 @@ class WP_Importer { $count = 0; - // Get count of permalinks + // Get count of permalinks. $meta_key = $importer_name . '_' . $bid . '_permalink'; $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; $offset = 0; - // Grab all comments in chunks + // Grab all comments in chunks. do { $sql = $wpdb->prepare( "SELECT comment_ID, comment_agent FROM $wpdb->comments LIMIT %d,%d", $offset, $limit ); $results = $wpdb->get_results( $sql ); - // Increment offset + // Increment offset. $offset = ( $limit + $offset ); if ( ! empty( $results ) ) { foreach ( $results as $r ) { - // Explode comment_agent key + // Explode comment_agent key. list ( $ca_bid, $source_comment_id ) = explode( '-', $r->comment_agent ); $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 ) { $hashtable[ $source_comment_id ] = intval( $r->comment_ID ); } @@ -203,7 +203,7 @@ class WP_Importer { * @return array */ 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' ) ); $headers = array(); @@ -267,7 +267,7 @@ class WP_Importer { global $wpdb, $wp_actions; // Or define( 'WP_IMPORTING', true ); $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(); } } @@ -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 ] ) ) { - // Set return value + // Set return value. $return = $out[ $param ]; } - // Check for missing required param + // Check for missing required param. if ( ! isset( $out[ $param ] ) && $required ) { - // Display message and exit + // Display message and exit. echo "\"$param\" parameter is required but was not specified\n"; exit(); } diff --git a/src/wp-admin/includes/class-wp-internal-pointers.php b/src/wp-admin/includes/class-wp-internal-pointers.php index f025af8425..a17caf5521 100644 --- a/src/wp-admin/includes/class-wp-internal-pointers.php +++ b/src/wp-admin/includes/class-wp-internal-pointers.php @@ -48,10 +48,10 @@ final class WP_Internal_Pointers { * ) */ $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 ] ) ) { return; } @@ -75,7 +75,7 @@ final class WP_Internal_Pointers { // None currently. ); - // Get dismissed pointers + // Get dismissed pointers. $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); $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 ) ); $got_pointers = true; } @@ -97,7 +97,7 @@ final class WP_Internal_Pointers { return; } - // Add pointers script and style to queue + // Add pointers script and style to queue. wp_enqueue_style( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' ); } diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 1f078edb42..95ae32c5e6 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -451,7 +451,7 @@ class WP_List_Table { * * @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 = ''; } else { $two = '2'; @@ -1004,8 +1004,8 @@ class WP_List_Table { $columns = get_column_headers( $this->screen ); $default = $this->get_default_primary_column_name(); - // If the primary column doesn't exist fall back to the - // first non-checkbox column. + // If the primary column doesn't exist, + // fall back to the first non-checkbox column. if ( ! isset( $columns[ $default ] ) ) { $default = WP_List_Table::get_default_primary_column_name(); } @@ -1035,7 +1035,7 @@ class WP_List_Table { * @return array */ 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 ) ) { // 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. diff --git a/src/wp-admin/includes/class-wp-ms-sites-list-table.php b/src/wp-admin/includes/class-wp-ms-sites-list-table.php index 35b47245cc..8188844913 100644 --- a/src/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -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}\.?$/', $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 ) ? '%' : '' ) ); $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'] : ''; if ( 'registered' === $order_by ) { - // registered is a valid field name. + // 'registered' is a valid field name. } elseif ( 'lastupdated' === $order_by ) { $order_by = 'last_updated'; } elseif ( 'blogname' === $order_by ) { diff --git a/src/wp-admin/includes/class-wp-ms-themes-list-table.php b/src/wp-admin/includes/class-wp-ms-themes-list-table.php index cb1f34999d..96e17efe58 100644 --- a/src/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -62,7 +62,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { * @return array */ protected function get_table_classes() { - // todo: remove and add CSS for .themes + // @todo Remove and add CSS for .themes. return array( 'widefat', 'plugins' ); } diff --git a/src/wp-admin/includes/class-wp-ms-users-list-table.php b/src/wp-admin/includes/class-wp-ms-users-list-table.php index b6e21e05f3..de9caf7d9d 100644 --- a/src/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-users-list-table.php @@ -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 */ $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 ); $this->items = $wp_user_search->get_results(); diff --git a/src/wp-admin/includes/class-wp-plugin-install-list-table.php b/src/wp-admin/includes/class-wp-plugin-install-list-table.php index acea5c4b28..2a0e004b6b 100644 --- a/src/wp-admin/includes/class-wp-plugin-install-list-table.php +++ b/src/wp-admin/includes/class-wp-plugin-install-list-table.php @@ -95,7 +95,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { $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(); if ( 'search' === $tab ) { @@ -471,7 +471,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { $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( $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']; } - // 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 ) ) { echo '</div></div>'; } 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">'; $group = $plugin['group']; @@ -768,7 +768,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table { <?php } - // Close off the group divs of the last one + // Close off the group divs of the last one. if ( ! empty( $group ) ) { echo '</div></div>'; } diff --git a/src/wp-admin/includes/class-wp-plugins-list-table.php b/src/wp-admin/includes/class-wp-plugins-list-table.php index a36ec05221..b92d1c53d9 100644 --- a/src/wp-admin/includes/class-wp-plugins-list-table.php +++ b/src/wp-admin/includes/class-wp-plugins-list-table.php @@ -186,40 +186,40 @@ class WP_Plugins_List_Table extends WP_List_Table { if ( isset( $plugin_info->response[ $plugin_file ] ) ) { $plugin_data = array_merge( (array) $plugin_info->response[ $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 ] ) ) { $plugins['upgrade'][ $plugin_file ] = $plugin_data; } } elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) { $plugin_data = array_merge( (array) $plugin_info->no_update[ $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 ] ) ) { $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 ( $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; } 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 ] ); } } elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) { 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; } 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 ] ); } } elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) ) || ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) { - // On the non-network screen, populate the active list with plugins that are individually activated - // On the network-admin screen, populate the active list with plugins that are network activated + // On the non-network screen, populate the active list with plugins that are individually activated. + // On the network admin screen, populate the active list with plugins that are network-activated. $plugins['active'][ $plugin_file ] = $plugin_data; if ( ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file ) ) { @@ -227,10 +227,10 @@ class WP_Plugins_List_Table extends WP_List_Table { } } else { 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; } - // 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; } } @@ -251,7 +251,7 @@ class WP_Plugins_List_Table extends WP_List_Table { $this->items = array(); 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 ); } @@ -631,7 +631,7 @@ class WP_Plugins_List_Table extends WP_List_Table { 'delete' => '', ); - // Do not restrict by default + // Do not restrict by default. $restrict_network_active = false; $restrict_network_only = false; @@ -643,10 +643,10 @@ class WP_Plugins_List_Table extends WP_List_Table { if ( $plugin_file != $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; $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; $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; } else { @@ -750,9 +750,9 @@ class WP_Plugins_List_Table extends WP_List_Table { __( 'Delete' ) ); } - } // end if $is_active - } // end if $screen->in_admin( 'network' ) - } // end if $context + } // End if $is_active. + } // End if $screen->in_admin( 'network' ). + } // End if $context. $actions = array_filter( $actions ); @@ -906,7 +906,7 @@ class WP_Plugins_List_Table extends WP_List_Table { $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' ) ) { $plugin_meta[] = sprintf( '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>', diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index 890d133889..a0f6740e3a 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -143,7 +143,7 @@ class WP_Posts_List_Table extends WP_List_Table { public function prepare_items() { 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(); $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_parent = $page->post_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; if ( is_object( $my_parent ) ) { $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 ); } - 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 ); $hierarchical_taxonomies = array(); $flat_taxonomies = array(); + foreach ( $taxonomy_names as $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 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; $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}"; $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=" - <?php - echo $inline_edit_classes . ' '; - 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"> + <legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> + <div class="inline-edit-col"> - <fieldset class="inline-edit-col-left"> - <legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> - <div class="inline-edit-col"> - <?php + <?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?> - if ( post_type_supports( $screen->post_type, 'title' ) ) : - if ( $bulk ) : - ?> - <div id="bulk-title-div"> - <div id="bulk-titles"></div> - </div> + <?php if ( $bulk ) : ?> - <?php else : // $bulk ?> + <div id="bulk-title-div"> + <div id="bulk-titles"></div> + </div> - <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 else : // $bulk ?> - <?php if ( is_post_type_viewable( $screen->post_type ) ) : // is_post_type_viewable check ?> + <label> + <span class="title"><?php _e( 'Title' ); ?></span> + <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> + </label> - <label> - <span class="title"><?php _e( 'Slug' ); ?></span> - <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> - </label> + <?php if ( is_post_type_viewable( $screen->post_type ) ) : ?> - <?php - endif; // is_post_type_viewable check - endif; // $bulk - endif; // post_type_supports title - ?> + <label> + <span class="title"><?php _e( 'Slug' ); ?></span> + <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span> + </label> - <?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'] = __( '— No Change —' ); - } + <?php endif; // is_post_type_viewable() ?> - $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 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 ( ! $bulk ) { - echo $authors_dropdown;} - endif; // post_type_supports author + 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'] = __( '— No Change —' ); + } + + $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' ) + ?> - if ( ! $bulk && $can_publish ) : + <?php + if ( ! $bulk ) { + echo $authors_dropdown; + } + endif; // post_type_supports( ... 'author' ) ?> - <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> + <?php 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> + + <em class="alignleft inline-edit-or"> + <?php + /* translators: Between password field and private checkbox on post quick edit interface. */ + _e( '–OR–' ); + ?> + </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; ?> + + </div> + </fieldset> + + <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> + + <fieldset class="inline-edit-col-center inline-edit-categories"> + <div class="inline-edit-col"> + + <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> + + <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" /> + <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> + <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?> + </ul> + + <?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> + + </div> + </fieldset> + + <?php endif; // count( $hierarchical_taxonomies ) && ! $bulk ?> + + <fieldset class="inline-edit-col-right"> + <div class="inline-edit-col"> - <em class="alignleft inline-edit-or"> <?php - /* translators: Between password field and private checkbox on post quick edit interface. */ - _e( '–OR–' ); + if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { + echo $authors_dropdown; + } ?> - </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 if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : ?> + + <?php 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'] = __( '— No Change —' ); + } + + /** + * 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( '— No Change —' ); ?></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; ?> - </div></fieldset> + <?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?> - <?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> + <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> - <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> + <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> + <?php $taxonomy_name = esc_attr( $taxonomy->name ); ?> - <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> + <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> - <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" /> - <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> - <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ); ?> - </ul> + <?php endif; // current_user_can( 'assign_terms' ) ?> - <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?> + <?php endforeach; // $flat_taxonomies as $taxonomy ?> - </div></fieldset> + <?php endif; // count( $flat_taxonomies ) && ! $bulk ?> - <?php endif; // count( $hierarchical_taxonomies ) && !$bulk ?> + <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> - <fieldset class="inline-edit-col-right"><div class="inline-edit-col"> + <?php if ( $bulk ) : ?> - <?php - if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { - echo $authors_dropdown; - } + <div class="inline-edit-group wp-clearfix"> - if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : + <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> - 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', - ); + <label class="alignleft"> + <span class="title"><?php _e( 'Comments' ); ?></span> + <select name="comment_status"> + <option value=""><?php _e( '— No Change —' ); ?></option> + <option value="open"><?php _e( 'Allow' ); ?></option> + <option value="closed"><?php _e( 'Do not allow' ); ?></option> + </select> + </label> - if ( $bulk ) { - $dropdown_args['show_option_no_change'] = __( '— No Change —' ); - } + <?php endif; ?> - /** - * 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 ); + <?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> - wp_dropdown_pages( $dropdown_args ); - ?> - </label> + <label class="alignright"> + <span class="title"><?php _e( 'Pings' ); ?></span> + <select name="ping_status"> + <option value=""><?php _e( '— No Change —' ); ?></option> + <option value="open"><?php _e( 'Allow' ); ?></option> + <option value="closed"><?php _e( 'Do not allow' ); ?></option> + </select> + </label> - <?php - endif; // hierarchical + <?php endif; ?> - if ( ! $bulk ) : - ?> + </div> - <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 else : // $bulk ?> - <?php - endif; // !$bulk - endif; // page-attributes - ?> + <div class="inline-edit-group wp-clearfix"> - <?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( '— No Change —' ); ?></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 ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> - <?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?> + <label class="alignleft"> + <input type="checkbox" name="comment_status" value="open" /> + <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> + </label> - <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> - <?php - if ( current_user_can( $taxonomy->cap->assign_terms ) ) : - $taxonomy_name = esc_attr( $taxonomy->name ); + <?php endif; ?> - ?> - <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 if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> - <?php endforeach; //$flat_taxonomies as $taxonomy ?> + <label class="alignleft"> + <input type="checkbox" name="ping_status" value="open" /> + <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> + </label> - <?php endif; // count( $flat_taxonomies ) && !$bulk ?> + <?php endif; ?> - <?php - if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : - if ( $bulk ) : - ?> + </div> - <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( '— No Change —' ); ?></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( '— No Change —' ); ?></option> - <option value="open"><?php _e( 'Allow' ); ?></option> - <option value="closed"><?php _e( 'Do not allow' ); ?></option> - </select> - </label> - <?php endif; ?> - </div> + <?php endif; // $bulk ?> - <?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 endif; // post_type_supports( ... comments or pings ) ?> - <?php - endif; // $bulk - endif; // post_type_supports comments or pings - ?> + <div class="inline-edit-group wp-clearfix"> - <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( '— No Change —' ); ?></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( '— No Change —' ); ?></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' ) ?> + <label class="inline-edit-status alignleft"> + <span class="title"><?php _e( 'Status' ); ?></span> + <select name="_status"> + <?php if ( $bulk ) : ?> + <option value="-1"><?php _e( '— No Change —' ); ?></option> + <?php endif; // $bulk ?> - </div> + <?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; ?> - <?php + <option value="pending"><?php _e( 'Pending Review' ); ?></option> + <option value="draft"><?php _e( 'Draft' ); ?></option> + </select> + </label> - if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) { - $post_formats = get_theme_support( 'post-formats' ); + <?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> - ?> - <label class="alignleft"> - <span class="title"><?php _ex( 'Format', 'post format' ); ?></span> - <select name="post_format"> - <option value="-1"><?php _e( '— No Change —' ); ?></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 ( $bulk ) : ?> - } + <label class="alignright"> + <span class="title"><?php _e( 'Sticky' ); ?></span> + <select name="sticky"> + <option value="-1"><?php _e( '— No Change —' ); ?></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></fieldset> + </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( '— No Change —' ); ?></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 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> - <?php - if ( ! $bulk ) { - wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); - ?> - <button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button> - <span class="spinner"></span> - <?php - } else { - submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false ); - } - ?> - <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> - <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> - <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?> - <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> - <?php } ?> - <br class="clear" /> - <div class="notice notice-error notice-alt inline hidden"> - <p class="error"></p> + + <div class="submit inline-edit-save"> + <button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button> + + <?php if ( ! $bulk ) : ?> + <?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?> + <button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button> + <span class="spinner"></span> + <?php else : ?> + <?php 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="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> + <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?> + <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> + <?php endif; ?> + <br class="clear" /> + + <div class="notice notice-error notice-alt inline hidden"> + <p class="error"></p> + </div> </div> - </div> - </td></tr> + + </td></tr> + <?php $bulk++; - } + endwhile; ?> - </tbody></table></form> + </tbody></table> + </form> <?php } } diff --git a/src/wp-admin/includes/class-wp-privacy-requests-table.php b/src/wp-admin/includes/class-wp-privacy-requests-table.php index eb9643d42e..e9abedb7c0 100644 --- a/src/wp-admin/includes/class-wp-privacy-requests-table.php +++ b/src/wp-admin/includes/class-wp-privacy-requests-table.php @@ -73,9 +73,11 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { * @return array Default 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. - // With 'Requester' sorting active, the next click on 'Requested' should be descending. + /* + * The initial sorting is by 'Requested' (post_date) and 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'] ); return array( @@ -146,7 +148,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { $counts = $this->get_request_counts(); $total_requests = absint( array_sum( (array) $counts ) ); - // Normalized admin URL + // Normalized admin URL. $admin_url = $this->get_admin_url(); $current_link_attributes = empty( $current_status ) ? ' class="current" aria-current="page"' : ''; diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php index dbd796593c..e694e6a06a 100644 --- a/src/wp-admin/includes/class-wp-screen.php +++ b/src/wp-admin/includes/class-wp-screen.php @@ -226,7 +226,7 @@ final class WP_Screen { // For those pesky meta boxes. if ( $hook_name && post_type_exists( $hook_name ) ) { $post_type = $id; - $id = 'post'; // changes later. ends up being $base. + $id = 'post'; // Changes later. Ends up being $base. } else { if ( '.php' == substr( $id, -4 ) ) { $id = substr( $id, 0, -4 ); @@ -923,7 +923,7 @@ final class WP_Screen { </div> </div> <?php - // Setup layout columns + // Setup 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. - // Add screen options + // Add screen options. if ( $this->show_screen_options() ) { $this->render_screen_options(); } @@ -1156,7 +1156,7 @@ final class WP_Screen { $special = array( '_title', 'cb', 'comment', 'media', 'name', 'title', 'username', 'blogname' ); 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 ) ) { continue; } @@ -1255,13 +1255,13 @@ final class WP_Screen { $per_page = apply_filters( "{$option}", $per_page ); } - // Back compat + // Back compat. if ( isset( $this->post_type ) ) { /** This filter is documented in wp-admin/includes/post.php */ $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' ); ?> @@ -1288,7 +1288,7 @@ final class WP_Screen { public function render_view_mode() { $screen = get_current_screen(); - // Currently only enabled for posts lists + // Currently only enabled for posts lists. if ( 'edit' !== $screen->base ) { return; } @@ -1316,7 +1316,7 @@ final class WP_Screen { global $mode; - // This needs a submit button + // This needs a submit button. add_filter( 'screen_options_show_submit', '__return_true' ); ?> <fieldset class="metabox-prefs view-mode"> diff --git a/src/wp-admin/includes/class-wp-site-health-auto-updates.php b/src/wp-admin/includes/class-wp-site-health-auto-updates.php index 05fbba9085..299744968c 100644 --- a/src/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/src/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -353,12 +353,12 @@ class WP_Site_Health_Auto_Updates { $checksums = get_core_checksums( $wp_version, 'en_US' ); $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 ) { $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 ) { return false; } @@ -415,7 +415,7 @@ class WP_Site_Health_Auto_Updates { */ function test_accepts_dev_updates() { include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z - // Only for dev versions + // Only for dev versions. if ( false === strpos( $wp_version, '-' ) ) { return false; } diff --git a/src/wp-admin/includes/class-wp-site-health.php b/src/wp-admin/includes/class-wp-site-health.php index 0da1f9e607..afb51e4816 100644 --- a/src/wp-admin/includes/class-wp-site-health.php +++ b/src/wp-admin/includes/class-wp-site-health.php @@ -103,7 +103,7 @@ class WP_Site_Health { if ( 'site-health' === $screen->id && ! isset( $_GET['tab'] ) ) { $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() ) ) { unset( $tests['direct']['https_status'] ); } @@ -1217,7 +1217,7 @@ class WP_Site_Health { __( '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', '<' ) ) { $result['status'] = 'recommended'; @@ -2235,7 +2235,7 @@ class WP_Site_Health { 'critical' => 0, ); - // Don't run https test on localhost + // Don't run https test on localhost. if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) { unset( $tests['direct']['https_status'] ); } diff --git a/src/wp-admin/includes/class-wp-site-icon.php b/src/wp-admin/includes/class-wp-site-icon.php index a16565e70f..8d991e4c75 100644 --- a/src/wp-admin/includes/class-wp-site-icon.php +++ b/src/wp-admin/includes/class-wp-site-icon.php @@ -154,7 +154,7 @@ class WP_Site_Icon { natsort( $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 ) { if ( isset( $size_array['crop'] ) ) { $only_crop_sizes[ $name ] = $size_array; diff --git a/src/wp-admin/includes/class-wp-terms-list-table.php b/src/wp-admin/includes/class-wp-terms-list-table.php index 1acacfc926..9af2f0e502 100644 --- a/src/wp-admin/includes/class-wp-terms-list-table.php +++ b/src/wp-admin/includes/class-wp-terms-list-table.php @@ -139,7 +139,7 @@ class WP_Terms_List_Table extends WP_List_Table { * @return bool */ public function has_items() { - // todo: populate $this->items in prepare_items() + // @todo Populate $this->items in prepare_items(). return true; } @@ -254,7 +254,11 @@ class WP_Terms_List_Table extends WP_List_Table { } else { $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 ); } else { 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"> - <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> + <form method="get"> + <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> <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="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> </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( - 'cb' => true, - 'description' => true, - 'name' => true, - 'slug' => true, - 'posts' => true, - ); + <?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 endif; ?> + </div> + </fieldset> + + <?php + $core_columns = array( + 'cb' => true, + 'description' => true, + 'name' => true, + 'slug' => true, + 'posts' => true, + ); - list( $columns ) = $this->get_column_info(); + list( $columns ) = $this->get_column_info(); - foreach ( $columns as $column_name => $column_display_name ) { - 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 */ - do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); - } + <div class="inline-edit-save submit"> + <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"> - <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="notice notice-error notice-alt inline hidden"> - <p class="error"></p> + <div class="notice notice-error notice-alt inline hidden"> + <p class="error"></p> + </div> </div> - </div> - </td></tr> - </tbody></table></form> + + </td></tr> + + </tbody></table> + </form> <?php } } diff --git a/src/wp-admin/includes/class-wp-theme-install-list-table.php b/src/wp-admin/includes/class-wp-theme-install-list-table.php index 637785f392..3edabf6d30 100644 --- a/src/wp-admin/includes/class-wp-theme-install-list-table.php +++ b/src/wp-admin/includes/class-wp-theme-install-list-table.php @@ -231,7 +231,7 @@ class WP_Theme_Install_List_Table extends WP_Themes_List_Table { ?> </div> <?php - } // end foreach $theme_names + } // End foreach $theme_names. $this->theme_installer(); } diff --git a/src/wp-admin/includes/class-wp-themes-list-table.php b/src/wp-admin/includes/class-wp-themes-list-table.php index fb8d131f5b..73143f393f 100644 --- a/src/wp-admin/includes/class-wp-themes-list-table.php +++ b/src/wp-admin/includes/class-wp-themes-list-table.php @@ -300,14 +300,14 @@ class WP_Themes_List_Table extends WP_List_Table { * @return bool */ public function search_theme( $theme ) { - // Search the features + // Search the features. foreach ( $this->features as $word ) { if ( ! in_array( $word, $theme->get( 'Tags' ) ) ) { return false; } } - // Match all phrases + // Match all phrases. foreach ( $this->search_terms as $word ) { if ( in_array( $word, $theme->get( 'Tags' ) ) ) { continue; diff --git a/src/wp-admin/includes/class-wp-upgrader.php b/src/wp-admin/includes/class-wp-upgrader.php index 706337403b..a399bad07f 100644 --- a/src/wp-admin/includes/class-wp-upgrader.php +++ b/src/wp-admin/includes/class-wp-upgrader.php @@ -195,7 +195,7 @@ class WP_Upgrader { if ( is_object( $wp_filesystem ) && $wp_filesystem->errors->has_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 ); return false; } @@ -238,7 +238,7 @@ class WP_Upgrader { } } return true; - } //end fs_connect(); + } /** * Download a package. @@ -267,8 +267,8 @@ class WP_Upgrader { return $reply; } - if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { //Local file or remote? - return $package; //must be a local file.. + if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) { // Local file or remote? + return $package; // Must be a local file. } if ( empty( $package ) ) { @@ -305,7 +305,7 @@ class WP_Upgrader { $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 ); if ( ! empty( $upgrade_files ) ) { 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' ); - // Clean up working directory + // Clean up working directory. if ( $wp_filesystem->is_dir( $working_dir ) ) { $wp_filesystem->delete( $working_dir, true ); } - // Unzip package to working directory + // Unzip package to working directory. $result = unzip_file( $package, $working_dir ); // Once extracted, delete the package if required. @@ -356,11 +356,11 @@ class WP_Upgrader { foreach ( $nested_files as $name => $details ) { $files[ $path . $name ] = $details; - // Append children recursively + // Append children recursively. if ( ! empty( $details['files'] ) ) { $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; } } @@ -388,7 +388,7 @@ class WP_Upgrader { return true; } - // Flatten the file list to iterate over + // Flatten the file list to iterate over. $files = $this->flatten_dirlist( $files ); // Check all files are writable before attempting to clear the destination. @@ -450,8 +450,8 @@ class WP_Upgrader { global $wp_filesystem, $wp_theme_directories; $defaults = array( - 'source' => '', // Please always pass this - 'destination' => '', // and this + 'source' => '', // Please always pass this. + 'destination' => '', // ...and this. 'clear_destination' => false, 'clear_working' => false, 'abort_if_destination_exists' => true, @@ -490,19 +490,23 @@ class WP_Upgrader { return $res; } - //Retain the Original source and destinations + // Retain the original source and destinations. $remote_source = $args['source']; $local_destination = $destination; $source_files = array_keys( $wp_filesystem->dirlist( $remote_source ) ); $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. - if ( 1 == count( $source_files ) && $wp_filesystem->is_dir( trailingslashit( $args['source'] ) . $source_files[0] . '/' ) ) { //Only one folder? Then we want its contents. + // 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. $source = trailingslashit( $args['source'] ) . trailingslashit( $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? - } 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. + // There are no files? + return new WP_Error( 'incompatible_archive_empty', $this->strings['incompatible_archive'], $this->strings['no_files'] ); + } else { + // It's only a single file, the upgrader will use the folder name of this file as the destination folder. + // Folder name is based on zip filename. $source = trailingslashit( $args['source'] ); } @@ -568,21 +572,22 @@ class WP_Upgrader { return $removed; } } elseif ( $args['abort_if_destination_exists'] && $wp_filesystem->exists( $remote_destination ) ) { - //If we're not clearing the destination folder and something exists there already, Bail. - //But first check to see if there are actually any files in the folder. + // If we're not clearing the destination folder and something exists there already, bail. + // But first check to see if there are actually any files in the folder. $_files = $wp_filesystem->dirlist( $remote_destination ); if ( ! empty( $_files ) ) { - $wp_filesystem->delete( $remote_source, true ); //Clear out the source files. + $wp_filesystem->delete( $remote_source, true ); // Clear out the source files. 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->mkdir( $remote_destination, FS_CHMOD_DIR ) ) { return new WP_Error( 'mkdir_failed_destination', $this->strings['mkdir_failed'], $remote_destination ); } } + // Copy new version of item into place. $result = copy_dir( $source, $remote_destination ); if ( is_wp_error( $result ) ) { @@ -592,7 +597,7 @@ class WP_Upgrader { return $result; } - //Clear the Working folder? + // Clear the working folder? if ( $args['clear_working'] ) { $wp_filesystem->delete( $remote_source, true ); } @@ -620,7 +625,7 @@ class WP_Upgrader { 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; } @@ -661,9 +666,9 @@ class WP_Upgrader { $defaults = array( 'package' => '', // Please always pass this. - 'destination' => '', // And this + 'destination' => '', // ...and this. '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, 'is_multi' => false, '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 ); - 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(); } - // Connect to the Filesystem first. + // Connect to the filesystem first. $res = $this->fs_connect( array( WP_CONTENT_DIR, $options['destination'] ) ); // Mainly for non-connected filesystem. if ( ! $res ) { @@ -740,7 +745,7 @@ class WP_Upgrader { // Don't output the 'no signature could be found' failure message for now. 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() ); // Report this failure back to WordPress.org for debugging purposes. @@ -765,7 +770,7 @@ class WP_Upgrader { 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. $working_dir = $this->unpack_package( $download, $delete_package ); @@ -857,7 +862,7 @@ class WP_Upgrader { $file = $wp_filesystem->abspath() . '.maintenance'; if ( $enable ) { $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() . '; ?>'; $wp_filesystem->delete( $file ); $wp_filesystem->put_contents( $file, $maintenance_string, FS_CHMOD_FILE ); diff --git a/src/wp-admin/includes/class-wp-users-list-table.php b/src/wp-admin/includes/class-wp-users-list-table.php index a69e889968..505aa9a435 100644 --- a/src/wp-admin/includes/class-wp-users-list-table.php +++ b/src/wp-admin/includes/class-wp-users-list-table.php @@ -137,7 +137,7 @@ class WP_Users_List_Table extends WP_List_Table { */ $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 ); $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 * Filtersing of the user table. * - * @since 3.1.0 + * @since 3.1.0 * * @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. * - * @since 3.1.0 + * @since 3.1.0 * * @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 * the role change drop-down. * - * @since 3.1.0 + * @since 3.1.0 * * @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. * - * @since 3.1.0 + * @since 3.1.0 * * @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 */ public function display_rows() { - // Query the post counts for this page + // Query the post counts for this page. if ( ! $this->is_site_users ) { $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 ); - // Set up the hover actions for this user + // Set up the hover actions for this user. $actions = array(); $checkbox = ''; $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' ) ) { - // 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 ) ) ); 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 = 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( '<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" />', @@ -514,7 +514,7 @@ class WP_Users_List_Table extends WP_List_Table { $classes .= ' has-row-actions column-primary'; } if ( 'posts' === $column_name ) { - $classes .= ' num'; // Special case for that column + $classes .= ' num'; // Special case for that column. } if ( in_array( $column_name, $hidden ) ) { diff --git a/src/wp-admin/includes/comment.php b/src/wp-admin/includes/comment.php index e99f8a6a50..afe38fa3cd 100644 --- a/src/wp-admin/includes/comment.php +++ b/src/wp-admin/includes/comment.php @@ -79,16 +79,17 @@ function edit_comment() { } if ( ! empty( $_POST['edit_date'] ) ) { - $aa = $_POST['aa']; - $mm = $_POST['mm']; - $jj = $_POST['jj']; - $hh = $_POST['hh']; - $mn = $_POST['mn']; - $ss = $_POST['ss']; - $jj = ( $jj > 31 ) ? 31 : $jj; - $hh = ( $hh > 23 ) ? $hh - 24 : $hh; - $mn = ( $mn > 59 ) ? $mn - 60 : $mn; - $ss = ( $ss > 59 ) ? $ss - 60 : $ss; + $aa = $_POST['aa']; + $mm = $_POST['mm']; + $jj = $_POST['jj']; + $hh = $_POST['hh']; + $mn = $_POST['mn']; + $ss = $_POST['ss']; + $jj = ( $jj > 31 ) ? 31 : $jj; + $hh = ( $hh > 23 ) ? $hh - 24 : $hh; + $mn = ( $mn > 59 ) ? $mn - 60 : $mn; + $ss = ( $ss > 59 ) ? $ss - 60 : $ss; + $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; } diff --git a/src/wp-admin/includes/credits.php b/src/wp-admin/includes/credits.php index 3289c18e4a..59ccc28c2e 100644 --- a/src/wp-admin/includes/credits.php +++ b/src/wp-admin/includes/credits.php @@ -15,7 +15,7 @@ * @return array|false A list of all of the contributors, or false on error. */ function wp_credits() { - // include an unmodified $wp_version + // Include an unmodified $wp_version. include( ABSPATH . WPINC . '/version.php' ); $locale = get_user_locale(); diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 6ecc49f8f1..e4cea79c43 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -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 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 } /** diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php index 0c65f2c6e3..98bcd6484c 100644 --- a/src/wp-admin/includes/file.php +++ b/src/wp-admin/includes/file.php @@ -1214,7 +1214,7 @@ function verify_file_signature( $filename, $signatures, $filename_for_errors = f // Check for a edge-case affecting PHP Maths abilities. if ( ! 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' ) ) { // 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.' ) ); } - if ( '/' == substr( $info['name'], -1 ) ) { // directory + if ( '/' == substr( $info['name'], -1 ) ) { // Directory. continue; } diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php index 5ea668c0a2..5d1a8d7bc3 100644 --- a/src/wp-admin/includes/image.php +++ b/src/wp-admin/includes/image.php @@ -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 ); - // If the original image's dimensions are over the threshold, scale the image - // and use it as the "full" size. + // If the original image's dimensions are over the threshold, + // scale the image and use it as the "full" size. if ( $threshold && ( $image_meta['width'] > $threshold || $image_meta['height'] > $threshold ) ) { $editor = wp_get_image_editor( $file ); @@ -282,7 +282,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) { return $image_meta; } - // Resize the image + // Resize the image. $resized = $editor->resize( $threshold, $threshold ); $rotated = null; @@ -305,10 +305,10 @@ function wp_create_image_subsizes( $file, $attachment_id ) { $image_meta['image_meta']['orientation'] = 1; } } else { - // TODO: log errors. + // TODO: Log errors. } } else { - // TODO: log errors. + // TODO: Log errors. } } 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. @@ -335,7 +335,7 @@ function wp_create_image_subsizes( $file, $attachment_id ) { $image_meta['image_meta']['orientation'] = 1; } } 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(); 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 ); if ( is_wp_error( $new_size_meta ) ) { - // TODO: log errors. + // TODO: Log errors. } else { // Save the size meta value. $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 ) ) { $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. * 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'] ) ) { $iptc = @iptcparse( $info['APP13'] ); - // Headline, "A brief synopsis of the caption." + // Headline, "A brief synopsis of the caption". if ( ! empty( $iptc['2#105'][0] ) ) { $meta['title'] = trim( $iptc['2#105'][0] ); /* * 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] ) ) { $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] ); mbstring_binary_safe_encoding(); diff --git a/src/wp-admin/includes/import.php b/src/wp-admin/includes/import.php index 52b623a447..1b36d6a4d9 100644 --- a/src/wp-admin/includes/import.php +++ b/src/wp-admin/includes/import.php @@ -136,7 +136,8 @@ function wp_import_handle_upload() { * @return array Importers with metadata for each. */ 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(); $cache_key = 'popular_importers_' . md5( $locale . $wp_version ); diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php index f52e9a4704..eaa3a1ca50 100644 --- a/src/wp-admin/includes/media.php +++ b/src/wp-admin/includes/media.php @@ -770,7 +770,7 @@ function media_upload_form_handler() { if ( $image_alt != get_post_meta( $attachment_id, '_wp_attachment_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 ) ); } } @@ -2529,7 +2529,7 @@ function media_upload_gallery_form( $errors ) { </div> <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 //media_upload_form( $errors ); ?> + <?php // media_upload_form( $errors ); ?> <table class="widefat"> <thead><tr> <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"> <?php wp_nonce_field( 'media-form' ); ?> - <?php //media_upload_form( $errors ); ?> + <?php // media_upload_form( $errors ); ?> <script type="text/javascript"> jQuery(function($){ diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php index efe46cce32..a22ad40374 100644 --- a/src/wp-admin/includes/privacy-tools.php +++ b/src/wp-admin/includes/privacy-tools.php @@ -321,7 +321,7 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) { } $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 ); $file_basename = 'wp-personal-data-file-' . $stripped_email . '-' . $obscura; $html_report_filename = $file_basename . '.html'; diff --git a/src/wp-admin/includes/revision.php b/src/wp-admin/includes/revision.php index 7a9943f196..cbf4eaeb38 100644 --- a/src/wp-admin/includes/revision.php +++ b/src/wp-admin/includes/revision.php @@ -55,7 +55,7 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) { $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 ) ) { $compare_from->post_title = __( '(no title)' ); } @@ -340,7 +340,7 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null 'from' => $from, 'diffData' => $diffs, '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 ), ); } diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index a566829eaf..bb993f2617 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -52,7 +52,7 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) { */ $max_index_length = 191; - // Blog specific tables. + // Blog-specific tables. $blog_tables = "CREATE TABLE $wpdb->termmeta ( meta_id bigint(20) unsigned NOT NULL auto_increment, term_id bigint(20) unsigned NOT NULL default '0', @@ -205,7 +205,7 @@ CREATE TABLE $wpdb->posts ( KEY user_email (user_email) ) $charset_collate;\n"; - // Multisite users table + // Multisite users table. $users_multi_table = "CREATE TABLE $wpdb->users ( ID bigint(20) unsigned NOT NULL auto_increment, user_login varchar(60) NOT NULL default '', @@ -236,7 +236,7 @@ CREATE TABLE $wpdb->posts ( KEY meta_key (meta_key($max_index_length)) ) $charset_collate;\n"; - // Global tables + // Global tables. if ( $is_multisite ) { $global_tables = $users_multi_table . $usermeta_table; } else { @@ -547,7 +547,7 @@ function populate_options( array $options = array() ) { ? $wp_current_db_version : $wp_db_version; } - // 3.0 multisite + // 3.0 multisite. if ( is_multisite() ) { /* translators: %s: Network title. */ $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 ); - // 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' ); $keys = "'" . implode( "', '", array_keys( $options ) ) . "'"; @@ -677,7 +677,7 @@ function populate_options( array $options = array() ) { // Delete obsolete magpie stuff. $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 ); } @@ -703,15 +703,14 @@ function populate_roles() { * @since 2.0.0 */ function populate_roles_160() { - // Add roles - + // Add roles. add_role( 'administrator', 'Administrator' ); add_role( 'editor', 'Editor' ); add_role( 'author', 'Author' ); add_role( 'contributor', 'Contributor' ); add_role( 'subscriber', 'Subscriber' ); - // Add caps for Administrator role + // Add caps for Administrator role. $role = get_role( 'administrator' ); $role->add_cap( 'switch_themes' ); $role->add_cap( 'edit_themes' ); @@ -744,7 +743,7 @@ function populate_roles_160() { $role->add_cap( 'level_1' ); $role->add_cap( 'level_0' ); - // Add caps for Editor role + // Add caps for Editor role. $role = get_role( 'editor' ); $role->add_cap( 'moderate_comments' ); $role->add_cap( 'manage_categories' ); @@ -766,7 +765,7 @@ function populate_roles_160() { $role->add_cap( 'level_1' ); $role->add_cap( 'level_0' ); - // Add caps for Author role + // Add caps for Author role. $role = get_role( 'author' ); $role->add_cap( 'upload_files' ); $role->add_cap( 'edit_posts' ); @@ -777,14 +776,14 @@ function populate_roles_160() { $role->add_cap( 'level_1' ); $role->add_cap( 'level_0' ); - // Add caps for Contributor role + // Add caps for Contributor role. $role = get_role( 'contributor' ); $role->add_cap( 'edit_posts' ); $role->add_cap( 'read' ); $role->add_cap( 'level_1' ); $role->add_cap( 'level_0' ); - // Add caps for Subscriber role + // Add caps for Subscriber role. $role = get_role( 'subscriber' ); $role->add_cap( 'read' ); $role->add_cap( 'level_0' ); @@ -1244,7 +1243,7 @@ We hope you enjoy your new site. Thanks! 'welcome_email' => $welcome_email, /* translators: %s: Site link. */ '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' ) . '/', 'add_new_users' => '0', 'upload_space_check_disabled' => is_multisite() ? get_site_option( 'upload_space_check_disabled' ) : '1', diff --git a/src/wp-admin/includes/screen.php b/src/wp-admin/includes/screen.php index 1abaa023da..42a19ec91e 100644 --- a/src/wp-admin/includes/screen.php +++ b/src/wp-admin/includes/screen.php @@ -117,7 +117,7 @@ function meta_box_prefs( $screen ) { if ( false == $box || ! $box['title'] ) { continue; } - // Submit box cannot be hidden + // Submit box cannot be hidden. if ( 'submitdiv' == $box['id'] || 'linksubmitdiv' == $box['id'] ) { continue; } @@ -156,7 +156,7 @@ function get_hidden_meta_boxes( $screen ) { $use_defaults = ! is_array( $hidden ); - // Hide slug boxes by default + // Hide slug boxes by default. if ( $use_defaults ) { $hidden = array(); if ( 'post' == $screen->base ) { diff --git a/src/wp-admin/includes/taxonomy.php b/src/wp-admin/includes/taxonomy.php index 1f8cab9956..e2877ca565 100644 --- a/src/wp-admin/includes/taxonomy.php +++ b/src/wp-admin/includes/taxonomy.php @@ -7,7 +7,7 @@ */ // -// Category +// Category. // /** @@ -192,7 +192,7 @@ function wp_update_category( $catarr ) { return false; } - // First, get all of the original fields + // First, get all of the original fields. $category = get_term( $cat_ID, 'category', ARRAY_A ); _make_cat_compat( $category ); @@ -206,7 +206,7 @@ function wp_update_category( $catarr ) { } // -// Tags +// Tags. // /** diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 3ed611d0c4..81e3d7d462 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -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' ); // -// Category Checklists +// Category Checklists. // /** @@ -165,7 +165,8 @@ function wp_terms_checklist( $post_id = 0, $args = array() ) { $output = ''; if ( $parsed_args['checked_ontop'] ) { - // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) + // Post-process $categories rather than adding an exclude to the get_terms() query + // to keep the query the same across all posts (for any query cache). $checked_categories = array(); $keys = array_keys( $categories ); @@ -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 ); } - // Then the rest of them + // Then the rest of them. $output .= $walker->walk( $categories, 0, $args ); if ( $parsed_args['echo'] ) { @@ -265,7 +266,7 @@ function wp_link_category_checklist( $link_id = 0 ) { if ( $link_id ) { $checked_categories = wp_get_link_cats( $link_id ); - // No selected categories, strange + // No selected categories, strange. if ( ! count( $checked_categories ) ) { $checked_categories[] = $default; } @@ -559,7 +560,7 @@ function wp_comment_trashnotice() { * @param array $meta */ function list_meta( $meta ) { - // Exit if no meta + // Exit if no meta. if ( ! $meta ) { echo ' <table id="list-table" style="display: none;"> @@ -572,7 +573,7 @@ function list_meta( $meta ) { <tbody id="the-list" data-wp-lists="list:meta"> <tr><td></td></tr> </tbody> -</table>'; //TBODY needed for list-manipulation JS +</table>'; // TBODY needed for list-manipulation JS. return; } $count = 0; @@ -632,7 +633,7 @@ function _list_meta_row( $entry, &$count ) { } $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']; $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\""; } - // 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 />'; $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 ) { $name = translate_user_role( $details['name'] ); - // preselect specified role + // Preselect specified role. if ( $selected == $role ) { $r .= "\n\t<option selected='selected' value='" . esc_attr( $role ) . "'>$name</option>"; } 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 ( '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 ] ) { return; } @@ -1067,7 +1068,7 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan } 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 ) ) { $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_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 ) { 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 ) ); - // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose + // Grab the ones the user has manually sorted. + // Pull them out of their previous context/priority and into the one the user chose. $sorted = get_user_option( "meta-box-order_$page" ); if ( ! $already_sorted && $sorted ) { foreach ( $sorted as $box_context => $ids ) { @@ -2192,12 +2194,12 @@ function _media_states( $post ) { } else { $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 ) ) { $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 ) ) { $media_states[] = __( 'Current Header Image' ); } @@ -2378,7 +2380,7 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit $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; if ( is_array( $other_attributes ) && isset( $other_attributes['id'] ) ) { $id = $other_attributes['id']; @@ -2388,9 +2390,9 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit $attributes = ''; if ( is_array( $other_attributes ) ) { 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; } @@ -2533,15 +2535,15 @@ function wp_star_rating( $args = array() ) { ); $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'] ); - // 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'] ) { $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 ); $half_stars = ceil( $rating - $full_stars ); $empty_stars = 5 - $full_stars - $half_stars; diff --git a/src/wp-admin/includes/theme.php b/src/wp-admin/includes/theme.php index 2e8e0172d4..9f7a181553 100644 --- a/src/wp-admin/includes/theme.php +++ b/src/wp-admin/includes/theme.php @@ -45,7 +45,8 @@ function delete_theme( $stylesheet, $redirect = '' ) { if ( ! WP_Filesystem( $credentials ) ) { 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(); if ( ! empty( $data ) ) { @@ -194,7 +195,7 @@ function get_theme_update_available( $theme ) { 'height' => 800, ), $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&theme=' . urlencode( $stylesheet ) ), 'upgrade-theme_' . $stylesheet ); 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. */ 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( __( 'Subject' ) => array( @@ -331,7 +332,7 @@ function get_theme_feature_list( $api = true ) { 'Subject' => __( 'Subject' ), ); - // Loop over the wporg canonical list and apply translations + // Loop over the wp.org canonical list and apply translations. $wporg_features = array(); foreach ( (array) $feature_list as $feature_category => $feature_items ) { 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`. */ function themes_api( $action, $args = array() ) { - // include an unmodified $wp_version + // Include an unmodified $wp_version. include( ABSPATH . WPINC . '/version.php' ); if ( is_array( $args ) ) { @@ -451,7 +452,7 @@ function themes_api( $action, $args = array() ) { } 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( 'id' => $slug, 'name' => $theme->display( 'Name' ), - 'screenshot' => array( $theme->get_screenshot() ), // @todo multiple + 'screenshot' => array( $theme->get_screenshot() ), // @todo Multiple screenshots. 'description' => $theme->display( 'Description' ), 'author' => $theme->display( 'Author', false, true ), '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 ) ) { unset( $prepared_themes[ $parents[ $current_theme ] ]['actions']['delete'] ); } diff --git a/src/wp-admin/includes/translation-install.php b/src/wp-admin/includes/translation-install.php index 6296f07c74..24983d01a4 100644 --- a/src/wp-admin/includes/translation-install.php +++ b/src/wp-admin/includes/translation-install.php @@ -17,7 +17,8 @@ * @return object|WP_Error On success an object of translations, WP_Error on failure. */ 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' ) ) ) { return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) ); @@ -47,12 +48,12 @@ function translations_api( $type, $args = null ) { 'body' => array( 'wp_version' => $wp_version, 'locale' => get_locale(), - 'version' => $args['version'], // Version of plugin, theme or core + 'version' => $args['version'], // Version of plugin, theme or core. ), ); 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 ); @@ -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 ) ); diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index 48e3e1277b..7811a73ba2 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/wp-admin/includes/update-core.php @@ -253,7 +253,7 @@ $_old_files = array( 'wp-includes/js/jquery/autocomplete.js', 'wp-includes/js/jquery/interface.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', // 3.1 '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-2.png', '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-app.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-rtl.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.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/plupload.silverlight.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/tinymce/plugins/spellchecker', 'wp-includes/js/tinymce/plugins/inlinepopups', @@ -787,7 +787,7 @@ $_old_files = array( 'wp-includes/random_compat/random_bytes_openssl.php', 'wp-includes/js/tinymce/wp-tinymce.js.gz', // 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 ); @@ -938,8 +938,8 @@ function update_core( $from, $to ) { $php_version = phpversion(); $mysql_version = $wpdb->db_version(); - $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 + $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. $php_compat = version_compare( $php_version, $required_php_version, '>=' ); if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && empty( $wpdb->is_mysql ) ) { $mysql_compat = true; @@ -1017,19 +1017,19 @@ function update_core( $from, $to ) { /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters( 'update_feedback', __( 'Preparing to install the latest version…' ) ); - // Don't copy wp-content, we'll deal with that below - // We also copy version.php last so failed updates report their old version + // Don't copy wp-content, we'll deal with that below. + // We also copy version.php last so failed updates report their old version. $skip = array( 'wp-content', 'wp-includes/version.php' ); $check_is_writable = array(); - // 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' ) ) { - // 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; $checksums = get_core_checksums( $wp_version, isset( $wp_local_package ) ? $wp_local_package : 'en_US' ); 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 ) ) { 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 */ apply_filters( 'update_feedback', __( 'Enabling Maintenance mode…' ) ); - // Create maintenance file to signal that we are upgrading + // Create maintenance file to signal that we are upgrading. $maintenance_string = '<?php $upgrading = ' . time() . '; ?>'; $maintenance_file = $to . '.maintenance'; $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 ) ) ); } - // 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 ( ! $wp_filesystem->copy( $from . $distro . 'wp-includes/version.php', $to . 'wp-includes/version.php', true /* overwrite */ ) ) { $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 ); } - // 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' ); $failed = array(); 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 ) ) { $total_size = 0; foreach ( $failed as $file ) { @@ -1146,8 +1146,8 @@ function update_core( $from, $to ) { } } - // Custom Content Directory needs updating now. - // Copy Languages + // Custom content directory needs updating now. + // Copy languages. if ( ! is_wp_error( $result ) && $wp_filesystem->is_dir( $from . $distro . 'wp-content/languages' ) ) { if ( WP_LANG_DIR != ABSPATH . WPINC . '/languages' || @is_dir( WP_LANG_DIR ) ) { $lang_dir = WP_LANG_DIR; @@ -1155,9 +1155,11 @@ function update_core( $from, $to ) { $lang_dir = WP_CONTENT_DIR . '/languages'; } - if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) { // Check 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. - clearstatcache(); // for FTP, Need to clear the stat cache + // Check if the language directory exists first. + if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) { + // If it's within the ABSPATH we can handle it here, otherwise they're out of luck. + $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 ) ) { @@ -1173,7 +1175,7 @@ function update_core( $from, $to ) { /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters( 'update_feedback', __( 'Disabling Maintenance mode…' ) ); - // 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 ); // 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. - // $development_build controls us overwriting bundled themes and plugins when a non-stable release is being updated + /* + * 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. + * $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 ) ) { 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, '>' ) ) { $directory = ( '/' == $file[ strlen( $file ) - 1 ] ); 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 ) ) { continue; } @@ -1201,7 +1206,8 @@ function update_core( $from, $to ) { if ( 'plugins' == $type ) { $dest = $wp_filesystem->wp_plugins_dir(); } 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 { 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 ) ) { $wp_filesystem->delete( $from, true ); return $result; } - // Remove old files + // Remove old files. foreach ( $_old_files as $old_file ) { $old_file = $to . $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(); - // 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 DB with separate request + // Upgrade DB with separate request. /** This filter is documented in wp-admin/includes/update-core.php */ apply_filters( 'update_feedback', __( 'Upgrading database…' ) ); $db_upgrade_url = admin_url( 'upgrade.php?step=upgrade_db' ); 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(); - // (Not all cache back ends listen to 'flush') + // Not all cache back ends listen to 'flush'. wp_cache_delete( 'alloptions', 'options' ); - // Remove working directory + // Remove working directory. $wp_filesystem->delete( $from, true ); - // Force refresh of update information + // Force refresh of update information. if ( function_exists( 'delete_site_transient' ) ) { delete_site_transient( 'update_core' ); } else { @@ -1396,7 +1402,7 @@ function _redirect_to_about_wordpress( $new_version ) { // Load the updated default text localization domain for new strings. load_default_textdomain(); - // See do_core_upgrade() + // See do_core_upgrade(). show_message( __( 'WordPress updated successfully' ) ); // 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. $affected_files = array(); - // Themes + // Themes. foreach ( $wp_theme_directories as $directory ) { $affected_theme_files = _upgrade_422_find_genericons_files_in_folder( $directory ); $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_files = array_merge( $affected_files, $affected_plugin_files ); @@ -1458,7 +1464,7 @@ function _upgrade_422_remove_genericons() { 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 ); if ( ! $wp_filesystem->exists( $remote_file ) ) { diff --git a/src/wp-admin/includes/update.php b/src/wp-admin/includes/update.php index 0caa04a963..384e1f98fa 100644 --- a/src/wp-admin/includes/update.php +++ b/src/wp-admin/includes/update.php @@ -723,7 +723,8 @@ function wp_theme_update_row( $theme_key, $theme ) { * @return void|false */ 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; $nag = isset( $upgrading ); if ( ! $nag ) { diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 505b0aad17..d2dc4246fe 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -154,7 +154,7 @@ if ( ! function_exists( 'wp_install_defaults' ) ) : function wp_install_defaults( $user_id ) { global $wpdb, $wp_rewrite, $table_prefix; - // Default category + // Default category. $cat_name = __( 'Uncategorized' ); /* translators: 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; - // First post + // First post. $now = current_time( 'mysql' ); $now_gmt = current_time( 'mysql', 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 ) ); - // 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_NAME', get_network()->site_name, $first_post ); } else { @@ -257,7 +257,7 @@ if ( ! function_exists( 'wp_install_defaults' ) ) : ) ); - // Default comment + // Default comment. if ( is_multisite() ) { $first_comment_author = get_site_option( 'first_comment_author' ); $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() ) { $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() ) { // Disable by default unless the suggested content is provided. $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 . '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 ) { $wpdb->delete( $wpdb->usermeta, @@ -550,7 +551,7 @@ function wp_install_maybe_enable_pretty_permalinks() { $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' ); if ( $first_post ) { $test_url = get_permalink( $first_post->ID ); @@ -852,7 +853,7 @@ function upgrade_all() { function upgrade_100() { 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 = ''" ); if ( $posts ) { 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" ); if ( $allposts ) : 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 ) ); - 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->post2cat, array( @@ -917,7 +918,7 @@ function upgrade_100() { function upgrade_101() { 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_status' ); 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(); $time_difference = $all_options->time_difference; @@ -968,17 +969,19 @@ function upgrade_110() { $diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server; $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 ); - // 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' - // <michel_v> I just slapped myself silly for not thinking about it earlier + /* + * 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'. + * <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' ); 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_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)" ); @@ -1052,17 +1055,17 @@ function upgrade_130() { 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 . 'optiontypes' ); $wpdb->query( 'DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups' ); $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='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" ); foreach ( $options as $option ) { if ( 1 != $option->dupes ) { // Could this be done in the query? @@ -1370,7 +1373,7 @@ function upgrade_230() { if ( $wp_current_db_version < 3570 ) { /* * 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(); $default_link_cat = 0; @@ -1411,7 +1414,7 @@ function upgrade_230() { $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" ); if ( ! empty( $links ) ) { foreach ( $links as $link ) { @@ -1460,11 +1463,11 @@ function upgrade_230() { } if ( $wp_current_db_version < 4772 ) { - // Obsolete linkcategories table + // Obsolete linkcategories table. $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" ); foreach ( (array) $terms as $term ) { if ( ( 'post_tag' == $term->taxonomy ) || ( 'category' == $term->taxonomy ) ) { @@ -1586,7 +1589,7 @@ function upgrade_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 ) { $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; if ( $wp_current_db_version < 11958 ) { - // Previously, setting depth to 1 would redundantly disable threading, but now 2 is the minimum depth to avoid confusion + // Previously, setting depth to 1 would redundantly disable threading, + // but now 2 is the minimum depth to avoid confusion. if ( get_option( 'thread_comments_depth' ) == '1' ) { update_option( 'thread_comments_depth', 2 ); update_option( 'thread_comments', 0 ); @@ -1769,7 +1773,7 @@ function upgrade_330() { $sidebars_widgets = $_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: $sidebars_widgets = retrieve_widgets(); $sidebars_widgets['array_version'] = 3; @@ -1827,7 +1831,7 @@ function upgrade_350() { global $wp_current_db_version, $wpdb; 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() ) { @@ -2021,7 +2025,7 @@ function upgrade_430_fix_comments() { * @since 4.3.1 */ function upgrade_431() { - // Fix incorrect cron entries for term splitting + // Fix incorrect cron entries for term splitting. $cron_array = _get_cron_array(); if ( isset( $cron_array['wp_batch_split_terms'] ) ) { unset( $cron_array['wp_batch_split_terms'] ); @@ -2138,11 +2142,13 @@ function upgrade_510() { * @since 5.3.0 */ 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, - // or by populate_options() that is called earlier in upgrade_all(). - // In the second case `admin_email_lifespan` should be reset so the verification screen - // is shown next time an admin logs in. + /* + * 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, + * or by populate_options() that is called earlier in upgrade_all(). + * 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' ) ) { update_option( 'admin_email_lifespan', 0 ); } @@ -2159,10 +2165,10 @@ function upgrade_530() { function upgrade_network() { global $wp_current_db_version, $wpdb; - // Always clear expired transients + // Always clear expired transients. delete_expired_transients( true ); - // 2.8. + // 2.8 if ( $wp_current_db_version < 11549 ) { $wpmu_sitewide_plugins = get_site_option( 'wpmu_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; } - // Didn't find it try to create it.. + // Didn't find it, so try to create it. $wpdb->query( $create_ddl ); // We cannot directly tell that whether this succeeded! @@ -2353,7 +2359,7 @@ function drop_index( $table, $index ) { global $wpdb; $wpdb->hide_errors(); $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++ ) { $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 ); // 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 ); } - // Separate individual queries into an array + // Separate individual queries into an array. if ( ! is_array( $queries ) ) { $queries = explode( ';', $queries ); $queries = array_filter( $queries ); @@ -2581,11 +2587,11 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N */ $queries = apply_filters( 'dbdelta_queries', $queries ); - $cqueries = array(); // Creation Queries - $iqueries = array(); // Insertion Queries + $cqueries = array(); // Creation queries. + $iqueries = array(); // Insertion queries. $for_update = array(); - // Create a tablename index for an array ($cqueries) of queries + // Create a tablename index for an array ($cqueries) of queries. foreach ( $queries as $qry ) { if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) { $cqueries[ trim( $matches[1], '`' ) ] = $qry; @@ -2597,7 +2603,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N } elseif ( preg_match( '|UPDATE ([^ ]*)|', $qry, $matches ) ) { $iqueries[] = $qry; } else { - // Unrecognized query type + // Unrecognized query type. } } @@ -2634,7 +2640,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N continue; } - // Fetch the table column structure from the database + // Fetch the table column structure from the database. $suppress = $wpdb->suppress_errors(); $tablefields = $wpdb->get_results( "DESCRIBE {$table};" ); $wpdb->suppress_errors( $suppress ); @@ -2782,7 +2788,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N $tablefield_field_lowercased = strtolower( $tablefield->Field ); $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 ) ) { // Get the field type from the query. @@ -2807,7 +2813,8 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N if ( $do_change ) { // 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}"; } } @@ -2817,7 +2824,8 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N $default_value = $matches[1]; if ( $tablefield->Default != $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}"; } } @@ -2832,7 +2840,8 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N // For every remaining field specified for the table. foreach ( $cfields as $fieldname => $fielddef ) { // 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; } @@ -2845,9 +2854,9 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N // For every index in the table. foreach ( $tableindices as $tableindex ) { + $keyname = strtolower( $tableindex->Key_name ); // Add the index to the index data array. - $keyname = strtolower( $tableindex->Key_name ); $index_ary[ $keyname ]['columns'][] = array( 'fieldname' => $tableindex->Column_name, '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. foreach ( (array) $indices as $index ) { // 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; } @@ -3068,7 +3078,7 @@ function make_site_theme_from_default( $theme_name, $template ) { $default_dir = WP_CONTENT_DIR . '/themes/' . WP_DEFAULT_THEME; // Copy files from the default theme to the site theme. - //$files = array('index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css'); + // $files = array( 'index.php', 'comments.php', 'comments-popup.php', 'footer.php', 'header.php', 'sidebar.php', 'style.css' ); $theme_dir = @opendir( $default_dir ); if ( $theme_dir ) { @@ -3269,7 +3279,7 @@ function maybe_disable_link_manager() { function pre_schema_upgrade() { global $wp_current_db_version, $wpdb; - // Upgrade versions prior to 2.9 + // Upgrade versions prior to 2.9. if ( $wp_current_db_version < 11557 ) { // 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" ); @@ -3284,7 +3294,7 @@ function pre_schema_upgrade() { // Multisite schema upgrades. 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 ) { // New primary key for signups. $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) ) $charset_collate; "; - // now create tables + // Now create tables. dbDelta( $ms_queries ); } endif; @@ -3367,20 +3377,20 @@ endif; */ 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' ) ) { return false; } - // Assume global tables should be upgraded + // Assume global tables should be upgraded. $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() ) { $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() ) { $should_upgrade = false; } diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php index 172dd2a7c9..8c7c181a20 100644 --- a/src/wp-admin/includes/user.php +++ b/src/wp-admin/includes/user.php @@ -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 ) ); if ( $link_ids ) { @@ -418,7 +418,7 @@ function wp_delete_user( $id, $reassign = null ) { } } - // FINALLY, delete user + // FINALLY, delete user. if ( is_multisite() ) { remove_user_from_blog( $id, get_current_blog_id() ); } else { @@ -474,7 +474,7 @@ function default_password_nag_handler( $errors = false ) { 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'] ) { delete_user_setting( 'default_password_nag' ); update_user_option( $user_ID, 'default_password_nag', false, true ); diff --git a/src/wp-admin/includes/widgets.php b/src/wp-admin/includes/widgets.php index 9f7dfb573f..7add657333 100644 --- a/src/wp-admin/includes/widgets.php +++ b/src/wp-admin/includes/widgets.php @@ -22,7 +22,7 @@ function wp_list_widgets() { $done = array(); 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; } @@ -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]['after_widget'] = '</div>'; - $params[0]['before_title'] = '%BEG_OF_TITLE%'; // deprecated - $params[0]['after_title'] = '%END_OF_TITLE%'; // deprecated + $params[0]['before_title'] = '%BEG_OF_TITLE%'; // Deprecated. + $params[0]['after_title'] = '%END_OF_TITLE%'; // Deprecated. if ( is_callable( $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']; $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(); $widget = $wp_registered_widgets[ $widget_id ]; @@ -226,7 +226,7 @@ function wp_widget_control( $sidebar_args ) { * for a multi-widget control. */ 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; // With id_base widget id's are constructed like {$id_base}-{$id_number}. if ( isset( $control['id_base'] ) ) { diff --git a/src/wp-admin/install-helper.php b/src/wp-admin/install-helper.php index 432a4a9fa5..a0d2f1ea9d 100644 --- a/src/wp-admin/install-helper.php +++ b/src/wp-admin/install-helper.php @@ -18,7 +18,7 @@ * $error_count = 0; * $tablename = $wpdb->links; * // 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 '' "; * $q = $wpdb->query( $ddl ); * } @@ -194,7 +194,7 @@ function check_column( $table_name, $col_name, $col_type, $is_null = null, $key return false; } return true; - } // end if found our column + } // End if found our column. } return false; } diff --git a/src/wp-admin/install.php b/src/wp-admin/install.php index 68408c9c41..33fd4814f7 100644 --- a/src/wp-admin/install.php +++ b/src/wp-admin/install.php @@ -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> <?php -} // end display_header() +} // End display_header(). /** * 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 ) ); $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; if ( isset( $_POST['weblog_title'] ) ) { $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'] ) : ''; ?>" /> </form> <?php -} // end display_setup_form() +} // End display_setup_form(). // Let's check to make sure WP isn't already installed. if ( is_blog_installed() ) { @@ -303,7 +303,7 @@ if ( ! empty( $_REQUEST['language'] ) ) { $scripts_to_print = array( 'jquery' ); switch ( $step ) { - case 0: // Step 0 + case 0: // Step 0. if ( wp_can_install_language_pack() && empty( $language ) ) { $languages = wp_get_available_translations(); if ( $languages ) { @@ -355,7 +355,7 @@ switch ( $step ) { $scripts_to_print[] = 'user-profile'; 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'] ) ) : ''; $user_name = isset( $_POST['user_name'] ) ? trim( wp_unslash( $_POST['user_name'] ) ) : ''; $admin_password = isset( $_POST['admin_password'] ) ? wp_unslash( $_POST['admin_password'] ) : ''; @@ -366,22 +366,22 @@ switch ( $step ) { // Check email address. $error = false; if ( empty( $user_name ) ) { - // TODO: poka-yoke + // TODO: Poka-yoke. display_setup_form( __( 'Please provide a valid username.' ) ); $error = true; } elseif ( $user_name != sanitize_user( $user_name, true ) ) { display_setup_form( __( 'The username you provided has invalid characters.' ) ); $error = true; } elseif ( $admin_password != $admin_password_check ) { - // TODO: poka-yoke + // TODO: Poka-yoke. display_setup_form( __( 'Your passwords do not match. Please try again.' ) ); $error = true; } elseif ( empty( $admin_email ) ) { - // TODO: poka-yoke + // TODO: Poka-yoke. display_setup_form( __( 'You must provide an email address.' ) ); $error = true; } elseif ( ! is_email( $admin_email ) ) { - // TODO: poka-yoke + // TODO: Poka-yoke. display_setup_form( __( 'Sorry, that isn’t a valid email address. Email addresses look like <code>username@example.com</code>.' ) ); $error = true; } diff --git a/src/wp-admin/link-manager.php b/src/wp-admin/link-manager.php index 1ca9bf64b3..cf34db0507 100644 --- a/src/wp-admin/link-manager.php +++ b/src/wp-admin/link-manager.php @@ -14,7 +14,7 @@ if ( ! current_user_can( 'manage_links' ) ) { $wp_list_table = _get_list_table( 'WP_Links_List_Table' ); -// Handle bulk deletes +// Handle bulk deletes. $doaction = $wp_list_table->current_action(); if ( $doaction && isset( $_REQUEST['linkcheck'] ) ) { diff --git a/src/wp-admin/link-parse-opml.php b/src/wp-admin/link-parse-opml.php index 55f0401a47..b26df319f1 100644 --- a/src/wp-admin/link-parse-opml.php +++ b/src/wp-admin/link-parse-opml.php @@ -72,7 +72,7 @@ function endElement( $parser, $tagName ) { // phpcs:ignore WordPress.NamingConve // Nothing to do. } -// Create an XML parser +// Create an XML parser. if ( ! function_exists( 'xml_parser_create' ) ) { trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); wp_die( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); @@ -80,7 +80,7 @@ if ( ! function_exists( 'xml_parser_create' ) ) { $xml_parser = xml_parser_create(); -// Set the functions to handle opening and closing tags +// Set the functions to handle opening and closing tags. xml_set_element_handler( $xml_parser, 'startElement', 'endElement' ); if ( ! xml_parse( $xml_parser, $opml, true ) ) { @@ -92,5 +92,5 @@ if ( ! xml_parse( $xml_parser, $opml, true ) ) { ); } -// Free up memory used by the XML parser +// Free up memory used by the XML parser. xml_parser_free( $xml_parser ); diff --git a/src/wp-admin/load-scripts.php b/src/wp-admin/load-scripts.php index bdb5fa5cec..d05fbfa1dc 100644 --- a/src/wp-admin/load-scripts.php +++ b/src/wp-admin/load-scripts.php @@ -37,7 +37,7 @@ require( ABSPATH . 'wp-admin/includes/noop.php' ); require( ABSPATH . WPINC . '/script-loader.php' ); require( ABSPATH . WPINC . '/version.php' ); -$expires_offset = 31536000; // 1 year +$expires_offset = 31536000; // 1 year. $out = ''; $wp_scripts = new WP_Scripts(); diff --git a/src/wp-admin/load-styles.php b/src/wp-admin/load-styles.php index 8b3cc0d75f..a13f97c392 100644 --- a/src/wp-admin/load-styles.php +++ b/src/wp-admin/load-styles.php @@ -38,7 +38,7 @@ if ( empty( $load ) ) { } $rtl = ( isset( $_GET['dir'] ) && 'rtl' == $_GET['dir'] ); -$expires_offset = 31536000; // 1 year +$expires_offset = 31536000; // 1 year. $out = ''; $wp_styles = new WP_Styles(); diff --git a/src/wp-admin/media-new.php b/src/wp-admin/media-new.php index 0cc82a5fd4..41e7db2f91 100644 --- a/src/wp-admin/media-new.php +++ b/src/wp-admin/media-new.php @@ -29,7 +29,7 @@ if ( isset( $_REQUEST['post_id'] ) ) { if ( $_POST ) { if ( isset( $_POST['html-upload'] ) && ! empty( $_FILES ) ) { check_admin_referer( 'media-form' ); - // Upload File button was clicked + // Upload File button was clicked. $upload_id = media_handle_upload( 'async-upload', $post_id ); if ( is_wp_error( $upload_id ) ) { wp_die( $upload_id ); diff --git a/src/wp-admin/media-upload.php b/src/wp-admin/media-upload.php index 2354cf629d..41de115a1e 100644 --- a/src/wp-admin/media-upload.php +++ b/src/wp-admin/media-upload.php @@ -28,7 +28,7 @@ wp_enqueue_script( 'media-gallery' ); header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); -// IDs should be integers +// IDs should be integers. $ID = isset( $ID ) ? (int) $ID : 0; $post_id = isset( $post_id ) ? (int) $post_id : 0; @@ -49,7 +49,7 @@ if ( ! empty( $_REQUEST['post_id'] ) && ! current_user_can( 'edit_post', $_REQUE ); } -// Upload type: image, video, file, ..? +// Upload type: image, video, file, ...? if ( isset( $_GET['type'] ) ) { $type = strval( $_GET['type'] ); } else { diff --git a/src/wp-admin/menu-header.php b/src/wp-admin/menu-header.php index 6efd0994c8..175a365d6b 100644 --- a/src/wp-admin/menu-header.php +++ b/src/wp-admin/menu-header.php @@ -69,7 +69,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { global $self, $parent_file, $submenu_file, $plugin_page, $typenow; $first = true; - // 0 = menu_title, 1 = capability, 2 = menu_slug, 3 = page_title, 4 = classes, 5 = hookname, 6 = icon_url + // 0 = menu_title, 1 = capability, 2 = menu_slug, 3 = page_title, 4 = classes, 5 = hookname, 6 = icon_url. foreach ( $menu as $key => $item ) { $admin_is_parent = false; $class = array(); @@ -184,7 +184,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { $first = true; - // 0 = menu_title, 1 = capability, 2 = menu_slug, 3 = page_title, 4 = classes + // 0 = menu_title, 1 = capability, 2 = menu_slug, 3 = page_title, 4 = classes. foreach ( $submenu_items as $sub_key => $sub_item ) { if ( ! current_user_can( $sub_item[1] ) ) { continue; @@ -238,7 +238,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { $title = wptexturize( $sub_item[0] ); if ( ! empty( $menu_hook ) || ( ( 'index.php' != $sub_item[2] ) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) && ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) ) ) { - // If admin.php is the current page or if the parent exists as a file in the plugins or admin dir + // If admin.php is the current page or if the parent exists as a file in the plugins or admin directory. if ( ( ! $admin_is_parent && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! is_dir( WP_PLUGIN_DIR . "/{$item[2]}" ) ) || file_exists( $menu_file ) ) { $sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), $item[2] ); } else { diff --git a/src/wp-admin/menu.php b/src/wp-admin/menu.php index 7aec19663d..f37ab9d3f7 100644 --- a/src/wp-admin/menu.php +++ b/src/wp-admin/menu.php @@ -60,7 +60,7 @@ if ( ! is_multisite() ) { $menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); -// $menu[5] = Posts +// $menu[5] = Posts. $menu[10] = array( __( 'Media' ), 'upload_files', 'upload.php', '', 'menu-top menu-icon-media', 'menu-media', 'dashicons-admin-media' ); $submenu['upload.php'][5] = array( __( 'Library' ), 'upload_files', 'upload.php' ); @@ -82,7 +82,7 @@ $menu[15] = array( __( 'Links' ), 'manage_links', 'lin $submenu['link-manager.php'][10] = array( _x( 'Add New', 'link' ), 'manage_links', 'link-add.php' ); $submenu['link-manager.php'][15] = array( __( 'Link Categories' ), 'manage_categories', 'edit-tags.php?taxonomy=link_category' ); -// $menu[20] = Pages +// $menu[20] = Pages. // Avoid the comment count query for users who cannot edit_posts. if ( current_user_can( 'edit_posts' ) ) { @@ -107,7 +107,7 @@ if ( current_user_can( 'edit_posts' ) ) { $submenu['edit-comments.php'][0] = array( __( 'All Comments' ), 'edit_posts', 'edit-comments.php' ); -$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group +$_wp_last_object_menu = 25; // The index of the last top-level menu in the object menu group. $types = (array) get_post_types( array( @@ -139,7 +139,7 @@ foreach ( array_merge( $builtin, $types ) as $ptype ) { } $menu_class = 'menu-top menu-icon-' . $ptype_for_id; - // 'post' special case + // 'post' special case. if ( 'post' === $ptype ) { $menu_class .= ' open-if-no-js'; $ptype_file = 'edit.php'; @@ -219,7 +219,7 @@ if ( ! is_multisite() ) { * @since 3.0.0 */ function _add_themes_utility_last() { - // Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook + // Must use API on the admin_menu hook, direct modification is only possible on/before the _admin_menu hook. add_submenu_page( 'themes.php', __( 'Theme Editor' ), __( 'Theme Editor' ), 'edit_themes', 'theme-editor.php' ); } @@ -297,11 +297,11 @@ $menu[80] = array( __( 'Settings' ), 'manage_optio $submenu['options-general.php'][40] = array( __( 'Permalinks' ), 'manage_options', 'options-permalink.php' ); $submenu['options-general.php'][45] = array( __( 'Privacy' ), 'manage_privacy_options', 'options-privacy.php' ); -$_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group +$_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group. $menu[99] = array( '', 'read', 'separator-last', '', 'wp-menu-separator' ); -// Back-compat for old top-levels +// Back-compat for old top-levels. $_wp_real_parent_file['post.php'] = 'edit.php'; $_wp_real_parent_file['post-new.php'] = 'edit.php'; $_wp_real_parent_file['edit-pages.php'] = 'edit.php?post_type=page'; diff --git a/src/wp-admin/nav-menus.php b/src/wp-admin/nav-menus.php index d707e49cbf..c2d399f42d 100644 --- a/src/wp-admin/nav-menus.php +++ b/src/wp-admin/nav-menus.php @@ -12,14 +12,14 @@ /** Load WordPress Administration Bootstrap */ require_once( dirname( __FILE__ ) . '/admin.php' ); -// Load all the nav menu interface functions +// Load all the nav menu interface functions. require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' ); if ( ! current_theme_supports( 'menus' ) && ! current_theme_supports( 'widgets' ) ) { wp_die( __( 'Your theme does not support navigation menus or widgets.' ) ); } -// Permissions Check +// Permissions check. if ( ! current_user_can( 'edit_theme_options' ) ) { wp_die( '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' . @@ -34,21 +34,21 @@ if ( wp_is_mobile() ) { wp_enqueue_script( 'jquery-touch-punch' ); } -// Container for any messages displayed to the user +// Container for any messages displayed to the user. $messages = array(); -// Container that stores the name of the active menu +// Container that stores the name of the active menu. $nav_menu_selected_title = ''; -// The menu id of the current menu being edited +// The menu id of the current menu being edited. $nav_menu_selected_id = isset( $_REQUEST['menu'] ) ? (int) $_REQUEST['menu'] : 0; -// Get existing menu locations assignments +// Get existing menu locations assignments. $locations = get_registered_nav_menus(); $menu_locations = get_nav_menu_locations(); $num_locations = count( array_keys( $locations ) ); -// Allowed actions: add, update, delete +// Allowed actions: add, update, delete. $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'edit'; /* @@ -325,13 +325,13 @@ switch ( $action ) { wp_save_nav_menu_items( $nav_menu_selected_id, absint( $_REQUEST['menu-item'] ) ); } if ( isset( $_REQUEST['zero-menu-state'] ) ) { - // If there are menu items, add them + // If there are menu items, add them. wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ); - // Auto-save nav_menu_locations + // Auto-save nav_menu_locations. $locations = get_nav_menu_locations(); foreach ( $locations as $location => $menu_id ) { $locations[ $location ] = $nav_menu_selected_id; - break; // There should only be 1 + break; // There should only be 1. } set_theme_mod( 'nav_menu_locations', $locations ); } @@ -399,7 +399,7 @@ switch ( $action ) { $new_menu_locations = array_map( 'absint', $_POST['menu-locations'] ); $menu_locations = array_merge( $menu_locations, $new_menu_locations ); - // Set menu locations + // Set menu locations. set_theme_mod( 'nav_menu_locations', $menu_locations ); $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'Menu locations updated.' ) . '</p></div>'; @@ -471,7 +471,7 @@ if ( ! $add_new_screen && 0 < $menu_count && isset( $_GET['action'] ) && 'delete if ( $one_theme_location_no_menus ) { $nav_menu_selected_id = 0; } elseif ( empty( $nav_menu_selected_id ) && ! empty( $nav_menus ) && ! $add_new_screen ) { - // if we have no selection yet, and we have menus, set to the first one in the list. + // If we have no selection yet, and we have menus, set to the first one in the list. $nav_menu_selected_id = $nav_menus[0]->term_id; } @@ -536,7 +536,7 @@ if ( ! current_theme_supports( 'menus' ) && ! $num_locations ) { ) . '</p></div>'; } -if ( ! $locations_screen ) : // Main tab +if ( ! $locations_screen ) : // Main tab. $overview = '<p>' . __( 'This screen is used for managing your navigation menus.' ) . '</p>'; $overview .= '<p>' . sprintf( /* translators: 1: URL to Widgets screen, 2 and 3: The names of the default themes. */ @@ -584,7 +584,7 @@ if ( ! $locations_screen ) : // Main tab 'content' => $editing_menus, ) ); -else : // Locations Tab. +else : // Locations tab. $locations_overview = '<p>' . __( 'This screen is used for globally assigning menus to locations defined by your theme.' ) . '</p>'; $locations_overview .= '<ul><li>' . __( 'To assign menus to one or more theme locations, <strong>select a menu from each location’s drop down.</strong> When you’re finished, <strong>click Save Changes</strong>' ) . '</li>'; $locations_overview .= '<li>' . __( 'To edit a menu currently assigned to a theme location, <strong>click the adjacent ’Edit’ link</strong>' ) . '</li>'; @@ -745,7 +745,7 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' ); </div><!-- .locations-row-links --> </td><!-- .menu-location-menus --> </tr><!-- .menu-locations-row --> - <?php } // foreach ?> + <?php } // End foreach. ?> </tbody> </table> <p class="button-controls wp-clearfix"><?php submit_button( __( 'Save Changes' ), 'primary left', 'nav-menu-locations', false ); ?></p> diff --git a/src/wp-admin/network/settings.php b/src/wp-admin/network/settings.php index c100a665f3..deb6397b7b 100644 --- a/src/wp-admin/network/settings.php +++ b/src/wp-admin/network/settings.php @@ -20,7 +20,7 @@ if ( ! current_user_can( 'manage_network_options' ) ) { $title = __( 'Network Settings' ); $parent_file = 'settings.php'; -// Handle network admin email change requests +// Handle network admin email change requests. if ( ! empty( $_GET['network_admin_hash'] ) ) { $new_admin_details = get_site_option( 'network_admin_hash' ); $redirect = 'settings.php?updated=false'; diff --git a/src/wp-admin/network/site-new.php b/src/wp-admin/network/site-new.php index d86058e0f4..6354f6d7ce 100644 --- a/src/wp-admin/network/site-new.php +++ b/src/wp-admin/network/site-new.php @@ -48,7 +48,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) { $domain = strtolower( $blog['domain'] ); } - // If not a subdomain installation, make sure the domain isn't a reserved word + // If not a subdomain installation, make sure the domain isn't a reserved word. if ( ! is_subdomain_install() ) { $subdirectory_reserved_names = get_subdirectory_reserved_names(); @@ -106,7 +106,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) { $password = 'N/A'; $user_id = email_exists( $email ); - if ( ! $user_id ) { // Create a new user with a random password + if ( ! $user_id ) { // Create a new user with a random password. /** * Fires immediately before a new user is created via the network site-new.php page. * diff --git a/src/wp-admin/network/site-settings.php b/src/wp-admin/network/site-settings.php index 7c3cae7200..00fc7e58c5 100644 --- a/src/wp-admin/network/site-settings.php +++ b/src/wp-admin/network/site-settings.php @@ -44,7 +44,7 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_ $key = wp_unslash( $key ); $val = wp_unslash( $val ); if ( $key === 0 || is_array( $val ) || in_array( $key, $skip_options ) ) { - continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options + continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options. } update_option( $key, $val ); } @@ -157,7 +157,7 @@ if ( ! empty( $messages ) ) { </tr> <?php } - } // End foreach + } // End foreach. /** * Fires at the end of the Edit Site form, before the submit button. * diff --git a/src/wp-admin/network/themes.php b/src/wp-admin/network/themes.php index f7711f034d..8fbce0a519 100644 --- a/src/wp-admin/network/themes.php +++ b/src/wp-admin/network/themes.php @@ -177,7 +177,7 @@ if ( $action ) { <?php require_once( ABSPATH . 'wp-admin/admin-footer.php' ); exit; - } // Endif verify-delete + } // End if verify-delete. foreach ( $themes as $theme ) { $delete_result = delete_theme( diff --git a/src/wp-admin/network/users.php b/src/wp-admin/network/users.php index 9c5bcc0ca4..cd39bf1465 100644 --- a/src/wp-admin/network/users.php +++ b/src/wp-admin/network/users.php @@ -28,7 +28,7 @@ if ( isset( $_GET['action'] ) ) { $id = intval( $_GET['id'] ); if ( $id != '0' && $id != '1' ) { - $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays + $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle arrays. $title = __( 'Users' ); $parent_file = 'users.php'; require_once( ABSPATH . 'wp-admin/admin-header.php' ); @@ -84,7 +84,7 @@ if ( isset( $_GET['action'] ) ) { $blogs = get_blogs_of_user( $user_id, true ); foreach ( (array) $blogs as $details ) { - if ( $details->userblog_id != get_network()->site_id ) { // main blog not a spam ! + if ( $details->userblog_id != get_network()->site_id ) { // Main blog is not a spam! update_blog_status( $details->userblog_id, 'spam', '1' ); } } diff --git a/src/wp-admin/options-discussion.php b/src/wp-admin/options-discussion.php index a61a5f6f8e..677396fbaf 100644 --- a/src/wp-admin/options-discussion.php +++ b/src/wp-admin/options-discussion.php @@ -220,7 +220,7 @@ printf( <p><?php _e( 'An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.' ); ?></p> <?php -// the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that? +// The above would be a good place to link to the documentation on the Gravatar functions, for putting it in themes. Anything like that? $show_avatars = get_option( 'show_avatars' ); $show_avatars_class = ''; @@ -294,7 +294,7 @@ $avatar_defaults = apply_filters( 'avatar_defaults', $avatar_defaults ); $default = get_option( 'avatar_default', 'mystery' ); $avatar_list = ''; -// Force avatars on to display these choices +// Force avatars on to display these choices. add_filter( 'pre_option_show_avatars', '__return_true', 100 ); foreach ( $avatar_defaults as $default_key => $default_name ) { diff --git a/src/wp-admin/options-general.php b/src/wp-admin/options-general.php index 13aa9c8114..825763163d 100644 --- a/src/wp-admin/options-general.php +++ b/src/wp-admin/options-general.php @@ -209,7 +209,7 @@ if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) { $tzstring = ''; } -if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists +if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists. $check_zone_info = false; if ( 0 == $current_offset ) { $tzstring = 'UTC+0'; @@ -321,7 +321,7 @@ if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists foreach ( $date_formats as $format ) { echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'"; - if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===" + if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===". echo " checked='checked'"; $custom = false; } @@ -358,7 +358,7 @@ foreach ( $date_formats as $format ) { foreach ( $time_formats as $format ) { echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'"; - if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===" + if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===". echo " checked='checked'"; $custom = false; } diff --git a/src/wp-admin/options-media.php b/src/wp-admin/options-media.php index 4cc5e4c5ef..5627fd4883 100644 --- a/src/wp-admin/options-media.php +++ b/src/wp-admin/options-media.php @@ -107,7 +107,7 @@ if ( isset( $GLOBALS['wp_settings']['media']['embeds'] ) ) : <h2 class="title"><?php _e( 'Uploading Files' ); ?></h2> <table class="form-table" role="presentation"> <?php - // If upload_url_path is not the default (empty), and upload_path is not the default ('wp-content/uploads' or empty) + // If upload_url_path is not the default (empty), and upload_path is not the default ('wp-content/uploads' or empty). if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) : ?> <tr> diff --git a/src/wp-admin/options-permalink.php b/src/wp-admin/options-permalink.php index b9a69678ff..27b8edc3b1 100644 --- a/src/wp-admin/options-permalink.php +++ b/src/wp-admin/options-permalink.php @@ -419,7 +419,7 @@ else : </form> <?php endif; ?> <?php endif; ?> -<?php } // multisite ?> +<?php } // End if ! is_multisite(). ?> </div> diff --git a/src/wp-admin/options.php b/src/wp-admin/options.php index 1aaad130b4..4f4264e92d 100644 --- a/src/wp-admin/options.php +++ b/src/wp-admin/options.php @@ -52,7 +52,7 @@ if ( ! current_user_can( $capability ) ) { ); } -// Handle admin email change requests +// Handle admin email change requests. if ( ! empty( $_GET['adminhash'] ) ) { $new_admin_details = get_option( 'adminhash' ); $redirect = 'options-general.php?updated=false'; diff --git a/src/wp-admin/plugin-editor.php b/src/wp-admin/plugin-editor.php index 0b44fbb499..ddbeceed2f 100644 --- a/src/wp-admin/plugin-editor.php +++ b/src/wp-admin/plugin-editor.php @@ -79,6 +79,7 @@ $real_file = WP_PLUGIN_DIR . '/' . $file; // Handle fallback editing of file when JavaScript is not available. $edit_error = null; $posted_content = null; + if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); if ( is_wp_error( $r ) ) { @@ -101,80 +102,80 @@ if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { } } - // List of allowable extensions - $editable_extensions = wp_get_plugin_file_editable_extensions( $plugin ); +// List of allowable extensions. +$editable_extensions = wp_get_plugin_file_editable_extensions( $plugin ); if ( ! is_file( $real_file ) ) { wp_die( sprintf( '<p>%s</p>', __( 'File does not exist! Please double check the name and try again.' ) ) ); } else { - // Get the extension of the file + // Get the extension of the file. if ( preg_match( '/\.([^.]+)$/', $real_file, $matches ) ) { $ext = strtolower( $matches[1] ); - // If extension is not in the acceptable list, skip it + // If extension is not in the acceptable list, skip it. if ( ! in_array( $ext, $editable_extensions ) ) { wp_die( sprintf( '<p>%s</p>', __( 'Files of this type are not editable.' ) ) ); } } } - get_current_screen()->add_help_tab( - array( - 'id' => 'overview', - 'title' => __( 'Overview' ), - 'content' => - '<p>' . __( 'You can use the plugin editor to make changes to any of your plugins’ individual PHP files. Be aware that if you make changes, plugins updates will overwrite your customizations.' ) . '</p>' . - '<p>' . __( 'Choose a plugin to edit from the dropdown menu and click the Select button. Click once on any file name to load it in the editor, and make your changes. Don’t forget to save your changes (Update File) when you’re finished.' ) . '</p>' . - '<p>' . __( 'The Documentation menu below the editor lists the PHP functions recognized in the plugin file. Clicking Look Up takes you to a web page about that particular function.' ) . '</p>' . - '<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>' . - '<ul>' . - '<li id="editor-keyboard-trap-help-2">' . __( 'In the editing area, the Tab key enters a tab character.' ) . '</li>' . - '<li id="editor-keyboard-trap-help-3">' . __( 'To move away from this area, press the Esc key followed by the Tab key.' ) . '</li>' . - '<li id="editor-keyboard-trap-help-4">' . __( 'Screen reader users: when in forms mode, you may need to press the Esc key twice.' ) . '</li>' . - '</ul>' . - '<p>' . __( 'If you want to make changes but don’t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit plugins, write your own from scratch, or just better understand their anatomy, check out the links below.' ) . '</p>' . - ( is_network_admin() ? '<p>' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '</p>' : '' ), - ) - ); - - get_current_screen()->set_help_sidebar( - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . - '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-editor-screen/">Documentation on Editing Plugins</a>' ) . '</p>' . - '<p>' . __( '<a href="https://developer.wordpress.org/plugins/">Documentation on Writing Plugins</a>' ) . '</p>' . - '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' - ); - - $settings = array( - 'codeEditor' => wp_enqueue_code_editor( array( 'file' => $real_file ) ), - ); - wp_enqueue_script( 'wp-theme-plugin-editor' ); - wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) ); - wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.themeOrPlugin = "plugin";' ) ); - - require_once( ABSPATH . 'wp-admin/admin-header.php' ); - - update_recently_edited( WP_PLUGIN_DIR . '/' . $file ); - - if ( ! empty( $posted_content ) ) { - $content = $posted_content; - } else { - $content = file_get_contents( $real_file ); - } +get_current_screen()->add_help_tab( + array( + 'id' => 'overview', + 'title' => __( 'Overview' ), + 'content' => + '<p>' . __( 'You can use the plugin editor to make changes to any of your plugins’ individual PHP files. Be aware that if you make changes, plugins updates will overwrite your customizations.' ) . '</p>' . + '<p>' . __( 'Choose a plugin to edit from the dropdown menu and click the Select button. Click once on any file name to load it in the editor, and make your changes. Don’t forget to save your changes (Update File) when you’re finished.' ) . '</p>' . + '<p>' . __( 'The Documentation menu below the editor lists the PHP functions recognized in the plugin file. Clicking Look Up takes you to a web page about that particular function.' ) . '</p>' . + '<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>' . + '<ul>' . + '<li id="editor-keyboard-trap-help-2">' . __( 'In the editing area, the Tab key enters a tab character.' ) . '</li>' . + '<li id="editor-keyboard-trap-help-3">' . __( 'To move away from this area, press the Esc key followed by the Tab key.' ) . '</li>' . + '<li id="editor-keyboard-trap-help-4">' . __( 'Screen reader users: when in forms mode, you may need to press the Esc key twice.' ) . '</li>' . + '</ul>' . + '<p>' . __( 'If you want to make changes but don’t want them to be overwritten when the plugin is updated, you may be ready to think about writing your own plugin. For information on how to edit plugins, write your own from scratch, or just better understand their anatomy, check out the links below.' ) . '</p>' . + ( is_network_admin() ? '<p>' . __( 'Any edits to files from this screen will be reflected on all sites in the network.' ) . '</p>' : '' ), + ) +); + +get_current_screen()->set_help_sidebar( + '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . + '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-editor-screen/">Documentation on Editing Plugins</a>' ) . '</p>' . + '<p>' . __( '<a href="https://developer.wordpress.org/plugins/">Documentation on Writing Plugins</a>' ) . '</p>' . + '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' +); + +$settings = array( + 'codeEditor' => wp_enqueue_code_editor( array( 'file' => $real_file ) ), +); +wp_enqueue_script( 'wp-theme-plugin-editor' ); +wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) ); +wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'wp.themePluginEditor.themeOrPlugin = "plugin";' ) ); + +require_once( ABSPATH . 'wp-admin/admin-header.php' ); + +update_recently_edited( WP_PLUGIN_DIR . '/' . $file ); + +if ( ! empty( $posted_content ) ) { + $content = $posted_content; +} else { + $content = file_get_contents( $real_file ); +} - if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) { - $functions = wp_doc_link_parse( $content ); +if ( '.php' == substr( $real_file, strrpos( $real_file, '.' ) ) ) { + $functions = wp_doc_link_parse( $content ); - if ( ! empty( $functions ) ) { - $docs_select = '<select name="docs-list" id="docs-list">'; - $docs_select .= '<option value="">' . __( 'Function Name…' ) . '</option>'; - foreach ( $functions as $function ) { - $docs_select .= '<option value="' . esc_attr( $function ) . '">' . esc_html( $function ) . '()</option>'; - } - $docs_select .= '</select>'; + if ( ! empty( $functions ) ) { + $docs_select = '<select name="docs-list" id="docs-list">'; + $docs_select .= '<option value="">' . __( 'Function Name…' ) . '</option>'; + foreach ( $functions as $function ) { + $docs_select .= '<option value="' . esc_attr( $function ) . '">' . esc_html( $function ) . '()</option>'; } + $docs_select .= '</select>'; } +} - $content = esc_textarea( $content ); - ?> +$content = esc_textarea( $content ); +?> <div class="wrap"> <h1><?php echo esc_html( $title ); ?></h1> @@ -217,19 +218,19 @@ if ( ! is_file( $real_file ) ) { <form action="plugin-editor.php" method="get"> <strong><label for="plugin"><?php _e( 'Select plugin to edit:' ); ?> </label></strong> <select name="plugin" id="plugin"> -<?php -foreach ( $plugins as $plugin_key => $a_plugin ) { - $plugin_name = $a_plugin['Name']; - if ( $plugin_key == $plugin ) { - $selected = " selected='selected'"; - } else { - $selected = ''; - } - $plugin_name = esc_attr( $plugin_name ); - $plugin_key = esc_attr( $plugin_key ); - echo "\n\t<option value=\"$plugin_key\" $selected>$plugin_name</option>"; -} -?> + <?php + foreach ( $plugins as $plugin_key => $a_plugin ) { + $plugin_name = $a_plugin['Name']; + if ( $plugin_key == $plugin ) { + $selected = " selected='selected'"; + } else { + $selected = ''; + } + $plugin_name = esc_attr( $plugin_name ); + $plugin_key = esc_attr( $plugin_key ); + echo "\n\t<option value=\"$plugin_key\" $selected>$plugin_name</option>"; + } + ?> </select> <?php submit_button( __( 'Select' ), '', 'Submit', false ); ?> </form> @@ -255,50 +256,59 @@ foreach ( $plugins as $plugin_key => $a_plugin ) { </ul> </ul> </div> + <form name="template" id="template" action="plugin-editor.php" method="post"> <?php wp_nonce_field( 'edit-plugin_' . $file, 'nonce' ); ?> - <div> - <label for="newcontent" id="theme-plugin-editor-label"><?php _e( 'Selected file content:' ); ?></label> - <textarea cols="70" rows="25" name="newcontent" id="newcontent" aria-describedby="editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"><?php echo $content; ?></textarea> - <input type="hidden" name="action" value="update" /> - <input type="hidden" name="file" value="<?php echo esc_attr( $file ); ?>" /> - <input type="hidden" name="plugin" value="<?php echo esc_attr( $plugin ); ?>" /> + <div> + <label for="newcontent" id="theme-plugin-editor-label"><?php _e( 'Selected file content:' ); ?></label> + <textarea cols="70" rows="25" name="newcontent" id="newcontent" aria-describedby="editor-keyboard-trap-help-1 editor-keyboard-trap-help-2 editor-keyboard-trap-help-3 editor-keyboard-trap-help-4"><?php echo $content; ?></textarea> + <input type="hidden" name="action" value="update" /> + <input type="hidden" name="file" value="<?php echo esc_attr( $file ); ?>" /> + <input type="hidden" name="plugin" value="<?php echo esc_attr( $plugin ); ?>" /> + </div> + + <?php if ( ! empty( $docs_select ) ) : ?> + <div id="documentation" class="hide-if-no-js"> + <label for="docs-list"><?php _e( 'Documentation:' ); ?></label> + <?php echo $docs_select; ?> + <input disabled id="docs-lookup" type="button" class="button" value="<?php esc_attr_e( 'Look Up' ); ?>" onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'https://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_user_locale() ); ?>&version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&redirect=true'); }" /> </div> - <?php if ( ! empty( $docs_select ) ) : ?> - <div id="documentation" class="hide-if-no-js"><label for="docs-list"><?php _e( 'Documentation:' ); ?></label> <?php echo $docs_select; ?> <input disabled id="docs-lookup" type="button" class="button" value="<?php esc_attr_e( 'Look Up' ); ?> " onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'https://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_user_locale() ); ?>&version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&redirect=true'); }" /></div> - <?php endif; ?> -<?php if ( is_writeable( $real_file ) ) : ?> - <div class="editor-notices"> + <?php endif; ?> + + <?php if ( is_writeable( $real_file ) ) : ?> + <div class="editor-notices"> <?php if ( in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) ) { ?> <div class="notice notice-warning inline active-plugin-edit-warning"> - <p><?php _e( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ); ?></p> - </div> + <p><?php _e( '<strong>Warning:</strong> Making changes to active plugins is not recommended.' ); ?></p> + </div> <?php } ?> - </div> - <p class="submit"> - <?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?> - <span class="spinner"></span> - </p> -<?php else : ?> - <p><em> - <?php - printf( - /* translators: %s: Documentation URL. */ - __( 'You need to make this file writable before you can save your changes. See <a href="%s">Changing File Permissions</a> for more information.' ), - __( 'https://wordpress.org/support/article/changing-file-permissions/' ) - ); - ?> - </em></p> -<?php endif; ?> -<?php wp_print_file_editor_templates(); ?> + </div> + <p class="submit"> + <?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?> + <span class="spinner"></span> + </p> + <?php else : ?> + <p><em> + <?php + printf( + /* translators: %s: Documentation URL. */ + __( 'You need to make this file writable before you can save your changes. See <a href="%s">Changing File Permissions</a> for more information.' ), + __( 'https://wordpress.org/support/article/changing-file-permissions/' ) + ); + ?> + </em></p> + <?php endif; ?> + + <?php wp_print_file_editor_templates(); ?> </form> <br class="clear" /> </div> <?php $dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); if ( ! in_array( 'plugin_editor_notice', $dismissed_pointers, true ) ) : - // Get a back URL - $referer = wp_get_referer(); + // Get a back URL. + $referer = wp_get_referer(); + $excluded_referer_basenames = array( 'plugin-editor.php', 'wp-login.php' ); if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) { @@ -307,22 +317,22 @@ if ( ! in_array( 'plugin_editor_notice', $dismissed_pointers, true ) ) : $return_url = admin_url( '/' ); } ?> -<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js hidden"> - <div class="notification-dialog-background"></div> - <div class="notification-dialog"> - <div class="file-editor-warning-content"> - <div class="file-editor-warning-message"> - <h1><?php _e( 'Heads up!' ); ?></h1> - <p><?php _e( 'You appear to be making direct edits to your plugin in the WordPress dashboard. We recommend that you don’t! Editing plugins directly may introduce incompatibilities that break your site and your changes may be lost in future updates.' ); ?></p> - <p><?php _e( 'If you absolutely have to make direct edits to this plugin, use a file manager to create a copy with a new name and hang on to the original. That way, you can re-enable a functional version if something goes wrong.' ); ?></p> + <div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js hidden"> + <div class="notification-dialog-background"></div> + <div class="notification-dialog"> + <div class="file-editor-warning-content"> + <div class="file-editor-warning-message"> + <h1><?php _e( 'Heads up!' ); ?></h1> + <p><?php _e( 'You appear to be making direct edits to your plugin in the WordPress dashboard. We recommend that you don’t! Editing plugins directly may introduce incompatibilities that break your site and your changes may be lost in future updates.' ); ?></p> + <p><?php _e( 'If you absolutely have to make direct edits to this plugin, use a file manager to create a copy with a new name and hang on to the original. That way, you can re-enable a functional version if something goes wrong.' ); ?></p> + </div> + <p> + <a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a> + <button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button> + </p> </div> - <p> - <a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a> - <button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button> - </p> </div> </div> -</div> <?php endif; // Editor warning notice. diff --git a/src/wp-admin/plugin-install.php b/src/wp-admin/plugin-install.php index 52dd791684..68ae0dd0f1 100644 --- a/src/wp-admin/plugin-install.php +++ b/src/wp-admin/plugin-install.php @@ -5,7 +5,7 @@ * @package WordPress * @subpackage Administration */ -// TODO route this pages via a specific iframe handler instead of the do_action below +// TODO: Route this page via a specific iframe handler instead of the do_action below. if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'plugin-information' == $_GET['tab'] ) ) { define( 'IFRAME_REQUEST', true ); } diff --git a/src/wp-admin/plugins.php b/src/wp-admin/plugins.php index 459a2f82f6..ed2deb7315 100644 --- a/src/wp-admin/plugins.php +++ b/src/wp-admin/plugins.php @@ -63,11 +63,13 @@ if ( $action ) { } if ( isset( $_GET['from'] ) && 'import' == $_GET['from'] ) { - wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) ); // overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix + // Overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix. + wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) ); } elseif ( isset( $_GET['from'] ) && 'press-this' == $_GET['from'] ) { wp_redirect( self_admin_url( 'press-this.php' ) ); } else { - wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) ); // overrides the ?error=true one above + // Overrides the ?error=true one above. + wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) ); } exit; @@ -170,8 +172,8 @@ if ( $action ) { error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); } - ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed. - // Go back to "sandbox" scope so we get the same errors as before + ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed. + // Go back to "sandbox" scope so we get the same errors as before. plugin_sandbox_scrape( $plugin ); /** This action is documented in wp-admin/includes/plugin.php */ do_action( "activate_{$plugin}" ); @@ -254,21 +256,21 @@ if ( $action ) { check_admin_referer( 'bulk-plugins' ); - //$_POST = from the plugin form; $_GET = from the FTP details screen. + // $_POST = from the plugin form; $_GET = from the FTP details screen. $plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array(); if ( empty( $plugins ) ) { wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); exit; } - $plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete Activated plugins. + $plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete activated plugins. if ( empty( $plugins ) ) { wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) ); exit; } // Bail on all if any paths are invalid. - // validate_file() returns truthy for invalid files + // validate_file() returns truthy for invalid files. $invalid_plugin_files = array_filter( $plugins, 'validate_file' ); if ( $invalid_plugin_files ) { wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); @@ -375,11 +377,12 @@ if ( $action ) { exit; } else { $plugins_to_delete = count( $plugins ); - } // endif verify-delete + } // End if verify-delete. $delete_result = delete_plugins( $plugins ); - set_transient( 'plugins_delete_result_' . $user_ID, $delete_result ); //Store the result in a cache rather than a URL param due to object type & length + // Store the result in a cache rather than a URL param due to object type & length. + set_transient( 'plugins_delete_result_' . $user_ID, $delete_result ); wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) ); exit; @@ -420,7 +423,7 @@ if ( $action ) { $plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); /** This action is documented in wp-admin/edit.php */ - $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $action, $plugins ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores + $sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $action, $plugins ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores wp_safe_redirect( $sendback ); exit; } diff --git a/src/wp-admin/post-new.php b/src/wp-admin/post-new.php index a93a11bffe..479224d483 100644 --- a/src/wp-admin/post-new.php +++ b/src/wp-admin/post-new.php @@ -39,10 +39,10 @@ if ( 'post' == $post_type ) { // What if there isn't a post-new.php item for this post type? if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) { if ( isset( $_registered_pages[ get_plugin_page_hookname( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) { - // Fall back to edit.php for that post type, if it exists + // Fall back to edit.php for that post type, if it exists. $submenu_file = "edit.php?post_type=$post_type"; } else { - // Otherwise, give up and highlight the parent + // Otherwise, give up and highlight the parent. $submenu_file = $parent_file; } } diff --git a/src/wp-admin/post.php b/src/wp-admin/post.php index ef3e73a829..291a1a6ac0 100644 --- a/src/wp-admin/post.php +++ b/src/wp-admin/post.php @@ -71,11 +71,11 @@ if ( ! $sendback || switch ( $action ) { case 'post-quickdraft-save': - // Check nonce and capabilities + // Check nonce and capabilities. $nonce = $_REQUEST['_wpnonce']; $error_msg = false; - // For output of the quickdraft dashboard widget + // For output of the Quick Draft dashboard widget. require_once ABSPATH . 'wp-admin/includes/dashboard.php'; if ( ! wp_verify_nonce( $nonce, 'add-post' ) ) { @@ -202,11 +202,11 @@ switch ( $action ) { case 'editattachment': check_admin_referer( 'update-post_' . $post_id ); - // Don't let these be changed + // Don't let these be changed. unset( $_POST['guid'] ); $_POST['post_type'] = 'attachment'; - // Update the thumbnail filename + // Update the thumbnail filename. $newmeta = wp_get_attachment_metadata( $post_id, true ); $newmeta['thumb'] = wp_basename( $_POST['thumb'] ); @@ -218,12 +218,12 @@ switch ( $action ) { $post_id = edit_post(); - // Session cookie flag that the post was saved + // Session cookie flag that the post was saved. if ( isset( $_COOKIE['wp-saving-post'] ) && $_COOKIE['wp-saving-post'] === $post_id . '-check' ) { setcookie( 'wp-saving-post', $post_id . '-saved', time() + DAY_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN, is_ssl() ); } - redirect_post( $post_id ); // Send user on their way while we keep working + redirect_post( $post_id ); // Send user on their way while we keep working. exit(); @@ -349,5 +349,5 @@ switch ( $action ) { wp_redirect( admin_url( 'edit.php' ) ); exit(); -} // end switch +} // End switch. include( ABSPATH . 'wp-admin/admin-footer.php' ); diff --git a/src/wp-admin/revision.php b/src/wp-admin/revision.php index 2d435a6c34..12fa07f3f6 100644 --- a/src/wp-admin/revision.php +++ b/src/wp-admin/revision.php @@ -53,7 +53,7 @@ switch ( $action ) { break; } - // Don't allow revision restore when post is locked + // Don't allow revision restore when post is locked. if ( wp_check_post_lock( $post->ID ) ) { break; } @@ -86,7 +86,7 @@ switch ( $action ) { break; } - // Revisions disabled and we're not looking at an autosave + // Revisions disabled and we're not looking at an autosave. if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) { $redirect = 'edit.php?post_type=' . $post->post_type; break; diff --git a/src/wp-admin/setup-config.php b/src/wp-admin/setup-config.php index f9be50f05a..27a234a74c 100644 --- a/src/wp-admin/setup-config.php +++ b/src/wp-admin/setup-config.php @@ -55,7 +55,7 @@ if ( file_exists( ABSPATH . 'wp-config-sample.php' ) ) { ); } -// Check if wp-config.php has been created +// Check if wp-config.php has been created. if ( file_exists( ABSPATH . 'wp-config.php' ) ) { wp_die( '<p>' . sprintf( @@ -67,7 +67,7 @@ if ( file_exists( ABSPATH . 'wp-config.php' ) ) { ); } -// Check if wp-config.php exists above the root directory but is not part of another installation +// Check if wp-config.php exists above the root directory but is not part of another installation. if ( @file_exists( ABSPATH . '../wp-config.php' ) && ! @file_exists( ABSPATH . '../wp-settings.php' ) ) { wp_die( '<p>' . sprintf( @@ -115,7 +115,7 @@ function setup_config_display_header( $body_classes = array() ) { <body class="<?php echo implode( ' ', $body_classes ); ?>"> <p id="logo"><a href="<?php echo esc_url( __( 'https://wordpress.org/' ) ); ?>"><?php _e( 'WordPress' ); ?></a></p> <?php -} // end function setup_config_display_header(); +} // End function setup_config_display_header(); $language = ''; if ( ! empty( $_REQUEST['language'] ) ) { @@ -286,7 +286,7 @@ switch ( $step ) { wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' ) . $tryagain_link ); } - // Test the db connection. + // Test the DB connection. /**#@+ * * @ignore diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index c958353e1f..7e0d9ab870 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -117,6 +117,7 @@ validate_file_to_edit( $file, $allowed_files ); // Handle fallback editing of file when JavaScript is not available. $edit_error = null; $posted_content = null; + if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { $r = wp_edit_theme_plugin_file( wp_unslash( $_POST ) ); if ( is_wp_error( $r ) ) { @@ -139,49 +140,49 @@ if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { } } - $settings = array( - 'codeEditor' => wp_enqueue_code_editor( compact( 'file' ) ), - ); - wp_enqueue_script( 'wp-theme-plugin-editor' ); - wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) ); - wp_add_inline_script( 'wp-theme-plugin-editor', 'wp.themePluginEditor.themeOrPlugin = "theme";' ); +$settings = array( + 'codeEditor' => wp_enqueue_code_editor( compact( 'file' ) ), +); +wp_enqueue_script( 'wp-theme-plugin-editor' ); +wp_add_inline_script( 'wp-theme-plugin-editor', sprintf( 'jQuery( function( $ ) { wp.themePluginEditor.init( $( "#template" ), %s ); } )', wp_json_encode( $settings ) ) ); +wp_add_inline_script( 'wp-theme-plugin-editor', 'wp.themePluginEditor.themeOrPlugin = "theme";' ); - require_once( ABSPATH . 'wp-admin/admin-header.php' ); +require_once( ABSPATH . 'wp-admin/admin-header.php' ); - update_recently_edited( $file ); +update_recently_edited( $file ); - if ( ! is_file( $file ) ) { - $error = true; - } +if ( ! is_file( $file ) ) { + $error = true; +} - $content = ''; - if ( ! empty( $posted_content ) ) { - $content = $posted_content; - } elseif ( ! $error && filesize( $file ) > 0 ) { - $f = fopen( $file, 'r' ); - $content = fread( $f, filesize( $file ) ); +$content = ''; +if ( ! empty( $posted_content ) ) { + $content = $posted_content; +} elseif ( ! $error && filesize( $file ) > 0 ) { + $f = fopen( $file, 'r' ); + $content = fread( $f, filesize( $file ) ); - if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) { - $functions = wp_doc_link_parse( $content ); + if ( '.php' == substr( $file, strrpos( $file, '.' ) ) ) { + $functions = wp_doc_link_parse( $content ); - $docs_select = '<select name="docs-list" id="docs-list">'; - $docs_select .= '<option value="">' . esc_attr__( 'Function Name…' ) . '</option>'; - foreach ( $functions as $function ) { - $docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>'; - } - $docs_select .= '</select>'; + $docs_select = '<select name="docs-list" id="docs-list">'; + $docs_select .= '<option value="">' . esc_attr__( 'Function Name…' ) . '</option>'; + foreach ( $functions as $function ) { + $docs_select .= '<option value="' . esc_attr( urlencode( $function ) ) . '">' . htmlspecialchars( $function ) . '()</option>'; } - - $content = esc_textarea( $content ); + $docs_select .= '</select>'; } - $file_description = get_file_description( $relative_file ); - $file_show = array_search( $file, array_filter( $allowed_files ) ); - $description = esc_html( $file_description ); - if ( $file_description != $file_show ) { - $description .= ' <span>(' . esc_html( $file_show ) . ')</span>'; - } - ?> + $content = esc_textarea( $content ); +} + +$file_description = get_file_description( $relative_file ); +$file_show = array_search( $file, array_filter( $allowed_files ) ); +$description = esc_html( $file_description ); +if ( $file_description != $file_show ) { + $description .= ' <span>(' . esc_html( $file_show ) . ')</span>'; +} +?> <div class="wrap"> <h1><?php echo esc_html( $title ); ?></h1> @@ -195,6 +196,7 @@ if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { <pre><?php echo esc_html( $edit_error->get_error_message() ? $edit_error->get_error_message() : $edit_error->get_error_code() ); ?></pre> </div> <?php endif; ?> + <?php if ( preg_match( '/\.css$/', $file ) ) : ?> <div id="message" class="notice-info notice"> <p><strong><?php _e( 'Did you know?' ); ?></strong></p> @@ -213,38 +215,40 @@ if ( 'POST' === $_SERVER['REQUEST_METHOD'] ) { <div class="fileedit-sub"> <div class="alignleft"> <h2> -<?php -echo $theme->display( 'Name' ); -if ( $description ) { - echo ': ' . $description;} -?> + <?php + echo $theme->display( 'Name' ); + if ( $description ) { + echo ': ' . $description;} + ?> </h2> </div> <div class="alignright"> <form action="theme-editor.php" method="get"> <strong><label for="theme"><?php _e( 'Select theme to edit:' ); ?> </label></strong> <select name="theme" id="theme"> -<?php -foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) { - if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) { - continue; - } + <?php + foreach ( wp_get_themes( array( 'errors' => null ) ) as $a_stylesheet => $a_theme ) { + if ( $a_theme->errors() && 'theme_no_stylesheet' == $a_theme->errors()->get_error_code() ) { + continue; + } - $selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : ''; - echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display( 'Name' ) . '</option>'; -} -?> + $selected = $a_stylesheet == $stylesheet ? ' selected="selected"' : ''; + echo "\n\t" . '<option value="' . esc_attr( $a_stylesheet ) . '"' . $selected . '>' . $a_theme->display( 'Name' ) . '</option>'; + } + ?> </select> <?php submit_button( __( 'Select' ), '', 'Submit', false ); ?> </form> </div> <br class="clear" /> </div> + <?php if ( $theme->errors() ) { echo '<div class="error"><p><strong>' . __( 'This theme is broken.' ) . '</strong> ' . $theme->errors()->get_error_message() . '</p></div>'; } ?> + <div id="templateside"> <h2 id="theme-files-label"><?php _e( 'Theme Files' ); ?></h2> <ul role="tree" aria-labelledby="theme-files-label"> @@ -285,57 +289,59 @@ else : <input type="hidden" name="file" value="<?php echo esc_attr( $relative_file ); ?>" /> <input type="hidden" name="theme" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" /> </div> - <?php if ( ! empty( $functions ) ) : ?> - <div id="documentation" class="hide-if-no-js"> - <label for="docs-list"><?php _e( 'Documentation:' ); ?></label> - <?php echo $docs_select; ?> - <input disabled id="docs-lookup" type="button" class="button" value="<?php esc_attr_e( 'Look Up' ); ?>" onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'https://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_user_locale() ); ?>&version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&redirect=true'); }" /> - </div> - <?php endif; ?> - <div> - <div class="editor-notices"> - <?php if ( is_child_theme() && $theme->get_stylesheet() == get_template() ) : ?> - <div class="notice notice-warning inline"> - <p> - <?php - if ( is_writeable( $file ) ) { - ?> - <strong><?php _e( 'Caution:' ); ?></strong><?php } ?> - <?php _e( 'This is a file in your current parent theme.' ); ?> - </p> - </div> + <?php if ( ! empty( $functions ) ) : ?> + <div id="documentation" class="hide-if-no-js"> + <label for="docs-list"><?php _e( 'Documentation:' ); ?></label> + <?php echo $docs_select; ?> + <input disabled id="docs-lookup" type="button" class="button" value="<?php esc_attr_e( 'Look Up' ); ?>" onclick="if ( '' != jQuery('#docs-list').val() ) { window.open( 'https://api.wordpress.org/core/handbook/1.0/?function=' + escape( jQuery( '#docs-list' ).val() ) + '&locale=<?php echo urlencode( get_user_locale() ); ?>&version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&redirect=true'); }" /> + </div> + <?php endif; ?> + + <div> + <div class="editor-notices"> + <?php if ( is_child_theme() && $theme->get_stylesheet() == get_template() ) : ?> + <div class="notice notice-warning inline"> + <p> + <?php if ( is_writeable( $file ) ) : ?> + <strong><?php _e( 'Caution:' ); ?></strong> + <?php endif; ?> + <?php _e( 'This is a file in your current parent theme.' ); ?> + </p> + </div> + <?php endif; ?> + </div> + <?php if ( is_writeable( $file ) ) : ?> + <p class="submit"> + <?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?> + <span class="spinner"></span> + </p> + <?php else : ?> + <p><em> + <?php + printf( + /* translators: %s: Documentation URL. */ + __( 'You need to make this file writable before you can save your changes. See <a href="%s">Changing File Permissions</a> for more information.' ), + __( 'https://wordpress.org/support/article/changing-file-permissions/' ) + ); + ?> + </em></p> <?php endif; ?> </div> - <?php if ( is_writeable( $file ) ) : ?> - <p class="submit"> - <?php submit_button( __( 'Update File' ), 'primary', 'submit', false ); ?> - <span class="spinner"></span> - </p> - <?php else : ?> - <p><em> - <?php - printf( - /* translators: %s: Documentation URL. */ - __( 'You need to make this file writable before you can save your changes. See <a href="%s">Changing File Permissions</a> for more information.' ), - __( 'https://wordpress.org/support/article/changing-file-permissions/' ) - ); - ?> - </em></p> - <?php endif; ?> - </div> - <?php wp_print_file_editor_templates(); ?> + + <?php wp_print_file_editor_templates(); ?> </form> <?php -endif; // $error +endif; // End if $error. ?> <br class="clear" /> </div> <?php $dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) : - // Get a back URL - $referer = wp_get_referer(); + // Get a back URL. + $referer = wp_get_referer(); + $excluded_referer_basenames = array( 'theme-editor.php', 'wp-login.php' ); if ( $referer && ! in_array( basename( parse_url( $referer, PHP_URL_PATH ) ), $excluded_referer_basenames, true ) ) { @@ -344,38 +350,38 @@ if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) : $return_url = admin_url( '/' ); } ?> -<div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js hidden"> - <div class="notification-dialog-background"></div> - <div class="notification-dialog"> - <div class="file-editor-warning-content"> - <div class="file-editor-warning-message"> - <h1><?php _e( 'Heads up!' ); ?></h1> + <div id="file-editor-warning" class="notification-dialog-wrap file-editor-warning hide-if-no-js hidden"> + <div class="notification-dialog-background"></div> + <div class="notification-dialog"> + <div class="file-editor-warning-content"> + <div class="file-editor-warning-message"> + <h1><?php _e( 'Heads up!' ); ?></h1> + <p> + <?php + _e( 'You appear to be making direct edits to your theme in the WordPress dashboard. We recommend that you don’t! Editing your theme directly could break your site and your changes may be lost in future updates.' ); + ?> + </p> + <?php + if ( ! $theme->parent() ) { + echo '<p>'; + echo sprintf( + /* translators: %s: Link to documentation on child themes. */ + __( 'If you need to tweak more than your theme’s CSS, you might want to try <a href="%s">making a child theme</a>.' ), + esc_url( __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ) ) + ); + echo '</p>'; + } + ?> + <p><?php _e( 'If you decide to go ahead with direct edits anyway, use a file manager to create a copy with a new name and hang on to the original. That way, you can re-enable a functional version if something goes wrong.' ); ?></p> + </div> <p> - <?php - _e( 'You appear to be making direct edits to your theme in the WordPress dashboard. We recommend that you don’t! Editing your theme directly could break your site and your changes may be lost in future updates.' ); - ?> + <a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a> + <button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button> </p> - <?php - if ( ! $theme->parent() ) { - echo '<p>'; - echo sprintf( - /* translators: %s: Link to documentation on child themes. */ - __( 'If you need to tweak more than your theme’s CSS, you might want to try <a href="%s">making a child theme</a>.' ), - esc_url( __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ) ) - ); - echo '</p>'; - } - ?> - <p><?php _e( 'If you decide to go ahead with direct edits anyway, use a file manager to create a copy with a new name and hang on to the original. That way, you can re-enable a functional version if something goes wrong.' ); ?></p> </div> - <p> - <a class="button file-editor-warning-go-back" href="<?php echo esc_url( $return_url ); ?>"><?php _e( 'Go back' ); ?></a> - <button type="button" class="file-editor-warning-dismiss button button-primary"><?php _e( 'I understand' ); ?></button> - </p> </div> </div> -</div> <?php -endif; // editor warning notice +endif; // Editor warning notice. include( ABSPATH . 'wp-admin/admin-footer.php' ); diff --git a/src/wp-admin/theme-install.php b/src/wp-admin/theme-install.php index b77e85054a..032710e8c3 100644 --- a/src/wp-admin/theme-install.php +++ b/src/wp-admin/theme-install.php @@ -54,7 +54,7 @@ wp_localize_script( 'l10n' => array( 'addNew' => __( 'Add New Theme' ), 'search' => __( 'Search Themes' ), - 'searchPlaceholder' => __( 'Search themes...' ), // placeholder (no ellipsis) + 'searchPlaceholder' => __( 'Search themes...' ), // Placeholder (no ellipsis). 'upload' => __( 'Upload Theme' ), 'back' => __( 'Back' ), 'error' => sprintf( diff --git a/src/wp-admin/themes.php b/src/wp-admin/themes.php index 244f573ce6..bffe381cdb 100644 --- a/src/wp-admin/themes.php +++ b/src/wp-admin/themes.php @@ -87,7 +87,7 @@ if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) { $title = __( 'Manage Themes' ); $parent_file = 'themes.php'; -// Help tab: Overview +// Help tab: Overview. if ( current_user_can( 'switch_themes' ) ) { $help_overview = '<p>' . __( 'This screen is used for managing your installed themes. Aside from the default theme(s) included with your WordPress installation, themes are designed and developed by third parties.' ) . '</p>' . '<p>' . __( 'From this screen you can:' ) . '</p>' . @@ -104,9 +104,9 @@ if ( current_user_can( 'switch_themes' ) ) { 'content' => $help_overview, ) ); -} // switch_themes +} // End if 'switch_themes'. -// Help tab: Adding Themes +// Help tab: Adding Themes. if ( current_user_can( 'install_themes' ) ) { if ( is_multisite() ) { $help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>'; @@ -125,9 +125,9 @@ if ( current_user_can( 'install_themes' ) ) { 'content' => $help_install, ) ); -} // install_themes +} // End if 'install_themes'. -// Help tab: Previewing and Customizing +// Help tab: Previewing and Customizing. if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { $help_customize = '<p>' . __( 'Tap or hover on any theme then click the Live Preview button to see a live preview of that theme and change theme options in a separate, full-screen view. You can also find a Live Preview button at the bottom of the theme details screen. Any installed theme can be previewed and customized in this way.' ) . '</p>' . @@ -141,7 +141,7 @@ if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) 'content' => $help_customize, ) ); -} // edit_theme_options && customize +} // End if 'edit_theme_options' && 'customize'. get_current_screen()->set_help_sidebar( '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . @@ -170,7 +170,7 @@ wp_localize_script( 'l10n' => array( 'addNew' => __( 'Add New Theme' ), 'search' => __( 'Search Installed Themes' ), - 'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis) + 'searchPlaceholder' => __( 'Search installed themes...' ), // Placeholder (no ellipsis). /* translators: %d: Number of themes. */ 'themesFound' => __( 'Number of Themes found: %d' ), 'noThemesFound' => __( 'No themes found. Try a different search.' ), @@ -250,7 +250,7 @@ if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) { continue; } - // 0 = name, 1 = capability, 2 = file + // 0 = name, 1 = capability, 2 = file. if ( ( strcmp( $self, $item[2] ) == 0 && empty( $parent_file ) ) || ( $parent_file && ( $item[2] == $parent_file ) ) ) { $class = ' current'; } diff --git a/src/wp-admin/update-core.php b/src/wp-admin/update-core.php index 2093201149..0f075e6442 100644 --- a/src/wp-admin/update-core.php +++ b/src/wp-admin/update-core.php @@ -591,7 +591,7 @@ function do_core_upgrade( $reinstall = false ) { } if ( ! WP_Filesystem( $credentials, ABSPATH, $allow_relaxed_file_ownership ) ) { - // Failed to connect, Error and request again + // Failed to connect. Error and request again. request_filesystem_credentials( $url, '', true, ABSPATH, array( 'version', 'locale' ), $allow_relaxed_file_ownership ); echo '</div>'; return; @@ -732,7 +732,7 @@ get_current_screen()->set_help_sidebar( ); if ( 'upgrade-core' == $action ) { - // Force a update check when requested + // Force a update check when requested. $force_check = ! empty( $_GET['force-check'] ); wp_version_check( array(), $force_check ); diff --git a/src/wp-admin/update.php b/src/wp-admin/update.php index 5a70aa87d9..88b954bcb7 100644 --- a/src/wp-admin/update.php +++ b/src/wp-admin/update.php @@ -91,7 +91,7 @@ if ( isset( $_GET['action'] ) ) { echo '<p>' . __( 'Plugin failed to reactivate due to a fatal error.' ) . '</p>'; error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); - ini_set( 'display_errors', true ); //Ensure that Fatal errors are displayed. + ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed. wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin ); include( WP_PLUGIN_DIR . '/' . $plugin ); } @@ -102,7 +102,7 @@ if ( isset( $_GET['action'] ) ) { wp_die( __( 'Sorry, you are not allowed to install plugins on this site.' ) ); } - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); // For plugins_api(). check_admin_referer( 'install-plugin_' . $plugin ); $api = plugins_api( @@ -132,7 +132,7 @@ if ( isset( $_GET['action'] ) ) { $url .= '&from=' . urlencode( stripslashes( $_GET['from'] ) ); } - $type = 'web'; //Install plugin type, From Web or an Upload. + $type = 'web'; // Install plugin type, From Web or an Upload. $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) ); $upgrader->install( $api->download_link ); @@ -158,7 +158,7 @@ if ( isset( $_GET['action'] ) ) { $title = sprintf( __( 'Installing Plugin from uploaded file: %s' ), esc_html( basename( $file_upload->filename ) ) ); $nonce = 'plugin-upload'; $url = add_query_arg( array( 'package' => $file_upload->id ), 'update.php?action=upload-plugin' ); - $type = 'upload'; //Install plugin type, From Web or an Upload. + $type = 'upload'; // Install plugin type, From Web or an Upload. $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin( compact( 'type', 'title', 'nonce', 'url' ) ) ); $result = $upgrader->install( $file_upload->package ); @@ -224,7 +224,7 @@ if ( isset( $_GET['action'] ) ) { wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) ); } - include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); //for themes_api.. + include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ); // For themes_api(). check_admin_referer( 'install-theme_' . $theme ); $api = themes_api( @@ -236,7 +236,7 @@ if ( isset( $_GET['action'] ) ) { 'tags' => false, ), ) - ); //Save on a bit of bandwidth. + ); // Save on a bit of bandwidth. if ( is_wp_error( $api ) ) { wp_die( $api ); @@ -251,7 +251,7 @@ if ( isset( $_GET['action'] ) ) { $title = sprintf( __( 'Installing Theme: %s' ), $api->name . ' ' . $api->version ); $nonce = 'install-theme_' . $theme; $url = 'update.php?action=install-theme&theme=' . urlencode( $theme ); - $type = 'web'; //Install theme type, From Web or an Upload. + $type = 'web'; // Install theme type, From Web or an Upload. $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) ); $upgrader->install( $api->download_link ); @@ -278,7 +278,7 @@ if ( isset( $_GET['action'] ) ) { $title = sprintf( __( 'Installing Theme from uploaded file: %s' ), esc_html( basename( $file_upload->filename ) ) ); $nonce = 'theme-upload'; $url = add_query_arg( array( 'package' => $file_upload->id ), 'update.php?action=upload-theme' ); - $type = 'upload'; //Install plugin type, From Web or an Upload. + $type = 'upload'; // Install theme type, From Web or an Upload. $upgrader = new Theme_Upgrader( new Theme_Installer_Skin( compact( 'type', 'title', 'nonce', 'url' ) ) ); $result = $upgrader->install( $file_upload->package ); diff --git a/src/wp-admin/upload.php b/src/wp-admin/upload.php index a5a5d21612..ac08bd38e3 100644 --- a/src/wp-admin/upload.php +++ b/src/wp-admin/upload.php @@ -29,7 +29,7 @@ if ( 'grid' === $mode ) { remove_action( 'admin_head', 'wp_admin_canonical_url' ); $q = $_GET; - // let JS handle this + // Let JS handle this. unset( $q['s'] ); $vars = wp_edit_attachments_query_vars( $q ); $ignore = array( 'mode', 'post_type', 'post_status', 'posts_per_page' ); @@ -114,7 +114,7 @@ if ( 'grid' === $mode ) { $wp_list_table = _get_list_table( 'WP_Media_List_Table' ); $pagenum = $wp_list_table->get_pagenum(); -// Handle bulk actions +// Handle bulk actions. $doaction = $wp_list_table->current_action(); if ( $doaction ) { diff --git a/src/wp-admin/user-edit.php b/src/wp-admin/user-edit.php index 10e39e8b27..aaee3401c3 100644 --- a/src/wp-admin/user-edit.php +++ b/src/wp-admin/user-edit.php @@ -235,14 +235,14 @@ switch ( $action ) { <hr class="wp-header-end"> <form id="your-profile" action="<?php echo esc_url( self_admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post" novalidate="novalidate" - <?php - /** - * Fires inside the your-profile form tag on the user editing screen. - * - * @since 3.0.0 - */ - do_action( 'user_edit_form_tag' ); - ?> + <?php + /** + * Fires inside the your-profile form tag on the user editing screen. + * + * @since 3.0.0 + */ + do_action( 'user_edit_form_tag' ); + ?> > <?php wp_nonce_field( 'update-user_' . $user_id ); ?> <?php if ( $wp_http_referer ) : ?> @@ -310,10 +310,9 @@ switch ( $action ) { ?> </td> </tr> - <?php -endif; // $_wp_admin_css_colors - if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : - ?> + <?php endif; // End if count ( $_wp_admin_css_colors ) > 1 ?> + + <?php if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) : ?> <tr class="user-comment-shortcuts-wrap"> <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> <td> @@ -411,14 +410,14 @@ endif; <tr class="user-role-wrap"><th><label for="role"><?php _e( 'Role' ); ?></label></th> <td><select name="role" id="role"> <?php - // Compare user role against currently editable roles + // Compare user role against currently editable roles. $user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) ); $user_role = reset( $user_roles ); - // print the full list of roles with the primary one selected. + // Print the full list of roles with the primary one selected. wp_dropdown_roles( $user_role ); - // print the 'no role' option. Make it selected if the user has no role yet. + // Print the 'no role' option. Make it selected if the user has no role yet. if ( $user_role ) { echo '<option value="">' . __( '— No role for this site —' ) . '</option>'; } else { @@ -427,7 +426,7 @@ endif; ?> </select></td></tr> <?php -endif; //!IS_PROFILE_PAGE + endif; // End if ! IS_PROFILE_PAGE. if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && ! isset( $super_admins ) ) { ?> @@ -478,7 +477,7 @@ endif; //!IS_PROFILE_PAGE $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; } - if ( ! in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere + if ( ! in_array( $profileuser->display_name, $public_display ) ) { // Only add this if it isn't duplicated elsewhere. $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; } diff --git a/src/wp-admin/user-new.php b/src/wp-admin/user-new.php index 2abd094519..bff39e8560 100644 --- a/src/wp-admin/user-new.php +++ b/src/wp-admin/user-new.php @@ -58,7 +58,7 @@ if ( isset( $_REQUEST['action'] ) && 'adduser' == $_REQUEST['action'] ) { ); } - // Adding an existing user to this blog + // Adding an existing user to this blog. $new_user_email = $user_details->user_email; $redirect = 'user-new.php'; $username = $user_details->user_login; @@ -174,7 +174,7 @@ Please click the following link to confirm the invite: die(); } } else { - // Adding a new user to this site + // Adding a new user to this site. $new_user_email = wp_unslash( $_REQUEST['email'] ); $user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email ); if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) { @@ -183,8 +183,8 @@ Please click the following link to confirm the invite: /** This filter is documented in wp-includes/user.php */ $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) ); if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) { - add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email - add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email + add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email. + add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email. } wpmu_signup_user( $new_user_login, @@ -446,7 +446,7 @@ if ( is_multisite() && current_user_can( 'promote_users' ) ) { <?php submit_button( __( 'Add Existing User' ), 'primary', 'adduser', true, array( 'id' => 'addusersub' ) ); ?> </form> <?php -} // is_multisite() +} // End if is_multisite(). if ( current_user_can( 'create_users' ) ) { if ( $do_both ) { @@ -547,7 +547,7 @@ if ( current_user_can( 'create_users' ) ) { <label for="send_user_notification"><?php _e( 'Send the new user an email about their account.' ); ?></label> </td> </tr> -<?php } // !is_multisite ?> +<?php } // End if ! is_multisite(). ?> <tr class="form-field"> <th scope="row"><label for="role"><?php _e( 'Role' ); ?></label></th> <td><select name="role" id="role"> @@ -579,7 +579,7 @@ if ( current_user_can( 'create_users' ) ) { <?php submit_button( __( 'Add New User' ), 'primary', 'createuser', true, array( 'id' => 'createusersub' ) ); ?> </form> -<?php } // current_user_can('create_users') ?> +<?php } // End if current_user_can( 'create_users' ). ?> </div> <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php index 48e169d69c..ff7220c312 100644 --- a/src/wp-admin/users.php +++ b/src/wp-admin/users.php @@ -25,7 +25,7 @@ $parent_file = 'users.php'; add_screen_option( 'per_page' ); -// contextual help - choose Help on the top right of admin panel to preview this. +// Contextual help - choose Help on the top right of admin panel to preview this. get_current_screen()->add_help_tab( array( 'id' => 'overview', @@ -131,7 +131,8 @@ switch ( $wp_list_table->current_action() ) { if ( ! current_user_can( 'promote_user', $id ) ) { wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 ); } - // The new role of the current user must also have the promote_users cap or be a multisite super admin + + // The new role of the current user must also have the promote_users cap or be a multisite super admin. if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap( 'promote_users' ) && ! ( is_multisite() && current_user_can( 'manage_network_users' ) ) ) { $update = 'err_admin_role'; @@ -594,6 +595,6 @@ if ( strlen( $usersearch ) ) { <?php break; -} // end of the $doaction switch +} // End of the $doaction switch. include( ABSPATH . 'wp-admin/admin-footer.php' ); diff --git a/src/wp-admin/widgets.php b/src/wp-admin/widgets.php index ada2bdd790..c364a45967 100644 --- a/src/wp-admin/widgets.php +++ b/src/wp-admin/widgets.php @@ -88,7 +88,7 @@ if ( ! current_theme_supports( 'widgets' ) ) { wp_die( __( 'The theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="https://developer.wordpress.org/themes/functionality/widgets/">follow these instructions</a>.' ) ); } -// These are the widgets grouped by sidebar +// These are the widgets grouped by sidebar. $sidebars_widgets = wp_get_sidebars_widgets(); if ( empty( $sidebars_widgets ) ) { @@ -101,7 +101,7 @@ foreach ( $sidebars_widgets as $sidebar_id => $widgets ) { } if ( ! is_registered_sidebar( $sidebar_id ) ) { - if ( ! empty( $widgets ) ) { // register the inactive_widgets area as sidebar + if ( ! empty( $widgets ) ) { // Register the inactive_widgets area as sidebar. register_sidebar( array( 'name' => __( 'Inactive Sidebar (not used)' ), @@ -120,7 +120,7 @@ foreach ( $sidebars_widgets as $sidebar_id => $widgets ) { } } -// register the inactive_widgets area as sidebar +// Register the inactive_widgets area as sidebar. register_sidebar( array( 'name' => __( 'Inactive Widgets' ), @@ -136,7 +136,7 @@ register_sidebar( retrieve_widgets(); -// We're saving a widget without js +// We're saving a widget without JS. if ( isset( $_POST['savewidget'] ) || isset( $_POST['removewidget'] ) ) { $widget_id = $_POST['widget-id']; check_admin_referer( "save-delete-widget-$widget_id" ); @@ -216,7 +216,7 @@ if ( isset( $_POST['savewidget'] ) || isset( $_POST['removewidget'] ) ) { exit; } -// Remove inactive widgets without js +// Remove inactive widgets without JS. if ( isset( $_POST['removeinactivewidgets'] ) ) { check_admin_referer( 'remove-inactive-widgets', '_wpnonce_remove_inactive_widgets' ); @@ -238,17 +238,17 @@ if ( isset( $_POST['removeinactivewidgets'] ) ) { exit; } -// Output the widget form without js +// Output the widget form without JS. if ( isset( $_GET['editwidget'] ) && $_GET['editwidget'] ) { $widget_id = $_GET['editwidget']; if ( isset( $_GET['addnew'] ) ) { - // Default to the first sidebar + // Default to the first sidebar. $keys = array_keys( $wp_registered_sidebars ); $sidebar = reset( $keys ); - if ( isset( $_GET['base'] ) && isset( $_GET['num'] ) ) { // multi-widget - // Copy minimal info from an existing instance of this widget to a new instance + if ( isset( $_GET['base'] ) && isset( $_GET['num'] ) ) { // Multi-widget. + // Copy minimal info from an existing instance of this widget to a new instance. foreach ( $wp_registered_widget_controls as $control ) { if ( $_GET['base'] === $control['id_base'] ) { $control_callback = $control['callback']; @@ -539,7 +539,10 @@ foreach ( $theme_sidebars as $sidebar => $registered_sidebar ) { ?> <div class="<?php echo esc_attr( $wrap_class ); ?>"> - <?php wp_list_widget_controls( $sidebar, $registered_sidebar['name'] ); // Show the control forms for each of the widgets in this sidebar ?> + <?php + // Show the control forms for each of the widgets in this sidebar. + wp_list_widget_controls( $sidebar, $registered_sidebar['name'] ); + ?> </div> <?php diff --git a/src/wp-content/themes/twentyeleven/archive.php b/src/wp-content/themes/twentyeleven/archive.php index 6202655f44..a21e626b70 100644 --- a/src/wp-content/themes/twentyeleven/archive.php +++ b/src/wp-content/themes/twentyeleven/archive.php @@ -40,16 +40,18 @@ get_header(); ?> <?php twentyeleven_content_nav( 'nav-above' ); ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> <?php - /* Include the Post-Format-specific template for the content. + /* + * Include the Post-Format-specific template for the content. * If you want to overload this in a child theme then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'content', get_post_format() ); ?> diff --git a/src/wp-content/themes/twentyeleven/author.php b/src/wp-content/themes/twentyeleven/author.php index 2c7501a6b3..5751e33410 100644 --- a/src/wp-content/themes/twentyeleven/author.php +++ b/src/wp-content/themes/twentyeleven/author.php @@ -36,9 +36,9 @@ get_header(); ?> <?php /* - * Since we called the_post() above, we need to - * rewind the loop back to the beginning that way - * we can run the loop properly, in full. + * Since we called the_post() above, we need + * to rewind the loop back to the beginning. + * That way we can run the loop properly, in full. */ rewind_posts(); ?> @@ -75,8 +75,8 @@ get_header(); ?> </div><!-- #author-info --> <?php endif; ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> @@ -85,7 +85,8 @@ get_header(); ?> /* * Include the Post-Format-specific template for the content. * If you want to overload this in a child theme then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'content', get_post_format() ); ?> diff --git a/src/wp-content/themes/twentyeleven/category.php b/src/wp-content/themes/twentyeleven/category.php index 07b6b7a2bf..1fac2c8247 100644 --- a/src/wp-content/themes/twentyeleven/category.php +++ b/src/wp-content/themes/twentyeleven/category.php @@ -39,8 +39,8 @@ get_header(); ?> <?php twentyeleven_content_nav( 'nav-above' ); ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> @@ -49,7 +49,8 @@ get_header(); ?> /* * Include the Post-Format-specific template for the content. * If you want to overload this in a child theme then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'content', get_post_format() ); ?> diff --git a/src/wp-content/themes/twentyeleven/comments.php b/src/wp-content/themes/twentyeleven/comments.php index 2fec43aba6..085598c03e 100644 --- a/src/wp-content/themes/twentyeleven/comments.php +++ b/src/wp-content/themes/twentyeleven/comments.php @@ -48,13 +48,13 @@ ?> </h2> - <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?> + <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?> <nav id="comment-nav-above"> <h1 class="assistive-text"><?php _e( 'Comment navigation', 'twentyeleven' ); ?></h1> <div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'twentyeleven' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'twentyeleven' ) ); ?></div> </nav> - <?php endif; // check for comment navigation ?> + <?php endif; // Check for comment navigation. ?> <ol class="commentlist"> <?php @@ -69,13 +69,13 @@ ?> </ol> - <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?> + <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?> <nav id="comment-nav-below"> <h1 class="assistive-text"><?php _e( 'Comment navigation', 'twentyeleven' ); ?></h1> <div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'twentyeleven' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'twentyeleven' ) ); ?></div> </nav> - <?php endif; // check for comment navigation ?> + <?php endif; // Check for comment navigation. ?> <?php /* diff --git a/src/wp-content/themes/twentyeleven/content-aside.php b/src/wp-content/themes/twentyeleven/content-aside.php index 83b0bf1826..ddd9b0d425 100644 --- a/src/wp-content/themes/twentyeleven/content-aside.php +++ b/src/wp-content/themes/twentyeleven/content-aside.php @@ -26,7 +26,7 @@ <?php endif; ?> </header><!-- .entry-header --> - <?php if ( is_search() ) : // Only display Excerpts for Search ?> + <?php if ( is_search() ) : // Only display excerpts for search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> diff --git a/src/wp-content/themes/twentyeleven/content-gallery.php b/src/wp-content/themes/twentyeleven/content-gallery.php index 7e633ac7f0..b9dcfc3097 100644 --- a/src/wp-content/themes/twentyeleven/content-gallery.php +++ b/src/wp-content/themes/twentyeleven/content-gallery.php @@ -24,7 +24,7 @@ </div><!-- .entry-meta --> </header><!-- .entry-header --> - <?php if ( is_search() ) : // Only display Excerpts for search pages ?> + <?php if ( is_search() ) : // Only display excerpts for search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> @@ -54,7 +54,7 @@ ); ?> </em></p> - <?php endif; // end twentyeleven_get_gallery_images() check ?> + <?php endif; // End twentyeleven_get_gallery_images() check. ?> <?php the_excerpt(); ?> <?php endif; ?> <?php @@ -82,7 +82,7 @@ $show_sep = true; ?> </span> - <?php endif; // End if categories ?> + <?php endif; // End if categories. ?> <?php /* translators: Used between list items, there is a space after the comma. */ $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) ); @@ -90,7 +90,7 @@ if ( $show_sep ) : ?> <span class="sep"> | </span> - <?php endif; // End if $show_sep ?> + <?php endif; // End if $show_sep. ?> <span class="tag-links"> <?php /* translators: 1: CSS classes, 2: List of tags. */ @@ -98,14 +98,14 @@ $show_sep = true; ?> </span> - <?php endif; // End if $tags_list ?> + <?php endif; // End if $tags_list. ?> <?php if ( comments_open() ) : ?> <?php if ( $show_sep ) : ?> <span class="sep"> | </span> - <?php endif; // End if $show_sep ?> + <?php endif; // End if $show_sep. ?> <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentyeleven' ) . '</span>', __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?></span> - <?php endif; // End if comments_open() ?> + <?php endif; // End if comments_open(). ?> <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> </footer><!-- .entry-meta --> diff --git a/src/wp-content/themes/twentyeleven/content-image.php b/src/wp-content/themes/twentyeleven/content-image.php index ceeeaba58d..5f681ac23f 100644 --- a/src/wp-content/themes/twentyeleven/content-image.php +++ b/src/wp-content/themes/twentyeleven/content-image.php @@ -65,7 +65,7 @@ printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyeleven' ), 'entry-utility-prep entry-utility-prep-cat-links', $categories_list ); ?> </span> - <?php endif; // End if categories ?> + <?php endif; // End if categories. ?> <?php /* translators: Used between list items, there is a space after the comma. */ $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) ); @@ -77,11 +77,11 @@ printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyeleven' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?> </span> - <?php endif; // End if $tags_list ?> + <?php endif; // End if $tags_list. ?> <?php if ( comments_open() ) : ?> <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentyeleven' ) . '</span>', __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?></span> - <?php endif; // End if comments_open() ?> + <?php endif; // End if comments_open(). ?> </div><!-- .entry-meta --> <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> diff --git a/src/wp-content/themes/twentyeleven/content-link.php b/src/wp-content/themes/twentyeleven/content-link.php index 6e283e15ae..78531703ec 100644 --- a/src/wp-content/themes/twentyeleven/content-link.php +++ b/src/wp-content/themes/twentyeleven/content-link.php @@ -26,7 +26,7 @@ <?php endif; ?> </header><!-- .entry-header --> - <?php if ( is_search() ) : // Only display Excerpts for Search ?> + <?php if ( is_search() ) : // Only display excerpts for search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> diff --git a/src/wp-content/themes/twentyeleven/content-quote.php b/src/wp-content/themes/twentyeleven/content-quote.php index a73f487bd8..5c547be64e 100644 --- a/src/wp-content/themes/twentyeleven/content-quote.php +++ b/src/wp-content/themes/twentyeleven/content-quote.php @@ -26,7 +26,7 @@ <?php endif; ?> </header><!-- .entry-header --> - <?php if ( is_search() ) : // Only display Excerpts for Search ?> + <?php if ( is_search() ) : // Only display excerpts for search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> @@ -58,7 +58,7 @@ $show_sep = true; ?> </span> - <?php endif; // End if categories ?> + <?php endif; // End if categories. ?> <?php /* translators: Used between list items, there is a space after the comma. */ $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) ); @@ -66,7 +66,7 @@ if ( $show_sep ) : ?> <span class="sep"> | </span> - <?php endif; // End if $show_sep ?> + <?php endif; // End if $show_sep. ?> <span class="tag-links"> <?php /* translators: 1: CSS classes, 2: List of tags. */ @@ -74,14 +74,14 @@ $show_sep = true; ?> </span> - <?php endif; // End if $tags_list ?> + <?php endif; // End if $tags_list. ?> <?php if ( comments_open() ) : ?> <?php if ( $show_sep ) : ?> <span class="sep"> | </span> - <?php endif; // End if $show_sep ?> + <?php endif; // End if $show_sep. ?> <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentyeleven' ) . '</span>', __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?></span> - <?php endif; // End if comments_open() ?> + <?php endif; // End if comments_open(). ?> <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> </footer><!-- .entry-meta --> diff --git a/src/wp-content/themes/twentyeleven/content-single.php b/src/wp-content/themes/twentyeleven/content-single.php index 55e3e50559..207c5c1b56 100644 --- a/src/wp-content/themes/twentyeleven/content-single.php +++ b/src/wp-content/themes/twentyeleven/content-single.php @@ -61,7 +61,10 @@ ?> <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> - <?php if ( get_the_author_meta( 'description' ) && ( ! function_exists( 'is_multi_author' ) || is_multi_author() ) ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries ?> + <?php + // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. + if ( get_the_author_meta( 'description' ) && ( ! function_exists( 'is_multi_author' ) || is_multi_author() ) ) : + ?> <div id="author-info"> <div id="author-avatar"> <?php diff --git a/src/wp-content/themes/twentyeleven/content-status.php b/src/wp-content/themes/twentyeleven/content-status.php index c4e9b4c425..9372596490 100644 --- a/src/wp-content/themes/twentyeleven/content-status.php +++ b/src/wp-content/themes/twentyeleven/content-status.php @@ -26,7 +26,7 @@ <?php endif; ?> </header><!-- .entry-header --> - <?php if ( is_search() ) : // Only display Excerpts for Search ?> + <?php if ( is_search() ) : // Only display excerpts for search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> diff --git a/src/wp-content/themes/twentyeleven/content.php b/src/wp-content/themes/twentyeleven/content.php index ad7d64ea56..d05aa83020 100644 --- a/src/wp-content/themes/twentyeleven/content.php +++ b/src/wp-content/themes/twentyeleven/content.php @@ -32,7 +32,7 @@ <?php endif; ?> </header><!-- .entry-header --> - <?php if ( is_search() ) : // Only display Excerpts for Search ?> + <?php if ( is_search() ) : // Only display excerpts for search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> @@ -52,7 +52,7 @@ <footer class="entry-meta"> <?php $show_sep = false; ?> - <?php if ( is_object_in_taxonomy( get_post_type(), 'category' ) ) : // Hide category text when not supported ?> + <?php if ( is_object_in_taxonomy( get_post_type(), 'category' ) ) : // Hide category text when not supported. ?> <?php /* translators: Used between list items, there is a space after the comma. */ $categories_list = get_the_category_list( __( ', ', 'twentyeleven' ) ); @@ -65,9 +65,9 @@ $show_sep = true; ?> </span> - <?php endif; // End if categories ?> - <?php endif; // End if is_object_in_taxonomy( get_post_type(), 'category' ) ?> - <?php if ( is_object_in_taxonomy( get_post_type(), 'post_tag' ) ) : // Hide tag text when not supported ?> + <?php endif; // End if categories. ?> + <?php endif; // End if is_object_in_taxonomy( get_post_type(), 'category' ). ?> + <?php if ( is_object_in_taxonomy( get_post_type(), 'post_tag' ) ) : // Hide tag text when not supported. ?> <?php /* translators: Used between list items, there is a space after the comma. */ $tags_list = get_the_tag_list( '', __( ', ', 'twentyeleven' ) ); @@ -75,7 +75,7 @@ if ( $show_sep ) : ?> <span class="sep"> | </span> - <?php endif; // End if $show_sep ?> + <?php endif; // End if $show_sep. ?> <span class="tag-links"> <?php /* translators: 1: CSS classes, 2: Tag list. */ @@ -83,15 +83,15 @@ $show_sep = true; ?> </span> - <?php endif; // End if $tags_list ?> - <?php endif; // End if is_object_in_taxonomy( get_post_type(), 'post_tag' ) ?> + <?php endif; // End if $tags_list. ?> + <?php endif; // End if is_object_in_taxonomy( get_post_type(), 'post_tag' ). ?> <?php if ( comments_open() ) : ?> <?php if ( $show_sep ) : ?> <span class="sep"> | </span> - <?php endif; // End if $show_sep ?> + <?php endif; // End if $show_sep. ?> <span class="comments-link"><?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentyeleven' ) . '</span>', __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?></span> - <?php endif; // End if comments_open() ?> + <?php endif; // End if comments_open(). ?> <?php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ?> </footer><!-- .entry-meta --> diff --git a/src/wp-content/themes/twentyeleven/functions.php b/src/wp-content/themes/twentyeleven/functions.php index d1d7d69bde..7835bbd1a2 100644 --- a/src/wp-content/themes/twentyeleven/functions.php +++ b/src/wp-content/themes/twentyeleven/functions.php @@ -27,7 +27,7 @@ * <code> * add_action( 'after_setup_theme', 'my_child_theme_setup' ); * function my_child_theme_setup() { - * // We are providing our own filter for excerpt_length (or using the unfiltered value) + * // We are providing our own filter for excerpt_length (or using the unfiltered value). * remove_filter( 'excerpt_length', 'twentyeleven_excerpt_length' ); * ... * } @@ -143,7 +143,7 @@ if ( ! function_exists( 'twentyeleven_setup' ) ) : // This theme uses wp_nav_menu() in one location. register_nav_menu( 'primary', __( 'Primary Menu', 'twentyeleven' ) ); - // Add support for a variety of post formats + // Add support for a variety of post formats. add_theme_support( 'post-formats', array( 'aside', 'link', 'gallery', 'status', 'quote', 'image' ) ); $theme_options = twentyeleven_get_theme_options(); @@ -165,7 +165,7 @@ if ( ! function_exists( 'twentyeleven_setup' ) ) : ) ); - // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images + // This theme uses Featured Images (also known as post thumbnails) for per-post/per-page Custom Header images. add_theme_support( 'post-thumbnails' ); // Add support for custom headers. @@ -285,7 +285,7 @@ if ( ! function_exists( 'twentyeleven_setup' ) ) : // Indicate widget sidebars can use selective refresh in the Customizer. add_theme_support( 'customize-selective-refresh-widgets' ); } -endif; // twentyeleven_setup +endif; // twentyeleven_setup() /** * Enqueue scripts and styles for front end. @@ -337,7 +337,7 @@ if ( ! function_exists( 'twentyeleven_header_style' ) ) : clip: rect(1px, 1px, 1px, 1px); } <?php - // If the user has set a custom color for the text use that + // If the user has set a custom color for the text, use that. else : ?> #site-title a, @@ -348,7 +348,7 @@ if ( ! function_exists( 'twentyeleven_header_style' ) ) : </style> <?php } -endif; // twentyeleven_header_style +endif; // twentyeleven_header_style() if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) : /** @@ -382,7 +382,7 @@ if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) : padding: 0 0 3em; } <?php - // If the user has set a custom color for the text use that + // If the user has set a custom color for the text, use that. if ( get_header_textcolor() != HEADER_TEXTCOLOR ) : ?> #site-title a, @@ -398,7 +398,7 @@ if ( ! function_exists( 'twentyeleven_admin_header_style' ) ) : </style> <?php } -endif; // twentyeleven_admin_header_style +endif; // twentyeleven_admin_header_style() if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) : /** @@ -428,7 +428,7 @@ if ( ! function_exists( 'twentyeleven_admin_header_image' ) ) : </div> <?php } -endif; // twentyeleven_admin_header_image +endif; // twentyeleven_admin_header_image() /** * Set the post excerpt length to 40 words. @@ -458,7 +458,7 @@ if ( ! function_exists( 'twentyeleven_continue_reading_link' ) ) : function twentyeleven_continue_reading_link() { return ' <a href="' . esc_url( get_permalink() ) . '">' . __( 'Continue reading <span class="meta-nav">→</span>', 'twentyeleven' ) . '</a>'; } -endif; // twentyeleven_continue_reading_link +endif; // twentyeleven_continue_reading_link() /** * Replace "[...]" in the Read More link with an ellipsis. @@ -609,7 +609,7 @@ if ( ! function_exists( 'twentyeleven_content_nav' ) ) : <?php endif; } -endif; // twentyeleven_content_nav +endif; // twentyeleven_content_nav() /** * Return the first link from the post content. If none found, the @@ -781,7 +781,7 @@ if ( ! function_exists( 'twentyeleven_comment' ) ) : break; endswitch; } -endif; // ends check for twentyeleven_comment() +endif; // twentyeleven_comment() if ( ! function_exists( 'twentyeleven_posted_on' ) ) : /** @@ -899,7 +899,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Eleven 3.3 */ diff --git a/src/wp-content/themes/twentyeleven/header.php b/src/wp-content/themes/twentyeleven/header.php index 852017e29b..d8afc3b577 100644 --- a/src/wp-content/themes/twentyeleven/header.php +++ b/src/wp-content/themes/twentyeleven/header.php @@ -83,7 +83,7 @@ if ( is_singular() && get_option( 'thread_comments' ) ) { </hgroup> <?php - // Check to see if the header image has been removed + // Check to see if the header image has been removed. $header_image = get_header_image(); if ( $header_image ) : // Compatibility with versions of WordPress prior to 3.4. @@ -121,10 +121,10 @@ if ( is_singular() && get_option( 'thread_comments' ) ) { ?> <img src="<?php header_image(); ?>" width="<?php echo esc_attr( $header_image_width ); ?>" height="<?php echo esc_attr( $header_image_height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" /> <?php - } // end check for featured image or standard header + } // End check for featured image or standard header. ?> </a> - <?php endif; // end check for removed header image ?> + <?php endif; // End check for removed header image. ?> <?php // Has the text been hidden? @@ -145,8 +145,14 @@ if ( is_singular() && get_option( 'thread_comments' ) ) { <nav id="access" role="navigation"> <h3 class="assistive-text"><?php _e( 'Main menu', 'twentyeleven' ); ?></h3> - <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assigned to the primary location is the one used. If one isn't assigned, the menu with the lowest ID is used. */ ?> - <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?> + <?php + /* + * Our navigation menu. If one isn't filled out, wp_nav_menu() falls back to wp_page_menu(). + * The menu assigned to the primary location is the one used. + * If one isn't assigned, the menu with the lowest ID is used. + */ + wp_nav_menu( array( 'theme_location' => 'primary' ) ); + ?> </nav><!-- #access --> </header><!-- #branding --> diff --git a/src/wp-content/themes/twentyeleven/image.php b/src/wp-content/themes/twentyeleven/image.php index 980bc3a002..8625991dda 100644 --- a/src/wp-content/themes/twentyeleven/image.php +++ b/src/wp-content/themes/twentyeleven/image.php @@ -75,32 +75,34 @@ get_header(); ?> } } - // If there is more than 1 attachment in a gallery + // If there is more than 1 attachment in a gallery... if ( count( $attachments ) > 1 ) { $k++; if ( isset( $attachments[ $k ] ) ) { - // get the URL of the next image attachment + // ...get the URL of the next image attachment. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); - } else { // or get the URL of the first image attachment + } else { + // ...or get the URL of the first image attachment. $next_attachment_url = get_attachment_link( $attachments[0]->ID ); } } else { - // or, if there's only 1 image, get the URL of the image + // Or, if there's only 1 image, get the URL of the image. $next_attachment_url = wp_get_attachment_url(); } ?> <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"> - <?php - /** - * Filter the Twenty Eleven default attachment size. - * - * @since Twenty Eleven 1.0 - * - * @param int The height and width attachment size dimensions in pixels. Default 848. - */ - $attachment_size = apply_filters( 'twentyeleven_attachment_size', 848 ); - echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); // filterable image width with 1024px limit for image height. - ?> + <?php + /** + * Filter the Twenty Eleven default attachment size. + * + * @since Twenty Eleven 1.0 + * + * @param int The height and width attachment size dimensions in pixels. Default 848. + */ + $attachment_size = apply_filters( 'twentyeleven_attachment_size', 848 ); + // Filterable image width with 1024px limit for image height. + echo wp_get_attachment_image( $post->ID, array( $attachment_size, 1024 ) ); + ?> </a> <?php if ( ! empty( $post->post_excerpt ) ) : ?> @@ -130,7 +132,7 @@ get_header(); ?> <?php comments_template(); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentyeleven/inc/theme-customizer.js b/src/wp-content/themes/twentyeleven/inc/theme-customizer.js index 002fc97950..70cb6d8a7f 100644 --- a/src/wp-content/themes/twentyeleven/inc/theme-customizer.js +++ b/src/wp-content/themes/twentyeleven/inc/theme-customizer.js @@ -10,7 +10,7 @@ } ); } ); - // Header text color + // Header text color. wp.customize( 'header_textcolor', function( value ) { value.bind( function( to ) { if ( 'blank' === to ) { diff --git a/src/wp-content/themes/twentyeleven/inc/theme-options.php b/src/wp-content/themes/twentyeleven/inc/theme-options.php index 012eb326f3..cb0556d006 100644 --- a/src/wp-content/themes/twentyeleven/inc/theme-options.php +++ b/src/wp-content/themes/twentyeleven/inc/theme-options.php @@ -37,26 +37,26 @@ add_action( 'admin_print_styles-appearance_page_theme_options', 'twentyeleven_ad function twentyeleven_theme_options_init() { register_setting( - 'twentyeleven_options', // Options group, see settings_fields() call in twentyeleven_theme_options_render_page() - 'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options() - 'twentyeleven_theme_options_validate' // The sanitization callback, see twentyeleven_theme_options_validate() + 'twentyeleven_options', // Options group, see settings_fields() call in twentyeleven_theme_options_render_page(). + 'twentyeleven_theme_options', // Database option, see twentyeleven_get_theme_options(). + 'twentyeleven_theme_options_validate' // The sanitization callback, see twentyeleven_theme_options_validate(). ); - // Register our settings field group + // Register our settings field group. add_settings_section( - 'general', // Unique identifier for the settings section - '', // Section title (we don't want one) - '__return_false', // Section callback (we don't want anything) - 'theme_options' // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page() + 'general', // Unique identifier for the settings section. + '', // Section title (we don't want one). + '__return_false', // Section callback (we don't want anything). + 'theme_options' // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page(). ); - // Register our individual settings fields + // Register our individual settings fields. add_settings_field( - 'color_scheme', // Unique identifier for the field for this section - __( 'Color Scheme', 'twentyeleven' ), // Setting field label - 'twentyeleven_settings_field_color_scheme', // Function that renders the settings field - 'theme_options', // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page() - 'general' // Settings section. Same as the first argument in the add_settings_section() above + 'color_scheme', // Unique identifier for the field for this section. + __( 'Color Scheme', 'twentyeleven' ), // Setting field label. + 'twentyeleven_settings_field_color_scheme', // Function that renders the settings field. + 'theme_options', // Menu slug, used to uniquely identify the page; see twentyeleven_theme_options_add_page(). + 'general' // Settings section. Same as the first argument in the add_settings_section() above. ); add_settings_field( 'link_color', __( 'Link Color', 'twentyeleven' ), 'twentyeleven_settings_field_link_color', 'theme_options', 'general' ); @@ -92,11 +92,11 @@ add_filter( 'option_page_capability_twentyeleven_options', 'twentyeleven_option_ */ function twentyeleven_theme_options_add_page() { $theme_page = add_theme_page( - __( 'Theme Options', 'twentyeleven' ), // Name of page - __( 'Theme Options', 'twentyeleven' ), // Label in menu - 'edit_theme_options', // Capability required - 'theme_options', // Menu slug, used to uniquely identify the page - 'twentyeleven_theme_options_render_page' // Function that renders the options page + __( 'Theme Options', 'twentyeleven' ), // Name of page. + __( 'Theme Options', 'twentyeleven' ), // Label in menu. + 'edit_theme_options', // Capability required. + 'theme_options', // Menu slug, used to uniquely identify the page. + 'twentyeleven_theme_options_render_page' // Function that renders the options page. ); if ( ! $theme_page ) { @@ -124,7 +124,7 @@ function twentyeleven_theme_options_help() { $screen = get_current_screen(); if ( method_exists( $screen, 'add_help_tab' ) ) { - // WordPress 3.3.0 + // WordPress 3.3.0. $screen->add_help_tab( array( 'title' => __( 'Overview', 'twentyeleven' ), @@ -135,7 +135,7 @@ function twentyeleven_theme_options_help() { $screen->set_help_sidebar( $sidebar ); } else { - // WordPress 3.2.0 + // WordPress 3.2.0. add_contextual_help( $screen, $help . $sidebar ); } } @@ -378,7 +378,7 @@ function twentyeleven_theme_options_validate( $input ) { $defaults = twentyeleven_get_default_theme_options(); $output = $defaults; - // Color scheme must be in our array of color scheme options + // Color scheme must be in our array of color scheme options. if ( isset( $input['color_scheme'] ) && array_key_exists( $input['color_scheme'], twentyeleven_color_schemes() ) ) { $output['color_scheme'] = $input['color_scheme']; } @@ -387,12 +387,12 @@ function twentyeleven_theme_options_validate( $input ) { $defaults['link_color'] = twentyeleven_get_default_link_color( $output['color_scheme'] ); $output['link_color'] = $defaults['link_color']; - // Link color must be 3 or 6 hexadecimal characters + // Link color must be 3 or 6 hexadecimal characters. if ( isset( $input['link_color'] ) && preg_match( '/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'] ) ) { $output['link_color'] = '#' . strtolower( ltrim( $input['link_color'], '#' ) ); } - // Theme layout must be in our array of theme layout options + // Theme layout must be in our array of theme layout options. if ( isset( $input['theme_layout'] ) && array_key_exists( $input['theme_layout'], twentyeleven_layouts() ) ) { $output['theme_layout'] = $input['theme_layout']; } @@ -582,7 +582,7 @@ function twentyeleven_customize_register( $wp_customize ) { ) ); - // Link Color (added to Color Scheme section in Customizer) + // Link Color (added to Color Scheme section in Customizer). $wp_customize->add_setting( 'twentyeleven_theme_options[link_color]', array( @@ -605,7 +605,7 @@ function twentyeleven_customize_register( $wp_customize ) { ) ); - // Default Layout + // Default Layout. $wp_customize->add_section( 'twentyeleven_layout', array( diff --git a/src/wp-content/themes/twentyeleven/inc/widgets.php b/src/wp-content/themes/twentyeleven/inc/widgets.php index ba4b4487d7..ec1ad74243 100644 --- a/src/wp-content/themes/twentyeleven/inc/widgets.php +++ b/src/wp-content/themes/twentyeleven/inc/widgets.php @@ -137,10 +137,10 @@ class Twenty_Eleven_Ephemera_Widget extends WP_Widget { echo $args['after_widget']; - // Reset the post globals as this query will have stomped on it + // Reset the post globals as this query will have stomped on it. wp_reset_postdata(); - // end check for ephemeral posts + // End check for ephemeral posts. endif; $cache[ $args['widget_id'] ] = ob_get_flush(); diff --git a/src/wp-content/themes/twentyeleven/index.php b/src/wp-content/themes/twentyeleven/index.php index a7e3c141db..a4a7c04f18 100644 --- a/src/wp-content/themes/twentyeleven/index.php +++ b/src/wp-content/themes/twentyeleven/index.php @@ -21,8 +21,8 @@ get_header(); ?> <?php twentyeleven_content_nav( 'nav-above' ); ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentyeleven/page.php b/src/wp-content/themes/twentyeleven/page.php index 4b322e84fa..eed2f13034 100644 --- a/src/wp-content/themes/twentyeleven/page.php +++ b/src/wp-content/themes/twentyeleven/page.php @@ -26,7 +26,7 @@ get_header(); ?> <?php comments_template( '', true ); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentyeleven/search.php b/src/wp-content/themes/twentyeleven/search.php index 8ea996223d..f7902d35f0 100644 --- a/src/wp-content/themes/twentyeleven/search.php +++ b/src/wp-content/themes/twentyeleven/search.php @@ -25,8 +25,8 @@ get_header(); ?> <?php twentyeleven_content_nav( 'nav-above' ); ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentyeleven/showcase.php b/src/wp-content/themes/twentyeleven/showcase.php index d986182596..2931b4073e 100644 --- a/src/wp-content/themes/twentyeleven/showcase.php +++ b/src/wp-content/themes/twentyeleven/showcase.php @@ -15,7 +15,7 @@ * @since Twenty Eleven 1.0 */ -// Enqueue showcase script for the slider +// Enqueue showcase script for the slider. wp_enqueue_script( 'twentyeleven-showcase', get_template_directory_uri() . '/js/showcase.js', array( 'jquery' ), '20110429' ); get_header(); ?> @@ -62,7 +62,7 @@ get_header(); ?> // The Featured Posts query. $featured = new WP_Query( $featured_args ); - // Proceed only if published posts exist + // Proceed only if published posts exist. if ( $featured->have_posts() ) : /* @@ -91,13 +91,13 @@ get_header(); ?> $counter_slider++; /* - * We're going to add a class to our featured post for featured images - * by default it'll have the feature-text class. + * We're going to add a class to our featured post for featured images. + * By default it will have the feature-text class. */ $feature_class = 'feature-text'; if ( has_post_thumbnail() ) { - // ... but if it has a featured image let's add some class + // ...but if it has a featured image let's add some class. $feature_class = 'feature-image small'; // Hang on. Let's check this here image out. @@ -144,10 +144,10 @@ get_header(); ?> <ul> <?php - // Reset the counter so that we end up with matching elements + // Reset the counter so that we end up with matching elements. $counter_slider = 0; - // Begin from zero + // Begin from zero. rewind_posts(); // Let's roll again. @@ -195,7 +195,7 @@ get_header(); ?> // Our new query for the Recent Posts section. $recent = new WP_Query( $recent_args ); - // The first Recent post is displayed normally + // The first Recent post is displayed normally. if ( $recent->have_posts() ) : $recent->the_post(); @@ -224,7 +224,7 @@ get_header(); ?> <?php endwhile; - // If we had some posts, close the <ol> + // If we had some posts, close the <ol>. if ( $recent->post_count > 0 ) { echo '</ol>'; } @@ -245,7 +245,7 @@ get_header(); ?> ); ?> - <?php endif; // end sidebar widget area ?> + <?php endif; // End sidebar widget area. ?> </div><!-- .widget-area --> </div><!-- #content --> diff --git a/src/wp-content/themes/twentyeleven/sidebar-page.php b/src/wp-content/themes/twentyeleven/sidebar-page.php index a12f1a233f..4ed5cd6ca7 100644 --- a/src/wp-content/themes/twentyeleven/sidebar-page.php +++ b/src/wp-content/themes/twentyeleven/sidebar-page.php @@ -23,7 +23,7 @@ get_header(); ?> <?php comments_template( '', true ); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentyeleven/sidebar.php b/src/wp-content/themes/twentyeleven/sidebar.php index 67fb7e5f11..df543cf73a 100644 --- a/src/wp-content/themes/twentyeleven/sidebar.php +++ b/src/wp-content/themes/twentyeleven/sidebar.php @@ -31,6 +31,6 @@ if ( 'content' != $current_layout ) : </ul> </aside> - <?php endif; // end sidebar widget area ?> + <?php endif; // End sidebar widget area. ?> </div><!-- #secondary .widget-area --> <?php endif; ?> diff --git a/src/wp-content/themes/twentyeleven/single.php b/src/wp-content/themes/twentyeleven/single.php index b1ebd8a674..186bb378d8 100644 --- a/src/wp-content/themes/twentyeleven/single.php +++ b/src/wp-content/themes/twentyeleven/single.php @@ -27,7 +27,7 @@ get_header(); ?> <?php comments_template( '', true ); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentyeleven/tag.php b/src/wp-content/themes/twentyeleven/tag.php index ab69a8c0ec..5d9e833a3c 100644 --- a/src/wp-content/themes/twentyeleven/tag.php +++ b/src/wp-content/themes/twentyeleven/tag.php @@ -39,8 +39,8 @@ get_header(); ?> <?php twentyeleven_content_nav( 'nav-above' ); ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentyfifteen/archive.php b/src/wp-content/themes/twentyfifteen/archive.php index 26a9a4b4ca..425a74ac71 100644 --- a/src/wp-content/themes/twentyfifteen/archive.php +++ b/src/wp-content/themes/twentyfifteen/archive.php @@ -31,14 +31,14 @@ get_header(); ?> </header><!-- .page-header --> <?php - // Start the Loop. + // Start the loop. while ( have_posts() ) : the_post(); /* - * Include the Post-Format-specific template for the content. - * If you want to override this in a child theme, then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php + * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfifteen/comments.php b/src/wp-content/themes/twentyfifteen/comments.php index c411f84891..355acecb76 100644 --- a/src/wp-content/themes/twentyfifteen/comments.php +++ b/src/wp-content/themes/twentyfifteen/comments.php @@ -65,7 +65,7 @@ if ( post_password_required() ) { <?php endif; // have_comments() ?> <?php - // If comments are closed and there are comments, let's leave a little note, shall we? + // If comments are closed and there are comments, let's leave a little note, shall we? if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?> <p class="no-comments"><?php _e( 'Comments are closed.', 'twentyfifteen' ); ?></p> diff --git a/src/wp-content/themes/twentyfifteen/content-link.php b/src/wp-content/themes/twentyfifteen/content-link.php index e3b260fd3c..2d442a1588 100644 --- a/src/wp-content/themes/twentyfifteen/content-link.php +++ b/src/wp-content/themes/twentyfifteen/content-link.php @@ -49,7 +49,7 @@ <!-- .entry-content --> <?php - // Author bio. + // Author bio. if ( is_single() && get_the_author_meta( 'description' ) ) : get_template_part( 'author-bio' ); endif; diff --git a/src/wp-content/themes/twentyfifteen/content.php b/src/wp-content/themes/twentyfifteen/content.php index 22cd5f855b..3206ad6b53 100644 --- a/src/wp-content/themes/twentyfifteen/content.php +++ b/src/wp-content/themes/twentyfifteen/content.php @@ -50,7 +50,7 @@ </div><!-- .entry-content --> <?php - // Author bio. + // Author bio. if ( is_single() && get_the_author_meta( 'description' ) ) : get_template_part( 'author-bio' ); endif; diff --git a/src/wp-content/themes/twentyfifteen/functions.php b/src/wp-content/themes/twentyfifteen/functions.php index 39b9f7b44c..55fc83ece7 100644 --- a/src/wp-content/themes/twentyfifteen/functions.php +++ b/src/wp-content/themes/twentyfifteen/functions.php @@ -252,7 +252,7 @@ if ( ! function_exists( 'twentyfifteen_setup' ) ) : // Indicate widget sidebars can use selective refresh in the Customizer. add_theme_support( 'customize-selective-refresh-widgets' ); } -endif; // twentyfifteen_setup +endif; // twentyfifteen_setup() add_action( 'after_setup_theme', 'twentyfifteen_setup' ); /** diff --git a/src/wp-content/themes/twentyfifteen/image.php b/src/wp-content/themes/twentyfifteen/image.php index 3eb25b3fb3..2f222ab9d3 100644 --- a/src/wp-content/themes/twentyfifteen/image.php +++ b/src/wp-content/themes/twentyfifteen/image.php @@ -13,7 +13,7 @@ get_header(); ?> <main id="main" class="site-main" role="main"> <?php - // Start the loop. + // Start the loop. while ( have_posts() ) : the_post(); ?> @@ -77,7 +77,7 @@ get_header(); ?> </article><!-- #post-<?php the_ID(); ?> --> <?php - // If comments are open or we have at least one comment, load up the comment template + // If comments are open or we have at least one comment, load up the comment template. if ( comments_open() || get_comments_number() ) : comments_template(); endif; diff --git a/src/wp-content/themes/twentyfifteen/inc/custom-header.php b/src/wp-content/themes/twentyfifteen/inc/custom-header.php index 763ef00d03..5b634f31fc 100644 --- a/src/wp-content/themes/twentyfifteen/inc/custom-header.php +++ b/src/wp-content/themes/twentyfifteen/inc/custom-header.php @@ -193,7 +193,7 @@ if ( ! function_exists( 'twentyfifteen_header_style' ) ) : </style> <?php } -endif; // twentyfifteen_header_style +endif; // twentyfifteen_header_style() /** * Enqueues front-end CSS for the header background color. diff --git a/src/wp-content/themes/twentyfifteen/inc/customizer.php b/src/wp-content/themes/twentyfifteen/inc/customizer.php index 3b74f2433f..9d70b07eda 100644 --- a/src/wp-content/themes/twentyfifteen/inc/customizer.php +++ b/src/wp-content/themes/twentyfifteen/inc/customizer.php @@ -266,7 +266,7 @@ if ( ! function_exists( 'twentyfifteen_get_color_scheme' ) ) : return $color_schemes['default']['colors']; } -endif; // twentyfifteen_get_color_scheme +endif; // twentyfifteen_get_color_scheme() if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) : /** @@ -286,7 +286,7 @@ if ( ! function_exists( 'twentyfifteen_get_color_scheme_choices' ) ) : return $color_scheme_control_options; } -endif; // twentyfifteen_get_color_scheme_choices +endif; // twentyfifteen_get_color_scheme_choices() if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) : /** @@ -306,7 +306,7 @@ if ( ! function_exists( 'twentyfifteen_sanitize_color_scheme' ) ) : return $value; } -endif; // twentyfifteen_sanitize_color_scheme +endif; // twentyfifteen_sanitize_color_scheme() /** * Enqueues front-end CSS for color scheme. diff --git a/src/wp-content/themes/twentyfifteen/inc/template-tags.php b/src/wp-content/themes/twentyfifteen/inc/template-tags.php index 9ef2a6af49..796599590a 100644 --- a/src/wp-content/themes/twentyfifteen/inc/template-tags.php +++ b/src/wp-content/themes/twentyfifteen/inc/template-tags.php @@ -163,10 +163,10 @@ function twentyfifteen_categorized_blog() { } if ( $all_the_cool_cats > 1 || is_preview() ) { - // This blog has more than 1 category so twentyfifteen_categorized_blog should return true. + // This blog has more than 1 category so twentyfifteen_categorized_blog() should return true. return true; } else { - // This blog has only 1 category so twentyfifteen_categorized_blog should return false. + // This blog has only 1 category so twentyfifteen_categorized_blog() should return false. return false; } } @@ -213,7 +213,7 @@ if ( ! function_exists( 'twentyfifteen_post_thumbnail' ) ) : </a> <?php - endif; // End is_singular() + endif; // End is_singular(). } endif; @@ -275,7 +275,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Fifteen 2.5 */ diff --git a/src/wp-content/themes/twentyfifteen/index.php b/src/wp-content/themes/twentyfifteen/index.php index 4abac6a1be..b8f812786a 100644 --- a/src/wp-content/themes/twentyfifteen/index.php +++ b/src/wp-content/themes/twentyfifteen/index.php @@ -33,9 +33,9 @@ get_header(); ?> the_post(); /* - * Include the Post-Format-specific template for the content. - * If you want to override this in a child theme, then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php + * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfifteen/js/functions.js b/src/wp-content/themes/twentyfifteen/js/functions.js index f968885829..f554ceefd1 100644 --- a/src/wp-content/themes/twentyfifteen/js/functions.js +++ b/src/wp-content/themes/twentyfifteen/js/functions.js @@ -79,6 +79,7 @@ * * Uses jQuery's width() function to determine the size of the window and add * the default ARIA attributes for the menu toggle if it's visible. + * * @since Twenty Fifteen 1.1 */ function onResizeARIA() { diff --git a/src/wp-content/themes/twentyfifteen/single.php b/src/wp-content/themes/twentyfifteen/single.php index 4de3a493ad..2a4bb89366 100644 --- a/src/wp-content/themes/twentyfifteen/single.php +++ b/src/wp-content/themes/twentyfifteen/single.php @@ -18,8 +18,8 @@ get_header(); ?> the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfourteen/archive.php b/src/wp-content/themes/twentyfourteen/archive.php index 82b79c0868..f11a57ff1a 100644 --- a/src/wp-content/themes/twentyfourteen/archive.php +++ b/src/wp-content/themes/twentyfourteen/archive.php @@ -44,13 +44,13 @@ get_header(); ?> </header><!-- .page-header --> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfourteen/author.php b/src/wp-content/themes/twentyfourteen/author.php index fd9ee047c7..fc3ba043f3 100644 --- a/src/wp-content/themes/twentyfourteen/author.php +++ b/src/wp-content/themes/twentyfourteen/author.php @@ -39,19 +39,19 @@ get_header(); ?> <?php /* - * Since we called the_post() above, we need to rewind - * the loop back to the beginning that way we can run - * the loop properly, in full. + * Since we called the_post() above, we need + * to rewind the loop back to the beginning. + * That way we can run the loop properly, in full. */ rewind_posts(); - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfourteen/category.php b/src/wp-content/themes/twentyfourteen/category.php index 674532b500..16ccf12c38 100644 --- a/src/wp-content/themes/twentyfourteen/category.php +++ b/src/wp-content/themes/twentyfourteen/category.php @@ -34,13 +34,13 @@ get_header(); ?> </header><!-- .archive-header --> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfourteen/content-featured-post.php b/src/wp-content/themes/twentyfourteen/content-featured-post.php index 707b957029..3be4774ce9 100644 --- a/src/wp-content/themes/twentyfourteen/content-featured-post.php +++ b/src/wp-content/themes/twentyfourteen/content-featured-post.php @@ -11,7 +11,7 @@ <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a class="post-thumbnail" href="<?php the_permalink(); ?>"> <?php - // Output the featured image. + // Output the featured image. if ( has_post_thumbnail() ) : if ( 'grid' == get_theme_mod( 'featured_content_layout' ) ) { the_post_thumbnail(); diff --git a/src/wp-content/themes/twentyfourteen/functions.php b/src/wp-content/themes/twentyfourteen/functions.php index 47f5141655..22135f5a3c 100644 --- a/src/wp-content/themes/twentyfourteen/functions.php +++ b/src/wp-content/themes/twentyfourteen/functions.php @@ -192,7 +192,7 @@ if ( ! function_exists( 'twentyfourteen_setup' ) ) : // Indicate widget sidebars can use selective refresh in the Customizer. add_theme_support( 'customize-selective-refresh-widgets' ); } -endif; // twentyfourteen_setup +endif; // twentyfourteen_setup() add_action( 'after_setup_theme', 'twentyfourteen_setup' ); /** @@ -455,11 +455,11 @@ if ( ! function_exists( 'twentyfourteen_the_attached_image' ) ) : } } - // get the URL of the next image attachment... if ( $next_id ) { + // ...get the URL of the next image attachment. $next_attachment_url = get_attachment_link( $next_id ); } else { - // or get the URL of the first image attachment. + // ...or get the URL of the first image attachment. $next_attachment_url = get_attachment_link( reset( $attachment_ids ) ); } } diff --git a/src/wp-content/themes/twentyfourteen/image.php b/src/wp-content/themes/twentyfourteen/image.php index eb4a1658d0..ed5a9f2e65 100644 --- a/src/wp-content/themes/twentyfourteen/image.php +++ b/src/wp-content/themes/twentyfourteen/image.php @@ -17,7 +17,7 @@ get_header(); <div id="content" class="site-content" role="main"> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); ?> @@ -72,7 +72,7 @@ get_header(); <?php comments_template(); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </section><!-- #primary --> diff --git a/src/wp-content/themes/twentyfourteen/inc/custom-header.php b/src/wp-content/themes/twentyfourteen/inc/custom-header.php index 92382eaa5e..a459c0b003 100644 --- a/src/wp-content/themes/twentyfourteen/inc/custom-header.php +++ b/src/wp-content/themes/twentyfourteen/inc/custom-header.php @@ -91,7 +91,7 @@ if ( ! function_exists( 'twentyfourteen_header_style' ) ) : </style> <?php } -endif; // twentyfourteen_header_style +endif; // twentyfourteen_header_style() if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : @@ -130,7 +130,7 @@ if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : </style> <?php } -endif; // twentyfourteen_admin_header_style +endif; // twentyfourteen_admin_header_style() if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : /** @@ -150,4 +150,4 @@ if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : </div> <?php } -endif; // twentyfourteen_admin_header_image +endif; // twentyfourteen_admin_header_image() diff --git a/src/wp-content/themes/twentyfourteen/inc/template-tags.php b/src/wp-content/themes/twentyfourteen/inc/template-tags.php index 98d8b92e8a..69ef45e736 100644 --- a/src/wp-content/themes/twentyfourteen/inc/template-tags.php +++ b/src/wp-content/themes/twentyfourteen/inc/template-tags.php @@ -133,24 +133,24 @@ endif; function twentyfourteen_categorized_blog() { $all_the_cool_cats = get_transient( 'twentyfourteen_category_count' ); if ( false === $all_the_cool_cats ) { - // Create an array of all the categories that are attached to posts + // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( 'hide_empty' => 1, ) ); - // Count the number of categories that are attached to the posts + // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'twentyfourteen_category_count', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 || is_preview() ) { - // This blog has more than 1 category so twentyfourteen_categorized_blog should return true + // This blog has more than 1 category so twentyfourteen_categorized_blog() should return true. return true; } else { - // This blog has only 1 category so twentyfourteen_categorized_blog should return false + // This blog has only 1 category so twentyfourteen_categorized_blog() should return false. return false; } } @@ -208,7 +208,7 @@ if ( ! function_exists( 'twentyfourteen_post_thumbnail' ) ) : </a> <?php - endif; // End is_singular() + endif; // End is_singular(). } endif; @@ -238,7 +238,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Fourteen 2.7 */ diff --git a/src/wp-content/themes/twentyfourteen/index.php b/src/wp-content/themes/twentyfourteen/index.php index 7f6d04a0a6..5ed4c35a09 100644 --- a/src/wp-content/themes/twentyfourteen/index.php +++ b/src/wp-content/themes/twentyfourteen/index.php @@ -35,8 +35,8 @@ if ( is_front_page() && twentyfourteen_has_featured_posts() ) { the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfourteen/js/functions.js b/src/wp-content/themes/twentyfourteen/js/functions.js index ac4629d77e..2235330981 100644 --- a/src/wp-content/themes/twentyfourteen/js/functions.js +++ b/src/wp-content/themes/twentyfourteen/js/functions.js @@ -1,5 +1,5 @@ /** - * Theme functions file + * Theme functions file. * * Contains handlers for navigation, accessibility, header sizing * footer widgets and Featured Content slider @@ -126,6 +126,7 @@ * * Uses jQuery's width() function to determine the size of the window and add * the default ARIA attributes for the menu toggle if it's visible. + * * @since Twenty Fourteen 1.4 */ function onResizeARIA() { diff --git a/src/wp-content/themes/twentyfourteen/page-templates/contributors.php b/src/wp-content/themes/twentyfourteen/page-templates/contributors.php index 635a259c27..7756149ec3 100644 --- a/src/wp-content/themes/twentyfourteen/page-templates/contributors.php +++ b/src/wp-content/themes/twentyfourteen/page-templates/contributors.php @@ -21,7 +21,7 @@ if ( is_front_page() && twentyfourteen_has_featured_posts() ) { <div id="primary" class="content-area"> <div id="content" class="site-content" role="main"> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentyfourteen/page-templates/full-width.php b/src/wp-content/themes/twentyfourteen/page-templates/full-width.php index ea5fa58873..b75ac8882e 100644 --- a/src/wp-content/themes/twentyfourteen/page-templates/full-width.php +++ b/src/wp-content/themes/twentyfourteen/page-templates/full-width.php @@ -21,7 +21,7 @@ if ( is_front_page() && twentyfourteen_has_featured_posts() ) { <div id="primary" class="content-area"> <div id="content" class="site-content" role="main"> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); diff --git a/src/wp-content/themes/twentyfourteen/page.php b/src/wp-content/themes/twentyfourteen/page.php index bd033aeb48..6ff35be7bf 100644 --- a/src/wp-content/themes/twentyfourteen/page.php +++ b/src/wp-content/themes/twentyfourteen/page.php @@ -25,7 +25,7 @@ if ( is_front_page() && twentyfourteen_has_featured_posts() ) { <div id="content" class="site-content" role="main"> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); diff --git a/src/wp-content/themes/twentyfourteen/search.php b/src/wp-content/themes/twentyfourteen/search.php index aea6505178..80dc4d1e22 100644 --- a/src/wp-content/themes/twentyfourteen/search.php +++ b/src/wp-content/themes/twentyfourteen/search.php @@ -24,13 +24,13 @@ get_header(); ?> </header><!-- .page-header --> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfourteen/single.php b/src/wp-content/themes/twentyfourteen/single.php index 1940c7329f..352ab3774f 100644 --- a/src/wp-content/themes/twentyfourteen/single.php +++ b/src/wp-content/themes/twentyfourteen/single.php @@ -12,13 +12,13 @@ get_header(); ?> <div id="primary" class="content-area"> <div id="content" class="site-content" role="main"> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfourteen/tag.php b/src/wp-content/themes/twentyfourteen/tag.php index dd363c4ab2..55099d15fd 100644 --- a/src/wp-content/themes/twentyfourteen/tag.php +++ b/src/wp-content/themes/twentyfourteen/tag.php @@ -36,13 +36,13 @@ get_header(); ?> </header><!-- .archive-header --> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentyfourteen/taxonomy-post_format.php b/src/wp-content/themes/twentyfourteen/taxonomy-post_format.php index 243e8f0c29..9cf9083cee 100644 --- a/src/wp-content/themes/twentyfourteen/taxonomy-post_format.php +++ b/src/wp-content/themes/twentyfourteen/taxonomy-post_format.php @@ -56,13 +56,13 @@ get_header(); ?> </header><!-- .archive-header --> <?php - // Start the Loop. + // Start the Loop. while ( have_posts() ) : the_post(); /* - * Include the post format-specific template for the content. If you want to - * use this in a child theme, then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme, then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentynineteen/archive.php b/src/wp-content/themes/twentynineteen/archive.php index dbe8e519b4..5c251e7108 100644 --- a/src/wp-content/themes/twentynineteen/archive.php +++ b/src/wp-content/themes/twentynineteen/archive.php @@ -31,7 +31,8 @@ get_header(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'template-parts/content/content', 'excerpt' ); diff --git a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php index 8582ce4e60..1546d0eb92 100644 --- a/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php +++ b/src/wp-content/themes/twentynineteen/classes/class-twentynineteen-svg-icons.php @@ -36,7 +36,7 @@ class TwentyNineteen_SVG_Icons { $repl = sprintf( '<svg class="svg-icon" width="%d" height="%d" aria-hidden="true" role="img" focusable="false" ', $size, $size ); $svg = preg_replace( '/^<svg /', $repl, trim( $arr[ $icon ] ) ); // Add extra attributes to SVG code. $svg = preg_replace( "/([\n\t]+)/", ' ', $svg ); // Remove newlines & tabs. - $svg = preg_replace( '/>\s*</', '><', $svg ); // Remove white space between SVG tags. + $svg = preg_replace( '/>\s*</', '><', $svg ); // Remove whitespace between SVG tags. return $svg; } return null; diff --git a/src/wp-content/themes/twentynineteen/comments.php b/src/wp-content/themes/twentynineteen/comments.php index d72ae857c8..d00ac46118 100644 --- a/src/wp-content/themes/twentynineteen/comments.php +++ b/src/wp-content/themes/twentynineteen/comments.php @@ -56,7 +56,7 @@ $discussion = twentynineteen_get_discussion_data(); ?> </h2><!-- .comments-title --> <?php - // Only show discussion meta information when comments are open and available. + // Only show discussion meta information when comments are open and available. if ( have_comments() && comments_open() ) { get_template_part( 'template-parts/post/discussion', 'meta' ); } @@ -85,7 +85,7 @@ $discussion = twentynineteen_get_discussion_data(); </ol><!-- .comment-list --> <?php - // Show comment navigation + // Show comment navigation. if ( have_comments() ) : $prev_icon = twentynineteen_get_icon_svg( 'chevron_left', 22 ); $next_icon = twentynineteen_get_icon_svg( 'chevron_right', 22 ); diff --git a/src/wp-content/themes/twentynineteen/image.php b/src/wp-content/themes/twentynineteen/image.php index 021293e57c..ff689f4463 100644 --- a/src/wp-content/themes/twentynineteen/image.php +++ b/src/wp-content/themes/twentynineteen/image.php @@ -14,7 +14,7 @@ get_header(); <main id="main" class="site-main"> <?php - // Start the loop. + // Start the Loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentynineteen/inc/template-functions.php b/src/wp-content/themes/twentynineteen/inc/template-functions.php index 4ec88c42ca..6c5153f01b 100644 --- a/src/wp-content/themes/twentynineteen/inc/template-functions.php +++ b/src/wp-content/themes/twentynineteen/inc/template-functions.php @@ -238,7 +238,7 @@ add_filter( 'wp_nav_menu', 'twentynineteen_add_ellipses_to_nav', 10, 2 ); */ function twentynineteen_nav_menu_link_attributes( $atts, $item, $args, $depth ) { - // Add [aria-haspopup] and [aria-expanded] to menu items that have children + // Add [aria-haspopup] and [aria-expanded] to menu items that have children. $item_has_children = in_array( 'menu-item-has-children', $item->classes ); if ( $item_has_children ) { $atts['aria-haspopup'] = 'true'; @@ -274,7 +274,7 @@ function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) { twentynineteen_get_icon_svg( 'chevron_left', 24 ) ); - // replace opening <a> with <button> + // Replace opening <a> with <button>. $output = preg_replace( '/<a\s.*?>/', $link, @@ -282,7 +282,7 @@ function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) { 1 // Limit. ); - // replace closing </a> with </button> + // Replace closing </a> with </button>. $output = preg_replace( '#</a>#i', '</button>', diff --git a/src/wp-content/themes/twentynineteen/inc/template-tags.php b/src/wp-content/themes/twentynineteen/inc/template-tags.php index a77f731122..ae3e3b17a5 100644 --- a/src/wp-content/themes/twentynineteen/inc/template-tags.php +++ b/src/wp-content/themes/twentynineteen/inc/template-tags.php @@ -76,10 +76,10 @@ if ( ! function_exists( 'twentynineteen_entry_footer' ) ) : // Hide author, post date, category and tag text for pages. if ( 'post' === get_post_type() ) { - // Posted by + // Posted by. twentynineteen_posted_by(); - // Posted on + // Posted on. twentynineteen_posted_on(); /* translators: Used between list items, there is a space after the comma. */ @@ -243,7 +243,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Nineteen 1.4 */ diff --git a/src/wp-content/themes/twentynineteen/js/customize-preview.js b/src/wp-content/themes/twentynineteen/js/customize-preview.js index 91b91f3e0c..260c3d42f8 100644 --- a/src/wp-content/themes/twentynineteen/js/customize-preview.js +++ b/src/wp-content/themes/twentynineteen/js/customize-preview.js @@ -18,10 +18,10 @@ color; if( 'custom' === to ){ - // If a custom primary color is selected, use the currently set primary_color_hue + // If a custom primary color is selected, use the currently set primary_color_hue. color = wp.customize.get().primary_color_hue; } else { - // If the "default" option is selected, get the default primary_color_hue + // If the "default" option is selected, get the default primary_color_hue. color = 199; } diff --git a/src/wp-content/themes/twentynineteen/js/priority-menu.js b/src/wp-content/themes/twentynineteen/js/priority-menu.js index 7cd6bb066b..85449b0e24 100644 --- a/src/wp-content/themes/twentynineteen/js/priority-menu.js +++ b/src/wp-content/themes/twentynineteen/js/priority-menu.js @@ -1,7 +1,7 @@ (function() { /** - * Debounce + * Debounce. * * @param {Function} func * @param {number} wait @@ -56,7 +56,7 @@ * @param {Element} element */ function showButton(element) { - // classList.remove is not supported in IE11 + // classList.remove is not supported in IE11. element.className = element.className.replace('is-empty', ''); } @@ -66,7 +66,7 @@ * @param {Element} element */ function hideButton(element) { - // classList.add is not supported in IE11 + // classList.add is not supported in IE11. if (!element.classList.contains('is-empty')) { element.className += ' is-empty'; } @@ -91,25 +91,25 @@ } /** - * Set menu container variable + * Set menu container variable. */ var navContainer = document.querySelector('.main-navigation'); var breaks = []; /** - * Let’s bail if we our menu doesn't exist + * Let’s bail if we our menu doesn't exist. */ if ( ! navContainer ) { return; } /** - * Refreshes the list item from the menu depending on the menu size + * Refreshes the list item from the menu depending on the menu size. */ function updateNavigationMenu( container ) { /** - * Let’s bail if our menu is empty + * Let’s bail if our menu is empty. */ if ( ! container.parentNode.querySelector('.main-menu[id]') ) { return; @@ -122,42 +122,42 @@ if ( isOverflowingNavivation( visibleList, toggleButton, container ) ) { - // Record the width of the list + // Record the width of the list. breaks.push( visibleList.offsetWidth ); - // Move last item to the hidden list + // Move last item to the hidden list. prependElement( hiddenList, ! visibleList.lastChild || null === visibleList.lastChild ? visibleList.previousElementSibling : visibleList.lastChild ); - // Show the toggle button + // Show the toggle button. showButton( toggleButton ); } else { - // There is space for another item in the nav + // There is space for another item in the nav. if ( getAvailableSpace( toggleButton, container ) > breaks[breaks.length - 1] ) { - // Move the item to the visible list + // Move the item to the visible list. visibleList.appendChild( hiddenList.firstChild.nextSibling ); breaks.pop(); } - // Hide the dropdown btn if hidden list is empty + // Hide the dropdown btn if hidden list is empty. if (breaks.length < 2) { hideButton( toggleButton ); } } - // Recur if the visible list is still overflowing the nav + // Recur if the visible list is still overflowing the nav. if ( isOverflowingNavivation( visibleList, toggleButton, container ) ) { updateNavigationMenu( container ); } } /** - * Run our priority+ function as soon as the document is `ready` + * Run our priority+ function as soon as the document is `ready`. */ document.addEventListener( 'DOMContentLoaded', function() { updateNavigationMenu( navContainer ); - // Also, run our priority+ function on selective refresh in the customizer + // Also, run our priority+ function on selective refresh in the customizer. var hasSelectiveRefresh = ( 'undefined' !== typeof wp && wp.customize && @@ -166,7 +166,7 @@ ); if ( hasSelectiveRefresh ) { - // Re-run our priority+ function on Nav Menu partial refreshes + // Re-run our priority+ function on Nav Menu partial refreshes. wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function ( placement ) { var isNewNavMenu = ( @@ -184,14 +184,14 @@ }); /** - * Run our priority+ function on load + * Run our priority+ function on load. */ window.addEventListener( 'load', function() { updateNavigationMenu( navContainer ); }); /** - * Run our priority+ function every time the window resizes + * Run our priority+ function every time the window resizes. */ var isResizing = false; window.addEventListener( 'resize', @@ -209,7 +209,7 @@ ); /** - * Run our priority+ function + * Run our priority+ function. */ updateNavigationMenu( navContainer ); diff --git a/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js b/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js index 2fa1905624..c8d1dd02e6 100644 --- a/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js +++ b/src/wp-content/themes/twentynineteen/js/touch-keyboard-navigation.js @@ -7,7 +7,7 @@ (function() { /** - * Debounce + * Debounce. * * @param {Function} func * @param {number} wait @@ -43,7 +43,7 @@ } /** - * Add class + * Add class. * * @param {Object} el * @param {string} cls @@ -55,7 +55,7 @@ } /** - * Delete class + * Delete class. * * @param {Object} el * @param {string} cls @@ -80,7 +80,7 @@ } /** - * Toggle Aria Expanded state for screenreaders + * Toggle Aria Expanded state for screenreaders. * * @param {Object} ariaItem */ @@ -99,24 +99,24 @@ } /** - * Open sub-menu + * Open sub-menu. * * @param {Object} currentSubMenu */ function openSubMenu( currentSubMenu ) { 'use strict'; - // Update classes - // classList.add is not supported in IE11 + // Update classes. + // classList.add is not supported in IE11. currentSubMenu.parentElement.className += ' off-canvas'; currentSubMenu.parentElement.lastElementChild.className += ' expanded-true'; - // Update aria-expanded state + // Update aria-expanded state. toggleAriaExpandedState( currentSubMenu ); } /** - * Close sub-menu + * Close sub-menu. * * @param {Object} currentSubMenu */ @@ -127,32 +127,32 @@ var menuItemAria = menuItem.querySelector('a[aria-expanded]'); var subMenu = currentSubMenu.closest('.sub-menu'); - // If this is in a sub-sub-menu, go back to parent sub-menu + // If this is in a sub-sub-menu, go back to parent sub-menu. if ( getCurrentParent( currentSubMenu, 'ul' ).classList.contains( 'sub-menu' ) ) { - // Update classes - // classList.remove is not supported in IE11 + // Update classes. + // classList.remove is not supported in IE11. menuItem.className = menuItem.className.replace( 'off-canvas', '' ); subMenu.className = subMenu.className.replace( 'expanded-true', '' ); - // Update aria-expanded and :focus states + // Update aria-expanded and :focus states. toggleAriaExpandedState( menuItemAria ); - // Or else close all sub-menus + // Or else close all sub-menus. } else { - // Update classes - // classList.remove is not supported in IE11 + // Update classes. + // classList.remove is not supported in IE11. menuItem.className = menuItem.className.replace( 'off-canvas', '' ); menuItem.lastElementChild.className = menuItem.lastElementChild.className.replace( 'expanded-true', '' ); - // Update aria-expanded and :focus states + // Update aria-expanded and :focus states. toggleAriaExpandedState( menuItemAria ); } } /** - * Find first ancestor of an element by selector + * Find first ancestor of an element by selector. * * @param {Object} child * @param {String} selector @@ -181,7 +181,7 @@ } /** - * Remove all off-canvas states + * Remove all off-canvas states. */ function removeAllFocusStates() { 'use strict'; @@ -202,7 +202,7 @@ } /** - * Matches polyfill for IE11 + * Matches polyfill for IE11. */ if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.msMatchesSelector; @@ -219,31 +219,31 @@ var url = event.target.getAttribute( 'href' ) ? event.target.getAttribute( 'href' ) : ''; - // Open submenu if url is # + // Open submenu if URL is #. if ( '#' === url && event.target.nextSibling.matches('.submenu-expand') ) { openSubMenu( event.target ); } } - // Check if .submenu-expand is touched + // Check if .submenu-expand is touched. if ( event.target.matches('.submenu-expand') ) { openSubMenu(event.target); - // Check if child of .submenu-expand is touched + // Check if child of .submenu-expand is touched. } else if ( null != getCurrentParent( event.target, '.submenu-expand' ) && getCurrentParent( event.target, '.submenu-expand' ).matches( '.submenu-expand' ) ) { openSubMenu( getCurrentParent( event.target, '.submenu-expand' ) ); - // Check if .menu-item-link-return is touched + // Check if .menu-item-link-return is touched. } else if ( event.target.matches('.menu-item-link-return') ) { closeSubMenu( event.target ); - // Check if child of .menu-item-link-return is touched + // Check if child of .menu-item-link-return is touched. } else if ( null != getCurrentParent( event.target, '.menu-item-link-return' ) && getCurrentParent( event.target, '.menu-item-link-return' ).matches( '.menu-item-link-return' ) ) { closeSubMenu( event.target ); } - // Prevent default mouse/focus events + // Prevent default mouse/focus events. removeAllFocusStates(); }, false); @@ -253,7 +253,7 @@ var mainNav = getCurrentParent( event.target, '.main-navigation' ); if ( null != mainNav && hasClass( mainNav, '.main-navigation' ) ) { - // Prevent default mouse events + // Prevent default mouse events. event.preventDefault(); } else if ( @@ -263,11 +263,11 @@ event.target.matches('.menu-item-link-return') || null != getCurrentParent( event.target, '.menu-item-link-return' ) && getCurrentParent( event.target, '.menu-item-link-return' ).matches( '.menu-item-link-return' ) ) { - // Prevent default mouse events + // Prevent default mouse events. event.preventDefault(); } - // Prevent default mouse/focus events + // Prevent default mouse/focus events. removeAllFocusStates(); }, false); @@ -276,7 +276,7 @@ if ( event.target.matches('.main-navigation > div > ul > li a') ) { - // Remove Focused elements in sibling div + // Remove Focused elements in sibling div. var currentDiv = getCurrentParent( event.target, 'div', '.main-navigation' ); var currentDivSibling = currentDiv.previousElementSibling === null ? currentDiv.nextElementSibling : currentDiv.previousElementSibling; var focusedElement = currentDivSibling.querySelector( '.is-focused' ); @@ -288,17 +288,17 @@ deleteClass( focusedElement, focusedClass ); } - // Add .is-focused class to top-level li + // Add .is-focused class to top-level li. if ( getCurrentParent( event.target, '.main-navigation > div > ul > li', '.main-navigation' ) ) { addClass( getCurrentParent( event.target, '.main-navigation > div > ul > li', '.main-navigation' ), focusedClass ); } - // Check for previous li + // Check for previous li. if ( prevLi && hasClass( prevLi, focusedClass ) ) { deleteClass( prevLi, focusedClass ); } - // Check for next li + // Check for next li. if ( nextLi && hasClass( nextLi, focusedClass ) ) { deleteClass( nextLi, focusedClass ); } @@ -308,25 +308,25 @@ document.addEventListener('click', function(event) { - // Remove all focused menu states when clicking outside site branding + // Remove all focused menu states when clicking outside site branding. if ( event.target !== document.getElementsByClassName( 'site-branding' )[0] ) { removeAllFocusStates(); } else { - // nothing + // Nothing. } }, false); } /** - * Run our sub-menu function as soon as the document is `ready` + * Run our sub-menu function as soon as the document is `ready`. */ document.addEventListener( 'DOMContentLoaded', function() { toggleSubmenuDisplay(); }); /** - * Run our sub-menu function on selective refresh in the customizer + * Run our sub-menu function on selective refresh in the customizer. */ document.addEventListener( 'customize-preview-menu-refreshed', function( e, params ) { if ( 'menu-1' === params.wpNavMenuArgs.theme_location ) { @@ -335,7 +335,7 @@ }); /** - * Run our sub-menu function every time the window resizes + * Run our sub-menu function every time the window resizes. */ var isResizing = false; window.addEventListener( 'resize', function() { diff --git a/src/wp-content/themes/twentynineteen/page.php b/src/wp-content/themes/twentynineteen/page.php index 16abcb2399..757e049e5b 100644 --- a/src/wp-content/themes/twentynineteen/page.php +++ b/src/wp-content/themes/twentynineteen/page.php @@ -17,7 +17,7 @@ get_header(); <?php - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); @@ -28,7 +28,7 @@ get_header(); comments_template(); } - endwhile; // End of the loop. + endwhile; // End the loop. ?> </main><!-- #main --> diff --git a/src/wp-content/themes/twentynineteen/search.php b/src/wp-content/themes/twentynineteen/search.php index 25ab5c245d..af9d26540c 100644 --- a/src/wp-content/themes/twentynineteen/search.php +++ b/src/wp-content/themes/twentynineteen/search.php @@ -32,7 +32,8 @@ get_header(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'template-parts/content/content', 'excerpt' ); diff --git a/src/wp-content/themes/twentynineteen/single.php b/src/wp-content/themes/twentynineteen/single.php index 830850ef7d..a2d7eac00e 100644 --- a/src/wp-content/themes/twentynineteen/single.php +++ b/src/wp-content/themes/twentynineteen/single.php @@ -17,7 +17,7 @@ get_header(); <?php - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); @@ -50,7 +50,7 @@ get_header(); comments_template(); } - endwhile; // End of the loop. + endwhile; // End the loop. ?> </main><!-- #main --> diff --git a/src/wp-content/themes/twentynineteen/template-parts/header/entry-header.php b/src/wp-content/themes/twentynineteen/template-parts/header/entry-header.php index 77491f0285..163436d4b1 100644 --- a/src/wp-content/themes/twentynineteen/template-parts/header/entry-header.php +++ b/src/wp-content/themes/twentynineteen/template-parts/header/entry-header.php @@ -24,7 +24,7 @@ $discussion = ! is_page() && twentynineteen_can_show_post_thumbnail() ? twentyni <?php twentynineteen_comment_count(); ?> </span> <?php - // Edit post link. + // Edit post link. edit_post_link( sprintf( wp_kses( diff --git a/src/wp-content/themes/twentyseventeen/archive.php b/src/wp-content/themes/twentyseventeen/archive.php index 1d0772275c..574efd37c7 100644 --- a/src/wp-content/themes/twentyseventeen/archive.php +++ b/src/wp-content/themes/twentyseventeen/archive.php @@ -30,14 +30,15 @@ get_header(); ?> if ( have_posts() ) : ?> <?php - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'template-parts/post/content', get_post_format() ); diff --git a/src/wp-content/themes/twentyseventeen/assets/js/customize-preview.js b/src/wp-content/themes/twentyseventeen/assets/js/customize-preview.js index dba7b79b9e..e97dd83ff4 100644 --- a/src/wp-content/themes/twentyseventeen/assets/js/customize-preview.js +++ b/src/wp-content/themes/twentyseventeen/assets/js/customize-preview.js @@ -9,7 +9,7 @@ // Collect information from customize-controls.js about which panels are opening. wp.customize.bind( 'preview-ready', function() { - // Initially hide the theme option placeholders on load + // Initially hide the theme option placeholders on load. $( '.panel-placeholder' ).hide(); wp.customize.preview.bind( 'section-highlight', function( data ) { diff --git a/src/wp-content/themes/twentyseventeen/inc/custom-header.php b/src/wp-content/themes/twentyseventeen/inc/custom-header.php index 60cb192516..cb2d77c9a4 100644 --- a/src/wp-content/themes/twentyseventeen/inc/custom-header.php +++ b/src/wp-content/themes/twentyseventeen/inc/custom-header.php @@ -115,7 +115,7 @@ if ( ! function_exists( 'twentyseventeen_header_style' ) ) : </style> <?php } -endif; // End of twentyseventeen_header_style. +endif; // End of twentyseventeen_header_style(). /** * Customize video play/pause button in the custom header. diff --git a/src/wp-content/themes/twentyseventeen/inc/template-tags.php b/src/wp-content/themes/twentyseventeen/inc/template-tags.php index db3245df6e..1667e9c2f0 100644 --- a/src/wp-content/themes/twentyseventeen/inc/template-tags.php +++ b/src/wp-content/themes/twentyseventeen/inc/template-tags.php @@ -80,7 +80,7 @@ if ( ! function_exists( 'twentyseventeen_entry_footer' ) ) : if ( ( $categories_list && twentyseventeen_categorized_blog() ) || $tags_list ) { echo '<span class="cat-tags-links">'; - // Make sure there's more than one category before displaying. + // Make sure there's more than one category before displaying. if ( $categories_list && twentyseventeen_categorized_blog() ) { echo '<span class="cat-links">' . twentyseventeen_get_svg( array( 'icon' => 'folder-open' ) ) . '<span class="screen-reader-text">' . __( 'Categories', 'twentyseventeen' ) . '</span>' . $categories_list . '</span>'; } @@ -133,7 +133,9 @@ function twentyseventeen_front_page_section( $partial = null, $id = 0 ) { if ( is_a( $partial, 'WP_Customize_Partial' ) ) { // Find out the id and set it up during a selective refresh. global $twentyseventeencounter; - $id = str_replace( 'panel_', '', $partial->id ); + + $id = str_replace( 'panel_', '', $partial->id ); + $twentyseventeencounter = $id; } @@ -148,8 +150,13 @@ function twentyseventeen_front_page_section( $partial = null, $id = 0 ) { wp_reset_postdata(); } elseif ( is_customize_preview() ) { // The output placeholder anchor. - /* translators: %s: The section ID. */ - echo '<article class="panel-placeholder panel twentyseventeen-panel twentyseventeen-panel' . $id . '" id="panel' . $id . '"><span class="twentyseventeen-panel-title">' . sprintf( __( 'Front Page Section %s Placeholder', 'twentyseventeen' ), $id ) . '</span></article>'; + printf( + '<article class="panel-placeholder panel twentyseventeen-panel twentyseventeen-panel%1$s" id="panel%1$s">' . + '<span class="twentyseventeen-panel-title">%2$s</span></article>', + $id, + /* translators: %s: The section ID. */ + sprintf( __( 'Front Page Section %s Placeholder', 'twentyseventeen' ), $id ) + ); } } @@ -204,7 +211,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Seventeen 2.2 */ diff --git a/src/wp-content/themes/twentyseventeen/index.php b/src/wp-content/themes/twentyseventeen/index.php index 1b6375545f..5df8f0231f 100644 --- a/src/wp-content/themes/twentyseventeen/index.php +++ b/src/wp-content/themes/twentyseventeen/index.php @@ -34,14 +34,15 @@ get_header(); ?> <?php if ( have_posts() ) : - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'template-parts/post/content', get_post_format() ); diff --git a/src/wp-content/themes/twentyseventeen/page.php b/src/wp-content/themes/twentyseventeen/page.php index 758816c5a7..fee6a8e49c 100644 --- a/src/wp-content/themes/twentyseventeen/page.php +++ b/src/wp-content/themes/twentyseventeen/page.php @@ -32,7 +32,7 @@ get_header(); ?> comments_template(); endif; - endwhile; // End of the loop. + endwhile; // End the loop. ?> </main><!-- #main --> diff --git a/src/wp-content/themes/twentyseventeen/search.php b/src/wp-content/themes/twentyseventeen/search.php index a1fd451a4d..ee62b22112 100644 --- a/src/wp-content/themes/twentyseventeen/search.php +++ b/src/wp-content/themes/twentyseventeen/search.php @@ -32,7 +32,7 @@ get_header(); ?> <?php if ( have_posts() ) : - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); @@ -43,7 +43,7 @@ get_header(); ?> */ get_template_part( 'template-parts/post/content', 'excerpt' ); - endwhile; // End of the loop. + endwhile; // End the loop. the_posts_pagination( array( diff --git a/src/wp-content/themes/twentyseventeen/single.php b/src/wp-content/themes/twentyseventeen/single.php index ec68d5f4eb..541e2d24a9 100644 --- a/src/wp-content/themes/twentyseventeen/single.php +++ b/src/wp-content/themes/twentyseventeen/single.php @@ -17,7 +17,7 @@ get_header(); ?> <main id="main" class="site-main" role="main"> <?php - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); @@ -35,7 +35,7 @@ get_header(); ?> ) ); - endwhile; // End of the loop. + endwhile; // End the loop. ?> </main><!-- #main --> diff --git a/src/wp-content/themes/twentysixteen/archive.php b/src/wp-content/themes/twentysixteen/archive.php index 079730f314..68a97fc537 100644 --- a/src/wp-content/themes/twentysixteen/archive.php +++ b/src/wp-content/themes/twentysixteen/archive.php @@ -31,14 +31,15 @@ get_header(); ?> </header><!-- .page-header --> <?php - // Start the Loop. + // Start the loop. while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'template-parts/content', get_post_format() ); diff --git a/src/wp-content/themes/twentysixteen/functions.php b/src/wp-content/themes/twentysixteen/functions.php index c180b826f3..4d743eb116 100644 --- a/src/wp-content/themes/twentysixteen/functions.php +++ b/src/wp-content/themes/twentysixteen/functions.php @@ -216,7 +216,7 @@ if ( ! function_exists( 'twentysixteen_setup' ) ) : // Indicate widget sidebars can use selective refresh in the Customizer. add_theme_support( 'customize-selective-refresh-widgets' ); } -endif; // twentysixteen_setup +endif; // twentysixteen_setup() add_action( 'after_setup_theme', 'twentysixteen_setup' ); /** diff --git a/src/wp-content/themes/twentysixteen/image.php b/src/wp-content/themes/twentysixteen/image.php index 620b47cf53..c17645c4f7 100644 --- a/src/wp-content/themes/twentysixteen/image.php +++ b/src/wp-content/themes/twentysixteen/image.php @@ -13,7 +13,7 @@ get_header(); ?> <main id="main" class="site-main" role="main"> <?php - // Start the loop. + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentysixteen/inc/customizer.php b/src/wp-content/themes/twentysixteen/inc/customizer.php index 370935802f..41f52667bc 100644 --- a/src/wp-content/themes/twentysixteen/inc/customizer.php +++ b/src/wp-content/themes/twentysixteen/inc/customizer.php @@ -103,7 +103,7 @@ if ( ! function_exists( 'twentysixteen_header_style' ) ) : </style> <?php } -endif; // twentysixteen_header_style +endif; // twentysixteen_header_style() /** * Adds postMessage support for site title and description for the Customizer. @@ -385,7 +385,7 @@ if ( ! function_exists( 'twentysixteen_get_color_scheme' ) ) : return $color_schemes['default']['colors']; } -endif; // twentysixteen_get_color_scheme +endif; // twentysixteen_get_color_scheme() if ( ! function_exists( 'twentysixteen_get_color_scheme_choices' ) ) : /** @@ -408,7 +408,7 @@ if ( ! function_exists( 'twentysixteen_get_color_scheme_choices' ) ) : return $color_scheme_control_options; } -endif; // twentysixteen_get_color_scheme_choices +endif; // twentysixteen_get_color_scheme_choices() if ( ! function_exists( 'twentysixteen_sanitize_color_scheme' ) ) : @@ -432,7 +432,7 @@ if ( ! function_exists( 'twentysixteen_sanitize_color_scheme' ) ) : return $value; } -endif; // twentysixteen_sanitize_color_scheme +endif; // twentysixteen_sanitize_color_scheme() /** * Enqueues front-end CSS for color scheme. diff --git a/src/wp-content/themes/twentysixteen/inc/template-tags.php b/src/wp-content/themes/twentysixteen/inc/template-tags.php index dfddc93228..af47d594af 100644 --- a/src/wp-content/themes/twentysixteen/inc/template-tags.php +++ b/src/wp-content/themes/twentysixteen/inc/template-tags.php @@ -147,7 +147,7 @@ if ( ! function_exists( 'twentysixteen_post_thumbnail' ) ) : </a> <?php - endif; // End is_singular() + endif; // End is_singular(). } endif; @@ -228,10 +228,10 @@ if ( ! function_exists( 'twentysixteen_categorized_blog' ) ) : } if ( $all_the_cool_cats > 1 || is_preview() ) { - // This blog has more than 1 category so twentysixteen_categorized_blog should return true. + // This blog has more than 1 category so twentysixteen_categorized_blog() should return true. return true; } else { - // This blog has only 1 category so twentysixteen_categorized_blog should return false. + // This blog has only 1 category so twentysixteen_categorized_blog() should return false. return false; } } @@ -271,7 +271,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Sixteen 2.0 */ diff --git a/src/wp-content/themes/twentysixteen/index.php b/src/wp-content/themes/twentysixteen/index.php index f6ec56c1db..0a1a3e0173 100644 --- a/src/wp-content/themes/twentysixteen/index.php +++ b/src/wp-content/themes/twentysixteen/index.php @@ -35,7 +35,8 @@ get_header(); ?> /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file - * called content-___.php (where ___ is the Post Format name) and that will be used instead. + * called content-___.php (where ___ is the Post Format name) and that + * will be used instead. */ get_template_part( 'template-parts/content', get_post_format() ); diff --git a/src/wp-content/themes/twentysixteen/page.php b/src/wp-content/themes/twentysixteen/page.php index a232c9fce1..f5d6b7adb9 100644 --- a/src/wp-content/themes/twentysixteen/page.php +++ b/src/wp-content/themes/twentysixteen/page.php @@ -28,7 +28,7 @@ get_header(); ?> comments_template(); } - // End of the loop. + // End the loop. endwhile; ?> diff --git a/src/wp-content/themes/twentysixteen/single.php b/src/wp-content/themes/twentysixteen/single.php index 3454170335..77a44d8692 100644 --- a/src/wp-content/themes/twentysixteen/single.php +++ b/src/wp-content/themes/twentysixteen/single.php @@ -45,7 +45,7 @@ get_header(); ?> ); } - // End of the loop. + // End the loop. endwhile; ?> diff --git a/src/wp-content/themes/twentyten/404.php b/src/wp-content/themes/twentyten/404.php index 914ef01089..c67f6ca502 100644 --- a/src/wp-content/themes/twentyten/404.php +++ b/src/wp-content/themes/twentyten/404.php @@ -23,7 +23,7 @@ get_header(); ?> </div><!-- #content --> </div><!-- #container --> <script type="text/javascript"> - // focus on search field after it has loaded + // Focus on search field after it has loaded. document.getElementById('s') && document.getElementById('s').focus(); </script> diff --git a/src/wp-content/themes/twentyten/archive.php b/src/wp-content/themes/twentyten/archive.php index 4efb055049..36c5e0b3e2 100644 --- a/src/wp-content/themes/twentyten/archive.php +++ b/src/wp-content/themes/twentyten/archive.php @@ -49,9 +49,9 @@ if ( have_posts() ) { <?php /* - * Since we called the_post() above, we need to - * rewind the loop back to the beginning that way - * we can run the loop properly, in full. + * Since we called the_post() above, we need + * to rewind the loop back to the beginning. + * That way we can run the loop properly, in full. */ rewind_posts(); diff --git a/src/wp-content/themes/twentyten/author.php b/src/wp-content/themes/twentyten/author.php index 8383d24d18..1a040e08c1 100644 --- a/src/wp-content/themes/twentyten/author.php +++ b/src/wp-content/themes/twentyten/author.php @@ -65,9 +65,9 @@ if ( get_the_author_meta( 'description' ) ) : <?php /* - * Since we called the_post() above, we need to - * rewind the loop back to the beginning that way - * we can run the loop properly, in full. + * Since we called the_post() above, we need + * to rewind the loop back to the beginning. + * That way we can run the loop properly, in full. */ rewind_posts(); diff --git a/src/wp-content/themes/twentyten/comments.php b/src/wp-content/themes/twentyten/comments.php index 753456aefe..a6fe78a41c 100644 --- a/src/wp-content/themes/twentyten/comments.php +++ b/src/wp-content/themes/twentyten/comments.php @@ -56,7 +56,7 @@ <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">←</span> Older Comments', 'twentyten' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div> </div> <!-- .navigation --> - <?php endif; // check for comment navigation ?> + <?php endif; // Check for comment navigation. ?> <ol class="commentlist"> <?php @@ -76,7 +76,7 @@ <div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">←</span> Older Comments', 'twentyten' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments <span class="meta-nav">→</span>', 'twentyten' ) ); ?></div> </div><!-- .navigation --> - <?php endif; // check for comment navigation ?> + <?php endif; // Check for comment navigation. ?> <?php /* @@ -88,7 +88,7 @@ <p class="nocomments"><?php _e( 'Comments are closed.', 'twentyten' ); ?></p> <?php endif; ?> -<?php endif; // end have_comments() ?> +<?php endif; // End have_comments(). ?> <?php comment_form(); ?> diff --git a/src/wp-content/themes/twentyten/functions.php b/src/wp-content/themes/twentyten/functions.php index 97f018d4ab..96629d1074 100644 --- a/src/wp-content/themes/twentyten/functions.php +++ b/src/wp-content/themes/twentyten/functions.php @@ -27,7 +27,7 @@ * <code> * add_action( 'after_setup_theme', 'my_child_theme_setup' ); * function my_child_theme_setup() { - * // We are providing our own filter for excerpt_length (or using the unfiltered value) + * // We are providing our own filter for excerpt_length (or using the unfiltered value). * remove_filter( 'excerpt_length', 'twentyten_excerpt_length' ); * ... * } @@ -119,15 +119,15 @@ if ( ! function_exists( 'twentyten_setup' ) ) : // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); - // This theme uses post thumbnails + // This theme uses post thumbnails. add_theme_support( 'post-thumbnails' ); - // Add default posts and comments RSS feed links to head + // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Make theme available for translation. - * Translations can be filed in the /languages/ directory + * Translations can be filed in the /languages/ directory. */ load_theme_textdomain( 'twentyten', get_template_directory() . '/languages' ); @@ -200,7 +200,7 @@ if ( ! function_exists( 'twentyten_setup' ) ) : */ set_post_thumbnail_size( $custom_header_support['width'], $custom_header_support['height'], true ); - // ... and thus ends the custom header business. + // ...and thus ends the custom header business. // Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI. register_default_headers( @@ -394,7 +394,7 @@ add_filter( 'use_default_gallery_style', '__return_false' ); function twentyten_remove_gallery_css( $css ) { return preg_replace( "#<style type='text/css'>(.*?)</style>#s", '', $css ); } -// Backwards compatibility with WordPress 3.0. +// Backward compatibility with WordPress 3.0. if ( version_compare( $GLOBALS['wp_version'], '3.1', '<' ) ) { add_filter( 'gallery_style', 'twentyten_remove_gallery_css' ); } @@ -740,7 +740,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Ten 2.9 */ diff --git a/src/wp-content/themes/twentyten/header.php b/src/wp-content/themes/twentyten/header.php index 6f3330796e..0349d0489c 100644 --- a/src/wp-content/themes/twentyten/header.php +++ b/src/wp-content/themes/twentyten/header.php @@ -86,7 +86,7 @@ if ( is_singular() && get_option( 'thread_comments' ) ) { $header_image_width = HEADER_IMAGE_WIDTH; } - // Check if this is a post or page, if it has a thumbnail, and if it's a big one + // Check if this is a post or page, if it has a thumbnail, and if it's a big one. if ( is_singular() && has_post_thumbnail( $post->ID ) ) { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ); if ( $image && $image[1] >= $header_image_width ) { @@ -105,15 +105,19 @@ if ( is_singular() && get_option( 'thread_comments' ) ) { ?> <img src="<?php header_image(); ?>" width="<?php echo esc_attr( $header_image_width ); ?>" height="<?php echo esc_attr( $header_image_height ); ?>" alt="" /> <?php - } // end check for featured image or standard header + } // End check for featured image or standard header. ?> </div><!-- #branding --> <div id="access" role="navigation"> - <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?> + <?php // Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. ?> <div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div> - <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?> <?php + /* + * Our navigation menu. If one isn't filled out, wp_nav_menu() falls back to wp_page_menu(). + * The menu assigned to the primary location is the one used. + * If one isn't assigned, the menu with the lowest ID is used. + */ wp_nav_menu( array( 'container_class' => 'menu-header', diff --git a/src/wp-content/themes/twentyten/loop-attachment.php b/src/wp-content/themes/twentyten/loop-attachment.php index 235c7dcc1c..bf1af53c54 100644 --- a/src/wp-content/themes/twentyten/loop-attachment.php +++ b/src/wp-content/themes/twentyten/loop-attachment.php @@ -105,40 +105,42 @@ if ( have_posts() ) { } } - // If there is more than 1 image attachment in a gallery + // If there is more than 1 image attachment in a gallery... if ( count( $attachments ) > 1 ) { $k++; if ( isset( $attachments[ $k ] ) ) { - // get the URL of the next image attachment + // ...get the URL of the next image attachment. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); - } else { // or get the URL of the first image attachment + } else { + // ...or get the URL of the first image attachment. $next_attachment_url = get_attachment_link( $attachments[0]->ID ); } } else { - // or, if there's only 1 image attachment, get the URL of the image + // Or, if there's only 1 image attachment, get the URL of the image. $next_attachment_url = wp_get_attachment_url(); } ?> <p class="attachment"><a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"> - <?php - /** - * Filter the Twenty Ten default attachment width. - * - * @since Twenty Ten 1.0 - * - * @param int The default attachment width in pixels. Default 900. - */ - $attachment_width = apply_filters( 'twentyten_attachment_size', 900 ); - /** - * Filter the Twenty Ten default attachment height. - * - * @since Twenty Ten 1.0 - * - * @param int The default attachment height in pixels. Default 900. - */ - $attachment_height = apply_filters( 'twentyten_attachment_height', 900 ); - echo wp_get_attachment_image( $post->ID, array( $attachment_width, $attachment_height ) ); // filterable image width with, essentially, no limit for image height. - ?> + <?php + /** + * Filter the Twenty Ten default attachment width. + * + * @since Twenty Ten 1.0 + * + * @param int The default attachment width in pixels. Default 900. + */ + $attachment_width = apply_filters( 'twentyten_attachment_size', 900 ); + /** + * Filter the Twenty Ten default attachment height. + * + * @since Twenty Ten 1.0 + * + * @param int The default attachment height in pixels. Default 900. + */ + $attachment_height = apply_filters( 'twentyten_attachment_height', 900 ); + // Filterable image width with, essentially, no limit for image height. + echo wp_get_attachment_image( $post->ID, array( $attachment_width, $attachment_height ) ); + ?> </a></p> <div id="nav-below" class="navigation"> @@ -177,4 +179,4 @@ if ( have_posts() ) { <?php comments_template(); ?> <?php endwhile; -}; // end of the loop. ?> +}; // End of the loop. ?> diff --git a/src/wp-content/themes/twentyten/loop-page.php b/src/wp-content/themes/twentyten/loop-page.php index 7a38f28f5f..d086648313 100644 --- a/src/wp-content/themes/twentyten/loop-page.php +++ b/src/wp-content/themes/twentyten/loop-page.php @@ -45,4 +45,4 @@ if ( have_posts() ) { <?php comments_template( '', true ); ?> <?php endwhile; -}; // end of the loop. ?> +}; // End of the loop. ?> diff --git a/src/wp-content/themes/twentyten/loop-single.php b/src/wp-content/themes/twentyten/loop-single.php index 4ae519be81..b51154e752 100644 --- a/src/wp-content/themes/twentyten/loop-single.php +++ b/src/wp-content/themes/twentyten/loop-single.php @@ -45,7 +45,7 @@ if ( have_posts() ) { ?> </div><!-- .entry-content --> - <?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries ?> + <?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries. ?> <div id="entry-author-info"> <div id="author-avatar"> <?php @@ -88,4 +88,4 @@ if ( have_posts() ) { <?php comments_template( '', true ); ?> <?php endwhile; -}; // end of the loop. ?> +}; // End of the loop. ?> diff --git a/src/wp-content/themes/twentyten/loop.php b/src/wp-content/themes/twentyten/loop.php index ebff81ec9f..fbe541096e 100644 --- a/src/wp-content/themes/twentyten/loop.php +++ b/src/wp-content/themes/twentyten/loop.php @@ -19,7 +19,7 @@ */ ?> -<?php /* Display navigation to next/previous pages when applicable */ ?> +<?php // Display navigation to next/previous pages when applicable. ?> <?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="nav-above" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div> @@ -94,7 +94,7 @@ while ( have_posts() ) : ); ?> </em></p> - <?php endif; // end twentyten_get_gallery_images() check ?> + <?php endif; // End twentyten_get_gallery_images() check. ?> <?php the_excerpt(); ?> <?php endif; ?> </div><!-- .entry-content --> @@ -197,9 +197,9 @@ while ( have_posts() ) : <?php endif; // This was the if statement that broke the loop into three parts based on categories. ?> -<?php endwhile; // End the loop. Whew. ?> +<?php endwhile; // End of the loop. Whew. ?> -<?php /* Display navigation to next/previous pages when applicable */ ?> +<?php // Display navigation to next/previous pages when applicable. ?> <?php if ( $wp_query->max_num_pages > 1 ) : ?> <div id="nav-below" class="navigation"> <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'twentyten' ) ); ?></div> diff --git a/src/wp-content/themes/twentyten/sidebar.php b/src/wp-content/themes/twentyten/sidebar.php index 40018d2f47..c3a618d14b 100644 --- a/src/wp-content/themes/twentyten/sidebar.php +++ b/src/wp-content/themes/twentyten/sidebar.php @@ -41,7 +41,7 @@ if ( ! dynamic_sidebar( 'primary-widget-area' ) ) : </ul> </li> - <?php endif; // end primary widget area ?> + <?php endif; // End primary widget area. ?> </ul> </div><!-- #primary .widget-area --> diff --git a/src/wp-content/themes/twentyten/tag.php b/src/wp-content/themes/twentyten/tag.php index 6eec1a1eea..dde9e32b86 100644 --- a/src/wp-content/themes/twentyten/tag.php +++ b/src/wp-content/themes/twentyten/tag.php @@ -19,14 +19,14 @@ get_header(); ?> ?> </h1> -<?php -/* - * Run the loop for the tag archive to output the posts - * If you want to overload this in a child theme then include a file - * called loop-tag.php and that will be used instead. - */ -get_template_part( 'loop', 'tag' ); -?> + <?php + /* + * Run the loop for the tag archive to output the posts + * If you want to overload this in a child theme then include a file + * called loop-tag.php and that will be used instead. + */ + get_template_part( 'loop', 'tag' ); + ?> </div><!-- #content --> </div><!-- #container --> diff --git a/src/wp-content/themes/twentythirteen/archive.php b/src/wp-content/themes/twentythirteen/archive.php index 9d2f0fe631..b4dc2eaa0c 100644 --- a/src/wp-content/themes/twentythirteen/archive.php +++ b/src/wp-content/themes/twentythirteen/archive.php @@ -42,8 +42,8 @@ get_header(); ?> </h1> </header><!-- .archive-header --> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentythirteen/author.php b/src/wp-content/themes/twentythirteen/author.php index 4756f01213..1b18c99966 100644 --- a/src/wp-content/themes/twentythirteen/author.php +++ b/src/wp-content/themes/twentythirteen/author.php @@ -38,9 +38,9 @@ get_header(); ?> <?php /* - * Since we called the_post() above, we need to - * rewind the loop back to the beginning that way - * we can run the loop properly, in full. + * Since we called the_post() above, we need + * to rewind the loop back to the beginning. + * That way we can run the loop properly, in full. */ rewind_posts(); ?> @@ -49,8 +49,8 @@ get_header(); ?> <?php get_template_part( 'author-bio' ); ?> <?php endif; ?> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentythirteen/category.php b/src/wp-content/themes/twentythirteen/category.php index 04de0383d0..e9250d4e03 100644 --- a/src/wp-content/themes/twentythirteen/category.php +++ b/src/wp-content/themes/twentythirteen/category.php @@ -23,13 +23,13 @@ get_header(); ?> ?> </h1> - <?php if ( category_description() ) : // Show an optional category description ?> + <?php if ( category_description() ) : // Show an optional category description. ?> <div class="archive-meta"><?php echo category_description(); ?></div> <?php endif; ?> </header><!-- .archive-header --> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentythirteen/comments.php b/src/wp-content/themes/twentythirteen/comments.php index 6348145780..a01ba833c0 100644 --- a/src/wp-content/themes/twentythirteen/comments.php +++ b/src/wp-content/themes/twentythirteen/comments.php @@ -61,7 +61,7 @@ if ( post_password_required() ) { <div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'twentythirteen' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'twentythirteen' ) ); ?></div> </nav><!-- .comment-navigation --> - <?php endif; // Check for comment navigation ?> + <?php endif; // Check for comment navigation. ?> <?php if ( ! comments_open() && get_comments_number() ) : ?> <p class="no-comments"><?php _e( 'Comments are closed.', 'twentythirteen' ); ?></p> diff --git a/src/wp-content/themes/twentythirteen/content.php b/src/wp-content/themes/twentythirteen/content.php index f575af8411..2f2c29a888 100644 --- a/src/wp-content/themes/twentythirteen/content.php +++ b/src/wp-content/themes/twentythirteen/content.php @@ -32,7 +32,7 @@ </div><!-- .entry-meta --> </header><!-- .entry-header --> - <?php if ( is_search() ) : // Only display Excerpts for Search ?> + <?php if ( is_search() ) : // Only display excerpts for search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> diff --git a/src/wp-content/themes/twentythirteen/functions.php b/src/wp-content/themes/twentythirteen/functions.php index 92723d4ea6..cf9718c76c 100644 --- a/src/wp-content/themes/twentythirteen/functions.php +++ b/src/wp-content/themes/twentythirteen/functions.php @@ -494,7 +494,7 @@ if ( ! function_exists( 'twentythirteen_entry_meta' ) ) : echo '<span class="tags-links">' . $tag_list . '</span>'; } - // Post author + // Post author. if ( 'post' == get_post_type() ) { printf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>', @@ -592,11 +592,11 @@ if ( ! function_exists( 'twentythirteen_the_attached_image' ) ) : } } - // get the URL of the next image attachment... if ( $next_id ) { + // ...get the URL of the next image attachment. $next_attachment_url = get_attachment_link( $next_id ); } else { - // or get the URL of the first image attachment. + // ...or get the URL of the first image attachment. $next_attachment_url = get_attachment_link( reset( $attachment_ids ) ); } } @@ -812,7 +812,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Thirteen 2.8 */ diff --git a/src/wp-content/themes/twentythirteen/image.php b/src/wp-content/themes/twentythirteen/image.php index 1ebbfc7af5..9404b1215e 100644 --- a/src/wp-content/themes/twentythirteen/image.php +++ b/src/wp-content/themes/twentythirteen/image.php @@ -15,7 +15,7 @@ get_header(); ?> <div id="content" class="site-content" role="main"> <?php - // Start the Loop. + // Start the loop. while ( have_posts() ) : the_post(); ?> @@ -94,7 +94,7 @@ get_header(); ?> <?php comments_template(); ?> - <?php endwhile; // End the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentythirteen/index.php b/src/wp-content/themes/twentythirteen/index.php index ec8de084dd..c68b3379e4 100644 --- a/src/wp-content/themes/twentythirteen/index.php +++ b/src/wp-content/themes/twentythirteen/index.php @@ -20,8 +20,8 @@ get_header(); ?> <div id="content" class="site-content" role="main"> <?php if ( have_posts() ) : ?> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentythirteen/page.php b/src/wp-content/themes/twentythirteen/page.php index 5fad9750e0..3a95900951 100644 --- a/src/wp-content/themes/twentythirteen/page.php +++ b/src/wp-content/themes/twentythirteen/page.php @@ -16,8 +16,8 @@ get_header(); ?> <div id="primary" class="content-area"> <div id="content" class="site-content" role="main"> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentythirteen/search.php b/src/wp-content/themes/twentythirteen/search.php index 2193ed4771..a94d48a2c9 100644 --- a/src/wp-content/themes/twentythirteen/search.php +++ b/src/wp-content/themes/twentythirteen/search.php @@ -23,8 +23,8 @@ get_header(); ?> </h1> </header> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentythirteen/single.php b/src/wp-content/themes/twentythirteen/single.php index 587ae86561..a5f7eeaa3c 100644 --- a/src/wp-content/themes/twentythirteen/single.php +++ b/src/wp-content/themes/twentythirteen/single.php @@ -12,8 +12,8 @@ get_header(); ?> <div id="primary" class="content-area"> <div id="content" class="site-content" role="main"> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentythirteen/tag.php b/src/wp-content/themes/twentythirteen/tag.php index dd020d6e64..bda7ed7be4 100644 --- a/src/wp-content/themes/twentythirteen/tag.php +++ b/src/wp-content/themes/twentythirteen/tag.php @@ -25,13 +25,13 @@ get_header(); ?> ?> </h1> - <?php if ( tag_description() ) : // Show an optional tag description ?> + <?php if ( tag_description() ) : // Show an optional tag description. ?> <div class="archive-meta"><?php echo tag_description(); ?></div> <?php endif; ?> </header><!-- .archive-header --> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentythirteen/taxonomy-post_format.php b/src/wp-content/themes/twentythirteen/taxonomy-post_format.php index 18673dd360..646d410625 100644 --- a/src/wp-content/themes/twentythirteen/taxonomy-post_format.php +++ b/src/wp-content/themes/twentythirteen/taxonomy-post_format.php @@ -28,8 +28,8 @@ get_header(); ?> </h1> </header><!-- .archive-header --> - <?php /* The loop */ ?> <?php + // Start the loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentytwelve/archive.php b/src/wp-content/themes/twentytwelve/archive.php index cb4d429f6b..b44a1c6c9f 100644 --- a/src/wp-content/themes/twentytwelve/archive.php +++ b/src/wp-content/themes/twentytwelve/archive.php @@ -43,12 +43,13 @@ get_header(); ?> </header><!-- .archive-header --> <?php - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); - /* Include the post format-specific template for the content. If you want to - * this in a child theme then include a file called content-___.php + /* + * Include the post format-specific template for the content. If you want + * to use this in a child theme then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentytwelve/author.php b/src/wp-content/themes/twentytwelve/author.php index 3a1e7a9f59..120ee066e2 100644 --- a/src/wp-content/themes/twentytwelve/author.php +++ b/src/wp-content/themes/twentytwelve/author.php @@ -19,7 +19,8 @@ get_header(); ?> <?php if ( have_posts() ) : ?> <?php - /* Queue the first post, that way we know + /* + * Queue the first post, that way we know * what author we're dealing with (if that is the case). * * We reset this later so we can run the loop @@ -38,9 +39,10 @@ get_header(); ?> </header><!-- .archive-header --> <?php - /* Since we called the_post() above, we need to - * rewind the loop back to the beginning that way - * we can run the loop properly, in full. + /* + * Since we called the_post() above, we need + * to rewind the loop back to the beginning. + * That way we can run the loop properly, in full. */ rewind_posts(); ?> @@ -77,8 +79,8 @@ get_header(); ?> </div><!-- .author-info --> <?php endif; ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentytwelve/category.php b/src/wp-content/themes/twentytwelve/category.php index 5d68df5454..ec8ce43f94 100644 --- a/src/wp-content/themes/twentytwelve/category.php +++ b/src/wp-content/themes/twentytwelve/category.php @@ -25,18 +25,19 @@ get_header(); ?> ?> </h1> - <?php if ( category_description() ) : // Show an optional category description ?> + <?php if ( category_description() ) : // Show an optional category description. ?> <div class="archive-meta"><?php echo category_description(); ?></div> <?php endif; ?> </header><!-- .archive-header --> <?php - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); - /* Include the post format-specific template for the content. If you want to - * this in a child theme then include a file called content-___.php + /* + * Include the post format-specific template for the content. If you want + * to use this in a child theme then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentytwelve/comments.php b/src/wp-content/themes/twentytwelve/comments.php index 5537fc460c..f78cb379af 100644 --- a/src/wp-content/themes/twentytwelve/comments.php +++ b/src/wp-content/themes/twentytwelve/comments.php @@ -57,16 +57,17 @@ if ( post_password_required() ) { ?> </ol><!-- .commentlist --> - <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // are there comments to navigate through ?> + <?php if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : // Are there comments to navigate through? ?> <nav id="comment-nav-below" class="navigation" role="navigation"> <h1 class="assistive-text section-heading"><?php _e( 'Comment navigation', 'twentytwelve' ); ?></h1> <div class="nav-previous"><?php previous_comments_link( __( '← Older Comments', 'twentytwelve' ) ); ?></div> <div class="nav-next"><?php next_comments_link( __( 'Newer Comments →', 'twentytwelve' ) ); ?></div> </nav> - <?php endif; // check for comment navigation ?> + <?php endif; // Check for comment navigation. ?> <?php - /* If there are no comments and comments are closed, let's leave a note. + /* + * If there are no comments and comments are closed, let's leave a note. * But we only want the note on posts and pages that had comments in the first place. */ if ( ! comments_open() && get_comments_number() ) : diff --git a/src/wp-content/themes/twentytwelve/content.php b/src/wp-content/themes/twentytwelve/content.php index e323195e14..102f0f814d 100644 --- a/src/wp-content/themes/twentytwelve/content.php +++ b/src/wp-content/themes/twentytwelve/content.php @@ -37,7 +37,7 @@ <?php endif; // comments_open() ?> </header><!-- .entry-header --> - <?php if ( is_search() ) : // Only display Excerpts for Search ?> + <?php if ( is_search() ) : // Only display excerpts for search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> @@ -58,7 +58,10 @@ <footer class="entry-meta"> <?php twentytwelve_entry_meta(); ?> <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?> - <?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?> + <?php + // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. + if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : + ?> <div class="author-info"> <div class="author-avatar"> <?php @@ -77,10 +80,10 @@ <p><?php the_author_meta( 'description' ); ?></p> <div class="author-link"> <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" rel="author"> - <?php - /* translators: %s: Author display name. */ - printf( __( 'View all posts by %s <span class="meta-nav">→</span>', 'twentytwelve' ), get_the_author() ); - ?> + <?php + /* translators: %s: Author display name. */ + printf( __( 'View all posts by %s <span class="meta-nav">→</span>', 'twentytwelve' ), get_the_author() ); + ?> </a> </div><!-- .author-link --> </div><!-- .author-description --> diff --git a/src/wp-content/themes/twentytwelve/functions.php b/src/wp-content/themes/twentytwelve/functions.php index 04da105b06..86c5f1130f 100644 --- a/src/wp-content/themes/twentytwelve/functions.php +++ b/src/wp-content/themes/twentytwelve/functions.php @@ -120,7 +120,7 @@ function twentytwelve_setup() { // This theme uses a custom image size for featured images, displayed on "standard" posts. add_theme_support( 'post-thumbnails' ); - set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop + set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop. // Indicate widget sidebars can use selective refresh in the Customizer. add_theme_support( 'customize-selective-refresh-widgets' ); @@ -482,7 +482,7 @@ if ( ! function_exists( 'twentytwelve_comment' ) ) : </article><!-- #comment-## --> <?php break; - endswitch; // end comment_type check + endswitch; // End comment_type check. } endif; @@ -706,7 +706,7 @@ if ( ! function_exists( 'wp_body_open' ) ) : /** * Fire the wp_body_open action. * - * Added for backwards compatibility to support pre 5.2.0 WordPress versions. + * Added for backward compatibility to support pre-5.2.0 WordPress versions. * * @since Twenty Twelve 3.0 */ diff --git a/src/wp-content/themes/twentytwelve/image.php b/src/wp-content/themes/twentytwelve/image.php index 1c7aff0b7e..dd15d651ae 100644 --- a/src/wp-content/themes/twentytwelve/image.php +++ b/src/wp-content/themes/twentytwelve/image.php @@ -73,38 +73,38 @@ get_header(); ?> if ( $attachment->ID == $post->ID ) { break; } -endforeach; + endforeach; - // If there is more than 1 attachment in a gallery + // If there is more than 1 attachment in a gallery... if ( count( $attachments ) > 1 ) : $k++; if ( isset( $attachments[ $k ] ) ) : - // get the URL of the next image attachment + // ...get the URL of the next image attachment. $next_attachment_url = get_attachment_link( $attachments[ $k ]->ID ); else : - // or get the URL of the first image attachment + // ...or get the URL of the first image attachment. $next_attachment_url = get_attachment_link( $attachments[0]->ID ); endif; -else : - // or, if there's only 1 image, get the URL of the image - $next_attachment_url = wp_get_attachment_url(); -endif; -?> + else : + // Or, if there's only 1 image, get the URL of the image. + $next_attachment_url = wp_get_attachment_url(); + endif; + ?> <a href="<?php echo esc_url( $next_attachment_url ); ?>" title="<?php the_title_attribute(); ?>" rel="attachment"> - <?php - /** - * Filter the image attachment size to use. - * - * @since Twenty Twelve 1.0 - * - * @param array $size { - * @type int The attachment height in pixels. - * @type int The attachment width in pixels. - * } - */ - $attachment_size = apply_filters( 'twentytwelve_attachment_size', array( 960, 960 ) ); - echo wp_get_attachment_image( $post->ID, $attachment_size ); - ?> + <?php + /** + * Filter the image attachment size to use. + * + * @since Twenty Twelve 1.0 + * + * @param array $size { + * @type int The attachment height in pixels. + * @type int The attachment width in pixels. + * } + */ + $attachment_size = apply_filters( 'twentytwelve_attachment_size', array( 960, 960 ) ); + echo wp_get_attachment_image( $post->ID, $attachment_size ); + ?> </a> <?php if ( ! empty( $post->post_excerpt ) ) : ?> @@ -134,7 +134,7 @@ endif; <?php comments_template(); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentytwelve/inc/custom-header.php b/src/wp-content/themes/twentytwelve/inc/custom-header.php index 636309b7c9..c985246f8b 100644 --- a/src/wp-content/themes/twentytwelve/inc/custom-header.php +++ b/src/wp-content/themes/twentytwelve/inc/custom-header.php @@ -70,7 +70,7 @@ add_action( 'admin_print_styles-appearance_page_custom-header', 'twentytwelve_cu function twentytwelve_header_style() { $text_color = get_header_textcolor(); - // If no custom options for text are set, let's bail + // If no custom options for text are set, let's bail. if ( $text_color == get_theme_support( 'custom-header', 'default-text-color' ) ) { return; } diff --git a/src/wp-content/themes/twentytwelve/index.php b/src/wp-content/themes/twentytwelve/index.php index c8bdc64a54..98649a8413 100644 --- a/src/wp-content/themes/twentytwelve/index.php +++ b/src/wp-content/themes/twentytwelve/index.php @@ -20,8 +20,8 @@ get_header(); ?> <div id="content" role="main"> <?php if ( have_posts() ) : ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> @@ -63,11 +63,11 @@ get_header(); ?> <p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p> <?php get_search_form(); ?> </div><!-- .entry-content --> - <?php endif; // end current_user_can() check ?> + <?php endif; // End current_user_can() check. ?> </article><!-- #post-0 --> - <?php endif; // end have_posts() check ?> + <?php endif; // End have_posts() check. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentytwelve/js/theme-customizer.js b/src/wp-content/themes/twentytwelve/js/theme-customizer.js index 8bf094be54..c388997da9 100644 --- a/src/wp-content/themes/twentytwelve/js/theme-customizer.js +++ b/src/wp-content/themes/twentytwelve/js/theme-customizer.js @@ -18,7 +18,7 @@ } ); } ); - // Header text color + // Header text color. wp.customize( 'header_textcolor', function( value ) { value.bind( function( to ) { if ( 'blank' === to ) { diff --git a/src/wp-content/themes/twentytwelve/page-templates/front-page.php b/src/wp-content/themes/twentytwelve/page-templates/front-page.php index 72efd0102b..28ce766b90 100644 --- a/src/wp-content/themes/twentytwelve/page-templates/front-page.php +++ b/src/wp-content/themes/twentytwelve/page-templates/front-page.php @@ -29,7 +29,7 @@ get_header(); ?> <?php get_template_part( 'content', 'page' ); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentytwelve/page-templates/full-width.php b/src/wp-content/themes/twentytwelve/page-templates/full-width.php index 13a1b39be9..370e76eaf8 100644 --- a/src/wp-content/themes/twentytwelve/page-templates/full-width.php +++ b/src/wp-content/themes/twentytwelve/page-templates/full-width.php @@ -25,7 +25,7 @@ get_header(); ?> ?> <?php get_template_part( 'content', 'page' ); ?> <?php comments_template( '', true ); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentytwelve/page.php b/src/wp-content/themes/twentytwelve/page.php index cf75606bd2..7107a61ce5 100644 --- a/src/wp-content/themes/twentytwelve/page.php +++ b/src/wp-content/themes/twentytwelve/page.php @@ -23,7 +23,7 @@ get_header(); ?> ?> <?php get_template_part( 'content', 'page' ); ?> <?php comments_template( '', true ); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentytwelve/search.php b/src/wp-content/themes/twentytwelve/search.php index 51c84522a3..99acfe4034 100644 --- a/src/wp-content/themes/twentytwelve/search.php +++ b/src/wp-content/themes/twentytwelve/search.php @@ -25,8 +25,8 @@ get_header(); ?> <?php twentytwelve_content_nav( 'nav-above' ); ?> - <?php /* Start the Loop */ ?> <?php + // Start the Loop. while ( have_posts() ) : the_post(); ?> diff --git a/src/wp-content/themes/twentytwelve/single.php b/src/wp-content/themes/twentytwelve/single.php index 10165cec39..4cc6a43a4b 100644 --- a/src/wp-content/themes/twentytwelve/single.php +++ b/src/wp-content/themes/twentytwelve/single.php @@ -27,7 +27,7 @@ get_header(); ?> <?php comments_template( '', true ); ?> - <?php endwhile; // end of the loop. ?> + <?php endwhile; // End of the loop. ?> </div><!-- #content --> </div><!-- #primary --> diff --git a/src/wp-content/themes/twentytwelve/tag.php b/src/wp-content/themes/twentytwelve/tag.php index 6d42da5bc3..041427729d 100644 --- a/src/wp-content/themes/twentytwelve/tag.php +++ b/src/wp-content/themes/twentytwelve/tag.php @@ -25,19 +25,19 @@ get_header(); ?> ?> </h1> - <?php if ( tag_description() ) : // Show an optional tag description ?> + <?php if ( tag_description() ) : // Show an optional tag description. ?> <div class="archive-meta"><?php echo tag_description(); ?></div> <?php endif; ?> </header><!-- .archive-header --> <?php - /* Start the Loop */ + // Start the Loop. while ( have_posts() ) : the_post(); /* - * Include the post format-specific template for the content. If you want to - * this in a child theme then include a file called content-___.php + * Include the post format-specific template for the content. If you want + * to use this in a child theme then include a file called content-___.php * (where ___ is the post format) and that will be used instead. */ get_template_part( 'content', get_post_format() ); diff --git a/src/wp-content/themes/twentytwenty/assets/js/color-calculations.js b/src/wp-content/themes/twentytwenty/assets/js/color-calculations.js index 5cecc1d76f..2587a48153 100644 --- a/src/wp-content/themes/twentytwenty/assets/js/color-calculations.js +++ b/src/wp-content/themes/twentytwenty/assets/js/color-calculations.js @@ -52,6 +52,7 @@ _twentyTwentyColor.prototype.setAccentColorsArray = function() { * Get a score for this color in contrast to its background color and surrounding text. * * @since Twenty Twenty 1.0 + * * @param {number} contrastBackground - WCAG contrast with the background color. * @param {number} contrastSurroundingText - WCAG contrast with surrounding text. * @return {number} - 0 is best, higher numbers have bigger difference with the desired scores. @@ -143,6 +144,7 @@ _twentyTwentyColor.prototype.getAccentColor = function() { * Return a new instance of the _twentyTwentyColor object. * * @since Twenty Twenty 1.0 + * * @param {string} backgroundColor - The background color. * @param {number} accentHue - The hue for our accent color. * @return {Object} - this diff --git a/src/wp-content/themes/twentytwenty/assets/js/customize-preview.js b/src/wp-content/themes/twentytwenty/assets/js/customize-preview.js index a191f44740..6bb361c740 100644 --- a/src/wp-content/themes/twentytwenty/assets/js/customize-preview.js +++ b/src/wp-content/themes/twentytwenty/assets/js/customize-preview.js @@ -25,11 +25,11 @@ return deferred.promise(); } - // Selective refresh for "Fixed Background Image" + // Selective refresh for "Fixed Background Image". api.selectiveRefresh.partialConstructor.cover_fixed = api.selectiveRefresh.Partial.extend( { /** - * Override the refresh method + * Override the refresh method. * * @return {jQuery.Promise} Resolved promise. */ @@ -49,7 +49,7 @@ } ); - // Selective refresh for "Image Overlay Opacity" + // Selective refresh for "Image Overlay Opacity". api.selectiveRefresh.partialConstructor.cover_opacity = api.selectiveRefresh.Partial.extend( { /** @@ -60,7 +60,7 @@ attrs: {}, /** - * Override the refresh method + * Override the refresh method. * * @return {jQuery.Promise} Resolved promise. */ diff --git a/src/wp-content/themes/twentytwenty/assets/js/index.js b/src/wp-content/themes/twentytwenty/assets/js/index.js index 5ded1852ac..b6919261e8 100644 --- a/src/wp-content/themes/twentytwenty/assets/js/index.js +++ b/src/wp-content/themes/twentytwenty/assets/js/index.js @@ -70,7 +70,7 @@ if ( ! Element.prototype.matches ) { } // Add a class to the body for when touch is enabled for browsers that don't support media queries -// for interaction media features. Adapted from <https://codepen.io/Ferie/pen/vQOMmO> +// for interaction media features. Adapted from <https://codepen.io/Ferie/pen/vQOMmO>. twentytwenty.touchEnabled = { init: function() { @@ -95,21 +95,21 @@ twentytwenty.coverModals = { init: function() { if ( document.querySelector( '.cover-modal' ) ) { - // Handle cover modals when they're toggled + // Handle cover modals when they're toggled. this.onToggle(); - // When toggled, untoggle if visitor clicks on the wrapping element of the modal + // When toggled, untoggle if visitor clicks on the wrapping element of the modal. this.outsideUntoggle(); - // Close on escape key press + // Close on escape key press. this.closeOnEscape(); - // Hide and show modals before and after their animations have played out + // Hide and show modals before and after their animations have played out. this.hideAndShowModals(); } }, - // Handle cover modals when they're toggled + // Handle cover modals when they're toggled. onToggle: function() { document.querySelectorAll( '.cover-modal' ).forEach( function( element ) { element.addEventListener( 'toggled', function( event ) { @@ -122,7 +122,7 @@ twentytwenty.coverModals = { body.classList.remove( 'showing-modal' ); body.classList.add( 'hiding-modal' ); - // Remove the hiding class after a delay, when animations have been run + // Remove the hiding class after a delay, when animations have been run. setTimeout( function() { body.classList.remove( 'hiding-modal' ); }, 500 ); @@ -131,7 +131,7 @@ twentytwenty.coverModals = { } ); }, - // Close modal on outside click + // Close modal on outside click. outsideUntoggle: function() { document.addEventListener( 'click', function( event ) { var target = event.target; @@ -143,7 +143,7 @@ twentytwenty.coverModals = { }.bind( this ) ); }, - // Close modal on escape key press + // Close modal on escape key press. closeOnEscape: function() { document.addEventListener( 'keydown', function( event ) { if ( event.keyCode === 27 ) { @@ -155,7 +155,7 @@ twentytwenty.coverModals = { }.bind( this ) ); }, - // Hide and show modals before and after their animations have played out + // Hide and show modals before and after their animations have played out. hideAndShowModals: function() { var _doc = document, _win = window, @@ -188,7 +188,7 @@ twentytwenty.coverModals = { }; } - // Show the modal + // Show the modal. modals.forEach( function( modal ) { modal.addEventListener( 'toggle-target-before-inactive', function( event ) { var styles = htmlStyles(), @@ -221,7 +221,7 @@ twentytwenty.coverModals = { modal.classList.add( 'show-modal' ); } ); - // Hide the modal after a delay, so animations have time to play out + // Hide the modal after a delay, so animations have time to play out. modal.addEventListener( 'toggle-target-after-inactive', function( event ) { if ( event.target !== modal ) { return; @@ -254,24 +254,24 @@ twentytwenty.coverModals = { } ); }, - // Untoggle a modal + // Untoggle a modal. untoggleModal: function( modal ) { var modalTargetClass, modalToggle = false; - // If the modal has specified the string (ID or class) used by toggles to target it, untoggle the toggles with that target string - // The modal-target-string must match the string toggles use to target the modal + // If the modal has specified the string (ID or class) used by toggles to target it, untoggle the toggles with that target string. + // The modal-target-string must match the string toggles use to target the modal. if ( modal.dataset.modalTargetString ) { modalTargetClass = modal.dataset.modalTargetString; modalToggle = document.querySelector( '*[data-toggle-target="' + modalTargetClass + '"]' ); } - // If a modal toggle exists, trigger it so all of the toggle options are included + // If a modal toggle exists, trigger it so all of the toggle options are included. if ( modalToggle ) { modalToggle.click(); - // If one doesn't exist, just hide the modal + // If one doesn't exist, just hide the modal. } else { modal.classList.remove( 'active' ); } @@ -298,23 +298,23 @@ twentytwenty.intrinsicRatioVideos = { var ratio, iTargetWidth, container = video.parentNode; - // Skip videos we want to ignore + // Skip videos we want to ignore. if ( video.classList.contains( 'intrinsic-ignore' ) || video.parentNode.classList.contains( 'intrinsic-ignore' ) ) { return true; } if ( ! video.dataset.origwidth ) { - // Get the video element proportions + // Get the video element proportions. video.setAttribute( 'data-origwidth', video.width ); video.setAttribute( 'data-origheight', video.height ); } iTargetWidth = container.offsetWidth; - // Get ratio from proportions + // Get ratio from proportions. ratio = iTargetWidth / video.dataset.origwidth; - // Scale based on ratio, thus retaining proportions + // Scale based on ratio, thus retaining proportions. video.style.width = iTargetWidth + 'px'; video.style.height = ( video.dataset.origheight * ratio ) + 'px'; } ); @@ -328,7 +328,7 @@ twentytwenty.intrinsicRatioVideos = { twentytwenty.modalMenu = { init: function() { - // If the current menu item is in a sub level, expand all the levels higher up on load + // If the current menu item is in a sub level, expand all the levels higher up on load. this.expandLevel(); this.keepFocusInModal(); }, @@ -462,13 +462,13 @@ twentytwenty.toggles = { clickedEl: false, init: function() { - // Do the toggle + // Do the toggle. this.toggle(); - // Check for toggle/untoggle on resize + // Check for toggle/untoggle on resize. this.resizeCheck(); - // Check for untoggle on escape key press + // Check for untoggle on escape key press. this.untoggleOnEscapeKeyPress(); }, @@ -476,12 +476,12 @@ twentytwenty.toggles = { var target, timeOutTime, classToToggle, self = this, _doc = document, - // Get our targets + // Get our targets. toggle = element, targetString = toggle.dataset.toggleTarget, activeClass = 'active'; - // Elements to focus after modals are closed + // Elements to focus after modals are closed. if ( ! _doc.querySelectorAll( '.show-modal' ).length ) { self.clickedEl = _doc.activeElement; } @@ -492,17 +492,17 @@ twentytwenty.toggles = { target = _doc.querySelector( targetString ); } - // Trigger events on the toggle targets before they are toggled + // Trigger events on the toggle targets before they are toggled. if ( target.classList.contains( activeClass ) ) { target.dispatchEvent( twentytwenty.createEvent( 'toggle-target-before-active' ) ); } else { target.dispatchEvent( twentytwenty.createEvent( 'toggle-target-before-inactive' ) ); } - // Get the class to toggle, if specified + // Get the class to toggle, if specified. classToToggle = toggle.dataset.classToToggle ? toggle.dataset.classToToggle : activeClass; - // For cover modals, set a short timeout duration so the class animations have time to play out + // For cover modals, set a short timeout duration so the class animations have time to play out. timeOutTime = 0; if ( target.classList.contains( 'cover-modal' ) ) { @@ -515,36 +515,36 @@ twentytwenty.toggles = { newTarget = subMenued ? toggle.closest( '.menu-item' ).querySelector( '.sub-menu' ) : target, duration = toggle.dataset.toggleDuration; - // Toggle the target of the clicked toggle + // Toggle the target of the clicked toggle. if ( toggle.dataset.toggleType === 'slidetoggle' && ! instantly && duration !== '0' ) { twentytwentyMenuToggle( newTarget, duration ); } else { newTarget.classList.toggle( classToToggle ); } - // If the toggle target is 'next', only give the clicked toggle the active class + // If the toggle target is 'next', only give the clicked toggle the active class. if ( targetString === 'next' ) { toggle.classList.toggle( activeClass ); } else if ( target.classList.contains( 'sub-menu' ) ) { toggle.classList.toggle( activeClass ); } else { - // If not, toggle all toggles with this toggle target + // If not, toggle all toggles with this toggle target. _doc.querySelector( '*[data-toggle-target="' + targetString + '"]' ).classList.toggle( activeClass ); } - // Toggle aria-expanded on the toggle + // Toggle aria-expanded on the toggle. twentytwentyToggleAttribute( toggle, 'aria-expanded', 'true', 'false' ); if ( self.clickedEl && -1 !== toggle.getAttribute( 'class' ).indexOf( 'close-' ) ) { twentytwentyToggleAttribute( self.clickedEl, 'aria-expanded', 'true', 'false' ); } - // Toggle body class + // Toggle body class. if ( toggle.dataset.toggleBodyClass ) { _doc.body.classList.toggle( toggle.dataset.toggleBodyClass ); } - // Check whether to set focus + // Check whether to set focus. if ( toggle.dataset.setFocus ) { focusElement = _doc.querySelector( toggle.dataset.setFocus ); @@ -557,10 +557,10 @@ twentytwenty.toggles = { } } - // Trigger the toggled event on the toggle target + // Trigger the toggled event on the toggle target. target.dispatchEvent( twentytwenty.createEvent( 'toggled' ) ); - // Trigger events on the toggle targets after they are toggled + // Trigger events on the toggle targets after they are toggled. if ( target.classList.contains( activeClass ) ) { target.dispatchEvent( twentytwenty.createEvent( 'toggle-target-after-active' ) ); } else { @@ -569,7 +569,7 @@ twentytwenty.toggles = { }, timeOutTime ); }, - // Do the toggle + // Do the toggle. toggle: function() { var self = this; @@ -581,7 +581,7 @@ twentytwenty.toggles = { } ); }, - // Check for toggle/untoggle on screen resize + // Check for toggle/untoggle on screen resize. resizeCheck: function() { if ( document.querySelectorAll( '*[data-untoggle-above], *[data-untoggle-below], *[data-toggle-above], *[data-toggle-below]' ).length ) { window.addEventListener( 'resize', function() { @@ -594,12 +594,12 @@ twentytwenty.toggles = { toggleAbove = toggle.dataset.toggleAbove, toggleBelow = toggle.dataset.toggleBelow; - // If no width comparison is set, continue + // If no width comparison is set, continue. if ( ! unToggleAbove && ! unToggleBelow && ! toggleAbove && ! toggleBelow ) { return; } - // If the toggle width comparison is true, toggle the toggle + // If the toggle width comparison is true, toggle the toggle. if ( ( ( ( unToggleAbove && winWidth > unToggleAbove ) || ( unToggleBelow && winWidth < unToggleBelow ) ) && @@ -615,7 +615,7 @@ twentytwenty.toggles = { } }, - // Close toggle on escape key press + // Close toggle on escape key press. untoggleOnEscapeKeyPress: function() { document.addEventListener( 'keyup', function( event ) { if ( event.key === 'Escape' ) { @@ -631,9 +631,9 @@ twentytwenty.toggles = { }; // twentytwenty.toggles /** - * Is the DOM ready + * Is the DOM ready? * - * this implementation is coming from https://gomakethings.com/a-native-javascript-equivalent-of-jquerys-ready-method/ + * This implementation is coming from https://gomakethings.com/a-native-javascript-equivalent-of-jquerys-ready-method/ * * @param {Function} fn Callback function to run. */ @@ -650,12 +650,12 @@ function twentytwentyDomReady( fn ) { } twentytwentyDomReady( function() { - twentytwenty.toggles.init(); // Handle toggles - twentytwenty.coverModals.init(); // Handle cover modals - twentytwenty.intrinsicRatioVideos.init(); // Retain aspect ratio of videos on window resize - twentytwenty.modalMenu.init(); // Modal Menu - twentytwenty.primaryMenu.init(); // Primary Menu - twentytwenty.touchEnabled.init(); // Add class to body if device is touch-enabled + twentytwenty.toggles.init(); // Handle toggles. + twentytwenty.coverModals.init(); // Handle cover modals. + twentytwenty.intrinsicRatioVideos.init(); // Retain aspect ratio of videos on window resize. + twentytwenty.modalMenu.init(); // Modal Menu. + twentytwenty.primaryMenu.init(); // Primary Menu. + twentytwenty.touchEnabled.init(); // Add class to body if device is touch-enabled. } ); /* ----------------------------------------------------------------------------------------------- @@ -717,9 +717,11 @@ function twentytwentyMenuToggle( target, duration ) { // The whole process happens without giving the browser a chance to render, so it's invisible. target.classList.toggle( 'active' ); - // Step 4: prepare animation. - // Position all the items with absolute offsets, at the same starting position. - // Shouldn't result in any visual changes if done right. + /* + * Step 4: prepare animation. + * Position all the items with absolute offsets, at the same starting position. + * Shouldn't result in any visual changes if done right. + */ menu.classList.add( 'is-toggling' ); target.classList.toggle( 'active' ); menuItems.forEach( function( menuItem, index ) { @@ -730,15 +732,19 @@ function twentytwentyMenuToggle( target, duration ) { menuItem.style.transform = 'translate(' + initialPosition.x + 'px, ' + initialPosition.y + 'px)'; } ); - // The double rAF is unfortunately needed, since we're toggling CSS classes, and - // the only way to ensure layout completion here across browsers is to wait twice. - // This just delays the start of the animation by 2 frames and is thus not an issue. + /* + * The double rAF is unfortunately needed, since we're toggling CSS classes, and + * the only way to ensure layout completion here across browsers is to wait twice. + * This just delays the start of the animation by 2 frames and is thus not an issue. + */ requestAnimationFrame( function() { requestAnimationFrame( function() { - // Step 5: start animation by moving everything to final position. - // All the layout work has already happened, while we were preparing for the animation. - // The animation now runs entirely in CSS, using cheap CSS properties (opacity and transform) - // that don't trigger the layout or paint stages. + /* + * Step 5: start animation by moving everything to final position. + * All the layout work has already happened, while we were preparing for the animation. + * The animation now runs entirely in CSS, using cheap CSS properties (opacity and transform) + * that don't trigger the layout or paint stages. + */ menu.classList.add( 'is-animating' ); menuItems.forEach( function( menuItem, index ) { var finalPosition = finalPositions[ index ]; @@ -774,7 +780,7 @@ function twentytwentyMenuToggle( target, duration ) { } /** - * traverses the DOM up to find elements matching the query + * Traverses the DOM up to find elements matching the query. * * @param {HTMLElement} target * @param {string} query @@ -783,7 +789,7 @@ function twentytwentyMenuToggle( target, duration ) { function twentytwentyFindParents( target, query ) { var parents = []; - // recursively go up the DOM adding matches to the parents array + // Recursively go up the DOM adding matches to the parents array. function traverse( item ) { var parent = item.parentNode; if ( parent instanceof HTMLElement ) { diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php index ef1f2e66c2..df95c56a37 100644 --- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php +++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-non-latin-languages.php @@ -26,7 +26,7 @@ if ( ! class_exists( 'TwentyTwenty_Non_Latin_Languages' ) ) { */ public static function get_non_latin_css( $type = 'front-end' ) { - // Fetch users locale. + // Fetch site locale. $locale = get_bloginfo( 'language' ); // Define fallback fonts for non-latin languages. diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php index 88ccf641f9..cc05187bcb 100644 --- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php +++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-script-loader.php @@ -29,7 +29,7 @@ if ( ! class_exists( 'TwentyTwenty_Script_Loader' ) ) { * @return string Script HTML string. */ public function filter_script_loader_tag( $tag, $handle ) { - foreach ( [ 'async', 'defer' ] as $attr ) { + foreach ( array( 'async', 'defer' ) as $attr ) { if ( ! wp_scripts()->get_data( $handle, $attr ) ) { continue; } diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php index 4dcf4d59f4..6193d3cd68 100644 --- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php +++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php @@ -32,10 +32,10 @@ if ( ! class_exists( 'TwentyTwenty_SVG_Icons' ) ) { if ( array_key_exists( $icon, $arr ) ) { $repl = '<svg class="svg-icon" aria-hidden="true" role="img" focusable="false" '; $svg = preg_replace( '/^<svg /', $repl, trim( $arr[ $icon ] ) ); // Add extra attributes to SVG code. - $svg = str_replace( '#1A1A1B', $color, $svg ); // Replace the color. - $svg = str_replace( '#', '%23', $svg ); // Urlencode hashes. + $svg = str_replace( '#1A1A1B', $color, $svg ); // Replace the color. + $svg = str_replace( '#', '%23', $svg ); // Urlencode hashes. $svg = preg_replace( "/([\n\t]+)/", ' ', $svg ); // Remove newlines & tabs. - $svg = preg_replace( '/>\s*</', '><', $svg ); // Remove white space between SVG tags. + $svg = preg_replace( '/>\s*</', '><', $svg ); // Remove whitespace between SVG tags. return $svg; } return null; diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php index 727817c75e..eda038e3c8 100644 --- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php +++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-comment.php @@ -33,7 +33,7 @@ if ( ! class_exists( 'TwentyTwenty_Walker_Comment' ) ) { $tag = ( 'div' === $args['style'] ) ? 'div' : 'li'; ?> - <<?php echo $tag; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>> + <<?php echo $tag; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?> id="comment-<?php comment_ID(); ?>" <?php comment_class( $this->has_children ? 'parent' : '', $comment ); ?>> <article id="div-comment-<?php comment_ID(); ?>" class="comment-body"> <footer class="comment-meta"> <div class="comment-author vcard"> @@ -45,7 +45,7 @@ if ( ! class_exists( 'TwentyTwenty_Walker_Comment' ) ) { if ( empty( $comment_author_url ) ) { echo wp_kses_post( $avatar ); } else { - printf( '<a href="%s" rel="external nofollow" class="url">', $comment_author_url ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --Escaped in https://developer.wordpress.org/reference/functions/get_comment_author_url/ + printf( '<a href="%s" rel="external nofollow" class="url">', $comment_author_url ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --Escaped in https://developer.wordpress.org/reference/functions/get_comment_author_url/ echo wp_kses_post( $avatar ); } } @@ -65,7 +65,7 @@ if ( ! class_exists( 'TwentyTwenty_Walker_Comment' ) ) { <div class="comment-metadata"> <a href="<?php echo esc_url( get_comment_link( $comment, $args ) ); ?>"> <?php - /* Translators: 1 = comment date, 2 = comment time */ + /* translators: 1: Comment date, 2: Comment time. */ $comment_timestamp = sprintf( __( '%1$s at %2$s', 'twentytwenty' ), get_comment_date( '', $comment ), get_comment_time() ); ?> <time datetime="<?php comment_time( 'c' ); ?>" title="<?php echo esc_attr( $comment_timestamp ); ?>"> @@ -121,7 +121,7 @@ if ( ! class_exists( 'TwentyTwenty_Walker_Comment' ) ) { <?php if ( $comment_reply_link ) { - echo $comment_reply_link; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --Link is escaped in https://developer.wordpress.org/reference/functions/get_comment_reply_link/ + echo $comment_reply_link; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Link is escaped in https://developer.wordpress.org/reference/functions/get_comment_reply_link/ } if ( $by_post_author ) { echo '<span class="by-post-author">' . __( 'By Post Author', 'twentytwenty' ) . '</span>'; diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-page.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-page.php index 0b16a1bf5e..62de1f76bd 100644 --- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-page.php +++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-walker-page.php @@ -66,7 +66,7 @@ if ( ! class_exists( 'TwentyTwenty_Walker_Page' ) ) { $css_classes = $css_classes ? ' class="' . esc_attr( $css_classes ) . '"' : ''; if ( '' === $page->post_title ) { - /* translators: %d: ID of a post */ + /* translators: %d: ID of a post. */ $page->post_title = sprintf( __( '#%d (no title)', 'twentytwenty' ), $page->ID ); } diff --git a/src/wp-content/themes/twentytwenty/comments.php b/src/wp-content/themes/twentytwenty/comments.php index 6a13a06c0c..9bc2d9b791 100644 --- a/src/wp-content/themes/twentytwenty/comments.php +++ b/src/wp-content/themes/twentytwenty/comments.php @@ -33,11 +33,11 @@ if ( $comments ) { if ( ! have_comments() ) { _e( 'Leave a comment', 'twentytwenty' ); } elseif ( '1' === $comments_number ) { - /* translators: %s: post title */ + /* translators: %s: Post title. */ printf( _x( 'One reply on “%s”', 'comments title', 'twentytwenty' ), get_the_title() ); } else { printf( - /* translators: 1: number of comments, 2: post title */ + /* translators: 1: Number of comments, 2: Post title. */ _nx( '%1$s reply on “%2$s”', '%1$s replies on “%2$s”', @@ -85,7 +85,7 @@ if ( $comments ) { } ?> - <nav class="comments-pagination pagination<?php echo $pagination_classes; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>" aria-label="<?php esc_attr_e( 'Comments', 'twentytwenty' ); ?>"> + <nav class="comments-pagination pagination<?php echo $pagination_classes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>" aria-label="<?php esc_attr_e( 'Comments', 'twentytwenty' ); ?>"> <?php echo wp_kses_post( $comment_pagination ); ?> </nav> diff --git a/src/wp-content/themes/twentytwenty/footer.php b/src/wp-content/themes/twentytwenty/footer.php index cadabad9d2..2571f5dcff 100644 --- a/src/wp-content/themes/twentytwenty/footer.php +++ b/src/wp-content/themes/twentytwenty/footer.php @@ -39,13 +39,13 @@ <a class="to-the-top" href="#site-header"> <span class="to-the-top-long"> <?php - /* translators: %s: HTML character for up arrow */ + /* translators: %s: HTML character for up arrow. */ printf( __( 'To the top %s', 'twentytwenty' ), '<span class="arrow" aria-hidden="true">↑</span>' ); ?> </span><!-- .to-the-top-long --> <span class="to-the-top-short"> <?php - /* translators: %s: HTML character for up arrow */ + /* translators: %s: HTML character for up arrow. */ printf( __( 'Up %s', 'twentytwenty' ), '<span class="arrow" aria-hidden="true">↑</span>' ); ?> </span><!-- .to-the-top-short --> diff --git a/src/wp-content/themes/twentytwenty/functions.php b/src/wp-content/themes/twentytwenty/functions.php index e6522027b8..049bbec5af 100644 --- a/src/wp-content/themes/twentytwenty/functions.php +++ b/src/wp-content/themes/twentytwenty/functions.php @@ -324,7 +324,7 @@ add_filter( 'get_custom_logo', 'twentytwenty_get_custom_logo' ); if ( ! function_exists( 'wp_body_open' ) ) { /** - * Shim for wp_body_open, ensuring backwards compatibility with versions of WordPress older than 5.2. + * Shim for wp_body_open, ensuring backward compatibility with versions of WordPress older than 5.2. */ function wp_body_open() { do_action( 'wp_body_open' ); diff --git a/src/wp-content/themes/twentytwenty/inc/custom-css.php b/src/wp-content/themes/twentytwenty/inc/custom-css.php index 8805165e1f..7c40de2eaa 100644 --- a/src/wp-content/themes/twentytwenty/inc/custom-css.php +++ b/src/wp-content/themes/twentytwenty/inc/custom-css.php @@ -35,7 +35,7 @@ if ( ! function_exists( 'twentytwenty_generate_css' ) ) { if ( $echo ) { - echo $return; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;) + echo $return; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;) } diff --git a/src/wp-content/themes/twentytwenty/inc/svg-icons.php b/src/wp-content/themes/twentytwenty/inc/svg-icons.php index 28979e8724..8882a13843 100644 --- a/src/wp-content/themes/twentytwenty/inc/svg-icons.php +++ b/src/wp-content/themes/twentytwenty/inc/svg-icons.php @@ -17,7 +17,7 @@ if ( ! function_exists( 'twentytwenty_the_theme_svg' ) ) { * @param string $color Color code. */ function twentytwenty_the_theme_svg( $svg_name, $group = 'ui', $color = '' ) { - echo twentytwenty_get_theme_svg( $svg_name, $group, $color ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_theme_svg();. + echo twentytwenty_get_theme_svg( $svg_name, $group, $color ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_theme_svg(). } } diff --git a/src/wp-content/themes/twentytwenty/inc/template-tags.php b/src/wp-content/themes/twentytwenty/inc/template-tags.php index afa7ab10c4..95c2e6070b 100644 --- a/src/wp-content/themes/twentytwenty/inc/template-tags.php +++ b/src/wp-content/themes/twentytwenty/inc/template-tags.php @@ -81,7 +81,7 @@ function twentytwenty_site_logo( $args = array(), $echo = true ) { return $html; } - echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } @@ -118,7 +118,7 @@ function twentytwenty_site_description( $echo = true ) { return $html; } - echo $html; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** @@ -178,7 +178,7 @@ add_filter( 'comment_reply_link', 'twentytwenty_filter_comment_reply_link' ); */ function twentytwenty_the_post_meta( $post_id = null, $location = 'single-top' ) { - echo twentytwenty_get_post_meta( $post_id, $location ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_post_meta(). + echo twentytwenty_get_post_meta( $post_id, $location ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped in twentytwenty_get_post_meta(). } @@ -350,7 +350,7 @@ function twentytwenty_get_post_meta( $post_id = null, $location = 'single-top' ) <span class="meta-text"> <?php printf( - /* translators: %s: Author name */ + /* translators: %s: Author name. */ __( 'By %s', 'twentytwenty' ), '<a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author_meta( 'display_name' ) ) . '</a>' ); diff --git a/src/wp-content/themes/twentytwenty/index.php b/src/wp-content/themes/twentytwenty/index.php index 79afa62920..54700e8862 100644 --- a/src/wp-content/themes/twentytwenty/index.php +++ b/src/wp-content/themes/twentytwenty/index.php @@ -35,7 +35,7 @@ get_header(); if ( $wp_query->found_posts ) { $archive_subtitle = sprintf( - /* translators: %s: Number of search results */ + /* translators: %s: Number of search results. */ _n( 'We found %s result for your search.', 'We found %s results for your search.', diff --git a/src/wp-content/themes/twentytwenty/searchform.php b/src/wp-content/themes/twentytwenty/searchform.php index 4631398fb3..027127b208 100644 --- a/src/wp-content/themes/twentytwenty/searchform.php +++ b/src/wp-content/themes/twentytwenty/searchform.php @@ -12,8 +12,8 @@ */ /* - * Generate a unique ID for each form and a string containing an aria-label if - * one was passed to get_search_form() in the args array. + * Generate a unique ID for each form and a string containing an aria-label + * if one was passed to get_search_form() in the args array. */ $unique_id = twentytwenty_unique_id( 'search-form-' ); diff --git a/src/wp-content/themes/twentytwenty/template-parts/content-cover.php b/src/wp-content/themes/twentytwenty/template-parts/content-cover.php index e1a76ec033..883032e5f3 100644 --- a/src/wp-content/themes/twentytwenty/template-parts/content-cover.php +++ b/src/wp-content/themes/twentytwenty/template-parts/content-cover.php @@ -44,10 +44,10 @@ $color_overlay_classes .= ' opacity-' . $color_overlay_opacity; ?> - <div class="cover-header <?php echo $cover_header_classes; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"<?php echo $cover_header_style; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;) ?>> + <div class="cover-header <?php echo $cover_header_classes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"<?php echo $cover_header_style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;) ?>> <div class="cover-header-inner-wrapper screen-height"> <div class="cover-header-inner"> - <div class="cover-color-overlay color-accent<?php echo esc_attr( $color_overlay_classes ); ?>"<?php echo $color_overlay_style; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;) ?>></div> + <div class="cover-color-overlay color-accent<?php echo esc_attr( $color_overlay_classes ); ?>"<?php echo $color_overlay_style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- We need to double check this, but for now, we want to pass PHPCS ;) ?>></div> <header class="entry-header has-text-align-center"> <div class="entry-header-inner section-inner medium"> diff --git a/src/wp-content/themes/twentytwenty/template-parts/entry-author-bio.php b/src/wp-content/themes/twentytwenty/template-parts/entry-author-bio.php index 801d92fd6d..b96fa310df 100644 --- a/src/wp-content/themes/twentytwenty/template-parts/entry-author-bio.php +++ b/src/wp-content/themes/twentytwenty/template-parts/entry-author-bio.php @@ -16,7 +16,7 @@ if ( (bool) get_the_author_meta( 'description' ) && (bool) get_theme_mod( 'show_ <h2 class="author-title heading-size-4"> <?php printf( - /* translators: %s: Author name */ + /* translators: %s: Author name. */ __( 'By %s', 'twentytwenty' ), esc_html( get_the_author() ) ); diff --git a/src/wp-content/themes/twentytwenty/template-parts/entry-header.php b/src/wp-content/themes/twentytwenty/template-parts/entry-header.php index 0cc56c4342..b5b6909fdb 100644 --- a/src/wp-content/themes/twentytwenty/template-parts/entry-header.php +++ b/src/wp-content/themes/twentytwenty/template-parts/entry-header.php @@ -59,7 +59,7 @@ if ( is_singular() ) { if ( has_excerpt() && is_singular() ) { ?> - <div class="intro-text section-inner max-percentage<?php echo $intro_text_width; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"> + <div class="intro-text section-inner max-percentage<?php echo $intro_text_width; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"> <?php the_excerpt(); ?> </div> diff --git a/src/wp-content/themes/twentytwenty/template-parts/featured-image.php b/src/wp-content/themes/twentytwenty/template-parts/featured-image.php index 7af668aa09..81283782df 100644 --- a/src/wp-content/themes/twentytwenty/template-parts/featured-image.php +++ b/src/wp-content/themes/twentytwenty/template-parts/featured-image.php @@ -19,7 +19,7 @@ if ( has_post_thumbnail() && ! post_password_required() ) { <figure class="featured-media"> - <div class="featured-media-inner section-inner<?php echo $featured_media_inner_classes; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"> + <div class="featured-media-inner section-inner<?php echo $featured_media_inner_classes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"> <?php the_post_thumbnail(); diff --git a/src/wp-content/themes/twentytwenty/template-parts/footer-menus-widgets.php b/src/wp-content/themes/twentytwenty/template-parts/footer-menus-widgets.php index 11c368002e..bb3e69678e 100644 --- a/src/wp-content/themes/twentytwenty/template-parts/footer-menus-widgets.php +++ b/src/wp-content/themes/twentytwenty/template-parts/footer-menus-widgets.php @@ -31,7 +31,7 @@ if ( $has_footer_menu || $has_social_menu || $has_sidebar_1 || $has_sidebar_2 ) if ( $has_footer_menu || $has_social_menu ) { ?> - <div class="footer-top<?php echo $footer_top_classes; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"> + <div class="footer-top<?php echo $footer_top_classes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static output ?>"> <?php if ( $has_footer_menu ) { ?> <nav aria-label="<?php esc_attr_e( 'Footer', 'twentytwenty' ); ?>" role="navigation" class="footer-menu-wrapper"> diff --git a/src/wp-content/themes/twentytwenty/template-parts/pagination.php b/src/wp-content/themes/twentytwenty/template-parts/pagination.php index 9ffdafdef7..23c8bfb79f 100644 --- a/src/wp-content/themes/twentytwenty/template-parts/pagination.php +++ b/src/wp-content/themes/twentytwenty/template-parts/pagination.php @@ -34,12 +34,12 @@ $posts_pagination = get_the_posts_pagination( ) ); -// If we're not outputting the previous page link, prepend a placeholder with visibility: hidden to take its place. +// If we're not outputting the previous page link, prepend a placeholder with `visibility: hidden` to take its place. if ( strpos( $posts_pagination, 'prev page-numbers' ) === false ) { $posts_pagination = str_replace( '<div class="nav-links">', '<div class="nav-links"><span class="prev page-numbers placeholder" aria-hidden="true">' . $prev_text . '</span>', $posts_pagination ); } -// If we're not outputting the next page link, append a placeholder with visibility: hidden to take its place. +// If we're not outputting the next page link, append a placeholder with `visibility: hidden` to take its place. if ( strpos( $posts_pagination, 'next page-numbers' ) === false ) { $posts_pagination = str_replace( '</div>', '<span class="next page-numbers placeholder" aria-hidden="true">' . $next_text . '</span></div>', $posts_pagination ); } @@ -50,7 +50,7 @@ if ( $posts_pagination ) { ?> <hr class="styled-separator pagination-separator is-style-wide" aria-hidden="true" /> - <?php echo $posts_pagination; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped during generation. ?> + <?php echo $posts_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped during generation. ?> </div><!-- .pagination-wrapper --> diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index 77ab5848ee..2f52797141 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -134,7 +134,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) { $wp_admin_bar->add_node( $wp_logo_menu_args ); if ( $about_url ) { - // Add "About WordPress" link + // Add "About WordPress" link. $wp_admin_bar->add_node( array( 'parent' => 'wp-logo', @@ -145,7 +145,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) { ); } - // Add WordPress.org link + // Add WordPress.org link. $wp_admin_bar->add_node( array( 'parent' => 'wp-logo-external', @@ -155,7 +155,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) { ) ); - // Add codex link + // Add Codex link. $wp_admin_bar->add_node( array( 'parent' => 'wp-logo-external', @@ -165,7 +165,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) { ) ); - // Add forums link + // Add forums link. $wp_admin_bar->add_node( array( 'parent' => 'wp-logo-external', @@ -175,7 +175,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) { ) ); - // Add feedback link + // Add feedback link. $wp_admin_bar->add_node( array( 'parent' => 'wp-logo-external', @@ -555,7 +555,7 @@ function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { } } - // Add site links + // Add site links. $wp_admin_bar->add_group( array( 'parent' => 'my-sites', diff --git a/src/wp-includes/author-template.php b/src/wp-includes/author-template.php index 6b18cad722..2646fb94c3 100644 --- a/src/wp-includes/author-template.php +++ b/src/wp-includes/author-template.php @@ -566,6 +566,6 @@ function is_multi_author() { * @since 3.2.0 * @access private */ -function __clear_multi_author_cache() { //phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore +function __clear_multi_author_cache() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore delete_transient( 'is_multi_author' ); } diff --git a/src/wp-includes/bookmark-template.php b/src/wp-includes/bookmark-template.php index e73f50c73d..604034d82f 100644 --- a/src/wp-includes/bookmark-template.php +++ b/src/wp-includes/bookmark-template.php @@ -116,7 +116,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) { if ( $bookmark->link_image != null && $parsed_args['show_images'] ) { if ( strpos( $bookmark->link_image, 'http' ) === 0 ) { $output .= "<img src=\"$bookmark->link_image\" $alt $title />"; - } else { // If it's a relative path + } else { // If it's a relative path. $output .= '<img src="' . get_option( 'siteurl' ) . "$bookmark->link_image\" $alt $title />"; } if ( $parsed_args['show_name'] ) { @@ -147,7 +147,7 @@ function _walk_bookmarks( $bookmarks, $args = '' ) { ); } $output .= $parsed_args['after'] . "\n"; - } // end while + } // End while. return $output; } @@ -254,7 +254,7 @@ function wp_list_bookmarks( $args = '' ) { } if ( $parsed_args['categorize'] ) { - // Split the bookmarks into ul's for each category + // Split the bookmarks into ul's for each category. foreach ( (array) $cats as $cat ) { $params = array_merge( $parsed_args, array( 'category' => $cat->term_id ) ); $bookmarks = get_bookmarks( $params ); @@ -284,7 +284,7 @@ function wp_list_bookmarks( $args = '' ) { $output .= $parsed_args['category_after'] . "\n"; } } else { - //output one single list using title_li for the title + // Output one single list using title_li for the title. $bookmarks = get_bookmarks( $parsed_args ); if ( ! empty( $bookmarks ) ) { diff --git a/src/wp-includes/bookmark.php b/src/wp-includes/bookmark.php index f131427bab..529d493311 100644 --- a/src/wp-includes/bookmark.php +++ b/src/wp-includes/bookmark.php @@ -180,7 +180,7 @@ function get_bookmarks( $args = '' ) { $inclusions = ''; if ( ! empty( $parsed_args['include'] ) ) { - $parsed_args['exclude'] = ''; //ignore exclude, category, and category_name params if using include + $parsed_args['exclude'] = ''; // Ignore exclude, category, and category_name params if using include. $parsed_args['category'] = ''; $parsed_args['category_name'] = ''; @@ -404,7 +404,7 @@ function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) { case 'link_category': // array( ints ) $value = array_map( 'absint', (array) $value ); // We return here so that the categories aren't filtered. - // The 'link_category' filter is for the name of a link category, not an array of a link's link categories + // The 'link_category' filter is for the name of a link category, not an array of a link's link categories. return $value; case 'link_visible': // bool stored as Y|N diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php index 6be007dc78..7d8c5ace6a 100644 --- a/src/wp-includes/canonical.php +++ b/src/wp-includes/canonical.php @@ -47,7 +47,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } // If we're not in wp-admin and the post has been published and preview nonce - // is non-existent or invalid then no need for preview in query + // is non-existent or invalid then no need for preview in query. if ( is_preview() && get_query_var( 'p' ) && 'publish' == get_post_status( get_query_var( 'p' ) ) ) { if ( ! isset( $_GET['preview_id'] ) || ! isset( $_GET['preview_nonce'] ) @@ -61,7 +61,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } if ( ! $requested_url && isset( $_SERVER['HTTP_HOST'] ) ) { - // build the URL in the address bar + // Build the URL in the address bar. $requested_url = is_ssl() ? 'https://' : 'http://'; $requested_url .= $_SERVER['HTTP_HOST']; $requested_url .= $_SERVER['REQUEST_URI']; @@ -75,7 +75,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect = $original; $redirect_url = false; - // Notice fixing + // Notice fixing. if ( ! isset( $redirect['path'] ) ) { $redirect['path'] = ''; } @@ -83,12 +83,14 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect['query'] = ''; } - // If the original URL ended with non-breaking spaces, they were almost - // certainly inserted by accident. Let's remove them, so the reader doesn't - // see a 404 error with no obvious cause. + /* + * If the original URL ended with non-breaking spaces, they were almost + * certainly inserted by accident. Let's remove them, so the reader doesn't + * see a 404 error with no obvious cause. + */ $redirect['path'] = preg_replace( '|(%C2%A0)+$|i', '', $redirect['path'] ); - // It's not a preview, so remove it from URL + // It's not a preview, so remove it from URL. if ( get_query_var( 'preview' ) ) { $redirect['query'] = remove_query_arg( 'preview', $redirect['query'] ); } @@ -120,10 +122,10 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } } - // These tests give us a WP-generated permalink + // These tests give us a WP-generated permalink. if ( is_404() ) { - // Redirect ?page_id, ?p=, ?attachment_id= to their respective url's + // Redirect ?page_id, ?p=, ?attachment_id= to their respective URLs. $id = max( get_query_var( 'p' ), get_query_var( 'page_id' ), get_query_var( 'attachment_id' ) ); $redirect_post = $id ? get_post( $id ) : false; if ( $redirect_post ) { @@ -162,7 +164,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect_url = get_permalink( $wp_query->post->ID ); } } elseif ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) { - // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 + // Rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101. if ( is_attachment() && ! array_diff( array_keys( $wp->query_vars ), array( 'attachment', 'attachment_id' ) ) && ! $redirect_url ) { @@ -199,20 +201,20 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } elseif ( ! empty( $_GET['m'] ) && ( is_year() || is_month() || is_day() ) ) { $m = get_query_var( 'm' ); switch ( strlen( $m ) ) { - case 4: // Yearly + case 4: // Yearly. $redirect_url = get_year_link( $m ); break; - case 6: // Monthly + case 6: // Monthly. $redirect_url = get_month_link( substr( $m, 0, 4 ), substr( $m, 4, 2 ) ); break; - case 8: // Daily + case 8: // Daily. $redirect_url = get_day_link( substr( $m, 0, 4 ), substr( $m, 4, 2 ), substr( $m, 6, 2 ) ); break; } if ( $redirect_url ) { $redirect['query'] = remove_query_arg( 'm', $redirect['query'] ); } - // now moving on to non ?m=X year/month/day links + // Now moving on to non ?m=X year/month/day links. } elseif ( is_day() && get_query_var( 'year' ) && get_query_var( 'monthnum' ) && ! empty( $_GET['day'] ) ) { $redirect_url = get_day_link( get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) ); if ( $redirect_url ) { @@ -236,7 +238,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect['query'] = remove_query_arg( 'author', $redirect['query'] ); } } - } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories) + } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (tags/categories). $term_count = 0; foreach ( $wp_query->tax_query->queried_terms as $tax_query ) { @@ -248,7 +250,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $tax_url = get_term_link( (int) $obj->term_id, $obj->taxonomy ); if ( $tax_url && ! is_wp_error( $tax_url ) ) { if ( ! empty( $redirect['query'] ) ) { - // Strip taxonomy query vars off the url. + // Strip taxonomy query vars off the URL. $qv_remove = array( 'term', 'taxonomy' ); if ( is_category() ) { $qv_remove[] = 'category_name'; @@ -256,7 +258,8 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } elseif ( is_tag() ) { $qv_remove[] = 'tag'; $qv_remove[] = 'tag_id'; - } else { // Custom taxonomies will have a custom query var, remove those too: + } else { + // Custom taxonomies will have a custom query var, remove those too. $tax_obj = get_taxonomy( $obj->taxonomy ); if ( false !== $tax_obj->query_var ) { $qv_remove[] = $tax_obj->query_var; @@ -265,18 +268,23 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $rewrite_vars = array_diff( array_keys( $wp_query->query ), array_keys( $_GET ) ); - if ( ! array_diff( $rewrite_vars, array_keys( $_GET ) ) ) { // Check to see if all the Query vars are coming from the rewrite, none are set via $_GET - $redirect['query'] = remove_query_arg( $qv_remove, $redirect['query'] ); //Remove all of the per-tax qv's + // Check to see if all the query vars are coming from the rewrite, none are set via $_GET. + if ( ! array_diff( $rewrite_vars, array_keys( $_GET ) ) ) { + // Remove all of the per-tax query vars. + $redirect['query'] = remove_query_arg( $qv_remove, $redirect['query'] ); - // Create the destination url for this taxonomy + // Create the destination URL for this taxonomy. $tax_url = parse_url( $tax_url ); - if ( ! empty( $tax_url['query'] ) ) { // Taxonomy accessible via ?taxonomy=..&term=.. or any custom qv.. + if ( ! empty( $tax_url['query'] ) ) { + // Taxonomy accessible via ?taxonomy=...&term=... or any custom query var. parse_str( $tax_url['query'], $query_vars ); $redirect['query'] = add_query_arg( $query_vars, $redirect['query'] ); - } else { // Taxonomy is accessible via a "pretty-URL" + } else { + // Taxonomy is accessible via a "pretty URL". $redirect['path'] = $tax_url['path']; } - } else { // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite + } else { + // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite. foreach ( $qv_remove as $_qv ) { if ( isset( $rewrite_vars[ $_qv ] ) ) { $redirect['query'] = remove_query_arg( $_qv, $redirect['query'] ); @@ -296,7 +304,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } } - // Post Paging + // Post paging. if ( is_singular() && get_query_var( 'page' ) ) { if ( ! $redirect_url ) { $redirect_url = get_permalink( get_queried_object_id() ); @@ -313,13 +321,13 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); } - // paging and feeds + // Paging and feeds. if ( get_query_var( 'paged' ) || is_feed() || get_query_var( 'cpage' ) ) { while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) { - // Strip off paging and feed - $redirect['path'] = preg_replace( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path'] ); // strip off any existing paging - $redirect['path'] = preg_replace( '#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path'] ); // strip off feed endings - $redirect['path'] = preg_replace( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path'] ); // strip off any existing comment paging + // Strip off paging and feed. + $redirect['path'] = preg_replace( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path'] ); // Strip off any existing paging. + $redirect['path'] = preg_replace( '#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path'] ); // Strip off feed endings. + $redirect['path'] = preg_replace( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path'] ); // Strip off any existing comment paging. } $addl_path = ''; @@ -372,7 +380,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); } - $redirect['path'] = user_trailingslashit( preg_replace( '|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path'] ) ); // strip off trailing /index.php/ + $redirect['path'] = user_trailingslashit( preg_replace( '|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path'] ) ); // Strip off trailing /index.php/. if ( ! empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos( $redirect['path'], '/' . $wp_rewrite->index . '/' ) === false ) { $redirect['path'] = trailingslashit( $redirect['path'] ) . $wp_rewrite->index . '/'; } @@ -395,7 +403,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { } } - // tack on any additional query vars + // Tack on any additional query vars. $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] ); if ( $redirect_url && ! empty( $redirect['query'] ) ) { parse_str( $redirect['query'], $_parsed_query ); @@ -420,7 +428,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect = @parse_url( $redirect_url ); } - // www.example.com vs example.com + // www.example.com vs. example.com $user_home = @parse_url( home_url() ); if ( ! empty( $user_home['host'] ) ) { $redirect['host'] = $user_home['host']; @@ -429,14 +437,14 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $user_home['path'] = '/'; } - // Handle ports + // Handle ports. if ( ! empty( $user_home['port'] ) ) { $redirect['port'] = $user_home['port']; } else { unset( $redirect['port'] ); } - // trailing /index.php + // Trailing /index.php. $redirect['path'] = preg_replace( '|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path'] ); $punctuation_pattern = implode( @@ -445,29 +453,29 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { 'preg_quote', array( ' ', - '%20', // space + '%20', // Space. '!', - '%21', // exclamation mark + '%21', // Exclamation mark. '"', - '%22', // double quote + '%22', // Double quote. "'", - '%27', // single quote + '%27', // Single quote. '(', - '%28', // opening bracket + '%28', // Opening bracket. ')', - '%29', // closing bracket + '%29', // Closing bracket. ',', - '%2C', // comma + '%2C', // Comma. '.', - '%2E', // period + '%2E', // Period. ';', - '%3B', // semicolon + '%3B', // Semicolon. '{', - '%7B', // opening curly bracket + '%7B', // Opening curly bracket. '}', - '%7D', // closing curly bracket - '%E2%80%9C', // opening curly quote - '%E2%80%9D', // closing curly quote + '%7D', // Closing curly bracket. + '%E2%80%9C', // Opening curly quote. + '%E2%80%9D', // Closing curly quote. ) ) ); @@ -479,22 +487,22 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { // Remove trailing spaces and end punctuation from certain terminating query string args. $redirect['query'] = preg_replace( "#((p|page_id|cat|tag)=[^&]*?)($punctuation_pattern)+$#", '$1', $redirect['query'] ); - // Clean up empty query strings + // Clean up empty query strings. $redirect['query'] = trim( preg_replace( '#(^|&)(p|page_id|cat|tag)=?(&|$)#', '&', $redirect['query'] ), '&' ); - // Redirect obsolete feeds + // Redirect obsolete feeds. $redirect['query'] = preg_replace( '#(^|&)feed=rss(&|$)#', '$1feed=rss2$2', $redirect['query'] ); - // Remove redundant leading ampersands + // Remove redundant leading ampersands. $redirect['query'] = preg_replace( '#^\??&*?#', '', $redirect['query'] ); } - // strip /index.php/ when we're not using PATHINFO permalinks + // Strip /index.php/ when we're not using PATHINFO permalinks. if ( ! $wp_rewrite->using_index_permalinks() ) { $redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] ); } - // trailing slashes + // Trailing slashes. if ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() && ! is_404() && ( ! is_front_page() || ( is_front_page() && ( get_query_var( 'paged' ) > 1 ) ) ) ) { $user_ts_type = ''; if ( get_query_var( 'paged' ) > 0 ) { @@ -513,18 +521,18 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { $redirect['path'] = trailingslashit( $redirect['path'] ); } - // Strip multiple slashes out of the URL + // Strip multiple slashes out of the URL. if ( strpos( $redirect['path'], '//' ) > -1 ) { $redirect['path'] = preg_replace( '|/+|', '/', $redirect['path'] ); } - // Always trailing slash the Front Page URL + // Always trailing slash the Front Page URL. if ( trailingslashit( $redirect['path'] ) == trailingslashit( $user_home['path'] ) ) { $redirect['path'] = trailingslashit( $redirect['path'] ); } - // Ignore differences in host capitalization, as this can lead to infinite redirects - // Only redirect no-www <=> yes-www + // Ignore differences in host capitalization, as this can lead to infinite redirects. + // Only redirect no-www <=> yes-www. if ( strtolower( $original['host'] ) == strtolower( $redirect['host'] ) || ( strtolower( $original['host'] ) != 'www.' . strtolower( $redirect['host'] ) && 'www.' . strtolower( $original['host'] ) != strtolower( $redirect['host'] ) ) ) { $redirect['host'] = $original['host']; @@ -596,18 +604,18 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { */ $redirect_url = apply_filters( 'redirect_canonical', $redirect_url, $requested_url ); - // yes, again -- in case the filter aborted the request + // Yes, again -- in case the filter aborted the request. if ( ! $redirect_url || strip_fragment_from_url( $redirect_url ) == strip_fragment_from_url( $requested_url ) ) { return; } if ( $do_redirect ) { - // protect against chained redirects + // Protect against chained redirects. if ( ! redirect_canonical( $redirect_url, false ) ) { wp_redirect( $redirect_url, 301 ); exit(); } else { - // Debug + // Debug. // die("1: $redirect_url<br />2: " . redirect_canonical( $redirect_url, false ) ); return; } @@ -687,7 +695,7 @@ function redirect_guess_404_permalink() { if ( get_query_var( 'name' ) ) { $where = $wpdb->prepare( 'post_name LIKE %s', $wpdb->esc_like( get_query_var( 'name' ) ) . '%' ); - // if any of post_type, year, monthnum, or day are set, use them to refine the query + // If any of post_type, year, monthnum, or day are set, use them to refine the query. if ( get_query_var( 'post_type' ) ) { $where .= $wpdb->prepare( ' AND post_type = %s', get_query_var( 'post_type' ) ); } else { diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php index 0c40c7e384..38287dc7c3 100644 --- a/src/wp-includes/capabilities.php +++ b/src/wp-includes/capabilities.php @@ -53,7 +53,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { break; case 'edit_user': case 'edit_users': - // Allow user to edit itself + // Allow user to edit themselves. if ( 'edit_user' == $cap && isset( $args[0] ) && $user_id == $args[0] ) { break; } @@ -137,7 +137,7 @@ function map_meta_cap( $cap, $user_id, ...$args ) { break; // edit_post breaks down to edit_posts, edit_published_posts, or - // edit_others_posts + // edit_others_posts. case 'edit_post': case 'edit_page': $post = get_post( $args[0] ); @@ -910,7 +910,7 @@ function grant_super_admin( $user_id ) { */ do_action( 'grant_super_admin', $user_id ); - // Directly fetch site_admins instead of using get_super_admins() + // Directly fetch site_admins instead of using get_super_admins(). $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); $user = get_userdata( $user_id ); @@ -957,7 +957,7 @@ function revoke_super_admin( $user_id ) { */ do_action( 'revoke_super_admin', $user_id ); - // Directly fetch site_admins instead of using get_super_admins() + // Directly fetch site_admins instead of using get_super_admins(). $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); $user = get_userdata( $user_id ); diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php index 63fda9eafd..4374359780 100644 --- a/src/wp-includes/category-template.php +++ b/src/wp-includes/category-template.php @@ -706,7 +706,7 @@ function wp_tag_cloud( $args = '' ) { 'order' => 'DESC', ) ) - ); // Always query top tags + ); // Always query top tags. if ( empty( $tags ) || is_wp_error( $tags ) ) { return; @@ -727,7 +727,8 @@ function wp_tag_cloud( $args = '' ) { $tags[ $key ]->id = $tag->term_id; } - $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args + // Here's where those top tags get sorted according to $args. + $return = wp_generate_tag_cloud( $tags, $args ); /** * Filters the tag cloud output. @@ -889,7 +890,7 @@ function wp_generate_tag_cloud( $tags, $args = '' ) { } $counts = array(); - $real_counts = array(); // For the alt tag + $real_counts = array(); // For the alt tag. foreach ( (array) $tags as $key => $tag ) { $real_counts[ $key ] = $tag->count; $counts[ $key ] = call_user_func( $args['topic_count_scale_callback'], $tag->count ); @@ -1053,7 +1054,7 @@ function _wp_object_count_sort_cb( $a, $b ) { } // -// Helper functions +// Helper functions. // /** @@ -1103,7 +1104,7 @@ function walk_category_dropdown_tree( ...$args ) { } // -// Tags +// Tags. // /** diff --git a/src/wp-includes/category.php b/src/wp-includes/category.php index 26b7ebe308..a0fe2b48e1 100644 --- a/src/wp-includes/category.php +++ b/src/wp-includes/category.php @@ -36,7 +36,7 @@ function get_categories( $args = '' ) { */ $args['taxonomy'] = apply_filters( 'get_categories_taxonomy', $args['taxonomy'], $args ); - // Back compat + // Back compat. if ( isset( $args['type'] ) && 'link' == $args['type'] ) { _deprecated_argument( __FUNCTION__, diff --git a/src/wp-includes/class-http.php b/src/wp-includes/class-http.php index 9e18811c28..2064950462 100644 --- a/src/wp-includes/class-http.php +++ b/src/wp-includes/class-http.php @@ -943,15 +943,15 @@ class WP_Http { return $maybe_relative_path; } - // Check for a scheme on the 'relative' url + // Check for a scheme on the 'relative' URL. if ( ! empty( $relative_url_parts['scheme'] ) ) { return $maybe_relative_path; } $absolute_path = $url_parts['scheme'] . '://'; - // Schemeless URLs will make it this far, so we check for a host in the relative url - // and convert it to a protocol-url + // Schemeless URLs will make it this far, so we check for a host in the relative URL + // and convert it to a protocol-URL. if ( isset( $relative_url_parts['host'] ) ) { $absolute_path .= $relative_url_parts['host']; if ( isset( $relative_url_parts['port'] ) ) { @@ -964,7 +964,7 @@ class WP_Http { } } - // Start off with the Absolute URL path. + // Start off with the absolute URL path. $path = ! empty( $url_parts['path'] ) ? $url_parts['path'] : '/'; // If it's a root-relative path, then great. @@ -988,7 +988,7 @@ class WP_Http { $path = preg_replace( '!^/(\.\./)+!', '', $path ); } - // Add the Query string. + // Add the query string. if ( ! empty( $relative_url_parts['query'] ) ) { $path .= '?' . $relative_url_parts['query']; } diff --git a/src/wp-includes/class-walker-nav-menu.php b/src/wp-includes/class-walker-nav-menu.php index 1d0fd714f7..5f4a53691c 100644 --- a/src/wp-includes/class-walker-nav-menu.php +++ b/src/wp-includes/class-walker-nav-menu.php @@ -270,4 +270,4 @@ class Walker_Nav_Menu extends Walker { $output .= "</li>{$n}"; } -} // Walker_Nav_Menu +} diff --git a/src/wp-includes/class-wp-admin-bar.php b/src/wp-includes/class-wp-admin-bar.php index 4a4cfc3bb4..519f382544 100644 --- a/src/wp-includes/class-wp-admin-bar.php +++ b/src/wp-includes/class-wp-admin-bar.php @@ -122,7 +122,7 @@ class WP_Admin_Bar { * } */ public function add_node( $args ) { - // Shim for old method signature: add_node( $parent_id, $menu_obj, $args ) + // Shim for old method signature: add_node( $parent_id, $menu_obj, $args ). if ( func_num_args() >= 3 && is_string( $args ) ) { $args = array_merge( array( 'parent' => $args ), func_get_arg( 2 ) ); } @@ -607,13 +607,13 @@ class WP_Admin_Bar { /** */ public function add_menus() { - // User related, aligned right. + // User-related, aligned right. add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 ); add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 ); add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 ); add_action( 'admin_bar_menu', 'wp_admin_bar_recovery_mode_menu', 8 ); - // Site related. + // Site-related. add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 ); add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 ); add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 ); @@ -621,7 +621,7 @@ class WP_Admin_Bar { add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 ); add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 ); - // Content related. + // Content-related. if ( ! is_network_admin() && ! is_user_admin() ) { add_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 ); add_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 70 ); diff --git a/src/wp-includes/class-wp-ajax-response.php b/src/wp-includes/class-wp-ajax-response.php index b8505d5964..43772d2610 100644 --- a/src/wp-includes/class-wp-ajax-response.php +++ b/src/wp-includes/class-wp-ajax-response.php @@ -129,7 +129,7 @@ class WP_Ajax_Response { $action = $_POST['action']; } $x = ''; - $x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action + $x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action. $x .= "<$what id='$id' " . ( false === $old_id ? '' : "old_id='$old_id' " ) . "position='$position'>"; $x .= $response; $x .= $s; diff --git a/src/wp-includes/class-wp-comment-query.php b/src/wp-includes/class-wp-comment-query.php index 9038b6194b..44def385cc 100644 --- a/src/wp-includes/class-wp-comment-query.php +++ b/src/wp-includes/class-wp-comment-query.php @@ -292,7 +292,7 @@ class WP_Comment_Query { 'meta_key' => '', 'meta_value' => '', 'meta_query' => '', - 'date_query' => null, // See WP_Date_Query + 'date_query' => null, // See WP_Date_Query. 'hierarchical' => false, 'cache_domain' => 'core', 'update_comment_meta_cache' => true, @@ -360,7 +360,7 @@ class WP_Comment_Query { $this->parse_query(); - // Parse meta query + // Parse meta query. $this->meta_query = new WP_Meta_Query(); $this->meta_query->parse_query_vars( $this->query_vars ); @@ -480,7 +480,7 @@ class WP_Comment_Query { */ $_comments = apply_filters_ref_array( 'the_comments', array( $_comments, &$this ) ); - // Convert to WP_Comment instances + // Convert to WP_Comment instances. $comments = array_map( 'get_comment', $_comments ); if ( $this->query_vars['hierarchical'] ) { @@ -734,7 +734,7 @@ class WP_Comment_Query { foreach ( $_raw_types as $type ) { switch ( $type ) { - // An empty translates to 'all', for backward compatibility + // An empty translates to 'all', for backward compatibility. case '': case 'all': break; diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index d65f82ad42..eb99381911 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -270,7 +270,8 @@ final class WP_Customize_Manager { $args['changeset_uuid'] = wp_generate_uuid4(); } - // The theme and messenger_channel should be supplied via $args, but they are also looked at in the $_REQUEST global here for back-compat. + // The theme and messenger_channel should be supplied via $args, + // but they are also looked at in the $_REQUEST global here for back-compat. if ( ! isset( $args['theme'] ) ) { if ( isset( $_REQUEST['customize_theme'] ) ) { $args['theme'] = wp_unslash( $_REQUEST['customize_theme'] ); @@ -383,7 +384,7 @@ final class WP_Customize_Manager { add_action( 'wp_ajax_customize_dismiss_autosave_or_lock', array( $this, 'handle_dismiss_autosave_or_lock_request' ) ); add_action( 'customize_register', array( $this, 'register_controls' ) ); - add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first + add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // Allow code to create settings first. add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) ); add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) ); @@ -504,7 +505,7 @@ final class WP_Customize_Manager { public function setup_theme() { global $pagenow; - // Check permissions for customize.php access since this method is called before customize.php can run any code, + // Check permissions for customize.php access since this method is called before customize.php can run any code. if ( 'customize.php' === $pagenow && ! current_user_can( 'customize' ) ) { if ( ! is_user_logged_in() ) { auth_redirect(); @@ -563,8 +564,8 @@ final class WP_Customize_Manager { // Once the theme is loaded, we'll validate it. add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) ); } else { - // If the requested theme is not the active theme and the user doesn't have the - // switch_themes cap, bail. + // If the requested theme is not the active theme and the user doesn't have + // the switch_themes cap, bail. if ( ! current_user_can( 'switch_themes' ) ) { $this->wp_die( -1, __( 'Sorry, you are not allowed to edit theme options on this site.' ) ); } @@ -898,7 +899,8 @@ final class WP_Customize_Manager { */ public function wp_loaded() { - // Unconditionally register core types for panels, sections, and controls in case plugin unhooks all customize_register actions. + // Unconditionally register core types for panels, sections, and controls + // in case plugin unhooks all customize_register actions. $this->register_panel_type( 'WP_Customize_Panel' ); $this->register_panel_type( 'WP_Customize_Themes_Panel' ); $this->register_section_type( 'WP_Customize_Section' ); @@ -2941,13 +2943,17 @@ final class WP_Customize_Manager { if ( $args['autosave'] && 'auto-draft' !== get_post_status( $changeset_post_id ) ) { // See _wp_translate_postdata() for why this is required as it will use the edit_post meta capability. add_filter( 'map_meta_cap', array( $this, 'grant_edit_post_capability_for_changeset' ), 10, 4 ); + $post_array['post_ID'] = $post_array['ID']; $post_array['post_type'] = 'customize_changeset'; - $r = wp_create_post_autosave( wp_slash( $post_array ) ); + + $r = wp_create_post_autosave( wp_slash( $post_array ) ); + remove_filter( 'map_meta_cap', array( $this, 'grant_edit_post_capability_for_changeset' ), 10 ); } else { $post_array['edit_date'] = true; // Prevent date clearing. - $r = wp_update_post( wp_slash( $post_array ), true ); + + $r = wp_update_post( wp_slash( $post_array ), true ); // Delete autosave revision for user when the changeset is updated. if ( ! empty( $args['user_id'] ) ) { @@ -3732,7 +3738,7 @@ final class WP_Customize_Manager { public function add_dynamic_settings( $setting_ids ) { $new_settings = array(); foreach ( $setting_ids as $setting_id ) { - // Skip settings already created + // Skip settings already created. if ( $this->get_setting( $setting_id ) ) { continue; } @@ -5202,8 +5208,8 @@ final class WP_Customize_Manager { ) ); - // Input type: checkbox - // With custom value + // Input type: checkbox. + // With custom value. $this->add_control( 'display_header_text', array( @@ -5226,8 +5232,8 @@ final class WP_Customize_Manager { ) ); - // Input type: Color - // With sanitize_callback + // Input type: color. + // With sanitize_callback. $this->add_setting( 'background_color', array( diff --git a/src/wp-includes/class-wp-customize-setting.php b/src/wp-includes/class-wp-customize-setting.php index c5efd0a7ee..c98c28a44b 100644 --- a/src/wp-includes/class-wp-customize-setting.php +++ b/src/wp-includes/class-wp-customize-setting.php @@ -861,7 +861,7 @@ class WP_Customize_Setting { if ( $create ) { if ( ! is_array( $node ) ) { - // account for an array overriding a string or object value + // Account for an array overriding a string or object value. $node = array(); } if ( ! isset( $node[ $last ] ) ) { diff --git a/src/wp-includes/class-wp-customize-widgets.php b/src/wp-includes/class-wp-customize-widgets.php index d899c26bf1..f1e6817d41 100644 --- a/src/wp-includes/class-wp-customize-widgets.php +++ b/src/wp-includes/class-wp-customize-widgets.php @@ -276,11 +276,11 @@ final class WP_Customize_Widgets { add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) ); $this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset. - // retrieve_widgets() looks at the global $sidebars_widgets + // retrieve_widgets() looks at the global $sidebars_widgets. $sidebars_widgets = $this->old_sidebars_widgets; $sidebars_widgets = retrieve_widgets( 'customize' ); add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 ); - // reset global cache var used by wp_get_sidebars_widgets() + // Reset global cache var used by wp_get_sidebars_widgets(). unset( $GLOBALS['_wp_sidebars_widgets'] ); } @@ -609,7 +609,7 @@ final class WP_Customize_Widgets { $parsed['id_base'] = $matches[1]; $parsed['number'] = intval( $matches[2] ); } else { - // likely an old single widget + // Likely an old single widget. $parsed['id_base'] = $widget_id; } return $parsed; @@ -772,7 +772,7 @@ final class WP_Customize_Widgets { $settings = array( 'registeredSidebars' => array_values( $wp_registered_sidebars ), 'registeredWidgets' => $wp_registered_widgets, - 'availableWidgets' => $available_widgets, // @todo Merge this with registered_widgets + 'availableWidgets' => $available_widgets, // @todo Merge this with registered_widgets. 'l10n' => array( 'saveBtnLabel' => __( 'Apply' ), 'saveBtnTooltip' => __( 'Save and preview changes before publishing them.' ), @@ -799,7 +799,7 @@ final class WP_Customize_Widgets { ); foreach ( $settings['registeredWidgets'] as &$registered_widget ) { - unset( $registered_widget['callback'] ); // may not be JSON-serializeable + unset( $registered_widget['callback'] ); // May not be JSON-serializeable. } $wp_scripts->add_data( @@ -949,14 +949,14 @@ final class WP_Customize_Widgets { } global $wp_registered_widgets, $wp_registered_widget_controls; - require_once ABSPATH . 'wp-admin/includes/widgets.php'; // for next_widget_id_number() + require_once ABSPATH . 'wp-admin/includes/widgets.php'; // For next_widget_id_number(). $sort = $wp_registered_widgets; usort( $sort, array( $this, '_sort_name_callback' ) ); $done = array(); 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; } @@ -968,7 +968,7 @@ final class WP_Customize_Widgets { } $available_widget = $widget; - unset( $available_widget['callback'] ); // not serializable to JSON + unset( $available_widget['callback'] ); // Not serializable to JSON. $args = array( 'widget_id' => $widget['id'], @@ -1190,7 +1190,7 @@ final class WP_Customize_Widgets { 'selectiveRefreshableWidgets' => $this->get_selective_refreshable_widgets(), ); foreach ( $settings['registeredWidgets'] as &$registered_widget ) { - unset( $registered_widget['callback'] ); // may not be JSON-serializeable + unset( $registered_widget['callback'] ); // May not be JSON-serializeable. } ?> @@ -1460,7 +1460,7 @@ final class WP_Customize_Widgets { } } - // Clean up any input vars that were manually added + // Clean up any input vars that were manually added. foreach ( $added_input_vars as $key ) { unset( $_POST[ $key ] ); unset( $_REQUEST[ $key ] ); @@ -1873,7 +1873,7 @@ final class WP_Customize_Widgets { } // - // Option Update Capturing + // Option Update Capturing. // /** diff --git a/src/wp-includes/class-wp-date-query.php b/src/wp-includes/class-wp-date-query.php index 34c5fa6dcb..8765c63401 100644 --- a/src/wp-includes/class-wp-date-query.php +++ b/src/wp-includes/class-wp-date-query.php @@ -273,7 +273,7 @@ class WP_Date_Query { * continue (though of course no items will be found for impossible dates). * This method only generates debug notices for these cases. * - * @since 4.1.0 + * @since 4.1.0 * * @param array $date_query The date_query array. * @return bool True if all values in the query are valid, false if one or more fail. @@ -315,7 +315,7 @@ class WP_Date_Query { $max_days_of_year = gmdate( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1; } else { - // otherwise we use the max of 366 (leap-year) + // Otherwise we use the max of 366 (leap-year). $max_days_of_year = 366; } @@ -675,7 +675,7 @@ class WP_Date_Query { * A wrapper for get_sql_for_clause(), included here for backward * compatibility while retaining the naming convention across Query classes. * - * @since 3.7.0 + * @since 3.7.0 * * @param array $query Date query arguments. * @return array { @@ -692,7 +692,7 @@ class WP_Date_Query { /** * Turns a first-order date query into SQL for a WHERE clause. * - * @since 4.1.0 + * @since 4.1.0 * * @param array $query Date query clause. * @param array $parent_query Parent query of the current date query. @@ -745,7 +745,7 @@ class WP_Date_Query { 'WEEKDAY' => array( 'dayofweek_iso' ), ); - // Check of the possible date units and add them to the query + // Check of the possible date units and add them to the query. foreach ( $date_units as $sql_part => $query_parts ) { foreach ( $query_parts as $query_part ) { if ( isset( $query[ $query_part ] ) ) { @@ -966,12 +966,12 @@ class WP_Date_Query { public function build_time_query( $column, $compare, $hour = null, $minute = null, $second = null ) { global $wpdb; - // Have to have at least one + // Have to have at least one. if ( ! isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) { return false; } - // Complex combined queries aren't supported for multi-value queries + // Complex combined queries aren't supported for multi-value queries. if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { $return = array(); @@ -993,7 +993,7 @@ class WP_Date_Query { return implode( ' AND ', $return ); } - // Cases where just one unit is set + // Cases where just one unit is set. if ( isset( $hour ) && ! isset( $minute ) && ! isset( $second ) ) { $value = $this->build_value( $compare, $hour ); if ( false !== $value ) { @@ -1019,7 +1019,7 @@ class WP_Date_Query { $format = ''; $time = ''; - // Hour + // Hour. if ( null !== $hour ) { $format .= '%H.'; $time .= sprintf( '%02d', $hour ) . '.'; @@ -1028,7 +1028,7 @@ class WP_Date_Query { $time .= '0.'; } - // Minute + // Minute. $format .= '%i'; $time .= sprintf( '%02d', $minute ); diff --git a/src/wp-includes/class-wp-editor.php b/src/wp-includes/class-wp-editor.php index 26824dfa9b..eece5f812f 100644 --- a/src/wp-includes/class-wp-editor.php +++ b/src/wp-includes/class-wp-editor.php @@ -293,7 +293,7 @@ final class _WP_Editors { remove_filter( 'the_editor_content', 'format_for_editor' ); } - // Back-compat for the `htmledit_pre` and `richedit_pre` filters + // Back-compat for the `htmledit_pre` and `richedit_pre` filters. if ( 'html' === $default_editor && has_filter( 'htmledit_pre' ) ) { /** This filter is documented in wp-includes/deprecated.php */ $content = apply_filters_deprecated( 'htmledit_pre', array( $content ), '4.3.0', 'format_for_editor' ); @@ -514,7 +514,7 @@ final class _WP_Editors { $plugurl = dirname( $url ); $strings = ''; - // Try to load langs/[locale].js and langs/[locale]_dlg.js + // Try to load langs/[locale].js and langs/[locale]_dlg.js. if ( ! in_array( $name, $loaded_langs, true ) ) { $path = str_replace( content_url(), '', $plugurl ); $path = WP_CONTENT_DIR . $path . '/langs/'; @@ -568,9 +568,11 @@ final class _WP_Editors { $mce_css = $settings['content_css']; - // The `editor-style.css` added by the theme is generally intended for the editor instance on the Edit Post screen. - // Plugins that use wp_editor() on the front-end can decide whether to add the theme stylesheet - // by using `get_editor_stylesheets()` and the `mce_css` or `tiny_mce_before_init` filters, see below. + /* + * The `editor-style.css` added by the theme is generally intended for the editor instance on the Edit Post screen. + * Plugins that use wp_editor() on the front-end can decide whether to add the theme stylesheet + * by using `get_editor_stylesheets()` and the `mce_css` or `tiny_mce_before_init` filters, see below. + */ if ( is_admin() ) { $editor_styles = get_editor_stylesheets(); @@ -771,7 +773,7 @@ final class _WP_Editors { 'body_class' => $body_class, ); - // Merge with the first part of the init array + // Merge with the first part of the init array. $mceInit = array_merge( self::$first_init, $mceInit ); if ( is_array( $set['tinymce'] ) ) { @@ -819,7 +821,7 @@ final class _WP_Editors { } self::$mce_settings[ $editor_id ] = $mceInit; - } // end if self::$this_tinymce + } // End if self::$this_tinymce. } /** @@ -913,7 +915,7 @@ final class _WP_Editors { self::enqueue_scripts( true ); - // Also add wp-includes/css/editor.css + // Also add wp-includes/css/editor.css. wp_enqueue_style( 'editor-buttons' ); if ( is_admin() ) { @@ -946,9 +948,11 @@ final class _WP_Editors { $settings['directionality'] = 'rtl'; } - // In production all plugins are loaded (they are in wp-editor.js.gz). - // The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default. - // Can be added from js by using the 'wp-before-tinymce-init' event. + /* + * In production all plugins are loaded (they are in wp-editor.js.gz). + * The 'wpview', 'wpdialogs', and 'media' TinyMCE plugins are not initialized by default. + * Can be added from js by using the 'wp-before-tinymce-init' event. + */ $settings['plugins'] = implode( ',', array( @@ -1033,7 +1037,7 @@ final class _WP_Editors { public static function get_mce_locale() { if ( empty( self::$mce_locale ) ) { $mce_locale = get_user_locale(); - self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1 + self::$mce_locale = empty( $mce_locale ) ? 'en' : strtolower( substr( $mce_locale, 0, 2 ) ); // ISO 639-1. } return self::$mce_locale; @@ -1107,7 +1111,7 @@ final class _WP_Editors { 'menubar' => false, 'branding' => false, - // Limit the preview styles in the menu/toolbar + // Limit the preview styles in the menu/toolbar. 'preview_styles' => 'font-family font-size font-weight font-style text-decoration text-transform', 'end_container_on_empty_block' => true, @@ -1120,7 +1124,7 @@ final class _WP_Editors { $suffix = SCRIPT_DEBUG ? '' : '.min'; $version = 'ver=' . get_bloginfo( 'version' ); - // Default stylesheets + // Default stylesheets. $settings['content_css'] = includes_url( "css/dashicons$suffix.css?$version" ) . ',' . includes_url( "js/tinymce/skins/wordpress/wp-content.css?$version" ); @@ -1135,7 +1139,7 @@ final class _WP_Editors { private static function get_translation() { if ( empty( self::$translation ) ) { self::$translation = array( - // Default TinyMCE strings + // Default TinyMCE strings. 'New document' => __( 'New document' ), 'Formats' => _x( 'Formats', 'TinyMCE' ), @@ -1200,7 +1204,7 @@ final class _WP_Editors { 'Upper Roman' => _x( 'Upper Roman', 'list style' ), 'Lower Roman' => _x( 'Lower Roman', 'list style' ), - // Anchor plugin + // Anchor plugin. 'Name' => _x( 'Name', 'Name of link anchor (TinyMCE)' ), 'Anchor' => _x( 'Anchor', 'Link anchor (TinyMCE)' ), 'Anchors' => _x( 'Anchors', 'Link anchors (TinyMCE)' ), @@ -1208,7 +1212,7 @@ final class _WP_Editors { __( 'Id should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.' ), 'Id' => _x( 'Id', 'Id for link anchor (TinyMCE)' ), - // Fullpage plugin + // Fullpage plugin. 'Document properties' => __( 'Document properties' ), 'Robots' => __( 'Robots' ), 'Title' => __( 'Title' ), @@ -1217,7 +1221,7 @@ final class _WP_Editors { 'Description' => __( 'Description' ), 'Author' => __( 'Author' ), - // Media, image plugins + // Media, image plugins. 'Image' => __( 'Image' ), 'Insert/edit image' => array( __( 'Insert/edit image' ), 'accessM' ), 'General' => __( 'General' ), @@ -1243,7 +1247,7 @@ final class _WP_Editors { 'Insert video' => __( 'Insert video' ), 'Embed' => __( 'Embed' ), - // Each of these have a corresponding plugin + // Each of these have a corresponding plugin. 'Special character' => __( 'Special character' ), 'Right to left' => _x( 'Right to left', 'editor button' ), 'Left to right' => _x( 'Left to right', 'editor button' ), @@ -1261,7 +1265,7 @@ final class _WP_Editors { 'Insert/edit link' => array( __( 'Insert/edit link' ), 'metaK' ), 'Remove link' => array( __( 'Remove link' ), 'accessS' ), - // Link plugin + // Link plugin. 'Link' => __( 'Link' ), 'Insert link' => __( 'Insert link' ), 'Target' => __( 'Target' ), @@ -1275,13 +1279,13 @@ final class _WP_Editors { 'Color' => __( 'Color' ), 'Custom color' => __( 'Custom color' ), - 'Custom...' => _x( 'Custom...', 'label for custom color' ), // no ellipsis + 'Custom...' => _x( 'Custom...', 'label for custom color' ), // No ellipsis. 'No color' => __( 'No color' ), 'R' => _x( 'R', 'Short for red in RGB' ), 'G' => _x( 'G', 'Short for green in RGB' ), 'B' => _x( 'B', 'Short for blue in RGB' ), - // Spelling, search/replace plugins + // Spelling, search/replace plugins. 'Could not find the specified string.' => __( 'Could not find the specified string.' ), 'Replace' => _x( 'Replace', 'find/replace' ), 'Next' => _x( 'Next', 'find/replace' ), @@ -1299,7 +1303,7 @@ final class _WP_Editors { 'Ignore' => _x( 'Ignore', 'spellcheck' ), 'Add to Dictionary' => __( 'Add to Dictionary' ), - // TinyMCE tables + // TinyMCE tables. 'Insert table' => __( 'Insert table' ), 'Delete table' => __( 'Delete table' ), 'Table properties' => __( 'Table properties' ), @@ -1373,7 +1377,7 @@ final class _WP_Editors { 'Your browser doesn\'t support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.' => __( 'Your browser does not support direct access to the clipboard. Please use keyboard shortcuts or your browser’s edit menu instead.' ), - // TinyMCE menus + // TinyMCE menus. 'Insert' => _x( 'Insert', 'TinyMCE menu' ), 'File' => _x( 'File', 'TinyMCE menu' ), 'Edit' => _x( 'Edit', 'TinyMCE menu' ), @@ -1382,23 +1386,23 @@ final class _WP_Editors { 'Table' => _x( 'Table', 'TinyMCE menu' ), 'Format' => _x( 'Format', 'TinyMCE menu' ), - // WordPress strings + // WordPress strings. 'Toolbar Toggle' => array( __( 'Toolbar Toggle' ), 'accessZ' ), 'Insert Read More tag' => array( __( 'Insert Read More tag' ), 'accessT' ), 'Insert Page Break tag' => array( __( 'Insert Page Break tag' ), 'accessP' ), - 'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor (no ellipsis) + 'Read more...' => __( 'Read more...' ), // Title on the placeholder inside the editor (no ellipsis). 'Distraction-free writing mode' => array( __( 'Distraction-free writing mode' ), 'accessW' ), - 'No alignment' => __( 'No alignment' ), // Tooltip for the 'alignnone' button in the image toolbar - 'Remove' => __( 'Remove' ), // Tooltip for the 'remove' button in the image toolbar - 'Edit|button' => __( 'Edit' ), // Tooltip for the 'edit' button in the image toolbar - 'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog - 'Apply' => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog - 'Link options' => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog - 'Visual' => _x( 'Visual', 'Name for the Visual editor tab' ), // Editor switch tab label - 'Text' => _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ), // Editor switch tab label - 'Add Media' => array( __( 'Add Media' ), 'accessM' ), // Tooltip for the 'Add Media' button in the block editor Classic block - - // Shortcuts help modal + 'No alignment' => __( 'No alignment' ), // Tooltip for the 'alignnone' button in the image toolbar. + 'Remove' => __( 'Remove' ), // Tooltip for the 'remove' button in the image toolbar. + 'Edit|button' => __( 'Edit' ), // Tooltip for the 'edit' button in the image toolbar. + 'Paste URL or type to search' => __( 'Paste URL or type to search' ), // Placeholder for the inline link dialog. + 'Apply' => __( 'Apply' ), // Tooltip for the 'apply' button in the inline link dialog. + 'Link options' => __( 'Link options' ), // Tooltip for the 'link options' button in the inline link dialog. + 'Visual' => _x( 'Visual', 'Name for the Visual editor tab' ), // Editor switch tab label. + 'Text' => _x( 'Text', 'Name for the Text editor tab (formerly HTML)' ), // Editor switch tab label. + 'Add Media' => array( __( 'Add Media' ), 'accessM' ), // Tooltip for the 'Add Media' button in the block editor Classic block. + + // Shortcuts help modal. 'Keyboard Shortcuts' => array( __( 'Keyboard Shortcuts' ), 'accessH' ), 'Classic Block Keyboard Shortcuts' => __( 'Classic Block Keyboard Shortcuts' ), 'Default shortcuts,' => __( 'Default shortcuts,' ), @@ -1496,7 +1500,7 @@ final class _WP_Editors { } } - // Set direction + // Set direction. if ( is_rtl() ) { $mce_translation['_dir'] = 'rtl'; } @@ -1643,7 +1647,7 @@ final class _WP_Editors { self::print_tinymce_scripts(); if ( self::$ext_plugins ) { - // Load the old-format English strings to prevent unsightly labels in old style popups + // Load the old-format English strings to prevent unsightly labels in old style popups. echo "<script type='text/javascript' src='{$baseurl}/langs/wp-langs-en.js?$version'></script>\n"; } } @@ -1828,14 +1832,14 @@ final class _WP_Editors { * @since 3.1.0 */ public static function wp_link_dialog() { - // Run once + // Run once. if ( self::$link_dialog_printed ) { return; } self::$link_dialog_printed = true; - // display: none is required here, see #WP27605 + // `display: none` is required here, see #WP27605. ?> <div id="wp-link-backdrop" style="display: none"></div> <div id="wp-link-wrap" class="wp-core-ui" style="display: none" role="dialog" aria-labelledby="link-modal-title"> diff --git a/src/wp-includes/class-wp-embed.php b/src/wp-includes/class-wp-embed.php index 5211bd369f..80461be52e 100644 --- a/src/wp-includes/class-wp-embed.php +++ b/src/wp-includes/class-wp-embed.php @@ -28,18 +28,18 @@ class WP_Embed { * Constructor */ public function __construct() { - // Hack to get the [embed] shortcode to run before wpautop() + // Hack to get the [embed] shortcode to run before wpautop(). add_filter( 'the_content', array( $this, 'run_shortcode' ), 8 ); add_filter( 'widget_text_content', array( $this, 'run_shortcode' ), 8 ); - // Shortcode placeholder for strip_shortcodes() + // Shortcode placeholder for strip_shortcodes(). add_shortcode( 'embed', '__return_false' ); - // Attempts to embed all URLs in a post + // Attempts to embed all URLs in a post. add_filter( 'the_content', array( $this, 'autoembed' ), 8 ); add_filter( 'widget_text_content', array( $this, 'autoembed' ), 8 ); - // After a post is saved, cache oEmbed items via Ajax + // After a post is saved, cache oEmbed items via Ajax. add_action( 'edit_form_advanced', array( $this, 'maybe_run_ajax_cache' ) ); add_action( 'edit_page_form', array( $this, 'maybe_run_ajax_cache' ) ); } @@ -59,16 +59,16 @@ class WP_Embed { public function run_shortcode( $content ) { global $shortcode_tags; - // Back up current registered shortcodes and clear them all out + // Back up current registered shortcodes and clear them all out. $orig_shortcode_tags = $shortcode_tags; remove_all_shortcodes(); add_shortcode( 'embed', array( $this, 'shortcode' ) ); - // Do the shortcode (only the [embed] one is registered) + // Do the shortcode (only the [embed] one is registered). $content = do_shortcode( $content, true ); - // Put the original shortcodes back + // Put the original shortcodes back. $shortcode_tags = $orig_shortcode_tags; return $content; @@ -161,11 +161,11 @@ class WP_Embed { $this->last_attr = $attr; - // kses converts & into & and we need to undo this + // KSES converts & into & and we need to undo this. // See https://core.trac.wordpress.org/ticket/11311 $url = str_replace( '&', '&', $url ); - // Look for known internal handlers + // Look for known internal handlers. ksort( $this->handlers ); foreach ( $this->handlers as $priority => $handlers ) { foreach ( $handlers as $id => $handler ) { @@ -339,7 +339,7 @@ class WP_Embed { return apply_filters( 'embed_oembed_html', $html, $url, $attr, $post_ID ); } - // Still unknown + // Still unknown. return $this->maybe_make_link( $url ); } @@ -381,7 +381,7 @@ class WP_Embed { return; } - // Trigger a caching + // Trigger a caching. if ( ! empty( $post->post_content ) ) { $this->post_ID = $post->ID; $this->usecache = false; @@ -486,7 +486,7 @@ class WP_Embed { ); if ( ! empty( $oembed_post_query->posts ) ) { - // Note: 'fields'=>'ids' is not being used in order to cache the post object as it will be needed. + // Note: 'fields' => 'ids' is not being used in order to cache the post object as it will be needed. $oembed_post_id = $oembed_post_query->posts[0]->ID; wp_cache_set( $cache_key, $oembed_post_id, $cache_group ); diff --git a/src/wp-includes/class-wp-fatal-error-handler.php b/src/wp-includes/class-wp-fatal-error-handler.php index 7e4f6d8c3c..f8c431ab3d 100644 --- a/src/wp-includes/class-wp-fatal-error-handler.php +++ b/src/wp-includes/class-wp-fatal-error-handler.php @@ -3,7 +3,7 @@ * Error Protection API: WP_Fatal_Error_Handler class * * @package WordPress - * @since 5.2.0 + * @since 5.2.0 */ /** diff --git a/src/wp-includes/class-wp-hook.php b/src/wp-includes/class-wp-hook.php index fec841cfa8..b8a936b0fd 100644 --- a/src/wp-includes/class-wp-hook.php +++ b/src/wp-includes/class-wp-hook.php @@ -80,7 +80,7 @@ final class WP_Hook implements Iterator, ArrayAccess { 'accepted_args' => $accepted_args, ); - // if we're adding a new priority to the list, put them back in sorted order + // If we're adding a new priority to the list, put them back in sorted order. if ( ! $priority_existed && count( $this->callbacks ) > 1 ) { ksort( $this->callbacks, SORT_NUMERIC ); } @@ -135,7 +135,7 @@ final class WP_Hook implements Iterator, ArrayAccess { // If we have a new priority that didn't exist, but ::apply_filters() or ::do_action() thinks it's the current priority... if ( $new_priority === $this->current_priority[ $index ] && ! $priority_existed ) { /* - * ... and the new priority is the same as what $this->iterations thinks is the previous + * ...and the new priority is the same as what $this->iterations thinks is the previous * priority, we need to move back to it. */ @@ -280,7 +280,7 @@ final class WP_Hook implements Iterator, ArrayAccess { $args[0] = $value; } - // Avoid the array_slice if possible. + // Avoid the array_slice() if possible. if ( $the_['accepted_args'] == 0 ) { $value = call_user_func( $the_['function'] ); } elseif ( $the_['accepted_args'] >= $num_args ) { diff --git a/src/wp-includes/class-wp-http-ixr-client.php b/src/wp-includes/class-wp-http-ixr-client.php index d05f864570..40fb7c47c1 100644 --- a/src/wp-includes/class-wp-http-ixr-client.php +++ b/src/wp-includes/class-wp-http-ixr-client.php @@ -20,14 +20,14 @@ class WP_HTTP_IXR_Client extends IXR_Client { */ public function __construct( $server, $path = false, $port = false, $timeout = 15 ) { if ( ! $path ) { - // Assume we have been given a URL instead + // Assume we have been given a URL instead. $bits = parse_url( $server ); $this->scheme = $bits['scheme']; $this->server = $bits['host']; $this->port = isset( $bits['port'] ) ? $bits['port'] : $port; $this->path = ! empty( $bits['path'] ) ? $bits['path'] : '/'; - // Make absolutely sure we have a path + // Make absolutely sure we have a path. if ( ! $this->path ) { $this->path = '/'; } @@ -62,7 +62,7 @@ class WP_HTTP_IXR_Client extends IXR_Client { 'body' => $xml, ); - // Merge Custom headers ala #8145 + // Merge Custom headers ala #8145. foreach ( $this->headers as $header => $value ) { $args['headers'][ $header ] = $value; } @@ -80,7 +80,7 @@ class WP_HTTP_IXR_Client extends IXR_Client { $args['timeout'] = $this->timeout; } - // Now send the request + // Now send the request. if ( $this->debug ) { echo '<pre class="ixr_request">' . htmlspecialchars( $xml ) . "\n</pre>\n\n"; } @@ -103,10 +103,10 @@ class WP_HTTP_IXR_Client extends IXR_Client { echo '<pre class="ixr_response">' . htmlspecialchars( wp_remote_retrieve_body( $response ) ) . "\n</pre>\n\n"; } - // Now parse what we've got back + // Now parse what we've got back. $this->message = new IXR_Message( wp_remote_retrieve_body( $response ) ); if ( ! $this->message->parse() ) { - // XML error + // XML error. $this->error = new IXR_Error( -32700, 'parse error. not well formed' ); return false; } @@ -117,7 +117,7 @@ class WP_HTTP_IXR_Client extends IXR_Client { return false; } - // Message must be OK + // Message must be OK. return true; } } diff --git a/src/wp-includes/class-wp-http-requests-hooks.php b/src/wp-includes/class-wp-http-requests-hooks.php index 549f53242c..373778c11a 100644 --- a/src/wp-includes/class-wp-http-requests-hooks.php +++ b/src/wp-includes/class-wp-http-requests-hooks.php @@ -50,7 +50,7 @@ class WP_HTTP_Requests_Hooks extends Requests_Hooks { public function dispatch( $hook, $parameters = array() ) { $result = parent::dispatch( $hook, $parameters ); - // Handle back-compat actions + // Handle back-compat actions. switch ( $hook ) { case 'curl.before_send': /** This action is documented in wp-includes/class-wp-http-curl.php */ diff --git a/src/wp-includes/class-wp-http-streams.php b/src/wp-includes/class-wp-http-streams.php index 3c2e339e67..ddab16e295 100644 --- a/src/wp-includes/class-wp-http-streams.php +++ b/src/wp-includes/class-wp-http-streams.php @@ -65,7 +65,7 @@ class WP_Http_Streams { } } - // Always pass a Path, defaulting to the root in cases such as http://example.com + // Always pass a path, defaulting to the root in cases such as http://example.com. if ( ! isset( $arrURL['path'] ) ) { $arrURL['path'] = '/'; } @@ -114,7 +114,7 @@ class WP_Http_Streams { array( 'ssl' => array( 'verify_peer' => $ssl_verify, - //'CN_match' => $arrURL['host'], // This is handled by self::verify_ssl_certificate() + // 'CN_match' => $arrURL['host'], // This is handled by self::verify_ssl_certificate(). 'capture_peer_cert' => $ssl_verify, 'SNI_enabled' => true, 'cafile' => $parsed_args['sslcertificates'], @@ -134,7 +134,7 @@ class WP_Http_Streams { $connection_error_str = null; if ( ! WP_DEBUG ) { - // In the event that the SSL connection fails, silence the many PHP Warnings. + // In the event that the SSL connection fails, silence the many PHP warnings. if ( $secure_transport ) { $error_reporting = error_reporting( 0 ); } @@ -176,7 +176,7 @@ class WP_Http_Streams { stream_set_timeout( $handle, $timeout, $utimeout ); - if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { //Some proxies require full URL in this field. + if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) { // Some proxies require full URL in this field. $requestPath = $url; } else { $requestPath = $arrURL['path'] . ( isset( $arrURL['query'] ) ? '?' . $arrURL['query'] : '' ); diff --git a/src/wp-includes/class-wp-image-editor-gd.php b/src/wp-includes/class-wp-image-editor-gd.php index 18a349a347..51313d456d 100644 --- a/src/wp-includes/class-wp-image-editor-gd.php +++ b/src/wp-includes/class-wp-image-editor-gd.php @@ -23,7 +23,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { public function __destruct() { if ( $this->image ) { - // we don't need the original in memory anymore + // We don't need the original in memory anymore. imagedestroy( $this->image ); } } @@ -41,7 +41,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { return false; } - // On some setups GD library does not provide imagerotate() - Ticket #11536 + // On some setups GD library does not provide imagerotate() - Ticket #11536. if ( isset( $args['methods'] ) && in_array( 'rotate', $args['methods'], true ) && ! function_exists( 'imagerotate' ) ) { @@ -307,8 +307,8 @@ class WP_Image_Editor_GD extends WP_Image_Editor { * @return bool|WP_Error */ public function crop( $src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false ) { - // If destination width/height isn't specified, use same as - // width/height from source. + // If destination width/height isn't specified, + // use same as width/height from source. if ( ! $dst_w ) { $dst_w = $src_w; } @@ -432,7 +432,7 @@ class WP_Image_Editor_GD extends WP_Image_Editor { return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); } } elseif ( 'image/png' === $mime_type ) { - // convert from full colors to index colors, like original PNG. + // Convert from full colors to index colors, like original PNG. if ( function_exists( 'imageistruecolor' ) && ! imageistruecolor( $image ) ) { imagetruecolortopalette( $image, false, imagecolorstotal( $image ) ); } @@ -448,9 +448,9 @@ class WP_Image_Editor_GD extends WP_Image_Editor { return new WP_Error( 'image_save_error', __( 'Image Editor Save Failed' ) ); } - // Set correct file permissions + // Set correct file permissions. $stat = stat( dirname( $filename ) ); - $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits + $perms = $stat['mode'] & 0000666; // Same permissions as parent folder, strip off the executable bits. chmod( $filename, $perms ); /** diff --git a/src/wp-includes/class-wp-image-editor-imagick.php b/src/wp-includes/class-wp-image-editor-imagick.php index 8fc70e6ac8..820288ea79 100644 --- a/src/wp-includes/class-wp-image-editor-imagick.php +++ b/src/wp-includes/class-wp-image-editor-imagick.php @@ -23,7 +23,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { public function __destruct() { if ( $this->image instanceof Imagick ) { - // we don't need the original in memory anymore + // We don't need the original in memory anymore. $this->image->clear(); $this->image->destroy(); } @@ -154,7 +154,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { return new WP_Error( 'invalid_image', __( 'File is not an image.' ), $this->file ); } - // Select the first frame to handle animated images properly + // Select the first frame to handle animated images properly. if ( is_callable( array( $this->image, 'setIteratorIndex' ) ) ) { $this->image->setIteratorIndex( 0 ); } @@ -263,7 +263,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { return $this->crop( $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h ); } - // Execute the resize + // Execute the resize. $thumb_result = $this->thumbnail_image( $dst_w, $dst_h ); if ( is_wp_error( $thumb_result ) ) { return $thumb_result; @@ -530,8 +530,8 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { $this->image->setImagePage( $src_w, $src_h, 0, 0 ); if ( $dst_w || $dst_h ) { - // If destination width/height isn't specified, use same as - // width/height from source. + // If destination width/height isn't specified, + // use same as width/height from source. if ( ! $dst_w ) { $dst_w = $src_w; } @@ -675,21 +675,21 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { } try { - // Store initial Format + // Store initial format. $orig_format = $this->image->getImageFormat(); $this->image->setImageFormat( strtoupper( $this->get_extension( $mime_type ) ) ); $this->make_image( $filename, array( $image, 'writeImage' ), array( $filename ) ); - // Reset original Format + // Reset original format. $this->image->setImageFormat( $orig_format ); } catch ( Exception $e ) { return new WP_Error( 'image_save_error', $e->getMessage(), $filename ); } - // Set correct file permissions + // Set correct file permissions. $stat = stat( dirname( $filename ) ); - $perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits + $perms = $stat['mode'] & 0000666; // Same permissions as parent folder, strip off the executable bits. chmod( $filename, $perms ); return array( @@ -714,14 +714,14 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { list( $filename, $extension, $mime_type ) = $this->get_output_format( null, $mime_type ); try { - // Temporarily change format for stream + // Temporarily change format for stream. $this->image->setImageFormat( strtoupper( $extension ) ); - // Output stream of image content + // Output stream of image content. header( "Content-Type: $mime_type" ); print $this->image->getImageBlob(); - // Reset Image to original Format + // Reset image to original format. $this->image->setImageFormat( $this->get_extension( $this->mime_type ) ); } catch ( Exception $e ) { return new WP_Error( 'image_stream_error', $e->getMessage() ); diff --git a/src/wp-includes/class-wp-image-editor.php b/src/wp-includes/class-wp-image-editor.php index e6222ece95..8cacb9c7ba 100644 --- a/src/wp-includes/class-wp-image-editor.php +++ b/src/wp-includes/class-wp-image-editor.php @@ -295,7 +295,7 @@ abstract class WP_Image_Editor { protected function get_output_format( $filename = null, $mime_type = null ) { $new_ext = null; - // By default, assume specified type takes priority + // By default, assume specified type takes priority. if ( $mime_type ) { $new_ext = $this->get_extension( $mime_type ); } @@ -310,7 +310,7 @@ abstract class WP_Image_Editor { } // Check to see if specified mime-type is the same as type implied by - // file extension. If so, prefer extension from file. + // file extension. If so, prefer extension from file. if ( ! $mime_type || ( $file_mime == $mime_type ) ) { $mime_type = $file_mime; $new_ext = $file_ext; @@ -353,7 +353,7 @@ abstract class WP_Image_Editor { * @return string filename */ public function generate_filename( $suffix = null, $dest_path = null, $extension = null ) { - // $suffix will be appended to the destination filename, just before the extension + // $suffix will be appended to the destination filename, just before the extension. if ( ! $suffix ) { $suffix = $this->get_suffix(); } @@ -429,7 +429,7 @@ abstract class WP_Image_Editor { break; case 3: // Rotate 180 degrees or flip horizontally and vertically. - // Flipping seems faster/uses less resources. + // Flipping seems faster and uses less resources. $result = $this->flip( true, true ); break; case 4: diff --git a/src/wp-includes/class-wp-locale.php b/src/wp-includes/class-wp-locale.php index 82f5be01db..578a87ad7d 100644 --- a/src/wp-includes/class-wp-locale.php +++ b/src/wp-includes/class-wp-locale.php @@ -118,7 +118,7 @@ class WP_Locale { * @global string $wp_version */ public function init() { - // The Weekdays + // The weekdays. $this->weekday[0] = /* translators: Weekday. */ __( 'Sunday' ); $this->weekday[1] = /* translators: Weekday. */ __( 'Monday' ); $this->weekday[2] = /* translators: Weekday. */ __( 'Tuesday' ); @@ -145,7 +145,7 @@ class WP_Locale { $this->weekday_abbrev[ __( 'Friday' ) ] = /* translators: Three-letter abbreviation of the weekday. */ __( 'Fri' ); $this->weekday_abbrev[ __( 'Saturday' ) ] = /* translators: Three-letter abbreviation of the weekday. */ __( 'Sat' ); - // The Months + // The months. $this->month['01'] = /* translators: Month name. */ __( 'January' ); $this->month['02'] = /* translators: Month name. */ __( 'February' ); $this->month['03'] = /* translators: Month name. */ __( 'March' ); @@ -159,7 +159,7 @@ class WP_Locale { $this->month['11'] = /* translators: Month name. */ __( 'November' ); $this->month['12'] = /* translators: Month name. */ __( 'December' ); - // The Months, genitive + // The months, genitive. $this->month_genitive['01'] = /* translators: Month name, genitive. */ _x( 'January', 'genitive' ); $this->month_genitive['02'] = /* translators: Month name, genitive. */ _x( 'February', 'genitive' ); $this->month_genitive['03'] = /* translators: Month name, genitive. */ _x( 'March', 'genitive' ); @@ -187,13 +187,13 @@ class WP_Locale { $this->month_abbrev[ __( 'November' ) ] = /* translators: Three-letter abbreviation of the month. */ _x( 'Nov', 'November abbreviation' ); $this->month_abbrev[ __( 'December' ) ] = /* translators: Three-letter abbreviation of the month. */ _x( 'Dec', 'December abbreviation' ); - // The Meridiems + // The meridiems. $this->meridiem['am'] = __( 'am' ); $this->meridiem['pm'] = __( 'pm' ); $this->meridiem['AM'] = __( 'AM' ); $this->meridiem['PM'] = __( 'PM' ); - // Numbers formatting + // Numbers formatting. // See https://www.php.net/number_format /* translators: $thousands_sep argument for https://www.php.net/number_format, default is ',' */ diff --git a/src/wp-includes/class-wp-matchesmapregex.php b/src/wp-includes/class-wp-matchesmapregex.php index 86e38898a6..7145c48652 100644 --- a/src/wp-includes/class-wp-matchesmapregex.php +++ b/src/wp-includes/class-wp-matchesmapregex.php @@ -38,7 +38,7 @@ class WP_MatchesMapRegex { * * @var string */ - public $_pattern = '(\$matches\[[1-9]+[0-9]*\])'; // magic number + public $_pattern = '(\$matches\[[1-9]+[0-9]*\])'; // Magic number. /** * constructor diff --git a/src/wp-includes/class-wp-network-query.php b/src/wp-includes/class-wp-network-query.php index a12656c702..4df608c767 100644 --- a/src/wp-includes/class-wp-network-query.php +++ b/src/wp-includes/class-wp-network-query.php @@ -290,7 +290,7 @@ class WP_Network_Query { */ $_networks = apply_filters_ref_array( 'the_networks', array( $_networks, &$this ) ); - // Convert to WP_Network instances + // Convert to WP_Network instances. $this->networks = array_map( 'get_network', $_networks ); return $this->networks; diff --git a/src/wp-includes/class-wp-network.php b/src/wp-includes/class-wp-network.php index a9588e3775..1addcdd3b4 100644 --- a/src/wp-includes/class-wp-network.php +++ b/src/wp-includes/class-wp-network.php @@ -243,7 +243,7 @@ class WP_Network { return (int) $this->blog_id; } - if ( defined( 'BLOGID_CURRENT_SITE' ) ) { // deprecated. + if ( defined( 'BLOGID_CURRENT_SITE' ) ) { // Deprecated. $this->blog_id = (string) BLOGID_CURRENT_SITE; return (int) $this->blog_id; diff --git a/src/wp-includes/class-wp-oembed.php b/src/wp-includes/class-wp-oembed.php index f316f26663..f0db84561a 100644 --- a/src/wp-includes/class-wp-oembed.php +++ b/src/wp-includes/class-wp-oembed.php @@ -262,14 +262,14 @@ class WP_oEmbed { foreach ( $this->providers as $matchmask => $data ) { list( $providerurl, $regex ) = $data; - // Turn the asterisk-type provider URLs into regex + // Turn the asterisk-type provider URLs into regex. if ( ! $regex ) { $matchmask = '#' . str_replace( '___wildcard___', '(.+)', preg_quote( str_replace( '*', '___wildcard___', $matchmask ), '#' ) ) . '#i'; $matchmask = preg_replace( '|^#http\\\://|', '#https?\://', $matchmask ); } if ( preg_match( $matchmask, $url ) ) { - $provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML + $provider = str_replace( '{format}', 'json', $providerurl ); // JSON is easier to deal with than XML. break; } } @@ -439,7 +439,7 @@ class WP_oEmbed { */ $args = apply_filters( 'oembed_remote_get_args', $args, $url ); - // Fetch URL content + // Fetch URL content. $request = wp_safe_remote_get( $url, $args ); $html = wp_remote_retrieve_body( $request ); if ( $html ) { @@ -462,13 +462,13 @@ class WP_oEmbed { ) ); - // Strip <body> + // Strip <body>. $html_head_end = stripos( $html, '</head>' ); if ( $html_head_end ) { $html = substr( $html, 0, $html_head_end ); } - // Do a quick check + // Do a quick check. $tagfound = false; foreach ( $linktypes as $linktype => $format ) { if ( stripos( $html, $linktype ) ) { @@ -484,7 +484,7 @@ class WP_oEmbed { if ( ! empty( $atts['type'] ) && ! empty( $linktypes[ $atts['type'] ] ) && ! empty( $atts['href'] ) ) { $providers[ $linktypes[ $atts['type'] ] ] = htmlspecialchars_decode( $atts['href'] ); - // Stop here if it's JSON (that's all we need) + // Stop here if it's JSON (that's all we need). if ( 'json' == $linktypes[ $atts['type'] ] ) { break; } @@ -493,7 +493,7 @@ class WP_oEmbed { } } - // JSON is preferred to XML + // JSON is preferred to XML. if ( ! empty( $providers['json'] ) ) { return $providers['json']; } elseif ( ! empty( $providers['xml'] ) ) { diff --git a/src/wp-includes/class-wp-paused-extensions-storage.php b/src/wp-includes/class-wp-paused-extensions-storage.php index 7c51db8781..993ab060e0 100644 --- a/src/wp-includes/class-wp-paused-extensions-storage.php +++ b/src/wp-includes/class-wp-paused-extensions-storage.php @@ -3,7 +3,7 @@ * Error Protection API: WP_Paused_Extensions_Storage class * * @package WordPress - * @since 5.2.0 + * @since 5.2.0 */ /** diff --git a/src/wp-includes/class-wp-post-type.php b/src/wp-includes/class-wp-post-type.php index bb148067c0..09ada7c4a2 100644 --- a/src/wp-includes/class-wp-post-type.php +++ b/src/wp-includes/class-wp-post-type.php @@ -423,27 +423,27 @@ final class WP_Post_Type { $args['name'] = $this->name; - // If not set, default to the setting for public. + // If not set, default to the setting for 'public'. if ( null === $args['publicly_queryable'] ) { $args['publicly_queryable'] = $args['public']; } - // If not set, default to the setting for public. + // If not set, default to the setting for 'public'. if ( null === $args['show_ui'] ) { $args['show_ui'] = $args['public']; } - // If not set, default to the setting for show_ui. + // If not set, default to the setting for 'show_ui'. if ( null === $args['show_in_menu'] || ! $args['show_ui'] ) { $args['show_in_menu'] = $args['show_ui']; } - // If not set, default to the whether the full UI is shown. + // If not set, default to the setting for 'show_in_menu'. if ( null === $args['show_in_admin_bar'] ) { $args['show_in_admin_bar'] = (bool) $args['show_in_menu']; } - // If not set, default to the setting for public. + // If not set, default to the setting for 'public'. if ( null === $args['show_in_nav_menus'] ) { $args['show_in_nav_menus'] = $args['public']; } diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index 7a96e0160b..7233e2ba87 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -771,8 +771,8 @@ class WP_Query { $qv['w'] = absint( $qv['w'] ); $qv['m'] = is_scalar( $qv['m'] ) ? preg_replace( '|[^0-9]|', '', $qv['m'] ) : ''; $qv['paged'] = absint( $qv['paged'] ); - $qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // comma separated list of positive or negative integers - $qv['author'] = preg_replace( '|[^0-9,-]|', '', $qv['author'] ); // comma separated list of positive or negative integers + $qv['cat'] = preg_replace( '|[^0-9,-]|', '', $qv['cat'] ); // Comma-separated list of positive or negative integers. + $qv['author'] = preg_replace( '|[^0-9,-]|', '', $qv['author'] ); // Comma-separated list of positive or negative integers. $qv['pagename'] = trim( $qv['pagename'] ); $qv['name'] = trim( $qv['name'] ); $qv['title'] = trim( $qv['title'] ); @@ -812,8 +812,8 @@ class WP_Query { } elseif ( $qv['p'] ) { $this->is_single = true; } elseif ( ( '' !== $qv['hour'] ) && ( '' !== $qv['minute'] ) && ( '' !== $qv['second'] ) && ( '' != $qv['year'] ) && ( '' != $qv['monthnum'] ) && ( '' != $qv['day'] ) ) { - // If year, month, day, hour, minute, and second are set, a single - // post is being queried. + // If year, month, day, hour, minute, and second are set, + // a single post is being queried. $this->is_single = true; } elseif ( '' != $qv['pagename'] || ! empty( $qv['page_id'] ) ) { $this->is_page = true; @@ -948,7 +948,7 @@ class WP_Query { $this->is_paged = true; } - // if we're previewing inside the write screen + // If we're previewing inside the write screen. if ( '' != $qv['preview'] ) { $this->is_preview = true; } @@ -974,10 +974,10 @@ class WP_Query { $this->is_home = true; } - // Correct is_* for page_on_front and page_for_posts + // Correct `is_*` for 'page_on_front' and 'page_for_posts'. if ( $this->is_home && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) { $_query = wp_parse_args( $this->query ); - // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. + // 'pagename' can be set and empty depending on matched rewrite rules. Ignore an empty 'pagename'. if ( isset( $_query['pagename'] ) && '' == $_query['pagename'] ) { unset( $_query['pagename'] ); } @@ -988,7 +988,7 @@ class WP_Query { $this->is_page = true; $this->is_home = false; $qv['page_id'] = get_option( 'page_on_front' ); - // Correct <!--nextpage--> for page_on_front + // Correct <!--nextpage--> for 'page_on_front'. if ( ! empty( $qv['paged'] ) ) { $qv['page'] = $qv['paged']; unset( $qv['paged'] ); @@ -1001,7 +1001,7 @@ class WP_Query { if ( $this->queried_object && 'attachment' == $this->queried_object->post_type ) { if ( preg_match( '/^[^%]*%(?:postname)%/', get_option( 'permalink_structure' ) ) ) { - // See if we also have a post with the same slug + // See if we also have a post with the same slug. $post = get_page_by_path( $qv['pagename'], OBJECT, 'post' ); if ( $post ) { $this->queried_object = $post; @@ -1061,7 +1061,7 @@ class WP_Query { } $this->is_singular = $this->is_single || $this->is_page || $this->is_attachment; - // Done correcting is_* for page_on_front and page_for_posts + // Done correcting `is_*` for 'page_on_front' and 'page_for_posts'. if ( '404' == $qv['error'] ) { $this->set_404(); @@ -1108,7 +1108,7 @@ class WP_Query { foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy => $t ) { if ( 'post_tag' == $taxonomy ) { - continue; // Handled further down in the $q['tag'] block + continue; // Handled further down in the $q['tag'] block. } if ( $t->query_var && ! empty( $q[ $t->query_var ] ) ) { @@ -1148,12 +1148,13 @@ class WP_Query { } } - // If querystring 'cat' is an array, implode it. + // If query string 'cat' is an array, implode it. if ( is_array( $q['cat'] ) ) { $q['cat'] = implode( ',', $q['cat'] ); } - // Category stuff + // Category stuff. + if ( ! empty( $q['cat'] ) && ! $this->is_singular ) { $cat_in = array(); $cat_not_in = array(); @@ -1231,12 +1232,13 @@ class WP_Query { ); } - // If querystring 'tag' is array, implode it. + // If query string 'tag' is array, implode it. if ( is_array( $q['tag'] ) ) { $q['tag'] = implode( ',', $q['tag'] ); } - // Tag stuff + // Tag stuff. + if ( '' != $q['tag'] && ! $this->is_singular && $this->query_vars_changed ) { if ( strpos( $q['tag'], ',' ) !== false ) { $tags = preg_split( '/[,\r\n\t ]+/', $q['tag'] ); @@ -1336,12 +1338,12 @@ class WP_Query { $search = ''; - // added slashes screw with quote grouping when done early, so done later + // Added slashes screw with quote grouping when done early, so done later. $q['s'] = stripslashes( $q['s'] ); if ( empty( $_GET['s'] ) && $this->is_main_query() ) { $q['s'] = urldecode( $q['s'] ); } - // there are no line breaks in <input /> fields + // There are no line breaks in <input /> fields. $q['s'] = str_replace( array( "\r", "\n" ), '', $q['s'] ); $q['search_terms_count'] = 1; if ( ! empty( $q['sentence'] ) ) { @@ -1350,7 +1352,7 @@ class WP_Query { if ( preg_match_all( '/".*?("|$)|((?<=[\t ",+])|^)[^\t ",+]+/', $q['s'], $matches ) ) { $q['search_terms_count'] = count( $matches[0] ); $q['search_terms'] = $this->parse_search_terms( $matches[0] ); - // if the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence + // If the search string has only short terms or stopwords, or is 10+ terms long, match it as sentence. if ( empty( $q['search_terms'] ) || count( $q['search_terms'] ) > 9 ) { $q['search_terms'] = array( $q['s'] ); } @@ -1424,7 +1426,7 @@ class WP_Query { $stopwords = $this->get_search_stopwords(); foreach ( $terms as $term ) { - // keep before/after spaces when term is for exact match + // Keep before/after spaces when term is for exact match. if ( preg_match( '/^".+"$/', $term ) ) { $term = trim( $term, "\"'" ); } else { @@ -1514,17 +1516,17 @@ class WP_Query { $search_orderby = ''; - // sentence match in 'post_title' + // Sentence match in 'post_title'. if ( $like ) { $search_orderby .= $wpdb->prepare( "WHEN {$wpdb->posts}.post_title LIKE %s THEN 1 ", $like ); } - // sanity limit, sort as sentence when more than 6 terms - // (few searches are longer than 6 terms and most titles are not) + // Sanity limit, sort as sentence when more than 6 terms + // (few searches are longer than 6 terms and most titles are not). if ( $num_terms < 7 ) { - // all words in title + // All words in title. $search_orderby .= 'WHEN ' . implode( ' AND ', $q['search_orderby_title'] ) . ' THEN 2 '; - // any word in title, not needed when $num_terms == 1 + // Any word in title, not needed when $num_terms == 1. if ( $num_terms > 1 ) { $search_orderby .= 'WHEN ' . implode( ' OR ', $q['search_orderby_title'] ) . ' THEN 3 '; } @@ -1540,7 +1542,7 @@ class WP_Query { $search_orderby = '(CASE ' . $search_orderby . 'ELSE 6 END)'; } } else { - // single word or sentence search + // Single word or sentence search. $search_orderby = reset( $q['search_orderby_title'] ) . ' DESC'; } @@ -1772,14 +1774,14 @@ class WP_Query { // Shorthand. $q = &$this->query_vars; - // Fill again in case pre_get_posts unset some vars. + // Fill again in case 'pre_get_posts' unset some vars. $q = $this->fill_query_vars( $q ); - // Parse meta query + // Parse meta query. $this->meta_query = new WP_Meta_Query(); $this->meta_query->parse_query_vars( $q ); - // Set a flag if a pre_get_posts hook changed the query vars. + // Set a flag if a 'pre_get_posts' hook changed the query vars. $hash = md5( serialize( $this->query_vars ) ); if ( $hash != $this->query_vars_hash ) { $this->query_vars_changed = true; @@ -1787,7 +1789,7 @@ class WP_Query { } unset( $hash ); - // First let's clear some variables + // First let's clear some variables. $distinct = ''; $whichauthor = ''; $whichmimetype = ''; @@ -1871,7 +1873,7 @@ class WP_Query { } if ( $this->is_feed ) { - // This overrides posts_per_page. + // This overrides 'posts_per_page'. if ( ! empty( $q['posts_per_rss'] ) ) { $q['posts_per_page'] = $q['posts_per_rss']; } else { @@ -1922,7 +1924,7 @@ class WP_Query { if ( '' !== $q['menu_order'] ) { $where .= " AND {$wpdb->posts}.menu_order = " . $q['menu_order']; } - // The "m" parameter is meant for months but accepts datetimes of varying specificity + // The "m" parameter is meant for months but accepts datetimes of varying specificity. if ( $q['m'] ) { $where .= " AND YEAR({$wpdb->posts}.post_date)=" . substr( $q['m'], 0, 4 ); if ( strlen( $q['m'] ) > 5 ) { @@ -1942,7 +1944,7 @@ class WP_Query { } } - // Handle the other individual date parameters + // Handle the other individual date parameters. $date_parameters = array(); if ( '' !== $q['hour'] ) { @@ -1979,7 +1981,7 @@ class WP_Query { } unset( $date_parameters, $date_query ); - // Handle complex date queries + // Handle complex date queries. if ( ! empty( $q['date_query'] ) ) { $this->date_query = new WP_Date_Query( $q['date_query'] ); $where .= $this->date_query->get_sql(); @@ -2004,7 +2006,7 @@ class WP_Query { // Only one request for a slug is possible, this is why name & pagename are overwritten above. break; - } //end foreach + } // End foreach. unset( $ptype_obj ); } @@ -2072,7 +2074,7 @@ class WP_Query { $q['p'] = absint( $q['attachment_id'] ); } - // If a post number is specified, load that post + // If a post number is specified, load that post. if ( $q['p'] ) { $where .= " AND {$wpdb->posts}.ID = " . $q['p']; } elseif ( $q['post__in'] ) { @@ -2117,7 +2119,7 @@ class WP_Query { $search = apply_filters_ref_array( 'posts_search', array( $search, &$this ) ); } - // Taxonomies + // Taxonomies. if ( ! $this->is_singular ) { $this->parse_tax_query( $q ); @@ -2129,7 +2131,7 @@ class WP_Query { if ( $this->is_tax ) { if ( empty( $post_type ) ) { - // Do a fully inclusive search for currently registered post types of queried taxonomies + // Do a fully inclusive search for currently registered post types of queried taxonomies. $post_type = array(); $taxonomies = array_keys( $this->tax_query->queried_terms ); foreach ( get_post_types( array( 'exclude_from_search' => false ) ) as $pt ) { @@ -2181,7 +2183,7 @@ class WP_Query { } } - // 'cat', 'category_name', 'tag_id' + // 'cat', 'category_name', 'tag_id'. foreach ( $this->tax_query->queried_terms as $queried_taxonomy => $queried_items ) { if ( empty( $queried_items['terms'][0] ) ) { continue; @@ -2210,7 +2212,7 @@ class WP_Query { $groupby = "{$wpdb->posts}.ID"; } - // Author/user stuff + // Author/user stuff. if ( ! empty( $q['author'] ) && $q['author'] != '0' ) { $q['author'] = addslashes_gpc( '' . urldecode( $q['author'] ) ); @@ -2230,15 +2232,15 @@ class WP_Query { $where .= " AND {$wpdb->posts}.post_author IN ($author__in) "; } - // Author stuff for nice URLs + // Author stuff for nice URLs. if ( '' != $q['author_name'] ) { if ( strpos( $q['author_name'], '/' ) !== false ) { $q['author_name'] = explode( '/', $q['author_name'] ); if ( $q['author_name'][ count( $q['author_name'] ) - 1 ] ) { - $q['author_name'] = $q['author_name'][ count( $q['author_name'] ) - 1 ]; // no trailing slash + $q['author_name'] = $q['author_name'][ count( $q['author_name'] ) - 1 ]; // No trailing slash. } else { - $q['author_name'] = $q['author_name'][ count( $q['author_name'] ) - 2 ]; // there was a trailing slash + $q['author_name'] = $q['author_name'][ count( $q['author_name'] ) - 2 ]; // There was a trailing slash. } } $q['author_name'] = sanitize_title_for_query( $q['author_name'] ); @@ -2276,7 +2278,7 @@ class WP_Query { } } - // MIME-Type stuff for attachment browsing + // MIME-Type stuff for attachment browsing. if ( isset( $q['post_mime_type'] ) && '' != $q['post_mime_type'] ) { $whichmimetype = wp_post_mime_type_where( $q['post_mime_type'], $wpdb->posts ); @@ -2564,7 +2566,7 @@ class WP_Query { $join = apply_filters_ref_array( 'posts_join', array( $join, &$this ) ); } - // Paging + // Paging. if ( empty( $q['nopaging'] ) && ! $this->is_singular ) { $page = absint( $q['paged'] ); if ( ! $page ) { @@ -2581,13 +2583,13 @@ class WP_Query { $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page']; } - // Comments feeds + // Comments feeds. if ( $this->is_comment_feed && ! $this->is_singular ) { if ( $this->is_archive || $this->is_search ) { $cjoin = "JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) $join "; $cwhere = "WHERE comment_approved = '1' $where"; $cgroupby = "{$wpdb->comments}.comment_id"; - } else { // Other non singular e.g. front + } else { // Other non-singular, e.g. front. $cjoin = "JOIN {$wpdb->posts} ON ( {$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID )"; $cwhere = "WHERE ( post_status = 'publish' OR ( post_status = 'inherit' AND post_type = 'attachment' ) ) AND comment_approved = '1'"; $cgroupby = ''; @@ -2650,7 +2652,7 @@ class WP_Query { $climits = ( ! empty( $climits ) ) ? $climits : ''; $comments = (array) $wpdb->get_results( "SELECT $distinct {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits" ); - // Convert to WP_Comment + // Convert to WP_Comment. $this->comments = array_map( 'get_comment', $comments ); $this->comment_count = count( $this->comments ); @@ -2990,7 +2992,7 @@ class WP_Query { $split_the_query = apply_filters( 'split_the_query', $split_the_query, $this ); if ( $split_the_query ) { - // First get the IDs and then fill in the objects + // First get the IDs and then fill in the objects. $this->request = "SELECT $found_rows $distinct {$wpdb->posts}.ID FROM {$wpdb->posts} $join WHERE 1=1 $where $groupby $orderby $limits"; @@ -3056,7 +3058,7 @@ class WP_Query { $comments_request = "SELECT {$wpdb->comments}.* FROM {$wpdb->comments} $cjoin $cwhere $cgroupby $corderby $climits"; $comments = $wpdb->get_results( $comments_request ); - // Convert to WP_Comment + // Convert to WP_Comment. $this->comments = array_map( 'get_comment', $comments ); $this->comment_count = count( $this->comments ); } @@ -3111,7 +3113,7 @@ class WP_Query { } } - // Put sticky posts at the top of the posts array + // Put sticky posts at the top of the posts array. $sticky_posts = get_option( 'sticky_posts' ); if ( $this->is_home && $page <= 1 && is_array( $sticky_posts ) && ! empty( $sticky_posts ) && ! $q['ignore_sticky_posts'] ) { $num_posts = count( $this->posts ); @@ -3120,13 +3122,13 @@ class WP_Query { for ( $i = 0; $i < $num_posts; $i++ ) { if ( in_array( $this->posts[ $i ]->ID, $sticky_posts ) ) { $sticky_post = $this->posts[ $i ]; - // Remove sticky from current position + // Remove sticky from current position. array_splice( $this->posts, $i, 1 ); - // Move to front, after other stickies + // Move to front, after other stickies. array_splice( $this->posts, $sticky_offset, 0, array( $sticky_post ) ); // Increment the sticky offset. The next sticky will be placed at this offset. $sticky_offset++; - // Remove post from sticky posts array + // Remove post from sticky posts array. $offset = array_search( $sticky_post->ID, $sticky_posts ); unset( $sticky_posts[ $offset ] ); } @@ -3137,7 +3139,7 @@ class WP_Query { $sticky_posts = array_diff( $sticky_posts, $q['post__not_in'] ); } - // Fetch sticky posts that weren't in the query results + // Fetch sticky posts that weren't in the query results. if ( ! empty( $sticky_posts ) ) { $stickies = get_posts( array( @@ -3280,7 +3282,7 @@ class WP_Query { global $post; $this->in_the_loop = true; - if ( $this->current_post == -1 ) { // loop has just started + if ( $this->current_post == -1 ) { // Loop has just started. /** * Fires once the loop is started. * @@ -3316,7 +3318,7 @@ class WP_Query { * @param WP_Query $this The WP_Query instance (passed by reference). */ do_action_ref_array( 'loop_end', array( &$this ) ); - // Do some cleaning up after the loop + // Do some cleaning up after the loop. $this->rewind_posts(); } elseif ( 0 === $this->post_count ) { /** @@ -3789,7 +3791,7 @@ class WP_Query { return false; } - // Only a Taxonomy provided. + // Only a taxonomy provided. if ( empty( $term ) ) { return true; } @@ -3886,7 +3888,7 @@ class WP_Query { * @return bool True, if front of site. */ public function is_front_page() { - // most likely case + // Most likely case. if ( 'posts' == get_option( 'show_on_front' ) && $this->is_home() ) { return true; } elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) ) { diff --git a/src/wp-includes/class-wp-recovery-mode-cookie-service.php b/src/wp-includes/class-wp-recovery-mode-cookie-service.php index ff042c5318..6d38e1e9e7 100644 --- a/src/wp-includes/class-wp-recovery-mode-cookie-service.php +++ b/src/wp-includes/class-wp-recovery-mode-cookie-service.php @@ -3,7 +3,7 @@ * Error Protection API: WP_Recovery_Mode_Cookie_Service class * * @package WordPress - * @since 5.2.0 + * @since 5.2.0 */ /** diff --git a/src/wp-includes/class-wp-recovery-mode-email-service.php b/src/wp-includes/class-wp-recovery-mode-email-service.php index 5b0dd2e4db..9ef935300c 100644 --- a/src/wp-includes/class-wp-recovery-mode-email-service.php +++ b/src/wp-includes/class-wp-recovery-mode-email-service.php @@ -3,7 +3,7 @@ * Error Protection API: WP_Recovery_Mode_Email_Link class * * @package WordPress - * @since 5.2.0 + * @since 5.2.0 */ /** diff --git a/src/wp-includes/class-wp-recovery-mode-key-service.php b/src/wp-includes/class-wp-recovery-mode-key-service.php index 229e7310ee..b33c4a1697 100644 --- a/src/wp-includes/class-wp-recovery-mode-key-service.php +++ b/src/wp-includes/class-wp-recovery-mode-key-service.php @@ -3,7 +3,7 @@ * Error Protection API: WP_Recovery_Mode_Key_Service class * * @package WordPress - * @since 5.2.0 + * @since 5.2.0 */ /** diff --git a/src/wp-includes/class-wp-recovery-mode-link-service.php b/src/wp-includes/class-wp-recovery-mode-link-service.php index bbeafc77a0..1344cb7cab 100644 --- a/src/wp-includes/class-wp-recovery-mode-link-service.php +++ b/src/wp-includes/class-wp-recovery-mode-link-service.php @@ -3,7 +3,7 @@ * Error Protection API: WP_Recovery_Mode_Link_Handler class * * @package WordPress - * @since 5.2.0 + * @since 5.2.0 */ /** diff --git a/src/wp-includes/class-wp-recovery-mode.php b/src/wp-includes/class-wp-recovery-mode.php index 608864d6ee..1ca96072ed 100644 --- a/src/wp-includes/class-wp-recovery-mode.php +++ b/src/wp-includes/class-wp-recovery-mode.php @@ -3,7 +3,7 @@ * Error Protection API: WP_Recovery_Mode class * * @package WordPress - * @since 5.2.0 + * @since 5.2.0 */ /** diff --git a/src/wp-includes/class-wp-rewrite.php b/src/wp-includes/class-wp-rewrite.php index 46b118361b..45a9fae6a4 100644 --- a/src/wp-includes/class-wp-rewrite.php +++ b/src/wp-includes/class-wp-rewrite.php @@ -442,7 +442,7 @@ class WP_Rewrite { $page_attachment_uris = array(); foreach ( $posts as $id => $post ) { - // URL => page name + // URL => page name. $uri = get_page_uri( $id ); $attachments = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = %d", $id ) ); if ( ! empty( $attachments ) ) { @@ -897,7 +897,7 @@ class WP_Rewrite { $num_tokens = count( $tokens[0] ); - $index = $this->index; //probably 'index.php' + $index = $this->index; // Probably 'index.php'. $feedindex = $index; $trackbackindex = $index; $embedindex = $index; @@ -1003,7 +1003,7 @@ class WP_Rewrite { // Start creating the array of rewrites for this dir. $rewrite = array(); - // ...adding on /feed/ regexes => queries + // ...adding on /feed/ regexes => queries. if ( $feed ) { $rewrite = array( $feedmatch => $feedquery, @@ -1012,7 +1012,7 @@ class WP_Rewrite { ); } - //...and /page/xx ones + // ...and /page/xx ones. if ( $paged ) { $rewrite = array_merge( $rewrite, array( $pagematch => $pagequery ) ); } @@ -1259,11 +1259,11 @@ class WP_Rewrite { return $rewrite; } - // robots.txt -- only if installed at the root + // robots.txt -- only if installed at the root. $home_path = parse_url( home_url() ); $robots_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'robots\.txt$' => $this->index . '?robots=1' ) : array(); - // favicon.ico -- only if installed at the root + // favicon.ico -- only if installed at the root. $favicon_rewrite = ( empty( $home_path['path'] ) || '/' == $home_path['path'] ) ? array( 'favicon\.ico$' => $this->index . '?favicon=1' ) : array(); // Old feed and service files. diff --git a/src/wp-includes/class-wp-session-tokens.php b/src/wp-includes/class-wp-session-tokens.php index 6d87d18f6d..033add33c4 100644 --- a/src/wp-includes/class-wp-session-tokens.php +++ b/src/wp-includes/class-wp-session-tokens.php @@ -143,7 +143,7 @@ abstract class WP_Session_Tokens { $session['ua'] = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); } - // Timestamp + // Timestamp. $session['login'] = time(); $token = wp_generate_password( 43, false, false ); diff --git a/src/wp-includes/class-wp-simplepie-file.php b/src/wp-includes/class-wp-simplepie-file.php index 15f879c953..6d43a3b013 100644 --- a/src/wp-includes/class-wp-simplepie-file.php +++ b/src/wp-includes/class-wp-simplepie-file.php @@ -51,7 +51,7 @@ class WP_SimplePie_File extends SimplePie_File { $args['headers'] = $this->headers; } - if ( SIMPLEPIE_USERAGENT != $this->useragent ) { //Use default WP user agent unless custom has been specified + if ( SIMPLEPIE_USERAGENT != $this->useragent ) { // Use default WP user agent unless custom has been specified. $args['user-agent'] = $this->useragent; } diff --git a/src/wp-includes/class-wp-site-query.php b/src/wp-includes/class-wp-site-query.php index 64b139dbbf..f2cc1b788a 100644 --- a/src/wp-includes/class-wp-site-query.php +++ b/src/wp-includes/class-wp-site-query.php @@ -198,7 +198,7 @@ class WP_Site_Query { 'search' => '', 'search_columns' => array(), 'count' => false, - 'date_query' => null, // See WP_Date_Query + 'date_query' => null, // See WP_Date_Query. 'update_site_cache' => true, 'update_site_meta_cache' => true, 'meta_query' => '', diff --git a/src/wp-includes/class-wp-tax-query.php b/src/wp-includes/class-wp-tax-query.php index d6ed8e1aee..1c2907b7cd 100644 --- a/src/wp-includes/class-wp-tax-query.php +++ b/src/wp-includes/class-wp-tax-query.php @@ -504,7 +504,7 @@ class WP_Tax_Query { protected function find_compatible_table_alias( $clause, $parent_query ) { $alias = false; - // Sanity check. Only IN queries use the JOIN syntax . + // Sanity check. Only IN queries use the JOIN syntax. if ( ! isset( $clause['operator'] ) || 'IN' !== $clause['operator'] ) { return $alias; } @@ -549,7 +549,7 @@ class WP_Tax_Query { return; } - // so long as there are shared terms, include_children requires that a taxonomy is set + // So long as there are shared terms, 'include_children' requires that a taxonomy is set. $query['include_children'] = false; } elseif ( ! taxonomy_exists( $query['taxonomy'] ) ) { $query = new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) ); diff --git a/src/wp-includes/class-wp-taxonomy.php b/src/wp-includes/class-wp-taxonomy.php index 24cc10187e..7cb35e9044 100644 --- a/src/wp-includes/class-wp-taxonomy.php +++ b/src/wp-includes/class-wp-taxonomy.php @@ -283,7 +283,7 @@ final class WP_Taxonomy { $args = array_merge( $defaults, $args ); - // If not set, default to the setting for public. + // If not set, default to the setting for 'public'. if ( null === $args['publicly_queryable'] ) { $args['publicly_queryable'] = $args['public']; } @@ -295,7 +295,7 @@ final class WP_Taxonomy { $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] ); } } else { - // Force query_var to false for non-public taxonomies. + // Force 'query_var' to false for non-public taxonomies. $args['query_var'] = false; } @@ -314,27 +314,27 @@ final class WP_Taxonomy { } } - // If not set, default to the setting for public. + // If not set, default to the setting for 'public'. if ( null === $args['show_ui'] ) { $args['show_ui'] = $args['public']; } - // If not set, default to the setting for show_ui. + // If not set, default to the setting for 'show_ui'. if ( null === $args['show_in_menu'] || ! $args['show_ui'] ) { $args['show_in_menu'] = $args['show_ui']; } - // If not set, default to the setting for public. + // If not set, default to the setting for 'public'. if ( null === $args['show_in_nav_menus'] ) { $args['show_in_nav_menus'] = $args['public']; } - // If not set, default to the setting for show_ui. + // If not set, default to the setting for 'show_ui'. if ( null === $args['show_tagcloud'] ) { $args['show_tagcloud'] = $args['show_ui']; } - // If not set, default to the setting for show_ui. + // If not set, default to the setting for 'show_ui'. if ( null === $args['show_in_quick_edit'] ) { $args['show_in_quick_edit'] = $args['show_ui']; } @@ -351,7 +351,7 @@ final class WP_Taxonomy { $args['object_type'] = array_unique( (array) $object_type ); - // If not set, use the default meta box + // If not set, use the default meta box. if ( null === $args['meta_box_cb'] ) { if ( $args['hierarchical'] ) { $args['meta_box_cb'] = 'post_categories_meta_box'; diff --git a/src/wp-includes/class-wp-text-diff-renderer-table.php b/src/wp-includes/class-wp-text-diff-renderer-table.php index 5155e2b802..2116c1ea97 100644 --- a/src/wp-includes/class-wp-text-diff-renderer-table.php +++ b/src/wp-includes/class-wp-text-diff-renderer-table.php @@ -249,32 +249,34 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { public function _changed( $orig, $final ) { $r = ''; - // Does the aforementioned additional processing - // *_matches tell what rows are "the same" in orig and final. Those pairs will be diffed to get word changes - // match is numeric: an index in other column - // match is 'X': no match. It is a new row - // *_rows are column vectors for the orig column and the final column. - // row >= 0: an indix of the $orig or $final array - // row < 0: a blank row for that column + /* + * Does the aforementioned additional processing: + * *_matches tell what rows are "the same" in orig and final. Those pairs will be diffed to get word changes. + * - match is numeric: an index in other column. + * - match is 'X': no match. It is a new row. + * *_rows are column vectors for the orig column and the final column. + * - row >= 0: an indix of the $orig or $final array. + * - row < 0: a blank row for that column. + */ list($orig_matches, $final_matches, $orig_rows, $final_rows) = $this->interleave_changed_lines( $orig, $final ); - // These will hold the word changes as determined by an inline diff + // These will hold the word changes as determined by an inline diff. $orig_diffs = array(); $final_diffs = array(); - // Compute word diffs for each matched pair using the inline diff + // Compute word diffs for each matched pair using the inline diff. foreach ( $orig_matches as $o => $f ) { if ( is_numeric( $o ) && is_numeric( $f ) ) { $text_diff = new Text_Diff( 'auto', array( array( $orig[ $o ] ), array( $final[ $f ] ) ) ); $renderer = new $this->inline_diff_renderer; $diff = $renderer->render( $text_diff ); - // If they're too different, don't include any <ins> or <dels> + // If they're too different, don't include any <ins> or <del>'s. if ( preg_match_all( '!(<ins>.*?</ins>|<del>.*?</del>)!', $diff, $diff_matches ) ) { - // length of all text between <ins> or <del> + // Length of all text between <ins> or <del>. $stripped_matches = strlen( strip_tags( join( ' ', $diff_matches[0] ) ) ); - // since we count lengith of text between <ins> or <del> (instead of picking just one), - // we double the length of chars not in those tags. + // Since we count length of text between <ins> or <del> (instead of picking just one), + // we double the length of chars not in those tags. $stripped_diff = strlen( strip_tags( $diff ) ) * 2 - $stripped_matches; $diff_ratio = $stripped_matches / $stripped_diff; if ( $diff_ratio > $this->_diff_threshold ) { @@ -282,7 +284,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { } } - // Un-inline the diffs by removing del or ins + // Un-inline the diffs by removing <del> or <ins>. $orig_diffs[ $o ] = preg_replace( '|<ins>.*?</ins>|', '', $diff ); $final_diffs[ $f ] = preg_replace( '|<del>.*?</del>|', '', $diff ); } @@ -374,28 +376,28 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { $o = (int) $o; $f = (int) $f; - // Already have better matches for these guys + // Already have better matches for these guys. if ( isset( $orig_matches[ $o ] ) && isset( $final_matches[ $f ] ) ) { continue; } - // First match for these guys. Must be best match + // First match for these guys. Must be best match. if ( ! isset( $orig_matches[ $o ] ) && ! isset( $final_matches[ $f ] ) ) { $orig_matches[ $o ] = $f; $final_matches[ $f ] = $o; continue; } - // Best match of this final is already taken? Must mean this final is a new row. + // Best match of this final is already taken? Must mean this final is a new row. if ( isset( $orig_matches[ $o ] ) ) { $final_matches[ $f ] = 'x'; } elseif ( isset( $final_matches[ $f ] ) ) { - // Best match of this orig is already taken? Must mean this orig is a deleted row. + // Best match of this orig is already taken? Must mean this orig is a deleted row. $orig_matches[ $o ] = 'x'; } } - // We read the text in this order + // We read the text in this order. ksort( $orig_matches ); ksort( $final_matches ); @@ -421,7 +423,7 @@ class WP_Text_Diff_Renderer_Table extends Text_Diff_Renderer { } } - // Pad the ends with blank rows if the columns aren't the same length + // Pad the ends with blank rows if the columns aren't the same length. $diff_count = count( $orig_rows ) - count( $final_rows ); if ( $diff_count < 0 ) { while ( $diff_count < 0 ) { diff --git a/src/wp-includes/class-wp-theme.php b/src/wp-includes/class-wp-theme.php index 1759230331..a72035331f 100644 --- a/src/wp-includes/class-wp-theme.php +++ b/src/wp-includes/class-wp-theme.php @@ -173,7 +173,7 @@ final class WP_Theme implements ArrayAccess { /** * Constructor for WP_Theme. * - * @since 3.4.0 + * @since 3.4.0 * * @global array $wp_theme_directories * @@ -435,7 +435,7 @@ final class WP_Theme implements ArrayAccess { /** * When converting the object to a string, the theme name is returned. * - * @since 3.4.0 + * @since 3.4.0 * * @return string Theme name, ready for display (translated) */ @@ -448,7 +448,7 @@ final class WP_Theme implements ArrayAccess { * * @staticvar array $properties * - * @since 3.4.0 + * @since 3.4.0 * * @param string $offset Property to check if set. * @return bool Whether the given property is set. @@ -477,7 +477,7 @@ final class WP_Theme implements ArrayAccess { /** * __get() magic method for properties formerly returned by current_theme_info() * - * @since 3.4.0 + * @since 3.4.0 * * @param string $offset Property to get. * @return mixed Property value. @@ -521,7 +521,7 @@ final class WP_Theme implements ArrayAccess { /** * Method to implement ArrayAccess for keys formerly returned by get_themes() * - * @since 3.4.0 + * @since 3.4.0 * * @param mixed $offset * @param mixed $value @@ -531,7 +531,7 @@ final class WP_Theme implements ArrayAccess { /** * Method to implement ArrayAccess for keys formerly returned by get_themes() * - * @since 3.4.0 + * @since 3.4.0 * * @param mixed $offset */ @@ -542,7 +542,7 @@ final class WP_Theme implements ArrayAccess { * * @staticvar array $keys * - * @since 3.4.0 + * @since 3.4.0 * * @param mixed $offset * @return bool @@ -583,7 +583,7 @@ final class WP_Theme implements ArrayAccess { * and care should be taken to use `$theme::display( 'Name' )` to get a properly * translated header. * - * @since 3.4.0 + * @since 3.4.0 * * @param mixed $offset * @return mixed @@ -959,7 +959,7 @@ final class WP_Theme implements ArrayAccess { 'seasonal' => __( 'Seasonal' ), ); - $feature_list = get_theme_feature_list( false ); // No API + $feature_list = get_theme_feature_list( false ); // No API. foreach ( $feature_list as $tags ) { $tags_list += $tags; } @@ -1341,7 +1341,7 @@ final class WP_Theme implements ArrayAccess { /** * Loads the theme's textdomain. * - * Translation files are not inherited from the parent theme. Todo: if this fails for the + * Translation files are not inherited from the parent theme. TODO: If this fails for the * child theme, it should probably try to load the parent theme's translations. * * @since 3.4.0 @@ -1414,7 +1414,7 @@ final class WP_Theme implements ArrayAccess { * * This hits the filesystem. * - * @since 4.4.0 + * @since 4.4.0 * * @return WP_Theme|false Object, or false if no theme is installed, which would be bad. */ diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index cde7811c88..afee925121 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -58,7 +58,7 @@ class WP_User_Query { private $compat_fields = array( 'results', 'total_users' ); - // SQL clauses + // SQL clauses. public $query_fields; public $query_from; public $query_where; @@ -439,7 +439,7 @@ class WP_User_Query { } } - // sorting + // Sorting. $qv['order'] = isset( $qv['order'] ) ? strtoupper( $qv['order'] ) : ''; $order = $this->parse_order( $qv['order'] ); @@ -489,7 +489,7 @@ class WP_User_Query { $this->query_orderby = 'ORDER BY ' . implode( ', ', $orderby_array ); - // limit + // Limit. if ( isset( $qv['number'] ) && $qv['number'] > 0 ) { if ( $qv['offset'] ) { $this->query_limit = $wpdb->prepare( 'LIMIT %d, %d', $qv['offset'], $qv['number'] ); @@ -763,7 +763,7 @@ class WP_User_Query { } elseif ( 'name' == $orderby || 'display_name' == $orderby ) { $_orderby = 'display_name'; } elseif ( 'post_count' == $orderby ) { - // todo: avoid the JOIN + // @todo Avoid the JOIN. $where = get_posts_by_author_sql( 'post' ); $this->query_from .= " LEFT OUTER JOIN ( SELECT post_author, COUNT(*) as post_count diff --git a/src/wp-includes/class-wp-user.php b/src/wp-includes/class-wp-user.php index 0042a7f489..b78a958579 100644 --- a/src/wp-includes/class-wp-user.php +++ b/src/wp-includes/class-wp-user.php @@ -160,7 +160,7 @@ class WP_User { /** * Sets up object properties, including capabilities. * - * @since 3.3.0 + * @since 3.3.0 * * @param object $data User DB row object. * @param int $site_id Optional. The site ID to initialize for. diff --git a/src/wp-includes/class-wp-walker.php b/src/wp-includes/class-wp-walker.php index fe15eb2e90..56bd0480c5 100644 --- a/src/wp-includes/class-wp-walker.php +++ b/src/wp-includes/class-wp-walker.php @@ -135,7 +135,7 @@ class Walker { $id_field = $this->db_fields['id']; $id = $element->$id_field; - //display this element + // Display this element. $this->has_children = ! empty( $children_elements[ $id ] ); if ( isset( $args[0] ) && is_array( $args[0] ) ) { $args[0]['has_children'] = $this->has_children; // Back-compat. @@ -143,14 +143,14 @@ class Walker { $this->start_el( $output, $element, $depth, ...array_values( $args ) ); - // descend only when the depth is right and there are childrens for this element + // Descend only when the depth is right and there are childrens for this element. if ( ( $max_depth == 0 || $max_depth > $depth + 1 ) && isset( $children_elements[ $id ] ) ) { foreach ( $children_elements[ $id ] as $child ) { if ( ! isset( $newlevel ) ) { $newlevel = true; - //start the child delimiter + // Start the child delimiter. $this->start_lvl( $output, $depth, ...array_values( $args ) ); } $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); @@ -159,11 +159,11 @@ class Walker { } if ( isset( $newlevel ) && $newlevel ) { - //end the child delimiter + // End the child delimiter. $this->end_lvl( $output, $depth, ...array_values( $args ) ); } - //end this element + // End this element. $this->end_el( $output, $element, $depth, ...array_values( $args ) ); } @@ -188,14 +188,14 @@ class Walker { public function walk( $elements, $max_depth, ...$args ) { $output = ''; - //invalid parameter or nothing to walk + // Invalid parameter or nothing to walk. if ( $max_depth < -1 || empty( $elements ) ) { return $output; } $parent_field = $this->db_fields['parent']; - // flat display + // Flat display. if ( -1 == $max_depth ) { $empty_array = array(); foreach ( $elements as $e ) { @@ -295,7 +295,7 @@ class Walker { $total_top = count( $elements ); } if ( $page_num < 1 || $per_page < 0 ) { - // No paging + // No paging. $paging = false; $start = 0; if ( -1 == $max_depth ) { @@ -311,7 +311,7 @@ class Walker { } } - // flat display + // Flat display. if ( -1 == $max_depth ) { if ( ! empty( $args[0]['reverse_top_level'] ) ) { $elements = array_reverse( $elements ); @@ -444,4 +444,4 @@ class Walker { unset( $children_elements[ $id ] ); } -} // Walker +} diff --git a/src/wp-includes/class-wp-widget-factory.php b/src/wp-includes/class-wp-widget-factory.php index 2fd4d9d60f..588d6ca710 100644 --- a/src/wp-includes/class-wp-widget-factory.php +++ b/src/wp-includes/class-wp-widget-factory.php @@ -93,7 +93,7 @@ class WP_Widget_Factory { $registered = array_map( '_get_widget_id_base', $registered ); foreach ( $keys as $key ) { - // don't register new widget if old widget with the same id is already registered + // Don't register new widget if old widget with the same id is already registered. if ( in_array( $this->widgets[ $key ]->id_base, $registered, true ) ) { unset( $this->widgets[ $key ] ); continue; diff --git a/src/wp-includes/class-wp-widget.php b/src/wp-includes/class-wp-widget.php index 0b6959fb13..d6e939bd99 100644 --- a/src/wp-includes/class-wp-widget.php +++ b/src/wp-includes/class-wp-widget.php @@ -399,13 +399,13 @@ class WP_Widget { $all_instances = $this->get_settings(); - // We need to update the data + // We need to update the data. if ( $this->updated ) { return; } if ( isset( $_POST['delete_widget'] ) && $_POST['delete_widget'] ) { - // Delete the settings for this instance of the widget + // Delete the settings for this instance of the widget. if ( isset( $_POST['the-widget-id'] ) ) { $del_id = $_POST['the-widget-id']; } else { @@ -464,7 +464,7 @@ class WP_Widget { $all_instances[ $number ] = $instance; } - break; // run only once + break; // Run only once. } } @@ -494,7 +494,7 @@ class WP_Widget { $all_instances = $this->get_settings(); if ( -1 == $widget_args['number'] ) { - // We echo out a form where 'number' can be set later + // We echo out a form where 'number' can be set later. $this->_set( '__i__' ); $instance = array(); } else { diff --git a/src/wp-includes/class-wp-xmlrpc-server.php b/src/wp-includes/class-wp-xmlrpc-server.php index 1eea9465b4..ac7189699d 100644 --- a/src/wp-includes/class-wp-xmlrpc-server.php +++ b/src/wp-includes/class-wp-xmlrpc-server.php @@ -60,7 +60,7 @@ class wp_xmlrpc_server extends IXR_Server { */ public function __construct() { $this->methods = array( - // WordPress API + // WordPress API. 'wp.getUsersBlogs' => 'this:wp_getUsersBlogs', 'wp.newPost' => 'this:wp_newPost', 'wp.editPost' => 'this:wp_editPost', @@ -85,13 +85,13 @@ class wp_xmlrpc_server extends IXR_Server { 'wp.editPage' => 'this:wp_editPage', 'wp.getPageList' => 'this:wp_getPageList', 'wp.getAuthors' => 'this:wp_getAuthors', - 'wp.getCategories' => 'this:mw_getCategories', // Alias + 'wp.getCategories' => 'this:mw_getCategories', // Alias. 'wp.getTags' => 'this:wp_getTags', 'wp.newCategory' => 'this:wp_newCategory', 'wp.deleteCategory' => 'this:wp_deleteCategory', 'wp.suggestCategories' => 'this:wp_suggestCategories', - 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias - 'wp.deleteFile' => 'this:wp_deletePost', // Alias + 'wp.uploadFile' => 'this:mw_newMediaObject', // Alias. + 'wp.deleteFile' => 'this:wp_deletePost', // Alias. 'wp.getCommentCount' => 'this:wp_getCommentCount', 'wp.getPostStatusList' => 'this:wp_getPostStatusList', 'wp.getPageStatusList' => 'this:wp_getPageStatusList', @@ -112,7 +112,7 @@ class wp_xmlrpc_server extends IXR_Server { 'wp.getRevisions' => 'this:wp_getRevisions', 'wp.restoreRevision' => 'this:wp_restoreRevision', - // Blogger API + // Blogger API. 'blogger.getUsersBlogs' => 'this:blogger_getUsersBlogs', 'blogger.getUserInfo' => 'this:blogger_getUserInfo', 'blogger.getPost' => 'this:blogger_getPost', @@ -121,7 +121,7 @@ class wp_xmlrpc_server extends IXR_Server { 'blogger.editPost' => 'this:blogger_editPost', 'blogger.deletePost' => 'this:blogger_deletePost', - // MetaWeblog API (with MT extensions to structs) + // MetaWeblog API (with MT extensions to structs). 'metaWeblog.newPost' => 'this:mw_newPost', 'metaWeblog.editPost' => 'this:mw_editPost', 'metaWeblog.getPost' => 'this:mw_getPost', @@ -129,12 +129,12 @@ class wp_xmlrpc_server extends IXR_Server { 'metaWeblog.getCategories' => 'this:mw_getCategories', 'metaWeblog.newMediaObject' => 'this:mw_newMediaObject', - // MetaWeblog API aliases for Blogger API - // see http://www.xmlrpc.com/stories/storyReader$2460 + // MetaWeblog API aliases for Blogger API. + // See http://www.xmlrpc.com/stories/storyReader$2460 'metaWeblog.deletePost' => 'this:blogger_deletePost', 'metaWeblog.getUsersBlogs' => 'this:blogger_getUsersBlogs', - // MovableType API + // MovableType API. 'mt.getCategoryList' => 'this:mt_getCategoryList', 'mt.getRecentPostTitles' => 'this:mt_getRecentPostTitles', 'mt.getPostCategories' => 'this:mt_getPostCategories', @@ -144,7 +144,7 @@ class wp_xmlrpc_server extends IXR_Server { 'mt.getTrackbackPings' => 'this:mt_getTrackbackPings', 'mt.publishPost' => 'this:mt_publishPost', - // PingBack + // Pingback. 'pingback.ping' => 'this:pingback_ping', 'pingback.extensions.getPingbacks' => 'this:pingback_extensions_getPingbacks', @@ -207,7 +207,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $number1 A number to add. @@ -278,7 +278,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( is_wp_error( $user ) ) { $this->error = new IXR_Error( 403, __( 'Incorrect username or password.' ) ); - // Flag that authentication has failed once on this wp_xmlrpc_server instance + // Flag that authentication has failed once on this wp_xmlrpc_server instance. $this->auth_failed = true; /** @@ -473,7 +473,7 @@ class wp_xmlrpc_server extends IXR_Server { */ public function initialise_blog_option_info() { $this->blog_options = array( - // Read only options + // Read-only options. 'software_name' => array( 'desc' => __( 'Software Name' ), 'readonly' => true, @@ -535,7 +535,7 @@ class wp_xmlrpc_server extends IXR_Server { 'value' => current_theme_supports( 'post-thumbnails' ), ), - // Updatable options + // Updatable options. 'time_zone' => array( 'desc' => __( 'Time Zone' ), 'readonly' => false, @@ -657,7 +657,7 @@ class wp_xmlrpc_server extends IXR_Server { return $this->error; } - // If this isn't on WPMU then just use blogger_getUsersBlogs + // If this isn't on WPMU then just use blogger_getUsersBlogs(). if ( ! is_multisite() ) { array_unshift( $args, 1 ); return $this->blogger_getUsersBlogs( $args ); @@ -1220,7 +1220,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @link https://en.wikipedia.org/wiki/RSS_enclosure for information on RSS enclosures. * - * @param array $args { + * @param array $args { * Method arguments. Note: top-level arguments must be ordered as documented. * * @type int $blog_id Blog ID (unused). @@ -1276,13 +1276,15 @@ class wp_xmlrpc_server extends IXR_Server { return $this->error; } - // convert the date field back to IXR form + // Convert the date field back to IXR form. if ( isset( $content_struct['post_date'] ) && ! ( $content_struct['post_date'] instanceof IXR_Date ) ) { $content_struct['post_date'] = $this->_convert_date( $content_struct['post_date'] ); } - // ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct, - // since _insert_post will ignore the non-GMT date if the GMT date is set + /* + * Ignore the existing GMT date if it is empty or a non-GMT date was supplied in $content_struct, + * since _insert_post() will ignore the non-GMT date if the GMT date is set. + */ if ( isset( $content_struct['post_date_gmt'] ) && ! ( $content_struct['post_date_gmt'] instanceof IXR_Date ) ) { if ( $content_struct['post_date_gmt'] == '0000-00-00 00:00:00' || isset( $content_struct['post_date'] ) ) { unset( $content_struct['post_date_gmt'] ); @@ -1489,7 +1491,7 @@ class wp_xmlrpc_server extends IXR_Server { } if ( isset( $post_data['post_thumbnail'] ) ) { - // empty value deletes, non-empty value adds/updates. + // Empty value deletes, non-empty value adds/updates. if ( ! $post_data['post_thumbnail'] ) { delete_post_thumbnail( $post_ID ); } elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) ) { @@ -1655,7 +1657,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 3.4.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id Blog ID (unused). @@ -1713,10 +1715,10 @@ class wp_xmlrpc_server extends IXR_Server { } /* - * If the API client did not provide post_date, then we must not perpetuate the value that was - * stored in the database, or it will appear to be an intentional edit. Conveying it here as if - * it was coming from the API client will cause an otherwise zeroed out post_date_gmt to get set - * with the value that was originally stored in the database when the draft was created. + * If the API client did not provide 'post_date', then we must not perpetuate the value that + * was stored in the database, or it will appear to be an intentional edit. Conveying it here + * as if it was coming from the API client will cause an otherwise zeroed out 'post_date_gmt' + * to get set with the value that was originally stored in the database when the draft was created. */ if ( ! isset( $content_struct['post_date'] ) ) { unset( $post['post_date'] ); @@ -1740,7 +1742,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see wp_delete_post() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id Blog ID (unused). @@ -2041,7 +2043,7 @@ class wp_xmlrpc_server extends IXR_Server { $taxonomy = (array) $taxonomy; - // hold the data of the term + // Hold the data of the term. $term_data = array(); $term_data['name'] = trim( $content_struct['name'] ); @@ -2142,7 +2144,7 @@ class wp_xmlrpc_server extends IXR_Server { $taxonomy = (array) $taxonomy; - // hold the data of the term + // Hold the data of the term. $term_data = array(); $term = get_term( $term_id, $content_struct['taxonomy'] ); @@ -2219,7 +2221,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see wp_delete_term() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id Blog ID (unused). @@ -2289,7 +2291,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see get_term() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id Blog ID (unused). @@ -2362,7 +2364,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see get_terms() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id Blog ID (unused). @@ -2454,7 +2456,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see get_taxonomy() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id Blog ID (unused). @@ -2520,7 +2522,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see get_taxonomies() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id Blog ID (unused). @@ -2560,11 +2562,11 @@ class wp_xmlrpc_server extends IXR_Server { $taxonomies = get_taxonomies( $filter, 'objects' ); - // holds all the taxonomy data + // Holds all the taxonomy data. $struct = array(); foreach ( $taxonomies as $taxonomy ) { - // capability check for post_types + // Capability check for post types. if ( ! current_user_can( $taxonomy->cap->assign_terms ) ) { continue; } @@ -2588,7 +2590,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @uses get_userdata() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -2670,7 +2672,7 @@ class wp_xmlrpc_server extends IXR_Server { * @uses get_users() * @see wp_getUser() for more on $fields and return values * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -2752,7 +2754,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @uses get_userdata() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -2801,7 +2803,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @uses wp_update_user() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -2841,11 +2843,11 @@ class wp_xmlrpc_server extends IXR_Server { return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit your profile.' ) ); } - // holds data of the user + // Holds data of the user. $user_data = array(); $user_data['ID'] = $user->ID; - // only set the user details if it was given + // Only set the user details if they were given. if ( isset( $content_struct['first_name'] ) ) { $user_data['first_name'] = $content_struct['first_name']; } @@ -2892,7 +2894,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.2.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -2930,7 +2932,7 @@ class wp_xmlrpc_server extends IXR_Server { if ( $page->ID && ( $page->post_type == 'page' ) ) { return $this->_prepare_page( $page ); } else { - // If the page doesn't exist indicate that. + // If the page doesn't exist, indicate that. return new IXR_Error( 404, __( 'Sorry, no such page.' ) ); } } @@ -2940,7 +2942,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.2.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3001,7 +3003,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see wp_xmlrpc_server::mw_newPost() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3012,7 +3014,7 @@ class wp_xmlrpc_server extends IXR_Server { * @return int|IXR_Error */ public function wp_newPage( $args ) { - // Items not escaped here will be escaped in newPost. + // Items not escaped here will be escaped in wp_newPost(). $username = $this->escape( $args[1] ); $password = $this->escape( $args[2] ); @@ -3027,7 +3029,7 @@ class wp_xmlrpc_server extends IXR_Server { // Mark this as content for a page. $args[3]['post_type'] = 'page'; - // Let mw_newPost do all of the heavy lifting. + // Let mw_newPost() do all of the heavy lifting. return $this->mw_newPost( $args ); } @@ -3036,7 +3038,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.2.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3061,7 +3063,7 @@ class wp_xmlrpc_server extends IXR_Server { /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.deletePage' ); - // Get the current page based on the page_id and + // Get the current page based on the 'page_id' and // make sure it is a page and not a post. $actual_page = get_post( $page_id, ARRAY_A ); if ( ! $actual_page || ( $actual_page['post_type'] != 'page' ) ) { @@ -3097,7 +3099,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.2.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3110,7 +3112,7 @@ class wp_xmlrpc_server extends IXR_Server { * @return array|IXR_Error */ public function wp_editPage( $args ) { - // Items will be escaped in mw_editPost. + // Items will be escaped in mw_editPost(). $page_id = (int) $args[1]; $username = $args[2]; $password = $args[3]; @@ -3142,7 +3144,7 @@ class wp_xmlrpc_server extends IXR_Server { // Mark this as content for a page. $content['post_type'] = 'page'; - // Arrange args in the way mw_editPost understands. + // Arrange args in the way mw_editPost() understands. $args = array( $page_id, $username, @@ -3151,7 +3153,7 @@ class wp_xmlrpc_server extends IXR_Server { $publish, ); - // Let mw_editPost do all of the heavy lifting. + // Let mw_editPost() do all of the heavy lifting. return $this->mw_editPost( $args ); } @@ -3162,7 +3164,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @global wpdb $wpdb WordPress database abstraction object. * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3191,7 +3193,7 @@ class wp_xmlrpc_server extends IXR_Server { /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'wp.getPageList' ); - // Get list of pages ids and titles + // Get list of page IDs and titles. $page_list = $wpdb->get_results( " SELECT ID page_id, @@ -3225,7 +3227,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.2.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3269,7 +3271,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.7.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3321,7 +3323,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.2.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3351,19 +3353,19 @@ class wp_xmlrpc_server extends IXR_Server { return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a category.' ) ); } - // If no slug was provided make it empty so that - // WordPress will generate one. + // If no slug was provided, make it empty + // so that WordPress will generate one. if ( empty( $category['slug'] ) ) { $category['slug'] = ''; } - // If no parent_id was provided make it empty - // so that it will be a top level page (no parent). + // If no parent_id was provided, make it empty + // so that it will be a top-level page (no parent). if ( ! isset( $category['parent_id'] ) ) { $category['parent_id'] = ''; } - // If no description was provided make it empty. + // If no description was provided, make it empty. if ( empty( $category['description'] ) ) { $category['description'] = ''; } @@ -3404,7 +3406,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3455,7 +3457,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.2.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3507,7 +3509,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.7.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3560,7 +3562,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.7.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3647,7 +3649,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.7.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3713,7 +3715,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.7.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3762,9 +3764,9 @@ class wp_xmlrpc_server extends IXR_Server { $comment['comment_approved'] = $content_struct['status']; } - // Do some timestamp voodoo + // Do some timestamp voodoo. if ( ! empty( $content_struct['date_created_gmt'] ) ) { - // We know this is supposed to be GMT, so we're going to slap that Z on there by force + // We know this is supposed to be GMT, so we're going to slap that Z on there by force. $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; $comment['comment_date'] = get_date_from_gmt( $dateCreated ); $comment['comment_date_gmt'] = iso8601_to_datetime( $dateCreated, 'gmt' ); @@ -3813,7 +3815,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.7.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3950,7 +3952,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.7.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -3985,7 +3987,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4034,7 +4036,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4069,7 +4071,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4104,7 +4106,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.6.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4139,7 +4141,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.6.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4161,7 +4163,7 @@ class wp_xmlrpc_server extends IXR_Server { return $this->error; } - // If no specific options where asked for, return all of them + // If no specific options where asked for, return all of them. if ( count( $options ) == 0 ) { $options = array_keys( $this->blog_options ); } @@ -4183,7 +4185,7 @@ class wp_xmlrpc_server extends IXR_Server { foreach ( $options as $option ) { if ( array_key_exists( $option, $this->blog_options ) ) { $data[ $option ] = $this->blog_options[ $option ]; - //Is the value static or dynamic? + // Is the value static or dynamic? if ( isset( $data[ $option ]['option'] ) ) { $data[ $option ]['value'] = get_option( $data[ $option ]['option'] ); unset( $data[ $option ]['option'] ); @@ -4203,7 +4205,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 2.6.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4243,7 +4245,7 @@ class wp_xmlrpc_server extends IXR_Server { update_option( $this->blog_options[ $o_name ]['option'], wp_unslash( $o_value ) ); } - //Now return the updated values + // Now return the updated values. return $this->_getOptions( $option_names ); } @@ -4252,7 +4254,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 3.1.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4313,7 +4315,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 3.1.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4371,7 +4373,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 3.1.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4400,7 +4402,7 @@ class wp_xmlrpc_server extends IXR_Server { $formats = get_post_format_strings(); - // find out if they want a list of currently supports formats + // Find out if they want a list of currently supports formats. if ( isset( $args[3] ) && is_array( $args[3] ) ) { if ( $args[3]['show-supported'] ) { if ( current_theme_supports( 'post-formats' ) ) { @@ -4425,7 +4427,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see get_post_type_object() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4498,7 +4500,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @see get_post_types() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4561,7 +4563,7 @@ class wp_xmlrpc_server extends IXR_Server { * @uses wp_get_post_revisions() * @see wp_getPost() for more on $fields * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4632,7 +4634,7 @@ class wp_xmlrpc_server extends IXR_Server { continue; } - // Skip autosaves + // Skip autosaves. if ( wp_is_post_autosave( $revision ) ) { continue; } @@ -4650,7 +4652,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @uses wp_restore_post_revision() * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4707,8 +4709,9 @@ class wp_xmlrpc_server extends IXR_Server { return (bool) $post; } - /* Blogger API functions. - * specs on http://plant.blogger.com/api and https://groups.yahoo.com/group/bloggerDev/ + /* + * Blogger API functions. + * Specs on http://plant.blogger.com/api and https://groups.yahoo.com/group/bloggerDev/ */ /** @@ -4718,7 +4721,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4808,7 +4811,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4851,7 +4854,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -4906,7 +4909,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type string $appkey (unused) @@ -4921,7 +4924,7 @@ class wp_xmlrpc_server extends IXR_Server { $this->escape( $args ); - // $args[0] = appkey - ignored + // $args[0] = appkey - ignored. $username = $args[2]; $password = $args[3]; if ( isset( $args[4] ) ) { @@ -5079,7 +5082,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -5158,7 +5161,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -5212,8 +5215,9 @@ class wp_xmlrpc_server extends IXR_Server { return true; } - /* MetaWeblog API functions - * specs on wherever Dave Winer wants them to be + /* + * MetaWeblog API functions. + * Specs on wherever Dave Winer wants them to be. */ /** @@ -5243,7 +5247,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -5296,7 +5300,7 @@ class wp_xmlrpc_server extends IXR_Server { $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); $post_type = 'post'; } else { - // No other post_type values are allowed here + // No other 'post_type' values are allowed here. return new IXR_Error( 401, __( 'Invalid post type.' ) ); } } else { @@ -5318,7 +5322,7 @@ class wp_xmlrpc_server extends IXR_Server { return new IXR_Error( 401, $error_message ); } - // Check for a valid post format if one was given + // Check for a valid post format if one was given. if ( isset( $content_struct['wp_post_format'] ) ) { $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { @@ -5326,7 +5330,7 @@ class wp_xmlrpc_server extends IXR_Server { } } - // Let WordPress generate the post_name (slug) unless + // Let WordPress generate the 'post_name' (slug) unless // one has been provided. $post_name = ''; if ( isset( $content_struct['wp_slug'] ) ) { @@ -5340,14 +5344,14 @@ class wp_xmlrpc_server extends IXR_Server { $post_password = ''; } - // Only set a post parent if one was provided. + // Only set a post parent if one was given. if ( isset( $content_struct['wp_page_parent_id'] ) ) { $post_parent = $content_struct['wp_page_parent_id']; } else { $post_parent = 0; } - // Only set the menu_order if it was provided. + // Only set the 'menu_order' if it was given. if ( isset( $content_struct['wp_page_order'] ) ) { $menu_order = $content_struct['wp_page_order']; } else { @@ -5476,9 +5480,9 @@ class wp_xmlrpc_server extends IXR_Server { } } - // Do some timestamp voodoo + // Do some timestamp voodoo. if ( ! empty( $content_struct['date_created_gmt'] ) ) { - // We know this is supposed to be GMT, so we're going to slap that Z on there by force + // We know this is supposed to be GMT, so we're going to slap that Z on there by force. $dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z'; } elseif ( ! empty( $content_struct['dateCreated'] ) ) { $dateCreated = $content_struct['dateCreated']->getIso(); @@ -5508,7 +5512,7 @@ class wp_xmlrpc_server extends IXR_Server { $post_ID = get_default_post_to_edit( $post_type, true )->ID; $postdata['ID'] = $post_ID; - // Only posts can be sticky + // Only posts can be sticky. if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { $data = $postdata; $data['sticky'] = $content_struct['sticky']; @@ -5530,14 +5534,14 @@ class wp_xmlrpc_server extends IXR_Server { unset( $content_struct['wp_post_thumbnail'] ); } - // Handle enclosures + // Handle enclosures. $thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null; $this->add_enclosure_if_new( $post_ID, $thisEnclosure ); $this->attach_uploads( $post_ID, $post_content ); // Handle post formats if assigned, value is validated earlier - // in this function + // in this function. if ( isset( $content_struct['wp_post_format'] ) ) { set_post_format( $post_ID, $content_struct['wp_post_format'] ); } @@ -5605,7 +5609,7 @@ class wp_xmlrpc_server extends IXR_Server { public function attach_uploads( $post_ID, $post_content ) { global $wpdb; - // find any unattached files + // Find any unattached files. $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); if ( is_array( $attachments ) ) { foreach ( $attachments as $file ) { @@ -5621,7 +5625,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -5673,7 +5677,7 @@ class wp_xmlrpc_server extends IXR_Server { return new IXR_Error( 401, __( 'The post type may not be changed.' ) ); } - // Check for a valid post format if one was given + // Check for a valid post format if one was given. if ( isset( $content_struct['wp_post_format'] ) ) { $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { @@ -5710,7 +5714,7 @@ class wp_xmlrpc_server extends IXR_Server { $post_parent = $content_struct['wp_page_parent_id']; } - // Only set the menu_order if it was given. + // Only set the 'menu_order' if it was given. if ( isset( $content_struct['wp_page_order'] ) ) { $menu_order = $content_struct['wp_page_order']; } @@ -5722,7 +5726,7 @@ class wp_xmlrpc_server extends IXR_Server { $post_author = $postdata['post_author']; - // Only set the post_author if one is set. + // If an author id was provided then use it instead. if ( isset( $content_struct['wp_author_id'] ) ) { // Check permissions if attempting to switch author to or from another user. if ( $user->ID != $content_struct['wp_author_id'] || $user->ID != $post_author ) { @@ -5896,7 +5900,7 @@ class wp_xmlrpc_server extends IXR_Server { return new IXR_Error( 500, __( 'Sorry, the post could not be updated.' ) ); } - // Only posts can be sticky + // Only posts can be sticky. if ( $post_type == 'post' && isset( $content_struct['sticky'] ) ) { $data = $newpost; $data['sticky'] = $content_struct['sticky']; @@ -5953,7 +5957,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -6019,12 +6023,12 @@ class wp_xmlrpc_server extends IXR_Server { $allow_comments = ( 'open' == $postdata['comment_status'] ) ? 1 : 0; $allow_pings = ( 'open' == $postdata['ping_status'] ) ? 1 : 0; - // Consider future posts as published + // Consider future posts as published. if ( $postdata['post_status'] === 'future' ) { $postdata['post_status'] = 'publish'; } - // Get post format + // Get post format. $post_format = get_post_format( $post_ID ); if ( empty( $post_format ) ) { $post_format = 'standard'; @@ -6056,8 +6060,8 @@ class wp_xmlrpc_server extends IXR_Server { 'title' => $postdata['post_title'], 'link' => $link, 'permaLink' => $link, - // commented out because no other tool seems to use this - // 'content' => $entry['post_content'], + // Commented out because no other tool seems to use this. + // 'content' => $entry['post_content'], 'categories' => $categories, 'mt_excerpt' => $postdata['post_excerpt'], 'mt_text_more' => $post['extended'], @@ -6095,7 +6099,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -6171,12 +6175,12 @@ class wp_xmlrpc_server extends IXR_Server { $allow_comments = ( 'open' == $entry['comment_status'] ) ? 1 : 0; $allow_pings = ( 'open' == $entry['ping_status'] ) ? 1 : 0; - // Consider future posts as published + // Consider future posts as published. if ( $entry['post_status'] === 'future' ) { $entry['post_status'] = 'publish'; } - // Get post format + // Get post format. $post_format = get_post_format( $entry['ID'] ); if ( empty( $post_format ) ) { $post_format = 'standard'; @@ -6190,7 +6194,7 @@ class wp_xmlrpc_server extends IXR_Server { 'title' => $entry['post_title'], 'link' => $link, 'permaLink' => $link, - // commented out because no other tool seems to use this + // Commented out because no other tool seems to use this. // 'content' => $entry['post_content'], 'categories' => $categories, 'mt_excerpt' => $entry['post_excerpt'], @@ -6222,7 +6226,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -6281,7 +6285,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @global wpdb $wpdb WordPress database abstraction object. * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -6348,7 +6352,7 @@ class wp_xmlrpc_server extends IXR_Server { $errorString = sprintf( __( 'Could not write file %1$s (%2$s).' ), $name, $upload['error'] ); return new IXR_Error( 500, $errorString ); } - // Construct the attachment array + // Construct the attachment array. $post_id = 0; if ( ! empty( $data['post_id'] ) ) { $post_id = (int) $data['post_id']; @@ -6366,7 +6370,7 @@ class wp_xmlrpc_server extends IXR_Server { 'guid' => $upload['url'], ); - // Save the data + // Save the data. $id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); @@ -6382,7 +6386,7 @@ class wp_xmlrpc_server extends IXR_Server { $struct = $this->_prepare_media_item( get_post( $id ) ); - // Deprecated values + // Deprecated values. $struct['id'] = $struct['attachment_id']; $struct['file'] = $struct['title']; $struct['url'] = $struct['link']; @@ -6390,8 +6394,9 @@ class wp_xmlrpc_server extends IXR_Server { return $struct; } - /* MovableType API functions - * specs on http://www.movabletype.org/docs/mtmanual_programmatic.html + /* + * MovableType API functions. + * Specs on http://www.movabletype.org/docs/mtmanual_programmatic.html */ /** @@ -6399,7 +6404,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -6463,7 +6468,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $blog_id (unused) @@ -6516,7 +6521,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $post_ID @@ -6550,7 +6555,7 @@ class wp_xmlrpc_server extends IXR_Server { $categories = array(); $catids = wp_get_post_categories( intval( $post_ID ) ); - // first listed category will be the primary category + // First listed category will be the primary category. $isPrimary = true; foreach ( $catids as $catid ) { $categories[] = array( @@ -6569,7 +6574,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $post_ID @@ -6695,7 +6700,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type int $post_ID @@ -6730,16 +6735,16 @@ class wp_xmlrpc_server extends IXR_Server { $postdata['post_status'] = 'publish'; - // retain old cats - $cats = wp_get_post_categories( $post_ID ); - $postdata['post_category'] = $cats; + // Retain old categories. + $postdata['post_category'] = wp_get_post_categories( $post_ID ); $this->escape( $postdata ); return wp_update_post( $postdata ); } - /* PingBack functions - * specs on www.hixie.ch/specs/pingback/pingback + /* + * Pingback functions. + * Specs on www.hixie.ch/specs/pingback/pingback */ /** @@ -6747,7 +6752,7 @@ class wp_xmlrpc_server extends IXR_Server { * * @since 1.5.0 * - * @param array $args { + * @param array $args { * Method arguments. Note: arguments must be ordered as documented. * * @type string $pagelinkedfrom @@ -6781,54 +6786,56 @@ class wp_xmlrpc_server extends IXR_Server { return $this->pingback_error( 0, __( 'A valid URL was not provided.' ) ); } - // Check if the page linked to is in our site + // Check if the page linked to is on our site. $pos1 = strpos( $pagelinkedto, str_replace( array( 'http://www.', 'http://', 'https://www.', 'https://' ), '', get_option( 'home' ) ) ); if ( ! $pos1 ) { return $this->pingback_error( 0, __( 'Is there no link to us?' ) ); } - // let's find which post is linked to - // FIXME: does url_to_postid() cover all these cases already? - // if so, then let's use it and drop the old code. + /* + * Let's find which post is linked to. + * FIXME: Does url_to_postid() cover all these cases already? + * If so, then let's use it and drop the old code. + */ $urltest = parse_url( $pagelinkedto ); $post_ID = url_to_postid( $pagelinkedto ); if ( $post_ID ) { // $way } elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) { - // the path defines the post_ID (archives/p/XXXX) + // The path defines the post_ID (archives/p/XXXX). $blah = explode( '/', $match[0] ); $post_ID = (int) $blah[1]; } elseif ( isset( $urltest['query'] ) && preg_match( '#p=[0-9]{1,}#', $urltest['query'], $match ) ) { - // the querystring defines the post_ID (?p=XXXX) + // The query string defines the post_ID (?p=XXXX). $blah = explode( '=', $match[0] ); $post_ID = (int) $blah[1]; } elseif ( isset( $urltest['fragment'] ) ) { - // an #anchor is there, it's either... + // An #anchor is there, it's either... if ( intval( $urltest['fragment'] ) ) { - // ...an integer #XXXX (simplest case) + // ...an integer #XXXX (simplest case), $post_ID = (int) $urltest['fragment']; } elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) { - // ...a post id in the form 'post-###' + // ...a post ID in the form 'post-###', $post_ID = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] ); } elseif ( is_string( $urltest['fragment'] ) ) { - // ...or a string #title, a little more complicated + // ...or a string #title, a little more complicated. $title = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] ); $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title ); $post_ID = $wpdb->get_var( $sql ); if ( ! $post_ID ) { - // returning unknown error '0' is better than die()ing + // Returning unknown error '0' is better than die()'ing. return $this->pingback_error( 0, '' ); } } } else { - // TODO: Attempt to extract a post ID from the given URL + // TODO: Attempt to extract a post ID from the given URL. return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); } $post_ID = (int) $post_ID; $post = get_post( $post_ID ); - if ( ! $post ) { // Post_ID not found + if ( ! $post ) { // Post not found. return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); } @@ -6836,17 +6843,17 @@ class wp_xmlrpc_server extends IXR_Server { return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) ); } - // Check if pings are on + // Check if pings are on. if ( ! pings_open( $post ) ) { return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); } - // Let's check that the remote site didn't already pingback this entry + // Let's check that the remote site didn't already pingback this entry. if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom ) ) ) { return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); } - // very stupid, but gives time to the 'from' server to publish ! + // Very stupid, but gives time to the 'from' server to publish! sleep( 1 ); $remote_ip = preg_replace( '/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR'] ); @@ -6854,7 +6861,7 @@ class wp_xmlrpc_server extends IXR_Server { /** This filter is documented in wp-includes/class-http.php */ $user_agent = apply_filters( 'http_headers_useragent', 'WordPress/' . get_bloginfo( 'version' ) . '; ' . get_bloginfo( 'url' ), $pagelinkedfrom ); - // Let's check the remote site + // Let's check the remote site. $http_api_args = array( 'timeout' => 10, 'redirection' => 0, @@ -6904,16 +6911,16 @@ class wp_xmlrpc_server extends IXR_Server { $preg_target = preg_quote( $pagelinkedto, '|' ); foreach ( $p as $para ) { - if ( strpos( $para, $pagelinkedto ) !== false ) { // it exists, but is it a link? + if ( strpos( $para, $pagelinkedto ) !== false ) { // It exists, but is it a link? preg_match( '|<a[^>]+?' . $preg_target . '[^>]*>([^>]+?)</a>|', $para, $context ); - // If the URL isn't in a link context, keep looking + // If the URL isn't in a link context, keep looking. if ( empty( $context ) ) { continue; } - // We're going to use this fake tag to mark the context in a bit - // the marker is needed in case the link text appears more than once in the paragraph + // We're going to use this fake tag to mark the context in a bit. + // The marker is needed in case the link text appears more than once in the paragraph. $excerpt = preg_replace( '|\</?wpcontext\>|', '', $para ); // prevent really long link text @@ -6921,18 +6928,18 @@ class wp_xmlrpc_server extends IXR_Server { $context[1] = substr( $context[1], 0, 100 ) . '…'; } - $marker = '<wpcontext>' . $context[1] . '</wpcontext>'; // set up our marker - $excerpt = str_replace( $context[0], $marker, $excerpt ); // swap out the link for our marker - $excerpt = strip_tags( $excerpt, '<wpcontext>' ); // strip all tags but our context marker + $marker = '<wpcontext>' . $context[1] . '</wpcontext>'; // Set up our marker. + $excerpt = str_replace( $context[0], $marker, $excerpt ); // Swap out the link for our marker. + $excerpt = strip_tags( $excerpt, '<wpcontext>' ); // Strip all tags but our context marker. $excerpt = trim( $excerpt ); $preg_marker = preg_quote( $marker, '|' ); $excerpt = preg_replace( "|.*?\s(.{0,100}$preg_marker.{0,100})\s.*|s", '$1', $excerpt ); - $excerpt = strip_tags( $excerpt ); // YES, again, to remove the marker wrapper + $excerpt = strip_tags( $excerpt ); // YES, again, to remove the marker wrapper. break; } } - if ( empty( $context ) ) { // Link to target not found + if ( empty( $context ) ) { // Link to target not found. return $this->pingback_error( 17, __( 'The source URL does not contain a link to the target URL, and so cannot be used as a source.' ) ); } @@ -7002,14 +7009,14 @@ class wp_xmlrpc_server extends IXR_Server { $post_ID = url_to_postid( $url ); if ( ! $post_ID ) { - // We aren't sure that the resource is available and/or pingback enabled + // We aren't sure that the resource is available and/or pingback enabled. return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either doesn’t exist, or it is not a pingback-enabled resource.' ) ); } $actual_post = get_post( $post_ID, ARRAY_A ); if ( ! $actual_post ) { - // No such post = resource not found + // No such post = resource not found. return $this->pingback_error( 32, __( 'The specified target URL does not exist.' ) ); } diff --git a/src/wp-includes/class-wp.php b/src/wp-includes/class-wp.php index 508fae2f03..831c4de23d 100644 --- a/src/wp-includes/class-wp.php +++ b/src/wp-includes/class-wp.php @@ -173,10 +173,11 @@ class WP { $home_path = trim( parse_url( home_url(), PHP_URL_PATH ), '/' ); $home_path_regex = sprintf( '|^%s|i', preg_quote( $home_path, '|' ) ); - // Trim path info from the end and the leading home path from the - // front. For path info requests, this leaves us with the requesting - // filename, if any. For 404 requests, this leaves us with the - // requested permalink. + /* + * Trim path info from the end and the leading home path from the front. + * For path info requests, this leaves us with the requesting filename, if any. + * For 404 requests, this leaves us with the requested permalink. + */ $req_uri = str_replace( $pathinfo, '', $req_uri ); $req_uri = trim( $req_uri, '/' ); $req_uri = preg_replace( $home_path_regex, '', $req_uri ); @@ -189,7 +190,7 @@ class WP { $self = trim( $self, '/' ); // The requested permalink is in $pathinfo for path info requests and - // $req_uri for other requests. + // $req_uri for other requests. if ( ! empty( $pathinfo ) && ! preg_match( '|^.*' . $wp_rewrite->index . '$|', $pathinfo ) ) { $requested_path = $pathinfo; } else { @@ -206,7 +207,7 @@ class WP { // Look for matches. $request_match = $requested_path; if ( empty( $request_match ) ) { - // An empty request could only match against ^$ regex + // An empty request could only match against ^$ regex. if ( isset( $rewrite['$'] ) ) { $this->matched_rule = '$'; $query = $rewrite['$']; @@ -323,7 +324,7 @@ class WP { } } - // Convert urldecoded spaces back into + + // Convert urldecoded spaces back into '+'. foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy => $t ) { if ( $t->query_var && isset( $this->query_vars[ $t->query_var ] ) ) { $this->query_vars[ $t->query_var ] = str_replace( ' ', '+', $this->query_vars[ $t->query_var ] ); @@ -343,7 +344,7 @@ class WP { } } - // Limit publicly queried post_types to those that are publicly_queryable + // Limit publicly queried post_types to those that are 'publicly_queryable'. if ( isset( $this->query_vars['post_type'] ) ) { $queryable_post_types = get_post_types( array( 'publicly_queryable' => true ) ); if ( ! is_array( $this->query_vars['post_type'] ) ) { @@ -417,7 +418,7 @@ class WP { } elseif ( empty( $this->query_vars['feed'] ) ) { $headers['Content-Type'] = get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ); } else { - // Set the correct content type for feeds + // Set the correct content type for feeds. $type = $this->query_vars['feed']; if ( 'feed' == $this->query_vars['feed'] ) { $type = get_default_feed(); @@ -452,7 +453,7 @@ class WP { $headers['Last-Modified'] = $wp_last_modified; $headers['ETag'] = $wp_etag; - // Support for Conditional GET + // Support for conditional GET. if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ) { $client_etag = wp_unslash( $_SERVER['HTTP_IF_NONE_MATCH'] ); } else { @@ -460,10 +461,10 @@ class WP { } $client_last_modified = empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ? '' : trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); - // If string is empty, return 0. If not, attempt to parse into a timestamp + // If string is empty, return 0. If not, attempt to parse into a timestamp. $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; - // Make a timestamp for our most recent modification... + // Make a timestamp for our most recent modification.. $wp_modified_timestamp = strtotime( $wp_last_modified ); if ( ( $client_last_modified && $client_etag ) ? @@ -675,7 +676,7 @@ class WP { header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) ); } - // check for paged content that exceeds the max number of pages + // Check for paged content that exceeds the max number of pages. $next = '<!--nextpage-->'; if ( $p && false !== strpos( $p->post_content, $next ) && ! empty( $this->query_vars['page'] ) ) { $page = trim( $this->query_vars['page'], '/' ); diff --git a/src/wp-includes/class.wp-dependencies.php b/src/wp-includes/class.wp-dependencies.php index eb14bd04f0..6e9170eba8 100644 --- a/src/wp-includes/class.wp-dependencies.php +++ b/src/wp-includes/class.wp-dependencies.php @@ -152,14 +152,14 @@ class WP_Dependencies { $handle = $handle_parts[0]; $queued = in_array( $handle, $this->to_do, true ); - if ( in_array( $handle, $this->done, true ) ) { // Already done + if ( in_array( $handle, $this->done, true ) ) { // Already done. continue; } $moved = $this->set_group( $handle, $recursion, $group ); $new_group = $this->groups[ $handle ]; - if ( $queued && ! $moved ) { // already queued and in the right group + if ( $queued && ! $moved ) { // Already queued and in the right group. continue; } @@ -364,7 +364,7 @@ class WP_Dependencies { public function query( $handle, $list = 'registered' ) { switch ( $list ) { case 'registered': - case 'scripts': // back compat + case 'scripts': // Back compat. if ( isset( $this->registered[ $handle ] ) ) { return $this->registered[ $handle ]; } @@ -378,11 +378,11 @@ class WP_Dependencies { return $this->recurse_deps( $this->queue, $handle ); case 'to_do': - case 'to_print': // back compat + case 'to_print': // Back compat. return in_array( $handle, $this->to_do ); case 'done': - case 'printed': // back compat + case 'printed': // Back compat. return in_array( $handle, $this->done ); } return false; diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 0f58c1455a..0ad73cad98 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -430,7 +430,7 @@ function comment_author_url_link( $linktext = '', $before = '', $after = '', $co * @return void|string Void if `$echo` argument is true, comment classes if `$echo` is false. */ function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { - // Separates classes with a single space, collates classes for comment DIV + // Separates classes with a single space, collates classes for comment DIV. $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; if ( $echo ) { @@ -465,7 +465,7 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { return $classes; } - // Get the comment type (comment, trackback), + // Get the comment type (comment, trackback). $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type; // Add classes for comment authors that are registered users. @@ -473,7 +473,7 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { if ( $user ) { $classes[] = 'byuser'; $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); - // For comment authors who are the author of the post + // For comment authors who are the author of the post. $post = get_post( $post_id ); if ( $post ) { if ( $comment->user_id === $post->post_author ) { @@ -501,7 +501,7 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { $comment_alt++; - // Alt for top-level comments + // Alt for top-level comments. if ( 1 == $comment_depth ) { if ( $comment_thread_alt % 2 ) { $classes[] = 'thread-odd'; @@ -907,10 +907,10 @@ function get_comments_number_text( $zero = false, $one = false, $more = false ) */ if ( 'on' === _x( 'off', 'Comment number declension: on or off' ) ) { $text = preg_replace( '#<span class="screen-reader-text">.+?</span>#', '', $more ); - $text = preg_replace( '/&.+?;/', '', $text ); // Kill entities + $text = preg_replace( '/&.+?;/', '', $text ); // Kill entities. $text = trim( strip_tags( $text ), '% ' ); - // Replace '% Comments' with a proper plural form + // Replace '% Comments' with a proper plural form. if ( $text && ! preg_match( '/[0-9]+/', $text ) && false !== strpos( $more, '%' ) ) { /* translators: %s: Number of comments. */ $new_text = _n( '%s Comment', '%s Comments', $number ); @@ -927,7 +927,7 @@ function get_comments_number_text( $zero = false, $one = false, $more = false ) } } elseif ( $number == 0 ) { $output = ( false === $zero ) ? __( 'No Comments' ) : $zero; - } else { // must be one + } else { // Must be one. $output = ( false === $one ) ? __( '1 Comment' ) : $one; } /** @@ -1526,7 +1526,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false require( $include ); } elseif ( file_exists( TEMPLATEPATH . $file ) ) { require( TEMPLATEPATH . $file ); - } else { // Backward compat code will be removed in a future release + } else { // Backward compat code will be removed in a future release. require( ABSPATH . WPINC . '/theme-compat/comments.php' ); } } @@ -2052,7 +2052,7 @@ function wp_list_comments( $args = array(), $comments = null ) { */ $parsed_args = apply_filters( 'wp_list_comments_args', $parsed_args ); - // Figure out what comments we'll be looping through ($_comments) + // Figure out what comments we'll be looping through ($_comments). if ( null !== $comments ) { $comments = (array) $comments; if ( empty( $comments ) ) { @@ -2176,7 +2176,7 @@ function wp_list_comments( $args = array(), $comments = null ) { set_query_var( 'cpage', $parsed_args['page'] ); } } - // Validation check + // Validation check. $parsed_args['page'] = intval( $parsed_args['page'] ); if ( 0 == $parsed_args['page'] && 0 != $parsed_args['per_page'] ) { $parsed_args['page'] = 1; @@ -2452,7 +2452,7 @@ function comment_form( $args = array(), $post_id = null ) { // Ensure that the filtered args contain all required default values. $args = array_merge( $defaults, $args ); - // Remove aria-describedby from the email field if there's no associated description. + // Remove `aria-describedby` from the email field if there's no associated description. if ( isset( $args['fields']['email'] ) && false === strpos( $args['comment_notes_before'], 'id="email-notes"' ) ) { $args['fields']['email'] = str_replace( ' aria-describedby="email-notes"', @@ -2554,10 +2554,10 @@ function comment_form( $args = array(), $post_id = null ) { */ $comment_fields = apply_filters( 'comment_form_fields', $comment_fields ); - // Get an array of field names, excluding the textarea + // Get an array of field names, excluding the textarea. $comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) ); - // Get the first and the last field name, excluding the textarea + // Get the first and the last field name, excluding the textarea. $first_field = reset( $comment_field_keys ); $last_field = end( $comment_field_keys ); diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index fca5ab9db4..63ad45bc8e 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -438,7 +438,7 @@ function get_comment_count( $post_id = 0 ) { } // -// Comment meta functions +// Comment meta functions. // /** @@ -657,7 +657,7 @@ function sanitize_comment_cookies() { function wp_allow_comment( $commentdata, $avoid_die = false ) { global $wpdb; - // Simple duplicate check + // Simple duplicate check. // expected_slashed ($comment_post_ID, $comment_author, $comment_author_email, $comment_content) $dupe = $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s ", @@ -869,7 +869,7 @@ function wp_check_comment_flood( $is_flood, $ip, $email, $date, $avoid_die = fal return $is_flood; } - // don't throttle admins or moderators + // Don't throttle admins or moderators. if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) { return false; } @@ -1093,7 +1093,7 @@ function get_page_of_comment( $comment_ID, $args = array() ) { } } - // Find this comment's top level parent if threading is enabled + // Find this comment's top-level parent if threading is enabled. if ( $args['max_depth'] > 1 && 0 != $comment->comment_parent ) { return get_page_of_comment( $comment->comment_parent, $args ); } @@ -1120,7 +1120,7 @@ function get_page_of_comment( $comment_ID, $args = array() ) { if ( 0 == $older_comment_count ) { $page = 1; - // Divide comments older than this one by comments per page to get this comment's page number + // Divide comments older than this one by comments per page to get this comment's page number. } else { $page = ceil( ( $older_comment_count + 1 ) / $args['per_page'] ); } @@ -1180,7 +1180,7 @@ function wp_get_comment_fields_max_lengths() { $col_length = $wpdb->get_col_length( $wpdb->comments, $column ); $max_length = 0; - // No point if we can't get the DB column lengths + // No point if we can't get the DB column lengths. if ( is_wp_error( $col_length ) ) { break; } @@ -1272,7 +1272,7 @@ function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_ag $mod_keys = trim( get_option( 'blacklist_keys' ) ); if ( '' == $mod_keys ) { - return false; // If moderation keys are empty + return false; // If moderation keys are empty. } // Ensure HTML tags are not being used to bypass the blacklist. @@ -1283,12 +1283,12 @@ function wp_blacklist_check( $author, $email, $url, $comment, $user_ip, $user_ag foreach ( (array) $words as $word ) { $word = trim( $word ); - // Skip empty lines + // Skip empty lines. if ( empty( $word ) ) { continue; } - // Do some escaping magic so that '#' chars in the - // spam words don't break things: + // Do some escaping magic so that '#' chars + // in the spam words don't break things: $word = preg_quote( $word, '#' ); $pattern = "#$word#i"; @@ -1407,7 +1407,7 @@ function wp_delete_comment( $comment_id, $force_delete = false ) { clean_comment_cache( $children ); } - // Delete metadata + // Delete metadata. $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) ); foreach ( $meta_ids as $mid ) { delete_metadata_by_mid( 'comment', $mid ); @@ -1690,15 +1690,15 @@ function wp_get_comment_status( $comment_id ) { */ function wp_transition_comment_status( $new_status, $old_status, $comment ) { /* - * Translate raw statuses to human readable formats for the hooks. + * Translate raw statuses to human-readable formats for the hooks. * This is not a complete list of comment status, it's only the ones - * that need to be renamed + * that need to be renamed. */ $comment_statuses = array( 0 => 'unapproved', - 'hold' => 'unapproved', // wp_set_comment_status() uses "hold" + 'hold' => 'unapproved', // wp_set_comment_status() uses "hold". 1 => 'approved', - 'approve' => 'approved', // wp_set_comment_status() uses "approve" + 'approve' => 'approved', // wp_set_comment_status() uses "approve". ); if ( isset( $comment_statuses[ $new_status ] ) ) { $new_status = $comment_statuses[ $new_status ]; @@ -1707,7 +1707,7 @@ function wp_transition_comment_status( $new_status, $old_status, $comment ) { $old_status = $comment_statuses[ $old_status ]; } - // Call the hooks + // Call the hooks. if ( $new_status != $old_status ) { /** * Fires when the comment status is in transition. @@ -2020,7 +2020,7 @@ function wp_filter_comment( $commentdata ) { * @return bool Whether comment should be blocked. */ function wp_throttle_comment_flood( $block, $time_lastcomment, $time_newcomment ) { - if ( $block ) { // a plugin has already blocked... we'll let that decision stand + if ( $block ) { // A plugin has already blocked... we'll let that decision stand. return $block; } if ( ( $time_newcomment - $time_lastcomment ) < 15 ) { @@ -2321,7 +2321,7 @@ function wp_set_comment_status( $comment_id, $comment_status, $wp_error = false function wp_update_comment( $commentarr ) { global $wpdb; - // First, get all of the original fields + // First, get all of the original fields. $comment = get_comment( $commentarr['comment_ID'], ARRAY_A ); if ( empty( $comment ) ) { return 0; @@ -2430,7 +2430,7 @@ function wp_defer_comment_counting( $defer = null ) { if ( is_bool( $defer ) ) { $_defer = $defer; - // flush any deferred counts + // Flush any deferred counts. if ( ! $defer ) { wp_update_comment_count( null, true ); } @@ -2586,7 +2586,7 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) { return false; } - //Do not search for a pingback server on our own uploads + // Do not search for a pingback server on our own uploads. $uploads_dir = wp_get_upload_dir(); if ( 0 === strpos( $url, $uploads_dir['baseurl'] ) ) { return false; @@ -2613,7 +2613,7 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) { return false; } - // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file) + // Now do a GET since we're going to look in the html headers (and we're sure it's not a binary file). $response = wp_safe_remote_get( $url, array( @@ -2639,7 +2639,7 @@ function discover_pingback_server_uri( $url, $deprecated = '' ) { $pingback_server_url_len = $pingback_href_end - $pingback_href_start; $pingback_server_url = substr( $contents, $pingback_href_start, $pingback_server_url_len ); - // We may find rel="pingback" but an incomplete pingback URL + // We may find rel="pingback" but an incomplete pingback URL. if ( $pingback_server_url_len > 0 ) { // We got it! return $pingback_server_url; } @@ -2804,7 +2804,7 @@ function pingback( $content, $post_id ) { include_once( ABSPATH . WPINC . '/class-IXR.php' ); include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); - // original code by Mort (http://mort.mine.nu:8080) + // Original code by Mort (http://mort.mine.nu:8080). $post_links = array(); $post = get_post( $post_id ); @@ -2818,22 +2818,27 @@ function pingback( $content, $post_id ) { $content = $post->post_content; } - // Step 1 - // Parsing the post, external links (if any) are stored in the $post_links array + /* + * Step 1. + * Parsing the post, external links (if any) are stored in the $post_links array. + */ $post_links_temp = wp_extract_urls( $content ); - // Step 2. - // Walking thru the links array - // first we get rid of links pointing to sites, not to specific files - // Example: - // http://dummy-weblog.org - // http://dummy-weblog.org/ - // http://dummy-weblog.org/post.php - // We don't wanna ping first and second types, even if they have a valid <link/> - - foreach ( (array) $post_links_temp as $link_test ) : - if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID ) // If we haven't pung it already and it isn't a link to itself - && ! is_local_attachment( $link_test ) ) : // Also, let's never ping local attachments. + /* + * Step 2. + * Walking through the links array. + * First we get rid of links pointing to sites, not to specific files. + * Example: + * http://dummy-weblog.org + * http://dummy-weblog.org/ + * http://dummy-weblog.org/post.php + * We don't wanna ping first and second types, even if they have a valid <link/>. + */ + foreach ( (array) $post_links_temp as $link_test ) { + // If we haven't pung it already and it isn't a link to itself. + if ( ! in_array( $link_test, $pung ) && ( url_to_postid( $link_test ) != $post->ID ) + // Also, let's never ping local attachments. + && ! is_local_attachment( $link_test ) ) { $test = @parse_url( $link_test ); if ( $test ) { if ( isset( $test['query'] ) ) { @@ -2842,10 +2847,11 @@ function pingback( $content, $post_id ) { $post_links[] = $link_test; } } - endif; - endforeach; + } + } $post_links = array_unique( $post_links ); + /** * Fires just before pinging back links found in a post. * @@ -2862,10 +2868,10 @@ function pingback( $content, $post_id ) { if ( $pingback_server_url ) { set_time_limit( 60 ); - // Now, the RPC call + // Now, the RPC call. $pagelinkedfrom = get_permalink( $post ); - // using a timeout of 3 seconds should be enough to cover slow servers + // Using a timeout of 3 seconds should be enough to cover slow servers. $client = new WP_HTTP_IXR_Client( $pingback_server_url ); $client->timeout = 3; /** @@ -2881,10 +2887,10 @@ function pingback( $content, $post_id ) { * @param string $pagelinkedfrom URL of page linked from. */ $client->useragent = apply_filters( 'pingback_useragent', $client->useragent . ' -- WordPress/' . get_bloginfo( 'version' ), $client->useragent, $pingback_server_url, $pagelinkedto, $pagelinkedfrom ); - // when set to true, this outputs debug messages by itself + // When set to true, this outputs debug messages by itself. $client->debug = false; - if ( $client->query( 'pingback.ping', $pagelinkedfrom, $pagelinkedto ) || ( isset( $client->error->code ) && 48 == $client->error->code ) ) { // Already registered + if ( $client->query( 'pingback.ping', $pagelinkedfrom, $pagelinkedto ) || ( isset( $client->error->code ) && 48 == $client->error->code ) ) { // Already registered. add_ping( $post, $pagelinkedto ); } } @@ -2960,15 +2966,15 @@ function weblog_ping( $server = '', $path = '' ) { include_once( ABSPATH . WPINC . '/class-IXR.php' ); include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); - // using a timeout of 3 seconds should be enough to cover slow servers + // Using a timeout of 3 seconds should be enough to cover slow servers. $client = new WP_HTTP_IXR_Client( $server, ( ( ! strlen( trim( $path ) ) || ( '/' == $path ) ) ? false : $path ) ); $client->timeout = 3; $client->useragent .= ' -- WordPress/' . get_bloginfo( 'version' ); - // when set to true, this outputs debug messages by itself + // When set to true, this outputs debug messages by itself. $client->debug = false; $home = trailingslashit( home_url() ); - if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // then try a normal ping + if ( ! $client->query( 'weblogUpdates.extendedPing', get_option( 'blogname' ), $home, get_bloginfo( 'rss2_url' ) ) ) { // Then try a normal ping. $client->query( 'weblogUpdates.ping', get_option( 'blogname' ), $home ); } } @@ -3006,7 +3012,7 @@ function xmlrpc_pingback_error( $ixr_error ) { } // -// Cache +// Cache. // /** @@ -3085,7 +3091,7 @@ function _prime_comment_caches( $comment_ids, $update_meta_cache = true ) { } // -// Internal +// Internal. // /** @@ -3316,7 +3322,7 @@ function wp_handle_comment_submission( $comment_data ) { } - // If the user is logged in + // If the user is logged in. $user = wp_get_current_user(); if ( $user->exists() ) { if ( empty( $user->display_name ) ) { @@ -3330,8 +3336,8 @@ function wp_handle_comment_submission( $comment_data ) { if ( ! isset( $comment_data['_wp_unfiltered_html_comment'] ) || ! wp_verify_nonce( $comment_data['_wp_unfiltered_html_comment'], 'unfiltered-html-comment_' . $comment_post_ID ) ) { - kses_remove_filters(); // start with a clean slate - kses_init_filters(); // set up the filters + kses_remove_filters(); // Start with a clean slate. + kses_init_filters(); // Set up the filters. remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); add_filter( 'pre_comment_content', 'wp_filter_kses' ); } diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php index c11e2d51a9..c0675403b4 100644 --- a/src/wp-includes/compat.php +++ b/src/wp-includes/compat.php @@ -6,7 +6,7 @@ * @access private */ -// If gettext isn't available +// If gettext isn't available. if ( ! function_exists( '_' ) ) { function _( $string ) { return $string; @@ -326,11 +326,11 @@ if ( ! function_exists( 'hash_equals' ) ) : } endif; -// random_int was introduced in PHP 7.0 +// random_int() was introduced in PHP 7.0. if ( ! function_exists( 'random_int' ) ) { require ABSPATH . WPINC . '/random_compat/random.php'; } -// sodium_crypto_box was introduced in PHP 7.2 +// sodium_crypto_box() was introduced in PHP 7.2. if ( ! function_exists( 'sodium_crypto_box' ) ) { require ABSPATH . WPINC . '/sodium_compat/autoload.php'; } diff --git a/src/wp-includes/cron.php b/src/wp-includes/cron.php index 09d9735fbf..d1c7849063 100644 --- a/src/wp-includes/cron.php +++ b/src/wp-includes/cron.php @@ -32,7 +32,7 @@ * @return bool True if event successfully scheduled. False for failure. */ function wp_schedule_single_event( $timestamp, $hook, $args = array() ) { - // Make sure timestamp is a positive integer + // Make sure timestamp is a positive integer. if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { return false; } @@ -142,7 +142,7 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array() ) { */ $event = apply_filters( 'schedule_event', $event ); - // A plugin disallowed this event + // A plugin disallowed this event. if ( ! $event ) { return false; } @@ -186,7 +186,7 @@ function wp_schedule_single_event( $timestamp, $hook, $args = array() ) { * @return bool True if event successfully scheduled. False for failure. */ function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array() ) { - // Make sure timestamp is a positive integer + // Make sure timestamp is a positive integer. if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { return false; } @@ -214,7 +214,7 @@ function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array() ) { /** This filter is documented in wp-includes/cron.php */ $event = apply_filters( 'schedule_event', $event ); - // A plugin disallowed this event + // A plugin disallowed this event. if ( ! $event ) { return false; } @@ -251,7 +251,7 @@ function wp_schedule_event( $timestamp, $recurrence, $hook, $args = array() ) { * @return bool True if event successfully rescheduled. False for failure. */ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) { - // Make sure timestamp is a positive integer + // Make sure timestamp is a positive integer. if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { return false; } @@ -307,7 +307,7 @@ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) return $pre; } - // Now we assume something is wrong and fail to schedule + // Now we assume something is wrong and fail to schedule. if ( 0 == $interval ) { return false; } @@ -341,7 +341,7 @@ function wp_reschedule_event( $timestamp, $recurrence, $hook, $args = array() ) * @return bool True if event successfully unscheduled. False for failure. */ function wp_unschedule_event( $timestamp, $hook, $args = array() ) { - // Make sure timestamp is a positive integer + // Make sure timestamp is a positive integer. if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) { return false; } @@ -398,8 +398,8 @@ function wp_unschedule_event( $timestamp, $hook, $args = array() ) { * unscheduling one or more events fail. */ function wp_clear_scheduled_hook( $hook, $args = array() ) { - // Backward compatibility - // Previously this function took the arguments as discrete vars rather than an array like the rest of the API + // Backward compatibility. + // Previously, this function took the arguments as discrete vars rather than an array like the rest of the API. if ( ! is_array( $args ) ) { _deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) ); $args = array_slice( func_get_args(), 1 ); @@ -426,9 +426,11 @@ function wp_clear_scheduled_hook( $hook, $args = array() ) { return $pre; } - // This logic duplicates wp_next_scheduled() - // It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing, - // and, wp_next_scheduled() returns the same schedule in an infinite loop. + /* + * This logic duplicates wp_next_scheduled(). + * It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing, + * and, wp_next_scheduled() returns the same schedule in an infinite loop. + */ $crons = _get_cron_array(); if ( empty( $crons ) ) { return 0; @@ -648,12 +650,12 @@ function spawn_cron( $gmt_time = 0 ) { $lock = 0; } - // don't run if another process is currently running it or more than once every 60 sec. + // Don't run if another process is currently running it or more than once every 60 sec. if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time ) { return false; } - //sanity check + // Sanity check. $crons = wp_get_ready_cron_jobs(); if ( empty( $crons ) ) { return false; @@ -676,7 +678,7 @@ function spawn_cron( $gmt_time = 0 ) { wp_redirect( add_query_arg( 'doing_wp_cron', $doing_wp_cron, wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); echo ' '; - // flush any buffers and send the headers + // Flush any buffers and send the headers. wp_ob_end_flush_all(); flush(); @@ -743,7 +745,7 @@ function spawn_cron( $gmt_time = 0 ) { * events needed to be spawned), false if spawning fails for one or more events. */ function wp_cron() { - // Prevent infinite loops caused by lack of wp-cron.php + // Prevent infinite loops caused by lack of wp-cron.php. if ( strpos( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) !== false || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ) { return 0; } @@ -923,7 +925,7 @@ function wp_get_ready_cron_jobs() { } // -// Private functions +// Private functions. // /** diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php b/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php index e6d74fd3b3..d033602b93 100644 --- a/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php +++ b/src/wp-includes/customize/class-wp-customize-nav-menu-setting.php @@ -285,7 +285,7 @@ class WP_Customize_Nav_Menu_Setting extends WP_Customize_Setting { ) ); } - // @todo add support for $args['hide_empty'] === true + // @todo Add support for $args['hide_empty'] === true. return $menus; } diff --git a/src/wp-includes/customize/class-wp-customize-themes-section.php b/src/wp-includes/customize/class-wp-customize-themes-section.php index 14db083e70..2544fc2b5f 100644 --- a/src/wp-includes/customize/class-wp-customize-themes-section.php +++ b/src/wp-includes/customize/class-wp-customize-themes-section.php @@ -72,7 +72,7 @@ class WP_Customize_Themes_Section extends WP_Customize_Section { ?> <li id="accordion-section-{{ data.id }}" class="theme-section"> <button type="button" class="customize-themes-section-title themes-section-{{ data.id }}">{{ data.title }}</button> - <?php if ( current_user_can( 'install_themes' ) || is_multisite() ) : // @todo: upload support ?> + <?php if ( current_user_can( 'install_themes' ) || is_multisite() ) : // @todo Upload support. ?> <?php endif; ?> <div class="customize-themes-section themes-section-{{ data.id }} control-section-content themes-php"> <div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div> @@ -164,7 +164,7 @@ class WP_Customize_Themes_Section extends WP_Customize_Section { * @since 4.9.0 */ protected function filter_drawer_content_template() { - $feature_list = get_theme_feature_list( false ); // @todo: Use the .org API instead of the local core feature list. The .org API is currently outdated and will be reconciled when the .org themes directory is next redesigned. + $feature_list = get_theme_feature_list( false ); // @todo Use the .org API instead of the local core feature list. The .org API is currently outdated and will be reconciled when the .org themes directory is next redesigned. ?> <# if ( 'wporg' === data.action ) { #> <div class="filter-drawer filter-details"> diff --git a/src/wp-includes/customize/class-wp-customize-upload-control.php b/src/wp-includes/customize/class-wp-customize-upload-control.php index 46e2b98b97..5442dab42c 100644 --- a/src/wp-includes/customize/class-wp-customize-upload-control.php +++ b/src/wp-includes/customize/class-wp-customize-upload-control.php @@ -18,9 +18,9 @@ class WP_Customize_Upload_Control extends WP_Customize_Media_Control { public $type = 'upload'; public $mime_type = ''; public $button_labels = array(); - public $removed = ''; // unused - public $context; // unused - public $extensions = array(); // unused + public $removed = ''; // Unused. + public $context; // Unused. + public $extensions = array(); // Unused. /** * Refresh the parameters passed to the JavaScript via JSON. diff --git a/src/wp-includes/default-constants.php b/src/wp-includes/default-constants.php index 3fe2543215..5a367cd3c6 100644 --- a/src/wp-includes/default-constants.php +++ b/src/wp-includes/default-constants.php @@ -6,7 +6,7 @@ */ /** - * Defines initial WordPress constants + * Defines initial WordPress constants. * * @see wp_debug_mode() * @@ -69,7 +69,7 @@ function wp_initial_constants() { } if ( ! defined( 'WP_CONTENT_DIR' ) ) { - define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down + define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // No trailing slash, full paths only - WP_CONTENT_URL is defined further down. } // Add define( 'WP_DEBUG', true ); to wp-config.php to enable display of notices during development. @@ -77,8 +77,8 @@ function wp_initial_constants() { define( 'WP_DEBUG', false ); } - // Add define( 'WP_DEBUG_DISPLAY', null ); to wp-config.php use the globally configured setting for - // display_errors and not force errors to be displayed. Use false to force display_errors off. + // Add define( 'WP_DEBUG_DISPLAY', null ); to wp-config.php use the globally configured setting + // for 'display_errors' and not force errors to be displayed. Use false to force 'display_errors' off. if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) { define( 'WP_DEBUG_DISPLAY', true ); } @@ -115,7 +115,7 @@ function wp_initial_constants() { define( 'SHORTINIT', false ); } - // Constants for features added to WP that should short-circuit their plugin implementations + // Constants for features added to WP that should short-circuit their plugin implementations. define( 'WP_FEATURE_BETTER_PASSWORDS', true ); /**#@+ @@ -141,15 +141,15 @@ function wp_initial_constants() { } /** - * Defines plugin directory WordPress constants + * Defines plugin directory WordPress constants. * - * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in + * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in. * * @since 3.0.0 */ function wp_plugin_directory_constants() { if ( ! defined( 'WP_CONTENT_URL' ) ) { - define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); // full url - WP_CONTENT_DIR is defined further up + define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); // Full URL - WP_CONTENT_DIR is defined further up. } /** @@ -158,7 +158,7 @@ function wp_plugin_directory_constants() { * @since 2.6.0 */ if ( ! defined( 'WP_PLUGIN_DIR' ) ) { - define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash + define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // Full path, no trailing slash. } /** @@ -167,7 +167,7 @@ function wp_plugin_directory_constants() { * @since 2.6.0 */ if ( ! defined( 'WP_PLUGIN_URL' ) ) { - define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash + define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // Full URL, no trailing slash. } /** @@ -186,7 +186,7 @@ function wp_plugin_directory_constants() { * @since 2.8.0 */ if ( ! defined( 'WPMU_PLUGIN_DIR' ) ) { - define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash + define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // Full path, no trailing slash. } /** @@ -195,7 +195,7 @@ function wp_plugin_directory_constants() { * @since 2.8.0 */ if ( ! defined( 'WPMU_PLUGIN_URL' ) ) { - define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash + define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // Full URL, no trailing slash. } /** @@ -210,7 +210,7 @@ function wp_plugin_directory_constants() { } /** - * Defines cookie related WordPress constants + * Defines cookie-related WordPress constants. * * Defines constants after multisite is loaded. * @@ -218,7 +218,7 @@ function wp_plugin_directory_constants() { */ function wp_cookie_constants() { /** - * Used to guarantee unique hash cookies + * Used to guarantee unique hash cookies. * * @since 1.5.0 */ @@ -344,7 +344,7 @@ function wp_ssl_constants() { } /** - * Defines functionality related WordPress constants + * Defines functionality-related WordPress constants. * * @since 3.0.0 */ @@ -353,7 +353,7 @@ function wp_functionality_constants() { * @since 2.5.0 */ if ( ! defined( 'AUTOSAVE_INTERVAL' ) ) { - define( 'AUTOSAVE_INTERVAL', 60 ); + define( 'AUTOSAVE_INTERVAL', MINUTE_IN_SECONDS ); } /** @@ -371,25 +371,25 @@ function wp_functionality_constants() { * @since 3.3.0 */ if ( ! defined( 'WP_CRON_LOCK_TIMEOUT' ) ) { - define( 'WP_CRON_LOCK_TIMEOUT', 60 ); // In seconds + define( 'WP_CRON_LOCK_TIMEOUT', MINUTE_IN_SECONDS ); } } /** - * Defines templating related WordPress constants + * Defines templating-related WordPress constants. * * @since 3.0.0 */ function wp_templating_constants() { /** - * Filesystem path to the current active template directory + * Filesystem path to the current active template directory. * * @since 1.5.0 */ define( 'TEMPLATEPATH', get_template_directory() ); /** - * Filesystem path to the current active template stylesheet directory + * Filesystem path to the current active template stylesheet directory. * * @since 2.1.0 */ diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index a2b1296f5c..c0f7e9add6 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -12,14 +12,14 @@ * @package WordPress */ -// Strip, trim, kses, special chars for string saves +// Strip, trim, kses, special chars for string saves. foreach ( array( 'pre_term_name', 'pre_comment_author_name', 'pre_link_name', 'pre_link_target', 'pre_link_rel', 'pre_user_display_name', 'pre_user_first_name', 'pre_user_last_name', 'pre_user_nickname' ) as $filter ) { add_filter( $filter, 'sanitize_text_field' ); add_filter( $filter, 'wp_filter_kses' ); add_filter( $filter, '_wp_specialchars', 30 ); } -// Strip, kses, special chars for string display +// Strip, kses, special chars for string display. foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', 'link_rel', 'user_display_name', 'user_first_name', 'user_last_name', 'user_nickname' ) as $filter ) { if ( is_admin() ) { // These are expensive. Run only on admin pages for defense in depth. @@ -29,12 +29,12 @@ foreach ( array( 'term_name', 'comment_author_name', 'link_name', 'link_target', add_filter( $filter, '_wp_specialchars', 30 ); } -// Kses only for textarea saves +// Kses only for textarea saves. foreach ( array( 'pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description' ) as $filter ) { add_filter( $filter, 'wp_filter_kses' ); } -// Kses only for textarea admin displays +// Kses only for textarea admin displays. if ( is_admin() ) { foreach ( array( 'term_description', 'link_description', 'link_notes', 'user_description' ) as $filter ) { add_filter( $filter, 'wp_kses_data' ); @@ -42,14 +42,14 @@ if ( is_admin() ) { add_filter( 'comment_text', 'wp_kses_post' ); } -// Email saves +// Email saves. foreach ( array( 'pre_comment_author_email', 'pre_user_email' ) as $filter ) { add_filter( $filter, 'trim' ); add_filter( $filter, 'sanitize_email' ); add_filter( $filter, 'wp_filter_kses' ); } -// Email admin display +// Email admin display. foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) { add_filter( $filter, 'sanitize_email' ); if ( is_admin() ) { @@ -57,7 +57,7 @@ foreach ( array( 'comment_author_email', 'user_email' ) as $filter ) { } } -// Save URL +// Save URL. foreach ( array( 'pre_comment_author_url', 'pre_user_url', @@ -71,7 +71,7 @@ foreach ( array( add_filter( $filter, 'wp_filter_kses' ); } -// Display URL +// Display URL. foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url', 'post_guid' ) as $filter ) { if ( is_admin() ) { add_filter( $filter, 'wp_strip_all_tags' ); @@ -82,28 +82,28 @@ foreach ( array( 'user_url', 'link_url', 'link_image', 'link_rss', 'comment_url' } } -// Slugs +// Slugs. add_filter( 'pre_term_slug', 'sanitize_title' ); add_filter( 'wp_insert_post_data', '_wp_customize_changeset_filter_insert_post_data', 10, 2 ); -// Keys +// Keys. foreach ( array( 'pre_post_type', 'pre_post_status', 'pre_post_comment_status', 'pre_post_ping_status' ) as $filter ) { add_filter( $filter, 'sanitize_key' ); } -// Mime types +// Mime types. add_filter( 'pre_post_mime_type', 'sanitize_mime_type' ); add_filter( 'post_mime_type', 'sanitize_mime_type' ); -// Meta +// Meta. add_filter( 'register_meta_args', '_wp_register_meta_args_whitelist', 10, 2 ); -// Post meta +// Post meta. add_action( 'added_post_meta', 'wp_cache_set_posts_last_changed' ); add_action( 'updated_post_meta', 'wp_cache_set_posts_last_changed' ); add_action( 'deleted_post_meta', 'wp_cache_set_posts_last_changed' ); -// Term meta +// Term meta. add_action( 'added_term_meta', 'wp_cache_set_terms_last_changed' ); add_action( 'updated_term_meta', 'wp_cache_set_terms_last_changed' ); add_action( 'deleted_term_meta', 'wp_cache_set_terms_last_changed' ); @@ -116,12 +116,12 @@ add_filter( 'update_term_metadata_by_mid', 'wp_check_term_meta_support_prefilter add_filter( 'delete_term_metadata_by_mid', 'wp_check_term_meta_support_prefilter' ); add_filter( 'update_term_metadata_cache', 'wp_check_term_meta_support_prefilter' ); -// Comment meta +// Comment meta. add_action( 'added_comment_meta', 'wp_cache_set_comments_last_changed' ); add_action( 'updated_comment_meta', 'wp_cache_set_comments_last_changed' ); add_action( 'deleted_comment_meta', 'wp_cache_set_comments_last_changed' ); -// Places to balance tags on input +// Places to balance tags on input. foreach ( array( 'content_save_pre', 'excerpt_save_pre', 'comment_save_pre', 'pre_comment_content' ) as $filter ) { add_filter( $filter, 'convert_invalid_entities' ); add_filter( $filter, 'balanceTags', 50 ); @@ -137,13 +137,13 @@ foreach ( array( 'comment_author', 'term_name', 'link_name', 'link_description', add_filter( $filter, 'esc_html' ); } -// Format WordPress +// Format WordPress. foreach ( array( 'the_content', 'the_title', 'wp_title' ) as $filter ) { add_filter( $filter, 'capital_P_dangit', 11 ); } add_filter( 'comment_text', 'capital_P_dangit', 31 ); -// Format titles +// Format titles. foreach ( array( 'single_post_title', 'single_cat_title', 'single_tag_title', 'single_month_title', 'nav_menu_attr_title', 'nav_menu_description' ) as $filter ) { add_filter( $filter, 'wptexturize' ); add_filter( $filter, 'strip_tags' ); @@ -157,14 +157,14 @@ foreach ( array( 'term_description', 'get_the_post_type_description' ) as $filte add_filter( $filter, 'shortcode_unautop' ); } -// Format for RSS +// Format for RSS. add_filter( 'term_name_rss', 'convert_chars' ); -// Pre save hierarchy +// Pre save hierarchy. add_filter( 'wp_insert_post_parent', 'wp_check_post_hierarchy_for_loops', 10, 2 ); add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); -// Display filters +// Display filters. add_filter( 'the_title', 'wptexturize' ); add_filter( 'the_title', 'convert_chars' ); add_filter( 'the_title', 'trim' ); @@ -209,7 +209,7 @@ add_filter( 'widget_text_content', 'wpautop' ); add_filter( 'widget_text_content', 'shortcode_unautop' ); add_filter( 'widget_text_content', 'do_shortcode', 11 ); // Runs after wpautop(); note that $post global will be null when shortcodes run. -// RSS filters +// RSS filters. add_filter( 'the_title_rss', 'strip_tags' ); add_filter( 'the_title_rss', 'ent2ncr', 8 ); add_filter( 'the_title_rss', 'esc_html' ); @@ -226,17 +226,17 @@ add_filter( 'bloginfo_rss', 'ent2ncr', 8 ); add_filter( 'the_author', 'ent2ncr', 8 ); add_filter( 'the_guid', 'esc_url' ); -// Email filters +// Email filters. add_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); -// Mark site as no longer fresh +// Mark site as no longer fresh. foreach ( array( 'publish_post', 'publish_page', 'wp_ajax_save-widget', 'wp_ajax_widgets-order', 'customize_save_after' ) as $action ) { add_action( $action, '_delete_option_fresh_site', 0 ); } -// Misc filters +// Misc filters. add_filter( 'option_ping_sites', 'privacy_ping_filter' ); -add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop +add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop. add_filter( 'option_blog_charset', '_canonical_charset' ); add_filter( 'option_home', '_config_wp_home' ); add_filter( 'option_siteurl', '_config_wp_siteurl' ); @@ -276,7 +276,7 @@ add_action( 'auth_cookie_bad_hash', 'rest_cookie_collect_status' ); add_action( 'auth_cookie_valid', 'rest_cookie_collect_status' ); add_filter( 'rest_authentication_errors', 'rest_cookie_check_errors', 100 ); -// Actions +// Actions. add_action( 'wp_head', '_wp_render_title_tag', 1 ); add_action( 'wp_head', 'wp_enqueue_scripts', 1 ); add_action( 'wp_head', 'wp_resource_hints', 2 ); @@ -308,7 +308,7 @@ if ( isset( $_GET['replytocom'] ) ) { add_action( 'wp_head', 'wp_no_robots' ); } -// Login actions +// Login actions. add_filter( 'login_head', 'wp_resource_hints', 8 ); add_action( 'login_head', 'wp_print_head_scripts', 9 ); add_action( 'login_head', 'print_admin_styles', 9 ); @@ -316,22 +316,22 @@ add_action( 'login_head', 'wp_site_icon', 99 ); add_action( 'login_footer', 'wp_print_footer_scripts', 20 ); add_action( 'login_init', 'send_frame_options_header', 10, 0 ); -// Feed Generator Tags +// Feed generator tags. foreach ( array( 'rss2_head', 'commentsrss2_head', 'rss_head', 'rdf_header', 'atom_head', 'comments_atom_head', 'opml_head', 'app_head' ) as $action ) { add_action( $action, 'the_generator' ); } -// Feed Site Icon +// Feed Site Icon. add_action( 'atom_head', 'atom_site_icon' ); add_action( 'rss2_head', 'rss2_site_icon' ); -// WP Cron +// WP Cron. if ( ! defined( 'DOING_CRON' ) ) { add_action( 'init', 'wp_cron' ); } -// 2 Actions 2 Furious +// 2 Actions 2 Furious. add_action( 'do_feed_rdf', 'do_feed_rdf', 10, 0 ); add_action( 'do_feed_rss', 'do_feed_rss', 10, 0 ); add_action( 'do_feed_rss2', 'do_feed_rss2', 10, 1 ); @@ -359,7 +359,7 @@ add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); add_action( 'admin_init', 'send_frame_options_header', 10, 0 ); add_action( 'welcome_panel', 'wp_welcome_panel' ); -// Privacy +// Privacy. add_action( 'user_request_action_confirmed', '_wp_privacy_account_request_confirmed' ); add_action( 'user_request_action_confirmed', '_wp_privacy_send_request_confirmation_notification', 12 ); // After request marked as completed. add_filter( 'wp_privacy_personal_data_exporters', 'wp_register_comment_personal_data_exporter' ); @@ -369,42 +369,42 @@ add_filter( 'wp_privacy_personal_data_erasers', 'wp_register_comment_personal_da add_action( 'init', 'wp_schedule_delete_old_privacy_export_files' ); add_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' ); -// Cron tasks +// Cron tasks. add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' ); add_action( 'wp_scheduled_auto_draft_delete', 'wp_delete_auto_drafts' ); add_action( 'importer_scheduled_cleanup', 'wp_delete_attachment' ); add_action( 'upgrader_scheduled_cleanup', 'wp_delete_attachment' ); add_action( 'delete_expired_transients', 'delete_expired_transients' ); -// Navigation menu actions +// Navigation menu actions. add_action( 'delete_post', '_wp_delete_post_menu_item' ); add_action( 'delete_term', '_wp_delete_tax_menu_item', 10, 3 ); add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu', 10, 3 ); add_action( 'delete_post', '_wp_delete_customize_changeset_dependent_auto_drafts' ); -// Post Thumbnail CSS class filtering +// Post Thumbnail CSS class filtering. add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add' ); add_action( 'end_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_remove' ); -// Redirect Old Slugs +// Redirect old slugs. add_action( 'template_redirect', 'wp_old_slug_redirect' ); add_action( 'post_updated', 'wp_check_for_changed_slugs', 12, 3 ); add_action( 'attachment_updated', 'wp_check_for_changed_slugs', 12, 3 ); -// Redirect Old Dates +// Redirect old dates. add_action( 'post_updated', 'wp_check_for_changed_dates', 12, 3 ); add_action( 'attachment_updated', 'wp_check_for_changed_dates', 12, 3 ); -// Nonce check for Post Previews +// Nonce check for post previews. add_action( 'init', '_show_post_preview' ); -// Output JS to reset window.name for previews +// Output JS to reset window.name for previews. add_action( 'wp_head', 'wp_post_preview_js', 1 ); -// Timezone +// Timezone. add_filter( 'pre_option_gmt_offset', 'wp_timezone_override_offset' ); -// Admin Color Schemes +// Admin color schemes. add_action( 'admin_init', 'register_admin_color_schemes', 1 ); add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); @@ -414,15 +414,15 @@ add_filter( 'default_option_link_manager_enabled', '__return_true' ); // This option no longer exists; tell plugins we always support auto-embedding. add_filter( 'pre_option_embed_autourls', '__return_true' ); -// Default settings for heartbeat +// Default settings for heartbeat. add_filter( 'heartbeat_settings', 'wp_heartbeat_settings' ); -// Check if the user is logged out +// Check if the user is logged out. add_action( 'admin_enqueue_scripts', 'wp_auth_check_load' ); add_filter( 'heartbeat_send', 'wp_auth_check' ); add_filter( 'heartbeat_nopriv_send', 'wp_auth_check' ); -// Default authentication filters +// Default authentication filters. add_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); add_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 ); add_filter( 'authenticate', 'wp_authenticate_spam_check', 99 ); @@ -451,9 +451,9 @@ add_action( 'rest_api_init', 'create_initial_rest_routes', 99 ); add_action( 'parse_request', 'rest_api_loaded' ); /** - * Filters formerly mixed into wp-includes + * Filters formerly mixed into wp-includes. */ -// Theme +// Theme. add_action( 'wp_loaded', '_custom_header_background_just_in_time' ); add_action( 'wp_head', '_custom_logo_header_styles' ); add_action( 'plugins_loaded', '_wp_customize_include' ); @@ -462,34 +462,34 @@ add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' ); add_action( 'delete_attachment', '_delete_attachment_theme_mod' ); add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_dependent_auto_drafts', 20, 3 ); -// Calendar widget cache +// Calendar widget cache. add_action( 'save_post', 'delete_get_calendar_cache' ); add_action( 'delete_post', 'delete_get_calendar_cache' ); add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' ); add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' ); -// Author +// Author. add_action( 'transition_post_status', '__clear_multi_author_cache' ); -// Post -add_action( 'init', 'create_initial_post_types', 0 ); // highest priority +// Post. +add_action( 'init', 'create_initial_post_types', 0 ); // Highest priority. add_action( 'admin_menu', '_add_post_type_submenus' ); add_action( 'before_delete_post', '_reset_front_page_settings_for_post' ); add_action( 'wp_trash_post', '_reset_front_page_settings_for_post' ); add_action( 'change_locale', 'create_initial_post_types' ); -// Post Formats +// Post Formats. add_filter( 'request', '_post_format_request' ); add_filter( 'term_link', '_post_format_link', 10, 3 ); add_filter( 'get_post_format', '_post_format_get_term' ); add_filter( 'get_terms', '_post_format_get_terms', 10, 3 ); add_filter( 'wp_get_object_terms', '_post_format_wp_get_object_terms' ); -// KSES +// KSES. add_action( 'init', 'kses_init' ); add_action( 'set_current_user', 'kses_init' ); -// Script Loader +// Script Loader. add_action( 'wp_default_scripts', 'wp_default_scripts' ); add_action( 'wp_default_scripts', 'wp_default_packages' ); @@ -509,29 +509,29 @@ add_action( 'enqueue_block_editor_assets', 'enqueue_editor_block_styles_assets' add_action( 'wp_default_styles', 'wp_default_styles' ); add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); -// Taxonomy -add_action( 'init', 'create_initial_taxonomies', 0 ); // highest priority +// Taxonomy. +add_action( 'init', 'create_initial_taxonomies', 0 ); // Highest priority. add_action( 'change_locale', 'create_initial_taxonomies' ); -// Canonical +// Canonical. add_action( 'template_redirect', 'redirect_canonical' ); add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 ); -// Shortcodes -add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop() +// Shortcodes. +add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop(). -// Media +// Media. add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' ); add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' ); add_action( 'plugins_loaded', '_wp_add_additional_image_sizes', 0 ); -// Nav menu +// Nav menu. add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 ); -// Widgets +// Widgets. add_action( 'init', 'wp_widgets_init', 1 ); -// Admin Bar +// Admin Bar. // Don't remove. Wrong way to disable. add_action( 'template_redirect', '_wp_admin_bar_init', 0 ); add_action( 'admin_init', '_wp_admin_bar_init' ); @@ -540,12 +540,12 @@ add_action( 'activate_header', '_wp_admin_bar_init' ); add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); -// Former admin filters that can also be hooked on the front end +// Former admin filters that can also be hooked on the front end. add_action( 'media_buttons', 'media_buttons' ); add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); add_filter( 'media_send_to_editor', 'image_media_send_to_editor', 10, 3 ); -// Embeds +// Embeds. add_action( 'rest_api_init', 'wp_oembed_register_route' ); add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 ); @@ -580,7 +580,7 @@ add_filter( 'oembed_dataparse', 'wp_filter_oembed_iframe_title_attribute', 20, 3 add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 ); add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 ); -// Capabilities +// Capabilities. add_filter( 'user_has_cap', 'wp_maybe_grant_install_languages_cap', 1 ); add_filter( 'user_has_cap', 'wp_maybe_grant_resume_extensions_caps', 1 ); add_filter( 'user_has_cap', 'wp_maybe_grant_site_health_caps', 1, 4 ); diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php index d118f564e4..d8d32bb449 100644 --- a/src/wp-includes/deprecated.php +++ b/src/wp-includes/deprecated.php @@ -270,7 +270,7 @@ function user_can_edit_post($user_id, $post_id, $blog_id = 1) { function user_can_delete_post($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); - // right now if one can edit, one can delete + // Right now if one can edit, one can delete. return user_can_edit_post($user_id, $post_id, $blog_id); } @@ -327,7 +327,7 @@ function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) { function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); - // right now if one can edit a post, one can edit comments made on it + // Right now if one can edit a post, one can edit comments made on it. return user_can_edit_post($user_id, $post_id, $blog_id); } @@ -346,7 +346,7 @@ function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) { function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) { _deprecated_function( __FUNCTION__, '2.0.0', 'current_user_can()' ); - // right now if one can edit comments, one can delete comments + // Right now if one can edit comments, one can delete comments. return user_can_edit_post_comments($user_id, $post_id, $blog_id); } @@ -931,7 +931,7 @@ function get_links($category = -1, $before = '', $after = '<br />', $between = ' $orderby = substr($orderby, 1); } - if ( $category == -1 ) //get_bookmarks uses '' to signify all categories + if ( $category == -1 ) // get_bookmarks() uses '' to signify all categories. $category = ''; $results = get_bookmarks(array('category' => $category, 'orderby' => $orderby, 'order' => $order, 'show_updated' => $show_updated, 'limit' => $limit)); @@ -976,7 +976,7 @@ function get_links($category = -1, $before = '', $after = '<br />', $between = ' if ( $row->link_image != null && $show_images ) { if ( strpos($row->link_image, 'http') !== false ) $output .= "<img src=\"$row->link_image\" $alt $title />"; - else // If it's a relative path + else // If it's a relative path. $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; } else { $output .= $name; @@ -995,7 +995,7 @@ function get_links($category = -1, $before = '', $after = '<br />', $between = ' } $output .= "$after\n"; - } // end while + } // End while. if ( !$echo ) return $output; @@ -1019,7 +1019,7 @@ function get_links_list($order = 'name') { $order = strtolower($order); - // Handle link category sorting + // Handle link category sorting. $direction = 'ASC'; if ( '_' == substr($order,0,1) ) { $direction = 'DESC'; @@ -1031,17 +1031,17 @@ function get_links_list($order = 'name') { $cats = get_categories(array('type' => 'link', 'orderby' => $order, 'order' => $direction, 'hierarchical' => 0)); - // Display each category + // Display each category. if ( $cats ) { foreach ( (array) $cats as $cat ) { // Handle each category. - // Display the category name + // Display the category name. echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n"; - // Call get_links() with all the appropriate params + // Call get_links() with all the appropriate params. get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); - // Close the last category + // Close the last category. echo "\n\t</ul>\n</li>\n"; } } @@ -1254,7 +1254,7 @@ function get_category_children( $id, $before = '/', $after = '', $visited = arra return ''; $chain = ''; - /** TODO: consult hierarchy */ + /** TODO: Consult hierarchy */ $cat_ids = get_all_category_ids(); foreach ( (array) $cat_ids as $cat_id ) { if ( $cat_id == $id ) @@ -1877,11 +1877,11 @@ function get_attachment_icon_src( $id = 0, $fullsize = false ) { $file = get_attached_file( $post->ID ); if ( !$fullsize && $src = wp_get_attachment_thumb_url( $post->ID ) ) { - // We have a thumbnail desired, specified and existing + // We have a thumbnail desired, specified and existing. $src_file = wp_basename($src); } elseif ( wp_attachment_is_image( $post->ID ) ) { - // We have an image without a thumbnail + // We have an image without a thumbnail. $src = wp_get_attachment_url( $post->ID ); $src_file = & $file; @@ -2113,7 +2113,7 @@ function attribute_escape( $text ) { */ function register_sidebar_widget($name, $output_callback, $classname = '', ...$params) { _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_sidebar_widget()' ); - // Compat + // Compat. if ( is_array( $name ) ) { if ( count( $name ) === 3 ) { $name = sprintf( $name[0], $name[2] ); @@ -2167,7 +2167,7 @@ function unregister_sidebar_widget($id) { */ function register_widget_control($name, $control_callback, $width = '', $height = '', ...$params) { _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' ); - // Compat + // Compat. if ( is_array( $name ) ) { if ( count( $name ) === 3 ) { $name = sprintf( $name[0], $name[2] ); @@ -2271,7 +2271,7 @@ function get_usermeta( $user_id, $meta_key = '' ) { if ( !empty($meta_key) ) { $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key); $user = wp_cache_get($user_id, 'users'); - // Check the cached user object + // Check the cached user object. if ( false !== $user && isset($user->$meta_key) ) $metas = array($user->$meta_key); else @@ -2394,7 +2394,7 @@ function automatic_feed_links( $add = true ) { if ( $add ) add_theme_support( 'automatic-feed-links' ); else - remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+ + remove_action( 'wp_head', 'feed_links_extra', 3 ); // Just do this yourself in 3.0+. } /** @@ -2670,11 +2670,11 @@ function get_boundary_post_rel_link($title = '%title', $in_same_cat = false, $ex _deprecated_function( __FUNCTION__, '3.3.0' ); $posts = get_boundary_post($in_same_cat, $excluded_categories, $start); - // If there is no post stop. + // If there is no post, stop. if ( empty($posts) ) return; - // Even though we limited get_posts to return only 1 item it still returns an array of objects. + // Even though we limited get_posts() to return only 1 item it still returns an array of objects. $post = $posts[0]; if ( empty($post->post_title) ) @@ -3596,7 +3596,7 @@ function wp_htmledit_pre($output) { _deprecated_function( __FUNCTION__, '4.3.0', 'format_for_editor()' ); if ( !empty($output) ) - $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // convert only < > & + $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ) ); // Convert only '< > &'. /** * Filters the text before it is formatted for the HTML editor. @@ -3673,7 +3673,7 @@ function wp_get_http( $url, $file_path = false, $red = 1 ) { if ( false == $file_path ) return $headers; - // GET request - write it to the supplied filename + // GET request - write it to the supplied filename. $out_fp = fopen($file_path, 'w'); if ( !$out_fp ) return $headers; diff --git a/src/wp-includes/error-protection.php b/src/wp-includes/error-protection.php index 913b9bc8e8..fde37c7fff 100644 --- a/src/wp-includes/error-protection.php +++ b/src/wp-includes/error-protection.php @@ -3,7 +3,7 @@ * Error Protection API: Functions * * @package WordPress - * @since 5.2.0 + * @since 5.2.0 */ /** diff --git a/src/wp-includes/feed-atom-comments.php b/src/wp-includes/feed-atom-comments.php index 2d2681a983..20f3ee8f6d 100644 --- a/src/wp-includes/feed-atom-comments.php +++ b/src/wp-includes/feed-atom-comments.php @@ -45,19 +45,19 @@ do_action( 'rss_tag_pre', 'atom-comments' ); <updated><?php echo get_feed_build_date( 'Y-m-d\TH:i:s\Z' ); ?></updated> -<?php if ( is_singular() ) { ?> +<?php if ( is_singular() ) : ?> <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php comments_link_feed(); ?>" /> <link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?>" /> <id><?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?></id> -<?php } elseif ( is_search() ) { ?> +<?php elseif ( is_search() ) : ?> <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" /> <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link( '', 'atom' ); ?>" /> <id><?php echo get_search_comments_feed_link( '', 'atom' ); ?></id> -<?php } else { ?> +<?php else : ?> <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php bloginfo_rss( 'url' ); ?>" /> <link rel="self" type="application/atom+xml" href="<?php bloginfo_rss( 'comments_atom_url' ); ?>" /> <id><?php bloginfo_rss( 'comments_atom_url' ); ?></id> -<?php } ?> +<?php endif; ?> <?php /** * Fires at the end of the Atom comment feed header. @@ -67,12 +67,11 @@ do_action( 'rss_tag_pre', 'atom-comments' ); do_action( 'comments_atom_head' ); ?> <?php -if ( have_comments() ) : - while ( have_comments() ) : - the_comment(); - $comment_post = get_post( $comment->comment_post_ID ); - $GLOBALS['post'] = $comment_post; - ?> +while ( have_comments() ) : + the_comment(); + $comment_post = get_post( $comment->comment_post_ID ); + $GLOBALS['post'] = $comment_post; + ?> <entry> <title> <?php @@ -87,8 +86,8 @@ if ( have_comments() ) : printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() ); } ?> - </title> - <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> + </title> + <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> <author> <name><?php comment_author_rss(); ?></name> @@ -102,37 +101,43 @@ if ( have_comments() ) : <id><?php comment_guid(); ?></id> <updated><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></updated> <published><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></published> + <?php if ( post_password_required( $comment_post ) ) : ?> - <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content> - <?php else : // post pass ?> - <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content> - <?php - endif; // post pass - // Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt) - if ( $comment->comment_parent == 0 ) : // This comment is top level - ?> - <thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> + <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content> + <?php else : ?> + <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content> + <?php endif; // End if post_password_required(). ?> + <?php - else : // This comment is in reply to another comment - $parent_comment = get_comment( $comment->comment_parent ); - // The rel attribute below and the id tag above should be GUIDs, but WP doesn't create them for comments (unlike posts). Either way, it's more important that they both use the same system + // Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt). + if ( $comment->comment_parent == 0 ) : // This comment is top-level. + ?> + <thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> + <?php + else : // This comment is in reply to another comment. + $parent_comment = get_comment( $comment->comment_parent ); + /* + * The rel attribute below and the id tag above should be GUIDs, + * but WP doesn't create them for comments (unlike posts). + * Either way, it's more important that they both use the same system. + */ + ?> + <thr:in-reply-to ref="<?php comment_guid( $parent_comment ); ?>" href="<?php echo get_comment_link( $parent_comment ); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> + <?php + endif; + + /** + * Fires at the end of each Atom comment feed item. + * + * @since 2.2.0 + * + * @param int $comment_id ID of the current comment. + * @param int $comment_post_id ID of the post the current comment is connected to. + */ + do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID ); ?> - <thr:in-reply-to ref="<?php comment_guid( $parent_comment ); ?>" href="<?php echo get_comment_link( $parent_comment ); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" /> - <?php -endif; - /** - * Fires at the end of each Atom comment feed item. - * - * @since 2.2.0 - * - * @param int $comment_id ID of the current comment. - * @param int $comment_post_id ID of the post the current comment is connected to. - */ - do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID ); - ?> </entry> - <?php - endwhile; -endif; + <?php +endwhile; ?> </feed> diff --git a/src/wp-includes/feed-atom.php b/src/wp-includes/feed-atom.php index bce41086be..629ffc695e 100644 --- a/src/wp-includes/feed-atom.php +++ b/src/wp-includes/feed-atom.php @@ -50,8 +50,11 @@ do_action( 'rss_tag_pre', 'atom' ); <entry> <author> <name><?php the_author(); ?></name> - <?php $author_url = get_the_author_meta( 'url' ); if ( ! empty( $author_url ) ) : ?> - <uri><?php the_author_meta( 'url' ); ?></uri> + <?php + $author_url = get_the_author_meta( 'url' ); + if ( ! empty( $author_url ) ) : + ?> + <uri><?php the_author_meta( 'url' ); ?></uri> <?php endif; @@ -63,18 +66,24 @@ do_action( 'rss_tag_pre', 'atom' ); do_action( 'atom_author' ); ?> </author> + <title type="<?php html_type_rss(); ?>"><![CDATA[<?php the_title_rss(); ?>]]></title> <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php the_permalink_rss(); ?>" /> + <id><?php the_guid(); ?></id> <updated><?php echo get_post_modified_time( 'Y-m-d\TH:i:s\Z', true ); ?></updated> <published><?php echo get_post_time( 'Y-m-d\TH:i:s\Z', true ); ?></published> <?php the_category_rss( 'atom' ); ?> + <summary type="<?php html_type_rss(); ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary> + <?php if ( ! get_option( 'rss_use_excerpt' ) ) : ?> - <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss(); ?>"><![CDATA[<?php the_content_feed( 'atom' ); ?>]]></content> + <content type="<?php html_type_rss(); ?>" xml:base="<?php the_permalink_rss(); ?>"><![CDATA[<?php the_content_feed( 'atom' ); ?>]]></content> <?php endif; ?> + <?php atom_enclosure(); + /** * Fires at the end of each Atom feed item. * @@ -84,9 +93,9 @@ do_action( 'rss_tag_pre', 'atom' ); if ( get_comments_number() || comments_open() ) : ?> - <link rel="replies" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php the_permalink_rss(); ?>#comments" thr:count="<?php echo get_comments_number(); ?>"/> - <link rel="replies" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( 0, 'atom' ) ); ?>" thr:count="<?php echo get_comments_number(); ?>"/> - <thr:total><?php echo get_comments_number(); ?></thr:total> + <link rel="replies" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php the_permalink_rss(); ?>#comments" thr:count="<?php echo get_comments_number(); ?>"/> + <link rel="replies" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( 0, 'atom' ) ); ?>" thr:count="<?php echo get_comments_number(); ?>"/> + <thr:total><?php echo get_comments_number(); ?></thr:total> <?php endif; ?> </entry> <?php endwhile; ?> diff --git a/src/wp-includes/feed-rdf.php b/src/wp-includes/feed-rdf.php index 861425ae30..39cd15f04a 100644 --- a/src/wp-includes/feed-rdf.php +++ b/src/wp-includes/feed-rdf.php @@ -74,15 +74,18 @@ while ( have_posts() ) : <item rdf:about="<?php the_permalink_rss(); ?>"> <title><?php the_title_rss(); ?></title> <link><?php the_permalink_rss(); ?></link> - <dc:date><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', $post->post_date_gmt, false ); ?></dc:date> + <dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator> + <dc:date><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', $post->post_date_gmt, false ); ?></dc:date> <?php the_category_rss( 'rdf' ); ?> + <?php if ( get_option( 'rss_use_excerpt' ) ) : ?> - <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> -<?php else : ?> - <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> - <content:encoded><![CDATA[<?php the_content_feed( 'rdf' ); ?>]]></content:encoded> -<?php endif; ?> + <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> + <?php else : ?> + <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> + <content:encoded><![CDATA[<?php the_content_feed( 'rdf' ); ?>]]></content:encoded> + <?php endif; ?> + <?php /** * Fires at the end of each RDF feed item. diff --git a/src/wp-includes/feed-rss.php b/src/wp-includes/feed-rss.php index 0b58d5f0ee..5adf8913e7 100644 --- a/src/wp-includes/feed-rss.php +++ b/src/wp-includes/feed-rss.php @@ -17,7 +17,6 @@ echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '> <lastBuildDate><?php echo get_feed_build_date( 'D, d M Y H:i:s +0000' ); ?></lastBuildDate> <docs>http://backend.userland.com/rss092</docs> <language><?php bloginfo_rss( 'language' ); ?></language> - <?php /** * Fires at the end of the RSS Feed Header. diff --git a/src/wp-includes/feed-rss2-comments.php b/src/wp-includes/feed-rss2-comments.php index 357f77644a..5cbd06c1f0 100644 --- a/src/wp-includes/feed-rss2-comments.php +++ b/src/wp-includes/feed-rss2-comments.php @@ -70,53 +70,52 @@ do_action( 'rss_tag_pre', 'rss2-comments' ); */ do_action( 'commentsrss2_head' ); - if ( have_comments() ) : - while ( have_comments() ) : - the_comment(); - $comment_post = get_post( $comment->comment_post_ID ); - $GLOBALS['post'] = $comment_post; - ?> - <item> - <title> - <?php - if ( ! is_singular() ) { - $title = get_the_title( $comment_post->ID ); - /** This filter is documented in wp-includes/feed.php */ - $title = apply_filters( 'the_title_rss', $title ); - /* translators: Individual comment title. 1: Post title, 2: Comment author name. */ - printf( ent2ncr( __( 'Comment on %1$s by %2$s' ) ), $title, get_comment_author_rss() ); - } else { - /* translators: Comment author title. %s: Comment author name. */ - printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() ); - } - ?> - </title> - <link><?php comment_link(); ?></link> + while ( have_comments() ) : + the_comment(); + $comment_post = get_post( $comment->comment_post_ID ); + $GLOBALS['post'] = $comment_post; + ?> + <item> + <title> + <?php + if ( ! is_singular() ) { + $title = get_the_title( $comment_post->ID ); + /** This filter is documented in wp-includes/feed.php */ + $title = apply_filters( 'the_title_rss', $title ); + /* translators: Individual comment title. 1: Post title, 2: Comment author name. */ + printf( ent2ncr( __( 'Comment on %1$s by %2$s' ) ), $title, get_comment_author_rss() ); + } else { + /* translators: Comment author title. %s: Comment author name. */ + printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() ); + } + ?> + </title> + <link><?php comment_link(); ?></link> + <dc:creator><![CDATA[<?php echo get_comment_author_rss(); ?>]]></dc:creator> <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></pubDate> <guid isPermaLink="false"><?php comment_guid(); ?></guid> - <?php if ( post_password_required( $comment_post ) ) : ?> - <description><?php echo ent2ncr( __( 'Protected Comments: Please enter your password to view comments.' ) ); ?></description> - <content:encoded><![CDATA[<?php echo get_the_password_form(); ?>]]></content:encoded> - <?php else : // post pass ?> - <description><![CDATA[<?php comment_text_rss(); ?>]]></description> - <content:encoded><![CDATA[<?php comment_text(); ?>]]></content:encoded> - <?php - endif; // post pass - /** - * Fires at the end of each RSS2 comment feed item. - * - * @since 2.1.0 - * - * @param int $comment->comment_ID The ID of the comment being displayed. - * @param int $comment_post->ID The ID of the post the comment is connected to. - */ - do_action( 'commentrss2_item', $comment->comment_ID, $comment_post->ID ); + + <?php if ( post_password_required( $comment_post ) ) : ?> + <description><?php echo ent2ncr( __( 'Protected Comments: Please enter your password to view comments.' ) ); ?></description> + <content:encoded><![CDATA[<?php echo get_the_password_form(); ?>]]></content:encoded> + <?php else : ?> + <description><![CDATA[<?php comment_text_rss(); ?>]]></description> + <content:encoded><![CDATA[<?php comment_text(); ?>]]></content:encoded> + <?php endif; // End if post_password_required(). ?> + + <?php + /** + * Fires at the end of each RSS2 comment feed item. + * + * @since 2.1.0 + * + * @param int $comment->comment_ID The ID of the comment being displayed. + * @param int $comment_post->ID The ID of the post the comment is connected to. + */ + do_action( 'commentrss2_item', $comment->comment_ID, $comment_post->ID ); ?> - </item> - <?php - endwhile; -endif; - ?> + </item> + <?php endwhile; ?> </channel> </rss> diff --git a/src/wp-includes/feed-rss2.php b/src/wp-includes/feed-rss2.php index 1ba7707561..8b30313e6d 100644 --- a/src/wp-includes/feed-rss2.php +++ b/src/wp-includes/feed-rss2.php @@ -89,29 +89,33 @@ do_action( 'rss_tag_pre', 'rss2' ); <title><?php the_title_rss(); ?></title> <link><?php the_permalink_rss(); ?></link> <?php if ( get_comments_number() || comments_open() ) : ?> - <comments><?php comments_link_feed(); ?></comments> + <comments><?php comments_link_feed(); ?></comments> <?php endif; ?> - <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> + <dc:creator><![CDATA[<?php the_author(); ?>]]></dc:creator> + <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate> <?php the_category_rss( 'rss2' ); ?> - <guid isPermaLink="false"><?php the_guid(); ?></guid> + <?php if ( get_option( 'rss_use_excerpt' ) ) : ?> - <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> + <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> <?php else : ?> - <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> + <description><![CDATA[<?php the_excerpt_rss(); ?>]]></description> <?php $content = get_the_content_feed( 'rss2' ); ?> <?php if ( strlen( $content ) > 0 ) : ?> - <content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded> - <?php else : ?> - <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded> - <?php endif; ?> + <content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded> + <?php else : ?> + <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded> + <?php endif; ?> <?php endif; ?> + <?php if ( get_comments_number() || comments_open() ) : ?> - <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link( null, 'rss2' ) ); ?></wfw:commentRss> - <slash:comments><?php echo get_comments_number(); ?></slash:comments> + <wfw:commentRss><?php echo esc_url( get_post_comments_feed_link( null, 'rss2' ) ); ?></wfw:commentRss> + <slash:comments><?php echo get_comments_number(); ?></slash:comments> <?php endif; ?> + <?php rss_enclosure(); ?> + <?php /** * Fires at the end of each RSS2 feed item. diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index aa17296c0c..813aea29ae 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -475,7 +475,7 @@ function rss_enclosure() { foreach ( (array) $val as $enc ) { $enclosure = explode( "\n", $enc ); - // only get the first element, e.g. audio/mpeg from 'audio/mpeg mpga mp2 mp3' + // Only get the first element, e.g. 'audio/mpeg' from 'audio/mpeg mpga mp2 mp3'. $t = preg_split( '/[ \t]/', trim( $enclosure[2] ) ); $type = $t[0]; @@ -763,7 +763,7 @@ function fetch_feed( $url ) { $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' ); // We must manually overwrite $feed->sanitize because SimplePie's - // constructor sets it before we have a chance to set the sanitization class + // constructor sets it before we have a chance to set the sanitization class. $feed->sanitize = new WP_SimplePie_Sanitize_KSES(); $feed->set_cache_class( 'WP_Feed_Cache' ); diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index a44c9c6bfb..6c83349405 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -123,14 +123,14 @@ function wptexturize( $text, $reset = false ) { $default_no_texturize_tags = array( 'pre', 'code', 'kbd', 'style', 'script', 'tt' ); $default_no_texturize_shortcodes = array( 'code' ); - // if a plugin has provided an autocorrect array, use it + // If a plugin has provided an autocorrect array, use it. if ( isset( $wp_cockneyreplace ) ) { $cockney = array_keys( $wp_cockneyreplace ); $cockneyreplace = array_values( $wp_cockneyreplace ); } else { /* * translators: This is a comma-separated list of words that defy the syntax of quotations in normal use, - * for example... 'We do not have enough words yet' ... is a typical quoted phrase. But when we write + * for example... 'We do not have enough words yet'... is a typical quoted phrase. But when we write * lines of code 'til we have enough of 'em, then we need to insert apostrophes instead of quotes. */ $cockney = explode( @@ -181,7 +181,7 @@ function wptexturize( $text, $reset = false ) { $dynamic['/\'(?=\d\d(?:\Z|(?![%\d]|[.,]\d)))/'] = $apos_flag; } - // Quoted Numbers like '0.42' + // Quoted numbers like '0.42'. if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $open_sq_flag . '$1' . $closing_single_quote; } @@ -191,7 +191,7 @@ function wptexturize( $text, $reset = false ) { $dynamic[ '/(?<=\A|[([{"\-]|<|' . $spaces . ')\'/' ] = $open_sq_flag; } - // Apostrophe in a word. No spaces, double apostrophes, or other punctuation. + // Apostrophe in a word. No spaces, double apostrophes, or other punctuation. if ( "'" !== $apos ) { $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;!?"\'(){}[\]\-]|&[lg]t;|' . $spaces . ')/' ] = $apos_flag; } @@ -200,7 +200,7 @@ function wptexturize( $text, $reset = false ) { $dynamic_replacements['apos'] = array_values( $dynamic ); $dynamic = array(); - // Quoted Numbers like "42" + // Quoted numbers like "42". if ( '"' !== $opening_quote && '"' !== $closing_quote ) { $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $open_q_flag . '$1' . $closing_quote; } @@ -214,7 +214,7 @@ function wptexturize( $text, $reset = false ) { $dynamic_replacements['quote'] = array_values( $dynamic ); $dynamic = array(); - // Dashes and spaces + // Dashes and spaces. $dynamic['/---/'] = $em_dash; $dynamic[ '/(?<=^|' . $spaces . ')--(?=$|' . $spaces . ')/' ] = $em_dash; $dynamic['/(?<!xn)--/'] = $en_dash; @@ -224,7 +224,7 @@ function wptexturize( $text, $reset = false ) { $dynamic_replacements['dash'] = array_values( $dynamic ); } - // Must do this every time in case plugins use these filters in a context sensitive manner + // Must do this every time in case plugins use these filters in a context sensitive manner. /** * Filters the list of HTML elements not to texturize. * @@ -271,7 +271,7 @@ function wptexturize( $text, $reset = false ) { _wptexturize_pushpop_element( $curl, $no_texturize_tags_stack, $no_texturize_tags ); } } elseif ( '' === trim( $curl ) ) { - // This is a newline between delimiters. Performance improves when we check this. + // This is a newline between delimiters. Performance improves when we check this. continue; } elseif ( '[' === $first && $found_shortcodes && 1 === preg_match( '/^' . $shortcode_regex . '$/', $curl ) ) { @@ -285,7 +285,7 @@ function wptexturize( $text, $reset = false ) { continue; } } elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) { - // This is neither a delimiter, nor is this content inside of no_texturize pairs. Do texturize. + // This is neither a delimiter, nor is this content inside of no_texturize pairs. Do texturize. $curl = str_replace( $static_characters, $static_replacements, $curl ); @@ -304,7 +304,7 @@ function wptexturize( $text, $reset = false ) { $curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl ); } - // 9x9 (times), but never 0x9999 + // 9x9 (times), but never 0x9999. if ( 1 === preg_match( '/(?<=\d)x\d/', $curl ) ) { // Searching for a digit is 10 times more expensive than for the x, so we avoid doing this one! $curl = preg_replace( '/\b(\d(?(?<=0)[\d\.,]+|[\d\.,]*))x(\d[\d\.,]*)\b/', '$1×$2', $curl ); @@ -348,7 +348,7 @@ function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quo } elseif ( 0 !== $key && 0 === substr_count( $sentence, $close_quote ) ) { $sentence = preg_replace( $quote_pattern, $flag, $sentence, -1, $count ); if ( $count > 1 ) { - // This sentence appears to have multiple closing quotes. Attempt Vulcan logic. + // This sentence appears to have multiple closing quotes. Attempt Vulcan logic. $sentence = preg_replace( $flag_no_digit, $close_quote, $sentence, -1, $count2 ); if ( 0 === $count2 ) { // Try looking for a quote followed by a period. @@ -372,7 +372,7 @@ function wptexturize_primes( $haystack, $needle, $prime, $open_quote, $close_quo $sentence = str_replace( $flag, $close_quote, $sentence ); $sentence = preg_replace( $prime_pattern, $prime, $sentence ); } else { - // No closing quotes found. Just run primes pattern. + // No closing quotes found. Just run primes pattern. $sentence = preg_replace( $prime_pattern, $prime, $sentence ); } } else { @@ -428,10 +428,10 @@ function _wptexturize_pushpop_element( $text, &$stack, $disabled_elements ) { if ( $opening_tag ) { /* * This disables texturize until we find a closing tag of our type - * (e.g. <pre>) even if there was invalid nesting before that + * (e.g. <pre>) even if there was invalid nesting before that. * * Example: in the case <pre>sadsadasd</code>"baba"</pre> - * "baba" won't be texturize + * "baba" won't be texturized. */ array_push( $stack, $tag ); @@ -478,7 +478,7 @@ function wpautop( $pee, $br = true ) { foreach ( $pee_parts as $pee_part ) { $start = strpos( $pee_part, '<pre' ); - // Malformed html? + // Malformed HTML? if ( $start === false ) { $pee .= $pee_part; continue; @@ -493,7 +493,7 @@ function wpautop( $pee, $br = true ) { $pee .= $last_pee; } - // Change multiple <br>s into two line breaks, which will turn into paragraphs. + // Change multiple <br>'s into two line breaks, which will turn into paragraphs. $pee = preg_replace( '|<br\s*/?>\s*<br\s*/?>|', "\n\n", $pee ); $allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)'; @@ -676,7 +676,7 @@ function get_html_split_regex() { . '<' // Find start of element. . '(?' // Conditional expression follows. . $escaped // Find end of escaped element. - . '|' // ... else ... + . '|' // ...else... . '[^>]*>?' // Find end of normal element. . ')' . ')/'; @@ -696,7 +696,7 @@ function get_html_split_regex() { * * @staticvar string $html_regex * - * @param string $shortcode_regex The result from _get_wptexturize_shortcode_regex(). Optional. + * @param string $shortcode_regex The result from _get_wptexturize_shortcode_regex(). Optional. * @return string The regular expression */ function _get_wptexturize_split_regex( $shortcode_regex = '' ) { @@ -746,8 +746,8 @@ function _get_wptexturize_shortcode_regex( $tagnames ) { $tagregexp = "(?:$tagregexp)(?=[\\s\\]\\/])"; // Excerpt of get_shortcode_regex(). // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation $regex = - '\[' // Find start of shortcode. - . '[\/\[]?' // Shortcodes may begin with [/ or [[ + '\[' // Find start of shortcode. + . '[\/\[]?' // Shortcodes may begin with [/ or [[. . $tagregexp // Only match registered shortcodes, because performance. . '(?:' . '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical. @@ -755,7 +755,7 @@ function _get_wptexturize_shortcode_regex( $tagnames ) { . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >. . ')*+' // Possessive critical. . '\]' // Find end of shortcode. - . '\]?'; // Shortcodes may end with ]] + . '\]?'; // Shortcodes may end with ]]. // phpcs:enable return $regex; @@ -850,34 +850,34 @@ function shortcode_unautop( $pee ) { // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound,WordPress.WhiteSpace.PrecisionAlignment.Found -- don't remove regex indentation $pattern = '/' - . '<p>' // Opening paragraph - . '(?:' . $spaces . ')*+' // Optional leading whitespace - . '(' // 1: The shortcode - . '\\[' // Opening bracket - . "($tagregexp)" // 2: Shortcode name - . '(?![\\w-])' // Not followed by word character or hyphen - // Unroll the loop: Inside the opening shortcode tag - . '[^\\]\\/]*' // Not a closing bracket or forward slash + . '<p>' // Opening paragraph. + . '(?:' . $spaces . ')*+' // Optional leading whitespace. + . '(' // 1: The shortcode. + . '\\[' // Opening bracket. + . "($tagregexp)" // 2: Shortcode name. + . '(?![\\w-])' // Not followed by word character or hyphen. + // Unroll the loop: Inside the opening shortcode tag. + . '[^\\]\\/]*' // Not a closing bracket or forward slash. . '(?:' - . '\\/(?!\\])' // A forward slash not followed by a closing bracket - . '[^\\]\\/]*' // Not a closing bracket or forward slash + . '\\/(?!\\])' // A forward slash not followed by a closing bracket. + . '[^\\]\\/]*' // Not a closing bracket or forward slash. . ')*?' . '(?:' - . '\\/\\]' // Self closing tag and closing bracket + . '\\/\\]' // Self closing tag and closing bracket. . '|' - . '\\]' // Closing bracket - . '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags - . '[^\\[]*+' // Not an opening bracket + . '\\]' // Closing bracket. + . '(?:' // Unroll the loop: Optionally, anything between the opening and closing shortcode tags. + . '[^\\[]*+' // Not an opening bracket. . '(?:' - . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag - . '[^\\[]*+' // Not an opening bracket + . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag. + . '[^\\[]*+' // Not an opening bracket. . ')*+' - . '\\[\\/\\2\\]' // Closing shortcode tag + . '\\[\\/\\2\\]' // Closing shortcode tag. . ')?' . ')' . ')' - . '(?:' . $spaces . ')*+' // optional trailing whitespace - . '<\\/p>' // closing paragraph + . '(?:' . $spaces . ')*+' // Optional trailing whitespace. + . '<\\/p>' // Closing paragraph. . '/'; // phpcs:enable @@ -915,7 +915,7 @@ function seems_utf8( $str ) { } elseif ( ( $c & 0xFE ) == 0xFC ) { $n = 5; // 1111110b } else { - return false; // Does not match any model + return false; // Does not match any model. } for ( $j = 0; $j < $n; $j++ ) { // n bytes matching 10bbbbbb follow ? if ( ( ++$i == $length ) || ( ( ord( $str[ $i ] ) & 0xC0 ) != 0x80 ) ) { @@ -956,19 +956,19 @@ function _wp_specialchars( $string, $quote_style = ENT_NOQUOTES, $charset = fals return ''; } - // Don't bother if there are no specialchars - saves some processing + // Don't bother if there are no specialchars - saves some processing. if ( ! preg_match( '/[&<>"\']/', $string ) ) { return $string; } - // Account for the previous behaviour of the function when the $quote_style is not an accepted value + // Account for the previous behaviour of the function when the $quote_style is not an accepted value. if ( empty( $quote_style ) ) { $quote_style = ENT_NOQUOTES; } elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { $quote_style = ENT_QUOTES; } - // Store the site charset as a static to avoid multiple calls to wp_load_alloptions() + // Store the site charset as a static to avoid multiple calls to wp_load_alloptions(). if ( ! $charset ) { static $_charset = null; if ( ! isset( $_charset ) ) { @@ -1034,19 +1034,19 @@ function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) { return ''; } - // Don't bother if there are no entities - saves a lot of processing + // Don't bother if there are no entities - saves a lot of processing. if ( strpos( $string, '&' ) === false ) { return $string; } - // Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value + // Match the previous behaviour of _wp_specialchars() when the $quote_style is not an accepted value. if ( empty( $quote_style ) ) { $quote_style = ENT_NOQUOTES; } elseif ( ! in_array( $quote_style, array( 0, 2, 3, 'single', 'double' ), true ) ) { $quote_style = ENT_QUOTES; } - // More complete than get_html_translation_table( HTML_SPECIALCHARS ) + // More complete than get_html_translation_table( HTML_SPECIALCHARS ). $single = array( ''' => '\'', ''' => '\'', @@ -1094,10 +1094,10 @@ function wp_specialchars_decode( $string, $quote_style = ENT_NOQUOTES ) { $translation_preg = $others_preg; } - // Remove zero padding on numeric entities + // Remove zero padding on numeric entities. $string = preg_replace( array_keys( $translation_preg ), array_values( $translation_preg ), $string ); - // Replace characters according to translation table + // Replace characters according to translation table. return strtr( $string, $translation ); } @@ -1120,7 +1120,7 @@ function wp_check_invalid_utf8( $string, $strip = false ) { return ''; } - // Store the site charset as a static to avoid multiple calls to get_option() + // Store the site charset as a static to avoid multiple calls to get_option(). static $is_utf8 = null; if ( ! isset( $is_utf8 ) ) { $is_utf8 = in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ); @@ -1129,23 +1129,23 @@ function wp_check_invalid_utf8( $string, $strip = false ) { return $string; } - // Check for support for utf8 in the installed PCRE library once and store the result in a static + // Check for support for utf8 in the installed PCRE library once and store the result in a static. static $utf8_pcre = null; if ( ! isset( $utf8_pcre ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged $utf8_pcre = @preg_match( '/^./u', 'a' ); } - // We can't demand utf8 in the PCRE installation, so just return the string in those cases + // We can't demand utf8 in the PCRE installation, so just return the string in those cases. if ( ! $utf8_pcre ) { return $string; } - // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- preg_match fails when it encounters invalid UTF8 in $string + // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- preg_match fails when it encounters invalid UTF8 in $string. if ( 1 === @preg_match( '/^./us', $string ) ) { return $string; } - // Attempt to strip the bad chars if requested (not recommended) + // Attempt to strip the bad chars if requested (not recommended). if ( $strip && function_exists( 'iconv' ) ) { return iconv( 'utf-8', 'utf-8', $string ); } @@ -1607,7 +1607,7 @@ function remove_accents( $string ) { if ( seems_utf8( $string ) ) { $chars = array( - // Decompositions for Latin-1 Supplement + // Decompositions for Latin-1 Supplement. 'ª' => 'a', 'º' => 'o', 'À' => 'A', @@ -1672,7 +1672,7 @@ function remove_accents( $string ) { 'þ' => 'th', 'ÿ' => 'y', 'Ø' => 'O', - // Decompositions for Latin Extended-A + // Decompositions for Latin Extended-A. 'Ā' => 'A', 'ā' => 'a', 'Ă' => 'A', @@ -1801,22 +1801,22 @@ function remove_accents( $string ) { 'Ž' => 'Z', 'ž' => 'z', 'ſ' => 's', - // Decompositions for Latin Extended-B + // Decompositions for Latin Extended-B. 'Ș' => 'S', 'ș' => 's', 'Ț' => 'T', 'ț' => 't', - // Euro Sign + // Euro sign. '€' => 'E', - // GBP (Pound) Sign + // GBP (Pound) sign. '£' => '', - // Vowels with diacritic (Vietnamese) - // unmarked + // Vowels with diacritic (Vietnamese). + // Unmarked. 'Ơ' => 'O', 'ơ' => 'o', 'Ư' => 'U', 'ư' => 'u', - // grave accent + // Grave accent. 'Ầ' => 'A', 'ầ' => 'a', 'Ằ' => 'A', @@ -1831,7 +1831,7 @@ function remove_accents( $string ) { 'ừ' => 'u', 'Ỳ' => 'Y', 'ỳ' => 'y', - // hook + // Hook. 'Ả' => 'A', 'ả' => 'a', 'Ẩ' => 'A', @@ -1856,7 +1856,7 @@ function remove_accents( $string ) { 'ử' => 'u', 'Ỷ' => 'Y', 'ỷ' => 'y', - // tilde + // Tilde. 'Ẫ' => 'A', 'ẫ' => 'a', 'Ẵ' => 'A', @@ -1873,7 +1873,7 @@ function remove_accents( $string ) { 'ữ' => 'u', 'Ỹ' => 'Y', 'ỹ' => 'y', - // acute accent + // Acute accent. 'Ấ' => 'A', 'ấ' => 'a', 'Ắ' => 'A', @@ -1886,7 +1886,7 @@ function remove_accents( $string ) { 'ớ' => 'o', 'Ứ' => 'U', 'ứ' => 'u', - // dot below + // Dot below. 'Ạ' => 'A', 'ạ' => 'a', 'Ậ' => 'A', @@ -1911,15 +1911,15 @@ function remove_accents( $string ) { 'ự' => 'u', 'Ỵ' => 'Y', 'ỵ' => 'y', - // Vowels with diacritic (Chinese, Hanyu Pinyin) + // Vowels with diacritic (Chinese, Hanyu Pinyin). 'ɑ' => 'a', - // macron + // Macron. 'Ǖ' => 'U', 'ǖ' => 'u', - // acute accent + // Acute accent. 'Ǘ' => 'U', 'ǘ' => 'u', - // caron + // Caron. 'Ǎ' => 'A', 'ǎ' => 'a', 'Ǐ' => 'I', @@ -1930,12 +1930,12 @@ function remove_accents( $string ) { 'ǔ' => 'u', 'Ǚ' => 'U', 'ǚ' => 'u', - // grave accent + // Grave accent. 'Ǜ' => 'U', 'ǜ' => 'u', ); - // Used for locale-specific rules + // Used for locale-specific rules. $locale = get_locale(); if ( 'de_DE' == $locale || 'de_DE_formal' == $locale || 'de_CH' == $locale || 'de_CH_informal' == $locale ) { @@ -1963,7 +1963,7 @@ function remove_accents( $string ) { $string = strtr( $string, $chars ); } else { $chars = array(); - // Assume ISO-8859-1 if not UTF-8 + // Assume ISO-8859-1 if not UTF-8. $chars['in'] = "\x80\x83\x8a\x8e\x9a\x9e" . "\x9f\xa2\xa5\xb5\xc0\xc1\xc2" . "\xc3\xc4\xc5\xc7\xc8\xc9\xca" @@ -2028,10 +2028,10 @@ function sanitize_file_name( $filename ) { } } - // Split the filename into a base and extension[s] + // Split the filename into a base and extension[s]. $parts = explode( '.', $filename ); - // Return if only one extension + // Return if only one extension. if ( count( $parts ) <= 2 ) { /** * Filters a sanitized filename string. @@ -2044,7 +2044,7 @@ function sanitize_file_name( $filename ) { return apply_filters( 'sanitize_file_name', $filename, $filename_raw ); } - // Process multiple extensions + // Process multiple extensions. $filename = array_shift( $parts ); $extension = array_pop( $parts ); $mimes = get_allowed_mime_types(); @@ -2093,9 +2093,10 @@ function sanitize_user( $username, $strict = false ) { $raw_username = $username; $username = wp_strip_all_tags( $username ); $username = remove_accents( $username ); - // Kill octets + // Kill octets. $username = preg_replace( '|%([a-fA-F0-9][a-fA-F0-9])|', '', $username ); - $username = preg_replace( '/&.+?;/', '', $username ); // Kill entities + // Kill entities. + $username = preg_replace( '/&.+?;/', '', $username ); // If strict, reduce to ASCII for max portability. if ( $strict ) { @@ -2103,7 +2104,7 @@ function sanitize_user( $username, $strict = false ) { } $username = trim( $username ); - // Consolidate contiguous whitespace + // Consolidate contiguous whitespace. $username = preg_replace( '|\s+|', ' ', $username ); /** @@ -2229,27 +2230,27 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa $title = strtolower( $title ); if ( 'save' == $context ) { - // Convert nbsp, ndash and mdash to hyphens + // Convert  , &ndash, and &mdash to hyphens. $title = str_replace( array( '%c2%a0', '%e2%80%93', '%e2%80%94' ), '-', $title ); - // Convert nbsp, ndash and mdash HTML entities to hyphens + // Convert  , &ndash, and &mdash HTML entities to hyphens. $title = str_replace( array( ' ', ' ', '–', '–', '—', '—' ), '-', $title ); - // Convert forward slash to hyphen + // Convert forward slash to hyphen. $title = str_replace( '/', '-', $title ); - // Strip these characters entirely + // Strip these characters entirely. $title = str_replace( array( - // soft hyphens + // Soft hyphens. '%c2%ad', - // iexcl and iquest + // ¡ and ¿. '%c2%a1', '%c2%bf', - // angle quotes + // Angle quotes. '%c2%ab', '%c2%bb', '%e2%80%b9', '%e2%80%ba', - // curly quotes + // Curly quotes. '%e2%80%98', '%e2%80%99', '%e2%80%9c', @@ -2258,18 +2259,18 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa '%e2%80%9b', '%e2%80%9e', '%e2%80%9f', - // copy, reg, deg, hellip and trade + // ©, ®, °, &hellip, and &trade. '%c2%a9', '%c2%ae', '%c2%b0', '%e2%80%a6', '%e2%84%a2', - // acute accents + // Acute accents. '%c2%b4', '%cb%8a', '%cc%81', '%cd%81', - // grave accent, macron, caron + // Grave accent, macron, caron. '%cc%80', '%cc%84', '%cc%8c', @@ -2278,11 +2279,12 @@ function sanitize_title_with_dashes( $title, $raw_title = '', $context = 'displa $title ); - // Convert times to x + // Convert × to 'x'. $title = str_replace( '%c3%97', 'x', $title ); } - $title = preg_replace( '/&.+?;/', '', $title ); // kill entities + // Kill entities. + $title = preg_replace( '/&.+?;/', '', $title ); $title = str_replace( '.', '-', $title ); $title = preg_replace( '/[^%a-z0-9 _-]/', '', $title ); @@ -2329,10 +2331,10 @@ function sanitize_sql_orderby( $orderby ) { * @return string The sanitized value */ function sanitize_html_class( $class, $fallback = '' ) { - //Strip out any % encoded octets + // Strip out any %-encoded octets. $sanitized = preg_replace( '|%[a-fA-F0-9][a-fA-F0-9]|', '', $class ); - //Limit to A-Z,a-z,0-9,_,- + // Limit to A-Z, a-z, 0-9, '_', '-'. $sanitized = preg_replace( '/[^A-Za-z0-9_-]/', '', $sanitized ); if ( '' == $sanitized && $fallback ) { @@ -2381,10 +2383,10 @@ function convert_chars( $content, $deprecated = '' ) { */ function convert_invalid_entities( $content ) { $wp_htmltranswinuni = array( - '€' => '€', // the Euro sign + '€' => '€', // The Euro sign. '' => '', - '‚' => '‚', // these are Windows CP1252 specific characters - 'ƒ' => 'ƒ', // they would look weird on non-Windows browsers + '‚' => '‚', // These are Windows CP1252 specific characters. + 'ƒ' => 'ƒ', // They would look weird on non-Windows browsers. '„' => '„', '…' => '…', '†' => '†', @@ -2463,14 +2465,14 @@ function force_balance_tags( $text ) { $stacksize = 0; $tagqueue = ''; $newtext = ''; - // Known single-entity/self-closing tags + // Known single-entity/self-closing tags. $single_tags = array( 'area', 'base', 'basefont', 'br', 'col', 'command', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param', 'source' ); - // Tags that can be immediately nested within themselves + // Tags that can be immediately nested within themselves. $nestable_tags = array( 'blockquote', 'div', 'object', 'q', 'span' ); - // WP bug fix for comments - in case you REALLY meant to type '< !--' + // WP bug fix for comments - in case you REALLY meant to type '< !--'. $text = str_replace( '< !--', '< !--', $text ); - // WP bug fix for LOVE <3 (and other situations with '<' before a number) + // WP bug fix for LOVE <3 (and other situations with '<' before a number). $text = preg_replace( '#<([0-9]{1})#', '<$1', $text ); /** @@ -2526,7 +2528,7 @@ function force_balance_tags( $text ) { // Clear the shifter. $tagqueue = ''; - if ( $has_leading_slash ) { // End Tag. + if ( $has_leading_slash ) { // End tag. // If too many closing tags. if ( $stacksize <= 0 ) { $tag = ''; @@ -2534,7 +2536,7 @@ function force_balance_tags( $text ) { // If stacktop value = tag close value, then pop. } elseif ( $tagstack[ $stacksize - 1 ] === $tag ) { // Found closing tag. - $tag = '</' . $tag . '>'; // Close Tag. + $tag = '</' . $tag . '>'; // Close tag. array_pop( $tagstack ); $stacksize--; } else { // Closing tag not at top, search for it. @@ -2550,14 +2552,14 @@ function force_balance_tags( $text ) { } $tag = ''; } - } else { // Begin Tag. + } else { // Begin tag. if ( $has_self_closer ) { // If it presents itself as a self-closing tag... - // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such and - // immediately close it with a closing tag (the tag will encapsulate no text as a result) + // ...but it isn't a known single-entity self-closing tag, then don't let it be treated as such + // and immediately close it with a closing tag (the tag will encapsulate no text as a result). if ( ! $is_single_tag ) { $attributes = trim( substr( $attributes, 0, -1 ) ) . "></$tag"; } - } elseif ( $is_single_tag ) { // ElseIf it's a known single-entity tag but it doesn't close itself, do so + } elseif ( $is_single_tag ) { // Else if it's a known single-entity tag but it doesn't close itself, do so. $pre_attribute_ws = ' '; $attributes .= '/'; } else { // It's not a single-entity tag. @@ -2586,7 +2588,7 @@ function force_balance_tags( $text ) { $text = substr( $text, $i + $l ); } - // Clear Tag Queue. + // Clear tag queue. $newtext .= $tagqueue; // Add remaining text. @@ -2818,15 +2820,15 @@ function _make_url_clickable_cb( $matches ) { $url = $matches[2]; if ( ')' == $matches[3] && strpos( $url, '(' ) ) { - // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, add the closing parenthesis to the URL. - // Then we can let the parenthesis balancer do its thing below. + // If the trailing character is a closing parethesis, and the URL has an opening parenthesis in it, + // add the closing parenthesis to the URL. Then we can let the parenthesis balancer do its thing below. $url .= $matches[3]; $suffix = ''; } else { $suffix = $matches[3]; } - // Include parentheses in the URL only if paired + // Include parentheses in the URL only if paired. while ( substr_count( $url, '(' ) < substr_count( $url, ')' ) ) { $suffix = strrchr( $url, ')' ) . $suffix; $url = substr( $url, 0, strrpos( $url, ')' ) ); @@ -2873,7 +2875,7 @@ function _make_web_ftp_clickable_cb( $matches ) { $dest = $matches[2]; $dest = 'http://' . $dest; - // removed trailing [.,;:)] from URL + // Removed trailing [.,;:)] from URL. if ( in_array( substr( $dest, -1 ), array( '.', ',', ';', ':', ')' ) ) === true ) { $ret = substr( $dest, -1 ); $dest = substr( $dest, 0, strlen( $dest ) - 1 ); @@ -2926,8 +2928,8 @@ function _make_email_clickable_cb( $matches ) { */ function make_clickable( $text ) { $r = ''; - $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // split out HTML tags - $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code> + $textarr = preg_split( '/(<[^<>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Split out HTML tags. + $nested_code_pre = 0; // Keep track of how many levels link is nested inside <pre> or <code>. foreach ( $textarr as $piece ) { if ( preg_match( '|^<code[\s>]|i', $piece ) || preg_match( '|^<pre[\s>]|i', $piece ) || preg_match( '|^<script[\s>]|i', $piece ) || preg_match( '|^<style[\s>]|i', $piece ) ) { @@ -2941,10 +2943,10 @@ function make_clickable( $text ) { continue; } - // Long strings might contain expensive edge cases ... + // Long strings might contain expensive edge cases... if ( 10000 < strlen( $piece ) ) { - // ... break it up - foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses + // ...break it up. + foreach ( _split_str_by_whitespace( $piece, 2100 ) as $chunk ) { // 2100: Extra room for scheme and leading and trailing paretheses. if ( 2101 < strlen( $chunk ) ) { $r .= $chunk; // Too big, no whitespace: bail. } else { @@ -2952,20 +2954,20 @@ function make_clickable( $text ) { } } } else { - $ret = " $piece "; // Pad with whitespace to simplify the regexes + $ret = " $piece "; // Pad with whitespace to simplify the regexes. $url_clickable = '~ - ([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation - ( # 2: URL - [\\w]{1,20}+:// # Scheme and hier-part prefix - (?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long - [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character - (?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character - [\'.,;:!?)] # Punctuation URL character - [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character + ([\\s(<.,;:!?]) # 1: Leading whitespace, or punctuation. + ( # 2: URL. + [\\w]{1,20}+:// # Scheme and hier-part prefix. + (?=\S{1,2000}\s) # Limit to URLs less than about 2000 characters long. + [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]*+ # Non-punctuation URL character. + (?: # Unroll the Loop: Only allow puctuation URL character if followed by a non-punctuation URL character. + [\'.,;:!?)] # Punctuation URL character. + [\\w\\x80-\\xff#%\\~/@\\[\\]*(+=&$-]++ # Non-punctuation URL character. )* ) - (\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing) + (\)?) # 3: Trailing closing parenthesis (for parethesis balancing post processing). ~xS'; // The regex is a non-anchored pattern and does not have a single fixed starting character. // Tell PCRE to spend more time optimizing since, when used on a page load, it will probably be used several times. @@ -2980,7 +2982,7 @@ function make_clickable( $text ) { } } - // Cleanup of accidental links within links + // Cleanup of accidental links within links. return preg_replace( '#(<a([ \r\n\t]+[^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i', '$1$3</a>', $r ); } @@ -2996,14 +2998,14 @@ function make_clickable( $text ) { * * _split_str_by_whitespace( "1234 67890 1234 67890a cd 1234 890 123456789 1234567890a 45678 1 3 5 7 90 ", 10 ) == * array ( - * 0 => '1234 67890 ', // 11 characters: Perfect split - * 1 => '1234 ', // 5 characters: '1234 67890a' was too long - * 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long - * 3 => '1234 890 ', // 11 characters: Perfect split - * 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long - * 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split - * 6 => ' 45678 ', // 11 characters: Perfect split - * 7 => '1 3 5 7 90 ', // 11 characters: End of $string + * 0 => '1234 67890 ', // 11 characters: Perfect split. + * 1 => '1234 ', // 5 characters: '1234 67890a' was too long. + * 2 => '67890a cd ', // 10 characters: '67890a cd 1234' was too long. + * 3 => '1234 890 ', // 11 characters: Perfect split. + * 4 => '123456789 ', // 10 characters: '123456789 1234567890a' was too long. + * 5 => '1234567890a ', // 12 characters: Too long, but no inner whitespace on which to split. + * 6 => ' 45678 ', // 11 characters: Perfect split. + * 7 => '1 3 5 7 90 ', // 11 characters: End of $string. * ); * * @since 3.4.0 @@ -3188,10 +3190,10 @@ function wp_targeted_link_rel_callback( $matches ) { $link_html = $matches[1]; $original_link_html = $link_html; - // Consider the html escaped if there are no unescaped quotes + // Consider the HTML escaped if there are no unescaped quotes. $is_escaped = ! preg_match( '/(^|[^\\\\])[\'"]/', $link_html ); if ( $is_escaped ) { - // Replace only the quotes so that they are parsable by wp_kses_hair, leave the rest as is + // Replace only the quotes so that they are parsable by wp_kses_hair(), leave the rest as is. $link_html = preg_replace( '/\\\\([\'"])/', '$1', $link_html ); } @@ -3207,7 +3209,7 @@ function wp_targeted_link_rel_callback( $matches ) { */ $rel = apply_filters( 'wp_targeted_link_rel', 'noopener noreferrer', $link_html ); - // Return early if no rel values to be added or if no actual target attribute + // Return early if no rel values to be added or if no actual target attribute. if ( ! $rel || ! isset( $atts['target'] ) ) { return "<a $original_link_html>"; } @@ -3338,28 +3340,28 @@ function convert_smilies( $text ) { global $wp_smiliessearch; $output = ''; if ( get_option( 'use_smilies' ) && ! empty( $wp_smiliessearch ) ) { - // HTML loop taken from texturize function, could possible be consolidated - $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // capture the tags as well as in between - $stop = count( $textarr );// loop stuff + // HTML loop taken from texturize function, could possible be consolidated. + $textarr = preg_split( '/(<.*>)/U', $text, -1, PREG_SPLIT_DELIM_CAPTURE ); // Capture the tags as well as in between. + $stop = count( $textarr ); // Loop stuff. - // Ignore proessing of specific tags + // Ignore proessing of specific tags. $tags_to_ignore = 'code|pre|style|script|textarea'; $ignore_block_element = ''; for ( $i = 0; $i < $stop; $i++ ) { $content = $textarr[ $i ]; - // If we're in an ignore block, wait until we find its closing tag + // If we're in an ignore block, wait until we find its closing tag. if ( '' == $ignore_block_element && preg_match( '/^<(' . $tags_to_ignore . ')[^>]*>/', $content, $matches ) ) { $ignore_block_element = $matches[1]; } - // If it's not a tag and not in ignore block + // If it's not a tag and not in ignore block. if ( '' == $ignore_block_element && strlen( $content ) > 0 && '<' != $content[0] ) { $content = preg_replace_callback( $wp_smiliessearch, 'translate_smiley', $content ); } - // did we exit ignore block + // Did we exit ignore block? if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) { $ignore_block_element = ''; } @@ -3367,7 +3369,7 @@ function convert_smilies( $text ) { $output .= $content; } } else { - // return default text. + // Return default text. $output = $text; } return $output; @@ -3389,7 +3391,7 @@ function is_email( $email, $deprecated = false ) { _deprecated_argument( __FUNCTION__, '3.0.0' ); } - // Test for the minimum length the email can be + // Test for the minimum length the email can be. if ( strlen( $email ) < 6 ) { /** * Filters whether an email address is valid. @@ -3407,60 +3409,60 @@ function is_email( $email, $deprecated = false ) { return apply_filters( 'is_email', false, $email, 'email_too_short' ); } - // Test for an @ character after the first position + // Test for an @ character after the first position. if ( strpos( $email, '@', 1 ) === false ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'email_no_at' ); } - // Split out the local and domain parts + // Split out the local and domain parts. list( $local, $domain ) = explode( '@', $email, 2 ); // LOCAL PART - // Test for invalid characters + // Test for invalid characters. if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'local_invalid_chars' ); } // DOMAIN PART - // Test for sequences of periods + // Test for sequences of periods. if ( preg_match( '/\.{2,}/', $domain ) ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'domain_period_sequence' ); } - // Test for leading and trailing periods and whitespace + // Test for leading and trailing periods and whitespace. if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'domain_period_limits' ); } - // Split the domain into subs + // Split the domain into subs. $subs = explode( '.', $domain ); - // Assume the domain will have at least two subs + // Assume the domain will have at least two subs. if ( 2 > count( $subs ) ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); } - // Loop through each sub + // Loop through each sub. foreach ( $subs as $sub ) { - // Test for leading and trailing hyphens and whitespace + // Test for leading and trailing hyphens and whitespace. if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' ); } - // Test for invalid characters + // Test for invalid characters. if ( ! preg_match( '/^[a-z0-9-]+$/i', $sub ) ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' ); } } - // Congratulations your email made it! + // Congratulations, your email made it! /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'is_email', $email, $email, null ); } @@ -3549,7 +3551,7 @@ function get_date_from_gmt( $string, $format = 'Y-m-d H:i:s' ) { * @return int|float The offset in seconds. */ function iso8601_timezone_to_offset( $timezone ) { - // $timezone is either 'Z' or '[+|-]hhmm' + // $timezone is either 'Z' or '[+|-]hhmm'. if ( $timezone == 'Z' ) { $offset = 0; } else { @@ -3599,7 +3601,7 @@ function iso8601_to_datetime( $date_string, $timezone = 'user' ) { * @return string Filtered email address. */ function sanitize_email( $email ) { - // Test for the minimum length the email can be + // Test for the minimum length the email can be. if ( strlen( $email ) < 6 ) { /** * Filters a sanitized email address. @@ -3617,17 +3619,17 @@ function sanitize_email( $email ) { return apply_filters( 'sanitize_email', '', $email, 'email_too_short' ); } - // Test for an @ character after the first position + // Test for an @ character after the first position. if ( strpos( $email, '@', 1 ) === false ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'sanitize_email', '', $email, 'email_no_at' ); } - // Split out the local and domain parts + // Split out the local and domain parts. list( $local, $domain ) = explode( '@', $email, 2 ); // LOCAL PART - // Test for invalid characters + // Test for invalid characters. $local = preg_replace( '/[^a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]/', '', $local ); if ( '' === $local ) { /** This filter is documented in wp-includes/formatting.php */ @@ -3635,59 +3637,59 @@ function sanitize_email( $email ) { } // DOMAIN PART - // Test for sequences of periods + // Test for sequences of periods. $domain = preg_replace( '/\.{2,}/', '', $domain ); if ( '' === $domain ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'sanitize_email', '', $email, 'domain_period_sequence' ); } - // Test for leading and trailing periods and whitespace + // Test for leading and trailing periods and whitespace. $domain = trim( $domain, " \t\n\r\0\x0B." ); if ( '' === $domain ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'sanitize_email', '', $email, 'domain_period_limits' ); } - // Split the domain into subs + // Split the domain into subs. $subs = explode( '.', $domain ); - // Assume the domain will have at least two subs + // Assume the domain will have at least two subs. if ( 2 > count( $subs ) ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); } - // Create an array that will contain valid subs + // Create an array that will contain valid subs. $new_subs = array(); - // Loop through each sub + // Loop through each sub. foreach ( $subs as $sub ) { - // Test for leading and trailing hyphens + // Test for leading and trailing hyphens. $sub = trim( $sub, " \t\n\r\0\x0B-" ); - // Test for invalid characters + // Test for invalid characters. $sub = preg_replace( '/[^a-z0-9-]+/i', '', $sub ); - // If there's anything left, add it to the valid subs + // If there's anything left, add it to the valid subs. if ( '' !== $sub ) { $new_subs[] = $sub; } } - // If there aren't 2 or more valid subs + // If there aren't 2 or more valid subs. if ( 2 > count( $new_subs ) ) { /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); } - // Join valid subs into the new domain + // Join valid subs into the new domain. $domain = join( '.', $new_subs ); - // Put the email back together + // Put the email back together. $sanitized_email = $local . '@' . $domain; - // Congratulations your email made it! + // Congratulations, your email made it! /** This filter is documented in wp-includes/formatting.php */ return apply_filters( 'sanitize_email', $sanitized_email, $email, null ); } @@ -4304,9 +4306,10 @@ function esc_url( $url, $protocols = null, $_context = 'display' ) { } $url = str_replace( ';//', '://', $url ); - /* If the URL doesn't appear to contain a scheme, we - * presume it needs http:// prepended (unless a relative - * link starting with /, # or ? or a php file). + /* + * If the URL doesn't appear to contain a scheme, we presume + * it needs http:// prepended (unless it's a relative link + * starting with /, # or ?, or a PHP file). */ if ( strpos( $url, ':' ) === false && ! in_array( $url[0], array( '/', '#', '?' ) ) && ! preg_match( '/^[a-z0-9-]+?\.php/i', $url ) ) { @@ -4622,7 +4625,7 @@ function sanitize_option( $option, $value ) { case 'default_ping_status': case 'default_comment_status': - // Options that if not there have 0 value but need to be something like "closed" + // Options that if not there have 0 value but need to be something like "closed". if ( $value == '0' || $value == '' ) { $value = 'closed'; } @@ -4643,7 +4646,7 @@ function sanitize_option( $option, $value ) { break; case 'blog_charset': - $value = preg_replace( '/[^a-zA-Z0-9_-]/', '', $value ); // strips slashes + $value = preg_replace( '/[^a-zA-Z0-9_-]/', '', $value ); // Strips slashes. break; case 'blog_public': @@ -4678,7 +4681,7 @@ function sanitize_option( $option, $value ) { break; case 'gmt_offset': - $value = preg_replace( '/[^0-9:.-]/', '', $value ); // strips slashes + $value = preg_replace( '/[^0-9:.-]/', '', $value ); // Strips slashes. break; case 'siteurl': @@ -4948,31 +4951,31 @@ function wp_sprintf( $pattern, ...$args ) { $result = ''; $arg_index = 0; while ( $len > $start ) { - // Last character: append and break + // Last character: append and break. if ( strlen( $pattern ) - 1 == $start ) { $result .= substr( $pattern, -1 ); break; } - // Literal %: append and continue + // Literal %: append and continue. if ( substr( $pattern, $start, 2 ) == '%%' ) { $start += 2; $result .= '%'; continue; } - // Get fragment before next % + // Get fragment before next %. $end = strpos( $pattern, '%', $start + 1 ); if ( false === $end ) { $end = $len; } $fragment = substr( $pattern, $start, $end - $start ); - // Fragment has a specifier + // Fragment has a specifier. if ( $pattern[ $start ] == '%' ) { - // Find numbered arguments or take the next one in order + // Find numbered arguments or take the next one in order. if ( preg_match( '/^%(\d+)\$/', $fragment, $matches ) ) { - $index = $matches[1] - 1; // 0-based array vs 1-based sprintf arguments. + $index = $matches[1] - 1; // 0-based array vs 1-based sprintf() arguments. $arg = isset( $args[ $index ] ) ? $args[ $index ] : ''; $fragment = str_replace( "%{$matches[1]}$", '%', $fragment ); } else { @@ -4998,10 +5001,11 @@ function wp_sprintf( $pattern, ...$args ) { } } - // Append to result and move to next fragment + // Append to result and move to next fragment. $result .= $fragment; $start = $end; } + return $result; } @@ -5019,12 +5023,12 @@ function wp_sprintf( $pattern, ...$args ) { * @return string Localized list items and rest of the content. */ function wp_sprintf_l( $pattern, $args ) { - // Not a match + // Not a match. if ( substr( $pattern, 0, 2 ) != '%l' ) { return $pattern; } - // Nothing to work with + // Nothing to work with. if ( empty( $args ) ) { return ''; } @@ -5057,7 +5061,8 @@ function wp_sprintf_l( $pattern, $args ) { if ( count( $args ) == 1 ) { $result .= $l['between_only_two'] . array_shift( $args ); } - // Loop when more than two args + + // Loop when more than two args. $i = count( $args ); while ( $i ) { $arg = array_shift( $args ); @@ -5068,6 +5073,7 @@ function wp_sprintf_l( $pattern, $args ) { $result .= $l['between'] . $arg; } } + return $result . substr( $pattern, 2 ); } @@ -5089,13 +5095,16 @@ function wp_html_excerpt( $str, $count, $more = null ) { if ( null === $more ) { $more = ''; } + $str = wp_strip_all_tags( $str, true ); $excerpt = mb_substr( $str, 0, $count ); - // remove part of an entity at the end + + // Remove part of an entity at the end. $excerpt = preg_replace( '/&[^;\s]{0,6}$/', '', $excerpt ); if ( $str != $excerpt ) { $excerpt = trim( $excerpt ) . $more; } + return $excerpt; } @@ -5134,7 +5143,7 @@ function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) */ function _links_add_base( $m ) { global $_links_add_base; - //1 = attribute name 2 = quotation mark 3 = URL + // 1 = attribute name 2 = quotation mark 3 = URL. return $m[1] . '=' . $m[2] . ( preg_match( '#^(\w{1,20}):#', $m[3], $protocol ) && in_array( $protocol[1], wp_allowed_protocols() ) ? $m[3] : @@ -5308,8 +5317,8 @@ function _sanitize_text_fields( $str, $keep_newlines = false ) { // This will strip extra whitespace for us. $filtered = wp_strip_all_tags( $filtered, false ); - // Use html entities in a special case to make sure no later - // newline stripping stage could lead to a functional tag + // Use HTML entities in a special case to make sure no later + // newline stripping stage could lead to a functional tag. $filtered = str_replace( "<\n", "<\n", $filtered ); } @@ -5359,12 +5368,12 @@ function wp_basename( $path, $suffix = '' ) { * @return string The modified text. */ function capital_P_dangit( $text ) { - // Simple replacement for titles + // Simple replacement for titles. $current_filter = current_filter(); if ( 'the_title' === $current_filter || 'wp_title' === $current_filter ) { return str_replace( 'Wordpress', 'WordPress', $text ); } - // Still here? Use the more judicious replacement + // Still here? Use the more judicious replacement. static $dblq = false; if ( false === $dblq ) { $dblq = _x( '“', 'opening curly double quote' ); @@ -5522,7 +5531,7 @@ function get_url_in_content( $content ) { * Returns the regexp for common whitespace characters. * * By default, spaces include new lines, tabs, nbsp entities, and the UTF-8 nbsp. - * This is designed to replace the PCRE \s sequence. In ticket #22692, that + * This is designed to replace the PCRE \s sequence. In ticket #22692, that * sequence was found to be unreliable due to random inclusion of the A0 byte. * * @since 4.0.0 @@ -5798,7 +5807,7 @@ function wp_staticize_emoji( $text ) { } } - // Did we exit ignore block. + // Did we exit ignore block? if ( '' != $ignore_block_element && '</' . $ignore_block_element . '>' == $content ) { $ignore_block_element = ''; } @@ -5806,7 +5815,7 @@ function wp_staticize_emoji( $text ) { $output .= $content; } - // Finally, remove any stray U+FE0F characters + // Finally, remove any stray U+FE0F characters. $output = str_replace( '️', '', $output ); return $output; diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 67a6cd6dc5..ee478b742d 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -323,7 +323,7 @@ function wp_date( $format, $timestamp = null, $timezone = null ) { function wp_maybe_decline_date( $date, $format = '' ) { global $wp_locale; - // i18n functions are not available in SHORTINIT mode + // i18n functions are not available in SHORTINIT mode. if ( ! function_exists( '_x' ) ) { return $date; } @@ -384,7 +384,7 @@ function wp_maybe_decline_date( $date, $format = '' ) { } } - // Used for locale-specific rules + // Used for locale-specific rules. $locale = get_locale(); if ( 'ca' === $locale ) { @@ -590,7 +590,7 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) { * @return mixed Unserialized data can be any type. */ function maybe_unserialize( $original ) { - if ( is_serialized( $original ) ) { // don't attempt to unserialize data that wasn't serialized going in + if ( is_serialized( $original ) ) { // Don't attempt to unserialize data that wasn't serialized going in. return @unserialize( $original ); } return $original; @@ -609,7 +609,7 @@ function maybe_unserialize( $original ) { * @return bool False if not serialized and true if it was. */ function is_serialized( $data, $strict = true ) { - // if it isn't a string, it isn't serialized. + // If it isn't a string, it isn't serialized. if ( ! is_string( $data ) ) { return false; } @@ -653,7 +653,7 @@ function is_serialized( $data, $strict = true ) { } elseif ( false === strpos( $data, '"' ) ) { return false; } - // or else fall through + // Or else fall through. case 'a': case 'O': return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); @@ -708,9 +708,11 @@ function maybe_serialize( $data ) { return serialize( $data ); } - // Double serialization is required for backward compatibility. - // See https://core.trac.wordpress.org/ticket/12930 - // Also the world will end. See WP 3.6.1. + /* + * Double serialization is required for backward compatibility. + * See https://core.trac.wordpress.org/ticket/12930 + * Also the world will end. See WP 3.6.1. + */ if ( is_serialized( $data, false ) ) { return serialize( $data ); } @@ -897,8 +899,7 @@ function do_enclose( $content = null, $post ) { $type = isset( $headers['content-type'] ) ? $headers['content-type'] : ''; $allowed_types = array( 'video', 'audio' ); - // Check to see if we can figure out the mime type from - // the extension + // Check to see if we can figure out the mime type from the extension. $url_parts = @parse_url( $url ); if ( false !== $url_parts ) { $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION ); @@ -1121,7 +1122,7 @@ function add_query_arg( ...$args ) { } wp_parse_str( $query, $qs ); - $qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string + $qs = urlencode_deep( $qs ); // This re-URL-encodes things that were already in the query string. if ( is_array( $args[0] ) ) { foreach ( $args[0] as $k => $v ) { $qs[ $k ] = $v; @@ -1154,7 +1155,7 @@ function add_query_arg( ...$args ) { * @return string New URL query string. */ function remove_query_arg( $key, $query = false ) { - if ( is_array( $key ) ) { // removing multiple keys + if ( is_array( $key ) ) { // Removing multiple keys. foreach ( $key as $k ) { $query = add_query_arg( $k, false, $query ); } @@ -1485,7 +1486,7 @@ function cache_javascript_headers() { $expiresOffset = 10 * DAY_IN_SECONDS; header( 'Content-Type: text/javascript; charset=' . get_bloginfo( 'charset' ) ); - header( 'Vary: Accept-Encoding' ); // Handle proxies + header( 'Vary: Accept-Encoding' ); // Handle proxies. header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiresOffset ) . ' GMT' ); } @@ -1703,7 +1704,7 @@ function is_blog_installed() { if ( ! wp_installing() ) { $alloptions = wp_load_alloptions(); } - // If siteurl is not set to autoload, check it specifically + // If siteurl is not set to autoload, check it specifically. if ( ! isset( $alloptions['siteurl'] ) ) { $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); } else { @@ -2078,18 +2079,20 @@ function path_join( $base, $path ) { */ function wp_normalize_path( $path ) { $wrapper = ''; + if ( wp_is_stream( $path ) ) { list( $wrapper, $path ) = explode( '://', $path, 2 ); - $wrapper .= '://'; + + $wrapper .= '://'; } - // Standardise all paths to use / + // Standardise all paths to use '/'. $path = str_replace( '\\', '/', $path ); // Replace multiple slashes down to a singular, allowing for network shares having two slashes. $path = preg_replace( '|(?<=.)/+|', '/', $path ); - // Windows paths should uppercase the drive letter + // Windows paths should uppercase the drive letter. if ( ':' === substr( $path, 1, 1 ) ) { $path = ucfirst( $path ); } @@ -2181,22 +2184,27 @@ function wp_is_writable( $path ) { * @return bool Whether the path is writable. */ function win_is_writable( $path ) { - - if ( $path[ strlen( $path ) - 1 ] == '/' ) { // if it looks like a directory, check a random file within the directory + if ( $path[ strlen( $path ) - 1 ] == '/' ) { + // If it looks like a directory, check a random file within the directory. return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' ); - } elseif ( is_dir( $path ) ) { // If it's a directory (and not a file) check a random file within the directory + } elseif ( is_dir( $path ) ) { + // If it's a directory (and not a file), check a random file within the directory. return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); } - // check tmp file for read/write capabilities + + // Check tmp file for read/write capabilities. $should_delete_tmp_file = ! file_exists( $path ); - $f = @fopen( $path, 'a' ); + + $f = @fopen( $path, 'a' ); if ( $f === false ) { return false; } fclose( $f ); + if ( $should_delete_tmp_file ) { unlink( $path ); } + return true; } @@ -2327,7 +2335,7 @@ function _wp_upload_dir( $time = null ) { if ( empty( $upload_path ) || 'wp-content/uploads' == $upload_path ) { $dir = WP_CONTENT_DIR . '/uploads'; } elseif ( 0 !== strpos( $upload_path, ABSPATH ) ) { - // $dir is absolute, $upload_path is (maybe) relative to ABSPATH + // $dir is absolute, $upload_path is (maybe) relative to ABSPATH. $dir = path_join( ABSPATH, $upload_path ); } else { $dir = $upload_path; @@ -2351,7 +2359,7 @@ function _wp_upload_dir( $time = null ) { $url = trailingslashit( $siteurl ) . UPLOADS; } - // If multisite (and if not the main site in a post-MU network) + // If multisite (and if not the main site in a post-MU network). if ( is_multisite() && ! ( is_main_network() && is_main_site() && defined( 'MULTISITE' ) ) ) { if ( ! get_site_option( 'ms_files_rewriting' ) ) { @@ -2402,7 +2410,7 @@ function _wp_upload_dir( $time = null ) { $subdir = ''; if ( get_option( 'uploads_use_yearmonth_folders' ) ) { - // Generate the yearly and monthly dirs + // Generate the yearly and monthly directories. if ( ! $time ) { $time = current_time( 'mysql' ); } @@ -2524,7 +2532,7 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) $new_ext = ! empty( $ext2 ) ? $ext2 : $ext; // Ensure this never goes into infinite loop - // as it uses pathinfo() and regex in the check but string replacement for the changes. + // as it uses pathinfo() and regex in the check, but string replacement for the changes. $count = count( $files ); $i = 0; @@ -2565,7 +2573,7 @@ function _wp_check_existing_file_names( $filename, $files ) { $fname = pathinfo( $filename, PATHINFO_FILENAME ); $ext = pathinfo( $filename, PATHINFO_EXTENSION ); - // Edge case, file names like `.ext` + // Edge case, file names like `.ext`. if ( empty( $fname ) ) { return false; } @@ -2681,14 +2689,14 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { fclose( $ifp ); clearstatcache(); - // Set correct file permissions + // Set correct file permissions. $stat = @ stat( dirname( $new_file ) ); $perms = $stat['mode'] & 0007777; $perms = $perms & 0000666; chmod( $new_file, $perms ); clearstatcache(); - // Compute the URL + // Compute the URL. $url = $upload['url'] . "/$filename"; /** This filter is documented in wp-admin/includes/file.php */ @@ -2785,12 +2793,12 @@ function wp_check_filetype( $filename, $mimes = null ) { function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { $proper_filename = false; - // Do basic extension validation and MIME mapping + // Do basic extension validation and MIME mapping. $wp_filetype = wp_check_filetype( $filename, $mimes ); $ext = $wp_filetype['ext']; $type = $wp_filetype['type']; - // We can't do any further validation without a file to work with + // We can't do any further validation without a file to work with. if ( ! file_exists( $file ) ) { return compact( 'ext', 'type', 'proper_filename' ); } @@ -2800,7 +2808,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { // Validate image types. if ( $type && 0 === strpos( $type, 'image/' ) ) { - // Attempt to figure out what type of image it actually is + // Attempt to figure out what type of image it actually is. $real_mime = wp_get_image_mime( $file ); if ( $real_mime && $real_mime != $type ) { @@ -2822,7 +2830,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { ) ); - // Replace whatever is after the last period in the filename with the correct extension + // Replace whatever is after the last period in the filename with the correct extension. if ( ! empty( $mime_to_ext[ $real_mime ] ) ) { $filename_parts = explode( '.', $filename ); array_pop( $filename_parts ); @@ -2830,9 +2838,9 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { $new_filename = implode( '.', $filename_parts ); if ( $new_filename != $filename ) { - $proper_filename = $new_filename; // Mark that it changed + $proper_filename = $new_filename; // Mark that it changed. } - // Redefine the extension / MIME + // Redefine the extension / MIME. $wp_filetype = wp_check_filetype( $new_filename, $mimes ); $ext = $wp_filetype['ext']; $type = $wp_filetype['type']; @@ -2849,7 +2857,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { $real_mime = finfo_file( $finfo, $file ); finfo_close( $finfo ); - // fileinfo often misidentifies obscure files as one of these types + // fileinfo often misidentifies obscure files as one of these types. $nonspecific_types = array( 'application/octet-stream', 'application/encrypted', @@ -2920,7 +2928,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { } } - // The mime type must be allowed + // The mime type must be allowed. if ( $type ) { $allowed = get_allowed_mime_types(); @@ -3031,8 +3039,8 @@ function wp_get_mime_types() { 'ogv' => 'video/ogg', 'webm' => 'video/webm', 'mkv' => 'video/x-matroska', - '3gp|3gpp' => 'video/3gpp', // Can also be audio - '3g2|3gp2' => 'video/3gpp2', // Can also be audio + '3gp|3gpp' => 'video/3gpp', // Can also be audio. + '3g2|3gp2' => 'video/3gpp2', // Can also be audio. // Text formats. 'txt|asc|c|cc|h|srt' => 'text/plain', 'csv' => 'text/csv', @@ -3982,7 +3990,7 @@ function _wp_json_convert_string( $string ) { * This supports the JsonSerializable interface for PHP 5.2-5.3 as well. * * @ignore - * @since 4.4.0 + * @since 4.4.0 * @deprecated 5.3.0 This function is no longer needed as support for PHP 5.2-5.3 * has been dropped. * @access private @@ -4222,7 +4230,7 @@ function _mce_set_direction( $mce_init ) { function smilies_init() { global $wpsmiliestrans, $wp_smiliessearch; - // don't bother setting up smilies if they are disabled + // Don't bother setting up smilies if they are disabled. if ( ! get_option( 'use_smilies' ) ) { return; } @@ -4302,7 +4310,7 @@ function smilies_init() { $spaces = wp_spaces_regexp(); - // Begin first "subpattern" + // Begin first "subpattern". $wp_smiliessearch = '/(?<=' . $spaces . '|^)'; $subchar = ''; @@ -4310,11 +4318,11 @@ function smilies_init() { $firstchar = substr( $smiley, 0, 1 ); $rest = substr( $smiley, 1 ); - // new subpattern? + // New subpattern? if ( $firstchar != $subchar ) { if ( $subchar != '' ) { - $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern" - $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern" + $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern". + $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern". } $subchar = $firstchar; $wp_smiliessearch .= preg_quote( $firstchar, '/' ) . '(?:'; @@ -5348,32 +5356,32 @@ function wp_guess_url() { $abspath_fix = str_replace( '\\', '/', ABSPATH ); $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] ); - // The request is for the admin + // The request is for the admin. if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) { $path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] ); - // The request is for a file in ABSPATH + // The request is for a file in ABSPATH. } elseif ( $script_filename_dir . '/' == $abspath_fix ) { - // Strip off any file/query params in the path + // Strip off any file/query params in the path. $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] ); } else { if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], $abspath_fix ) ) { - // Request is hitting a file inside ABSPATH + // Request is hitting a file inside ABSPATH. $directory = str_replace( ABSPATH, '', $script_filename_dir ); - // Strip off the sub directory, and any file/query params + // Strip off the subdirectory, and any file/query params. $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ); } elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) { - // Request is hitting a file above ABSPATH + // Request is hitting a file above ABSPATH. $subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) ); - // Strip off any file/query params from the path, appending the sub directory to the installation + // Strip off any file/query params from the path, appending the subdirectory to the installation. $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ) . $subdirectory; } else { $path = $_SERVER['REQUEST_URI']; } } - $schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet + $schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet. $url = $schema . $_SERVER['HTTP_HOST'] . $path; } @@ -5641,9 +5649,9 @@ function wp_timezone_override_offset() { * @return int */ function _wp_timezone_choice_usort_callback( $a, $b ) { - // Don't use translated versions of Etc + // Don't use translated versions of Etc. if ( 'Etc' === $a['continent'] && 'Etc' === $b['continent'] ) { - // Make the order of these more like the old dropdown + // Make the order of these more like the old dropdown. if ( 'GMT+' === substr( $a['city'], 0, 4 ) && 'GMT+' === substr( $b['city'], 0, 4 ) ) { return -1 * ( strnatcasecmp( $a['city'], $b['city'] ) ); } @@ -5667,7 +5675,7 @@ function _wp_timezone_choice_usort_callback( $a, $b ) { } return strnatcasecmp( $a['t_city'], $b['t_city'] ); } else { - // Force Etc to the bottom of the list + // Force Etc to the bottom of the list. if ( 'Etc' === $a['continent'] ) { return 1; } @@ -5712,7 +5720,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) { continue; } - // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later + // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later. $exists = array( 0 => ( isset( $zone[0] ) && $zone[0] ), 1 => ( isset( $zone[1] ) && $zone[1] ), @@ -5742,33 +5750,33 @@ function wp_timezone_choice( $selected_zone, $locale = null ) { } foreach ( $zonen as $key => $zone ) { - // Build value in an array to join later + // Build value in an array to join later. $value = array( $zone['continent'] ); if ( empty( $zone['city'] ) ) { - // It's at the continent level (generally won't happen) + // It's at the continent level (generally won't happen). $display = $zone['t_continent']; } else { - // It's inside a continent group + // It's inside a continent group. - // Continent optgroup + // Continent optgroup. if ( ! isset( $zonen[ $key - 1 ] ) || $zonen[ $key - 1 ]['continent'] !== $zone['continent'] ) { $label = $zone['t_continent']; $structure[] = '<optgroup label="' . esc_attr( $label ) . '">'; } - // Add the city to the value + // Add the city to the value. $value[] = $zone['city']; $display = $zone['t_city']; if ( ! empty( $zone['subcity'] ) ) { - // Add the subcity to the value + // Add the subcity to the value. $value[] = $zone['subcity']; $display .= ' - ' . $zone['t_subcity']; } } - // Build the value + // Build the value. $value = join( '/', $value ); $selected = ''; if ( $value === $selected_zone ) { @@ -5776,13 +5784,13 @@ function wp_timezone_choice( $selected_zone, $locale = null ) { } $structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . '</option>'; - // Close continent optgroup + // Close continent optgroup. if ( ! empty( $zone['city'] ) && ( ! isset( $zonen[ $key + 1 ] ) || ( isset( $zonen[ $key + 1 ] ) && $zonen[ $key + 1 ]['continent'] !== $zone['continent'] ) ) ) { $structure[] = '</optgroup>'; } } - // Do UTC + // Do UTC. $structure[] = '<optgroup label="' . esc_attr__( 'UTC' ) . '">'; $selected = ''; if ( 'UTC' === $selected_zone ) { @@ -5791,7 +5799,7 @@ function wp_timezone_choice( $selected_zone, $locale = null ) { $structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __( 'UTC' ) . '</option>'; $structure[] = '</optgroup>'; - // Do manual UTC offsets + // Do manual UTC offsets. $structure[] = '<optgroup label="' . esc_attr__( 'Manual Offsets' ) . '">'; $offset_range = array( -12, @@ -5985,7 +5993,7 @@ function get_file_data( $file, $default_headers, $context = '' ) { */ $extra_headers = $context ? apply_filters( "extra_{$context}_headers", array() ) : array(); if ( $extra_headers ) { - $extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values + $extra_headers = array_combine( $extra_headers, $extra_headers ); // Keys equal values. $all_headers = array_merge( $extra_headers, (array) $default_headers ); } else { $all_headers = $default_headers; @@ -6174,8 +6182,8 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar $evanescent_hare = $start; $return = array(); - // Set evanescent_hare to one past hare - // Increment hare two steps + // Set evanescent_hare to one past hare. + // Increment hare two steps. while ( $tortoise && @@ -6189,12 +6197,12 @@ function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = ar $return[ $hare ] = true; } - // tortoise got lapped - must be a loop + // Tortoise got lapped - must be a loop. if ( $tortoise == $evanescent_hare || $tortoise == $hare ) { return $_return_loop ? $return : $tortoise; } - // Increment tortoise by one step + // Increment tortoise by one step. $tortoise = isset( $override[ $tortoise ] ) ? $override[ $tortoise ] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); } @@ -6277,7 +6285,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr $trace = debug_backtrace( false ); $caller = array(); $check_class = ! is_null( $ignore_class ); - $skip_frames++; // skip this function + $skip_frames++; // Skip this function. if ( ! isset( $truncate_paths ) ) { $truncate_paths = array( @@ -6291,7 +6299,7 @@ function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pr $skip_frames--; } elseif ( isset( $call['class'] ) ) { if ( $check_class && $ignore_class == $call['class'] ) { - continue; // Filter out calls + continue; // Filter out calls. } $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; @@ -6371,7 +6379,7 @@ function wp_is_stream( $path ) { $scheme_separator = strpos( $path, '://' ); if ( false === $scheme_separator ) { - // $path isn't a stream + // $path isn't a stream. return false; } @@ -6722,7 +6730,7 @@ function wp_post_preview_js() { return; } - // Has to match the window name used in post_submit_meta_box() + // Has to match the window name used in post_submit_meta_box(). $name = 'wp-preview-' . (int) $post->ID; ?> @@ -7012,7 +7020,7 @@ All at ###SITENAME### 'headers' => '', ); - // get site name + // Get site name. $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); /** @@ -7459,7 +7467,7 @@ function get_dirsize( $directory, $max_execution_time = null ) { $dirsize = array(); } - // Exclude individual site directories from the total when checking the main site of a network + // Exclude individual site directories from the total when checking the main site of a network, // as they are subdirectories and should not be counted. if ( is_multisite() && is_main_site() ) { $dirsize[ $directory ]['size'] = recurse_dirsize( $directory, $directory . '/sites', $max_execution_time ); diff --git a/src/wp-includes/functions.wp-scripts.php b/src/wp-includes/functions.wp-scripts.php index f7f88de2ae..3eefe4f903 100644 --- a/src/wp-includes/functions.wp-scripts.php +++ b/src/wp-includes/functions.wp-scripts.php @@ -74,7 +74,7 @@ function wp_print_scripts( $handles = false ) { * @since 2.1.0 */ do_action( 'wp_print_scripts' ); - if ( '' === $handles ) { // for wp_head + if ( '' === $handles ) { // For 'wp_head'. $handles = false; } diff --git a/src/wp-includes/functions.wp-styles.php b/src/wp-includes/functions.wp-styles.php index 49c947c420..e636a302ec 100644 --- a/src/wp-includes/functions.wp-styles.php +++ b/src/wp-includes/functions.wp-styles.php @@ -40,7 +40,7 @@ function wp_styles() { * @return string[] On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array. */ function wp_print_styles( $handles = false ) { - if ( '' === $handles ) { // for wp_head + if ( '' === $handles ) { // For 'wp_head'. $handles = false; } diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 85aacb44ff..344d9276fb 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -703,8 +703,8 @@ function bloginfo( $show = '' ) { */ function get_bloginfo( $show = '', $filter = 'raw' ) { switch ( $show ) { - case 'home': // DEPRECATED - case 'siteurl': // DEPRECATED + case 'home': // Deprecated. + case 'siteurl': // Deprecated. _deprecated_argument( __FUNCTION__, '2.2.0', @@ -1071,8 +1071,8 @@ function wp_get_document_title() { $title['title'] = single_term_title( '', false ); /* - * If we're on the blog page that is not the homepage or - * a single post of any post type, use the post title. + * If we're on the blog page that is not the homepage + * or a single post of any post type, use the post title. */ } elseif ( is_home() || is_singular() ) { $title['title'] = single_post_title( '', false ); @@ -1195,14 +1195,14 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { $search = get_query_var( 's' ); $title = ''; - $t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary + $t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary. - // If there is a post + // If there is a post. if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) { $title = single_post_title( '', false ); } - // If there's a post type archive + // If there's a post type archive. if ( is_post_type_archive() ) { $post_type = get_query_var( 'post_type' ); if ( is_array( $post_type ) ) { @@ -1214,12 +1214,12 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { } } - // If there's a category or tag + // If there's a category or tag. if ( is_category() || is_tag() ) { $title = single_term_title( '', false ); } - // If there's a taxonomy + // If there's a taxonomy. if ( is_tax() ) { $term = get_queried_object(); if ( $term ) { @@ -1228,7 +1228,7 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { } } - // If there's an author + // If there's an author. if ( is_author() && ! is_post_type_archive() ) { $author = get_queried_object(); if ( $author ) { @@ -1241,7 +1241,7 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { $title = post_type_archive_title( '', false ); } - // If there's a month + // If there's a month. if ( is_archive() && ! empty( $m ) ) { $my_year = substr( $m, 0, 4 ); $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) ); @@ -1249,7 +1249,7 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' ); } - // If there's a year + // If there's a year. if ( is_archive() && ! empty( $year ) ) { $title = $year; if ( ! empty( $monthnum ) ) { @@ -1260,13 +1260,13 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { } } - // If it's a search + // If it's a search. if ( is_search() ) { /* translators: 1: Separator, 2: Search query. */ $title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) ); } - // If it's a 404 page + // If it's a 404 page. if ( is_404() ) { $title = __( 'Page not found' ); } @@ -1285,8 +1285,8 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { */ $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) ); - // Determines position of the separator and direction of the breadcrumb - if ( 'right' == $seplocation ) { // sep on right, so reverse the order + // Determines position of the separator and direction of the breadcrumb. + if ( 'right' == $seplocation ) { // Separator on right, so reverse the order. $title_array = array_reverse( $title_array ); $title = implode( " $sep ", $title_array ) . $prefix; } else { @@ -1304,7 +1304,7 @@ function wp_title( $sep = '»', $display = true, $seplocation = '' ) { */ $title = apply_filters( 'wp_title', $title, $sep, $seplocation ); - // Send it out + // Send it out. if ( $display ) { echo $title; } else { @@ -1747,7 +1747,7 @@ function get_archives_link( $url, $text, $format = 'html', $before = '', $after $link_html = "\t<option value='$url'$selected_attr>$before $text $after</option>\n"; } elseif ( 'html' === $format ) { $link_html = "\t<li>$before<a href='$url'$aria_current>$text</a>$after</li>\n"; - } else { // custom + } else { // Custom. $link_html = "\t$before<a href='$url'$aria_current>$text</a>$after\n"; } @@ -1850,7 +1850,7 @@ function wp_get_archives( $args = '' ) { $order = 'DESC'; } - // this is what will separate dates on weekly archive links + // This is what will separate dates on weekly archive links. $archive_week_separator = '–'; $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $parsed_args['post_type'] ); @@ -2095,17 +2095,17 @@ function get_calendar( $initial = true, $echo = true ) { if ( isset( $_GET['w'] ) ) { $w = (int) $_GET['w']; } - // week_begins = 0 stands for Sunday + // week_begins = 0 stands for Sunday. $week_begins = (int) get_option( 'start_of_week' ); - // Let's figure out when we are + // Let's figure out when we are. if ( ! empty( $monthnum ) && ! empty( $year ) ) { $thismonth = zeroise( intval( $monthnum ), 2 ); $thisyear = (int) $year; } elseif ( ! empty( $w ) ) { - // We need to get the month from MySQL + // We need to get the month from MySQL. $thisyear = (int) substr( $m, 0, 4 ); - //it seems MySQL's weeks disagree with PHP's + // It seems MySQL's weeks disagree with PHP's. $d = ( ( $w - 1 ) * 7 ) + 6; $thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" ); } elseif ( ! empty( $m ) ) { @@ -2123,7 +2123,7 @@ function get_calendar( $initial = true, $echo = true ) { $unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear ); $last_day = gmdate( 't', $unixmonth ); - // Get the next and previous month and year with at least one post + // Get the next and previous month and year with at least one post. $previous = $wpdb->get_row( "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year FROM $wpdb->posts @@ -2198,7 +2198,7 @@ function get_calendar( $initial = true, $echo = true ) { $daywithpost = array(); - // Get days with posts + // Get days with posts. $dayswithposts = $wpdb->get_results( "SELECT DISTINCT DAYOFMONTH(post_date) FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' @@ -2212,7 +2212,7 @@ function get_calendar( $initial = true, $echo = true ) { } } - // See how much we should pad in the beginning + // See how much we should pad in the beginning. $pad = calendar_week_mod( gmdate( 'w', $unixmonth ) - $week_begins ); if ( 0 != $pad ) { $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad"> </td>'; @@ -2236,7 +2236,7 @@ function get_calendar( $initial = true, $echo = true ) { } if ( in_array( $day, $daywithpost ) ) { - // any posts today? + // Any posts today? $date_format = gmdate( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) ); /* translators: Post calendar label. %s: Date. */ $label = sprintf( __( 'Posts published on %s' ), $date_format ); @@ -3339,7 +3339,7 @@ function user_can_richedit() { if ( ! isset( $wp_rich_edit ) ) { $wp_rich_edit = false; - if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users + if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // Default to 'true' for logged out users. if ( $is_safari ) { $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 ); } elseif ( $is_IE ) { @@ -3371,8 +3371,8 @@ function user_can_richedit() { * @return string Either 'tinymce', or 'html', or 'test' */ function wp_default_editor() { - $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults - if ( wp_get_current_user() ) { // look for cookie + $r = user_can_richedit() ? 'tinymce' : 'html'; // Defaults. + if ( wp_get_current_user() ) { // Look for cookie. $ed = get_user_setting( 'editor', 'tinymce' ); $r = ( in_array( $ed, array( 'tinymce', 'html', 'test' ) ) ) ? $ed : $r; } @@ -4094,8 +4094,8 @@ function paginate_links( $args = '' ) { $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%'; $defaults = array( - 'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below) - 'format' => $format, // ?page=%#% : %#% is replaced by the page number + 'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below). + 'format' => $format, // ?page=%#% : %#% is replaced by the page number. 'total' => $total, 'current' => $current, 'aria_current' => 'page', @@ -4106,7 +4106,7 @@ function paginate_links( $args = '' ) { 'end_size' => 1, 'mid_size' => 2, 'type' => 'plain', - 'add_args' => array(), // array of query args to add + 'add_args' => array(), // Array of query args to add. 'add_fragment' => '', 'before_page_number' => '', 'after_page_number' => '', @@ -4136,13 +4136,13 @@ function paginate_links( $args = '' ) { $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) ); } - // Who knows what else people pass in $args + // Who knows what else people pass in $args. $total = (int) $args['total']; if ( $total < 2 ) { return; } $current = (int) $args['current']; - $end_size = (int) $args['end_size']; // Out of bounds? Make it the default. + $end_size = (int) $args['end_size']; // Out of bounds? Make it the default. if ( $end_size < 1 ) { $end_size = 1; } @@ -4313,7 +4313,7 @@ function register_admin_color_schemes() { ) ); - // Other color schemes are not available when running out of src + // Other color schemes are not available when running out of src. if ( false !== strpos( get_bloginfo( 'version' ), '-src' ) ) { return; } diff --git a/src/wp-includes/http.php b/src/wp-includes/http.php index 0e6a357927..0a91418e45 100644 --- a/src/wp-includes/http.php +++ b/src/wp-includes/http.php @@ -368,7 +368,7 @@ function wp_http_supports( $capabilities = array(), $url = null ) { $count = count( $capabilities ); - // If we have a numeric $capabilities array, spoof a wp_remote_request() associative $args array + // If we have a numeric $capabilities array, spoof a wp_remote_request() associative $args array. if ( $count && count( array_filter( array_keys( $capabilities ), 'is_numeric' ) ) == $count ) { $capabilities = array_combine( array_values( $capabilities ), array_fill( 0, $count, true ) ); } @@ -417,7 +417,7 @@ function get_allowed_http_origins() { $admin_origin = parse_url( admin_url() ); $home_origin = parse_url( home_url() ); - // @todo preserve port? + // @todo Preserve port? $allowed_origins = array_unique( array( 'http://' . $admin_origin['host'], @@ -549,7 +549,7 @@ function wp_http_validate_url( $url ) { $ip = $host; } else { $ip = gethostbyname( $host ); - if ( $ip === $host ) { // Error condition for gethostbyname() + if ( $ip === $host ) { // Error condition for gethostbyname(). return false; } } diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index 179aaebd5b..32a5a04f2a 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -1052,9 +1052,9 @@ function wp_kses_split2( $string, $allowed_html, $allowed_protocols ) { if ( $string == '' ) { return ''; } - // prevent multiple dashes in comments + // Prevent multiple dashes in comments. $string = preg_replace( '/--+/', '-', $string ); - // prevent three dashes closing a comment + // Prevent three dashes closing a comment. $string = preg_replace( '/-$/', '', $string ); return "<!--{$string}-->"; } @@ -1119,11 +1119,11 @@ function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) { return "<$element$xhtml_slash>"; } - // Split it + // Split it. $attrarr = wp_kses_hair( $attr, $allowed_protocols ); // Go through $attrarr, and save the allowed attributes for this element - // in $attr2 + // in $attr2. $attr2 = ''; foreach ( $attrarr as $arreach ) { if ( wp_kses_attr_check( $arreach['name'], $arreach['value'], $arreach['whole'], $arreach['vless'], $element, $allowed_html ) ) { @@ -1131,7 +1131,7 @@ function wp_kses_attr( $element, $attr, $allowed_html, $allowed_protocols ) { } } - // Remove any "<" or ">" characters + // Remove any "<" or ">" characters. $attr2 = preg_replace( '/[<>]/', '', $attr2 ); return "<$element$attr2$xhtml_slash>"; @@ -1204,7 +1204,7 @@ function wp_kses_attr_check( &$name, &$value, &$whole, $vless, $element, $allowe } if ( is_array( $allowed_attr[ $name_low ] ) ) { - // there are some checks + // There are some checks. foreach ( $allowed_attr[ $name_low ] as $currkey => $currval ) { if ( ! wp_kses_check_attr_val( $value, $vless, $currkey, $currval ) ) { $name = ''; @@ -1241,7 +1241,7 @@ function wp_kses_hair( $attr, $allowed_protocols ) { $attrname = ''; $uris = wp_kses_uri_attributes(); - // Loop through the whole attribute list + // Loop through the whole attribute list. while ( strlen( $attr ) != 0 ) { $working = 0; // Was the last operation successful? @@ -1258,14 +1258,14 @@ function wp_kses_hair( $attr, $allowed_protocols ) { break; case 1: - if ( preg_match( '/^\s*=\s*/', $attr ) ) { // equals sign + if ( preg_match( '/^\s*=\s*/', $attr ) ) { // Equals sign. $working = 1; $mode = 2; $attr = preg_replace( '/^\s*=\s*/', '', $attr ); break; } - if ( preg_match( '/^\s+/', $attr ) ) { // valueless + if ( preg_match( '/^\s+/', $attr ) ) { // Valueless. $working = 1; $mode = 0; if ( false === array_key_exists( $attrname, $attrarr ) ) { @@ -1346,17 +1346,17 @@ function wp_kses_hair( $attr, $allowed_protocols ) { } break; - } // switch + } // End switch. - if ( $working == 0 ) { // not well formed, remove and try again + if ( $working == 0 ) { // Not well-formed, remove and try again. $attr = wp_kses_html_error( $attr ); $mode = 0; } - } // while + } // End while. if ( $mode == 1 && false === array_key_exists( $attrname, $attrarr ) ) { - // special case, for when the attribute list ends with a valueless - // attribute like "selected" + // Special case, for when the attribute list ends with a valueless + // attribute like "selected". $attrarr[ $attrname ] = array( 'name' => $attrname, 'value' => '', @@ -1405,7 +1405,7 @@ function wp_kses_attr_parse( $element ) { $xhtml_slash = ''; } - // Split it + // Split it. $attrarr = wp_kses_hair_parse( $attr ); if ( false === $attrarr ) { return false; @@ -1444,14 +1444,14 @@ function wp_kses_hair_parse( $attr ) { . '\[\[?[^\[\]]+\]\]?' // Shortcode in the name position implies unfiltered_html. . ')' . '(?:' // Attribute value. - . '\s*=\s*' // All values begin with '=' + . '\s*=\s*' // All values begin with '='. . '(?:' - . '"[^"]*"' // Double-quoted + . '"[^"]*"' // Double-quoted. . '|' - . "'[^']*'" // Single-quoted + . "'[^']*'" // Single-quoted. . '|' - . '[^\s"\']+' // Non-quoted - . '(?:\s|$)' // Must have a space + . '[^\s"\']+' // Non-quoted. + . '(?:\s|$)' // Must have a space. . ')' . '|' . '(?:\s|$)' // If attribute has no value, space is required. @@ -1492,9 +1492,11 @@ function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) { switch ( strtolower( $checkname ) ) { case 'maxlen': - // The maxlen check makes sure that the attribute value has a length not - // greater than the given value. This can be used to avoid Buffer Overflows - // in WWW clients and various Internet servers. + /* + * The maxlen check makes sure that the attribute value has a length not + * greater than the given value. This can be used to avoid Buffer Overflows + * in WWW clients and various Internet servers. + */ if ( strlen( $value ) > $checkvalue ) { $ok = false; @@ -1502,8 +1504,10 @@ function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) { break; case 'minlen': - // The minlen check makes sure that the attribute value has a length not - // smaller than the given value. + /* + * The minlen check makes sure that the attribute value has a length not + * smaller than the given value. + */ if ( strlen( $value ) < $checkvalue ) { $ok = false; @@ -1511,11 +1515,13 @@ function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) { break; case 'maxval': - // The maxval check does two things: it checks that the attribute value is - // an integer from 0 and up, without an excessive amount of zeroes or - // whitespace (to avoid Buffer Overflows). It also checks that the attribute - // value is not greater than the given value. - // This check can be used to avoid Denial of Service attacks. + /* + * The maxval check does two things: it checks that the attribute value is + * an integer from 0 and up, without an excessive amount of zeroes or + * whitespace (to avoid Buffer Overflows). It also checks that the attribute + * value is not greater than the given value. + * This check can be used to avoid Denial of Service attacks. + */ if ( ! preg_match( '/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value ) ) { $ok = false; @@ -1526,8 +1532,10 @@ function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) { break; case 'minval': - // The minval check makes sure that the attribute value is a positive integer, - // and that it is not smaller than the given value. + /* + * The minval check makes sure that the attribute value is a positive integer, + * and that it is not smaller than the given value. + */ if ( ! preg_match( '/^\s{0,6}[0-9]{1,6}\s{0,6}$/', $value ) ) { $ok = false; @@ -1538,16 +1546,18 @@ function wp_kses_check_attr_val( $value, $vless, $checkname, $checkvalue ) { break; case 'valueless': - // The valueless check makes sure if the attribute has a value - // (like `<a href="blah">`) or not (`<option selected>`). If the given value - // is a "y" or a "Y", the attribute must not have a value. - // If the given value is an "n" or an "N", the attribute must have a value. + /* + * The valueless check makes sure if the attribute has a value + * (like `<a href="blah">`) or not (`<option selected>`). If the given value + * is a "y" or a "Y", the attribute must not have a value. + * If the given value is an "n" or an "N", the attribute must have a value. + */ if ( strtolower( $checkvalue ) != $vless ) { $ok = false; } break; - } // switch + } // End switch. return $ok; } @@ -1743,7 +1753,7 @@ function wp_kses_normalize_entities( $string ) { // Disarm all entities by converting & to & $string = str_replace( '&', '&', $string ); - // Change back the allowed entities in our entity whitelist + // Change back the allowed entities in our entity whitelist. $string = preg_replace_callback( '/&([A-Za-z]{2,8}[0-9]{0,2});/', 'wp_kses_named_entities', $string ); $string = preg_replace_callback( '/&#(0*[0-9]{1,7});/', 'wp_kses_normalize_entities2', $string ); $string = preg_replace_callback( '/&#[Xx](0*[0-9A-Fa-f]{1,6});/', 'wp_kses_normalize_entities3', $string ); @@ -1991,17 +2001,17 @@ function wp_filter_nohtml_kses( $data ) { * @since 2.0.0 */ function kses_init_filters() { - // Normal filtering + // Normal filtering. add_filter( 'title_save_pre', 'wp_filter_kses' ); - // Comment filtering + // Comment filtering. if ( current_user_can( 'unfiltered_html' ) ) { add_filter( 'pre_comment_content', 'wp_filter_post_kses' ); } else { add_filter( 'pre_comment_content', 'wp_filter_kses' ); } - // Post filtering + // Post filtering. add_filter( 'content_save_pre', 'wp_filter_post_kses' ); add_filter( 'excerpt_save_pre', 'wp_filter_post_kses' ); add_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ); @@ -2020,14 +2030,14 @@ function kses_init_filters() { * @since 2.0.6 */ function kses_remove_filters() { - // Normal filtering + // Normal filtering. remove_filter( 'title_save_pre', 'wp_filter_kses' ); - // Comment filtering + // Comment filtering. remove_filter( 'pre_comment_content', 'wp_filter_post_kses' ); remove_filter( 'pre_comment_content', 'wp_filter_kses' ); - // Post filtering + // Post filtering. remove_filter( 'content_save_pre', 'wp_filter_post_kses' ); remove_filter( 'excerpt_save_pre', 'wp_filter_post_kses' ); remove_filter( 'content_filtered_save_pre', 'wp_filter_post_kses' ); @@ -2061,7 +2071,7 @@ function kses_init() { */ function safecss_filter_attr( $css, $deprecated = '' ) { if ( ! empty( $deprecated ) ) { - _deprecated_argument( __FUNCTION__, '2.8.1' ); // Never implemented + _deprecated_argument( __FUNCTION__, '2.8.1' ); // Never implemented. } $css = wp_kses_no_null( $css ); diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index 0e7c07fef8..27dfd9ca5e 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -195,8 +195,8 @@ function get_permalink( $post = 0, $leavename = false ) { $category = get_category_parents( $category_object->parent, false, '/', true ) . $category; } } - // show default category in permalinks, without - // having to assign it explicitly + // Show default category in permalinks, + // without having to assign it explicitly. if ( empty( $category ) ) { $default_category = get_term( get_option( 'default_category' ), 'category' ); if ( $default_category && ! is_wp_error( $default_category ) ) { @@ -232,7 +232,7 @@ function get_permalink( $post = 0, $leavename = false ) { $permalink = home_url( str_replace( $rewritecode, $rewritereplace, $permalink ) ); $permalink = user_trailingslashit( $permalink, 'single' ); - } else { // if they're not using the fancy permalink option + } else { // If they're not using the fancy permalink option. $permalink = home_url( '?p=' . $post->ID ); } @@ -423,13 +423,13 @@ function get_attachment_link( $post = null, $leavename = false ) { if ( $wp_rewrite->using_permalinks() && $parent ) { if ( 'page' == $parent->post_type ) { - $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front + $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front. } else { $parentlink = get_permalink( $post->post_parent ); } if ( is_numeric( $post->post_name ) || false !== strpos( get_option( 'permalink_structure' ), '%category%' ) ) { - $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker + $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker. } else { $name = $post->post_name; } @@ -1087,7 +1087,7 @@ function edit_term_link( $link = '', $before = '', $after = '', $term = null, $e /** * Retrieves the permalink for a search. * - * @since 3.0.0 + * @since 3.0.0 * * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * @@ -1649,7 +1649,9 @@ function get_edit_user_link( $user_id = null ) { return apply_filters( 'get_edit_user_link', $link, $user->ID ); } -// Navigation links +// +// Navigation links. +// /** * Retrieves the previous post that is adjacent to the current post. @@ -2513,7 +2515,7 @@ function get_posts_nav_link( $args = array() ) { $max_num_pages = $wp_query->max_num_pages; $paged = get_query_var( 'paged' ); - //only have sep if there's both prev and next results + // Only have sep if there's both prev and next results. if ( $paged < 2 || $paged >= $max_num_pages ) { $args['sep'] = ''; } @@ -3881,7 +3883,7 @@ function wp_get_shortlink( $id = 0, $context = 'post', $allow_slugs = true ) { $shortlink = ''; - // Return p= link for all public post types. + // Return `?p=` link for all public post types. if ( ! empty( $post_id ) ) { $post_type = get_post_type_object( $post->post_type ); @@ -4091,7 +4093,7 @@ function get_avatar_data( $id_or_email, $args = null ) { 'force_default' => false, 'rating' => get_option( 'avatar_rating' ), 'scheme' => null, - 'processed_args' => null, // if used, should be a reference + 'processed_args' => null, // If used, should be a reference. 'extra_attr' => '', ) ); @@ -4177,17 +4179,17 @@ function get_avatar_data( $id_or_email, $args = null ) { $user = get_user_by( 'id', absint( $id_or_email ) ); } elseif ( is_string( $id_or_email ) ) { if ( strpos( $id_or_email, '@md5.gravatar.com' ) ) { - // md5 hash + // MD5 hash. list( $email_hash ) = explode( '@', $id_or_email ); } else { - // email address + // Email address. $email = $id_or_email; } } elseif ( $id_or_email instanceof WP_User ) { - // User Object + // User object. $user = $id_or_email; } elseif ( $id_or_email instanceof WP_Post ) { - // Post Object + // Post object. $user = get_user_by( 'id', (int) $id_or_email->post_author ); } elseif ( $id_or_email instanceof WP_Comment ) { if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) { diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 28de0aa4f5..9a24cfad4b 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -35,7 +35,7 @@ function wp_unregister_GLOBALS() { // phpcs:ignore WordPress.NamingConventions. die( 'GLOBALS overwrite attempt detected' ); } - // Variables that shouldn't be unset + // Variables that shouldn't be unset. $no_unset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' ); $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() ); @@ -65,22 +65,22 @@ function wp_fix_server_vars() { $_SERVER = array_merge( $default_server_values, $_SERVER ); - // Fix for IIS when running with PHP ISAPI + // Fix for IIS when running with PHP ISAPI. if ( empty( $_SERVER['REQUEST_URI'] ) || ( PHP_SAPI != 'cgi-fcgi' && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) { if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) { - // IIS Mod-Rewrite + // IIS Mod-Rewrite. $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL']; } elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) { - // IIS Isapi_Rewrite + // IIS Isapi_Rewrite. $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL']; } else { - // Use ORIG_PATH_INFO if there is no PATH_INFO + // Use ORIG_PATH_INFO if there is no PATH_INFO. if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) { $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO']; } - // Some IIS + PHP configurations puts the script-name in the path-info (No need to append it twice) + // Some IIS + PHP configurations put the script-name in the path-info (no need to append it twice). if ( isset( $_SERVER['PATH_INFO'] ) ) { if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) { $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO']; @@ -89,24 +89,24 @@ function wp_fix_server_vars() { } } - // Append the query string if it exists and isn't null + // Append the query string if it exists and isn't null. if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING']; } } } - // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests + // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests. if ( isset( $_SERVER['SCRIPT_FILENAME'] ) && ( strpos( $_SERVER['SCRIPT_FILENAME'], 'php.cgi' ) == strlen( $_SERVER['SCRIPT_FILENAME'] ) - 7 ) ) { $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED']; } - // Fix for Dreamhost and other PHP as CGI hosts + // Fix for Dreamhost and other PHP as CGI hosts. if ( strpos( $_SERVER['SCRIPT_NAME'], 'php.cgi' ) !== false ) { unset( $_SERVER['PATH_INFO'] ); } - // Fix empty PHP_SELF + // Fix empty PHP_SELF. $PHP_SELF = $_SERVER['PHP_SELF']; if ( empty( $PHP_SELF ) ) { $_SERVER['PHP_SELF'] = preg_replace( '/(\?.*)?$/', '', $_SERVER['REQUEST_URI'] ); @@ -471,7 +471,7 @@ function wp_set_wpdb_vars() { 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d', - // multisite: + // Multisite: 'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', @@ -549,7 +549,7 @@ function wp_start_object_cache() { wp_using_ext_object_cache( true ); } - // Re-initialize any hooks added manually by object-cache.php + // Re-initialize any hooks added manually by object-cache.php. if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); } @@ -666,7 +666,7 @@ function wp_get_active_and_valid_plugins() { $plugins = array(); $active_plugins = (array) get_option( 'active_plugins', array() ); - // Check for hacks file if the option is enabled + // Check for hacks file if the option is enabled. if ( get_option( 'hack_file' ) && file_exists( ABSPATH . 'my-hacks.php' ) ) { _deprecated_file( 'my-hacks.php', '1.5.0' ); array_unshift( $plugins, ABSPATH . 'my-hacks.php' ); @@ -679,10 +679,10 @@ function wp_get_active_and_valid_plugins() { $network_plugins = is_multisite() ? wp_get_active_network_plugins() : false; foreach ( $active_plugins as $plugin ) { - if ( ! validate_file( $plugin ) // $plugin must validate as file - && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' - && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist - // not already included as a network plugin + if ( ! validate_file( $plugin ) // $plugin must validate as file. + && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'. + && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist. + // Not already included as a network plugin. && ( ! $network_plugins || ! in_array( WP_PLUGIN_DIR . '/' . $plugin, $network_plugins ) ) ) { $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; @@ -960,7 +960,7 @@ function shutdown_action_hook() { * @return object The cloned object. */ function wp_clone( $object ) { - // Use parens for clone to accommodate PHP 4. See #17880 + // Use parens for clone to accommodate PHP 4. See #17880. return clone( $object ); } @@ -1149,16 +1149,16 @@ function wp_load_translations_early() { return; } - // We need $wp_local_package + // We need $wp_local_package. require ABSPATH . WPINC . '/version.php'; - // Translation and localization + // Translation and localization. require_once ABSPATH . WPINC . '/pomo/mo.php'; require_once ABSPATH . WPINC . '/l10n.php'; require_once ABSPATH . WPINC . '/class-wp-locale.php'; require_once ABSPATH . WPINC . '/class-wp-locale-switcher.php'; - // General libraries + // General libraries. require_once ABSPATH . WPINC . '/plugin.php'; $locales = array(); diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 1d7c79e526..1d599deb79 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -73,7 +73,7 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co } elseif ( $size === 'thumb' || $size === 'thumbnail' ) { $max_width = intval( get_option( 'thumbnail_size_w' ) ); $max_height = intval( get_option( 'thumbnail_size_h' ) ); - // last chance thumbnail size defaults + // Last chance thumbnail size defaults. if ( ! $max_width && ! $max_height ) { $max_width = 128; $max_height = 96; @@ -109,7 +109,7 @@ function image_constrain_size_for_editor( $width, $height, $size = 'medium', $co if ( intval( $content_width ) > 0 && 'edit' === $context ) { $max_width = min( intval( $content_width ), $max_width ); } - } else { // $size == 'full' has no constraint + } else { // $size === 'full' has no constraint. $max_width = $width; $max_height = $height; } @@ -230,7 +230,7 @@ function image_downsize( $id, $size = 'medium' ) { } } - // try for a new style intermediate size + // Try for a new style intermediate size. $intermediate = image_get_intermediate_size( $id, $size ); if ( $intermediate ) { @@ -239,7 +239,7 @@ function image_downsize( $id, $size = 'medium' ) { $height = $intermediate['height']; $is_intermediate = true; } elseif ( $size === 'thumbnail' ) { - // fall back to the old thumbnail + // Fall back to the old thumbnail. $thumb_file = wp_get_attachment_thumb_file( $id ); $info = null; @@ -256,13 +256,13 @@ function image_downsize( $id, $size = 'medium' ) { } if ( ! $width && ! $height && isset( $meta['width'], $meta['height'] ) ) { - // any other type: use the real image + // Any other type: use the real image. $width = $meta['width']; $height = $meta['height']; } if ( $img_url ) { - // we have the actual image size, but might need to further constrain it if content_width is narrower + // We have the actual image size, but might need to further constrain it if content_width is narrower. list( $width, $height ) = image_constrain_size_for_editor( $width, $height, $size ); return array( $img_url, $width, $height, $is_intermediate ); @@ -450,7 +450,7 @@ function wp_constrain_dimensions( $current_width, $current_height, $max_width = $did_height = true; } - // Calculate the larger/smaller ratios + // Calculate the larger/smaller ratios. $smaller_ratio = min( $width_ratio, $height_ratio ); $larger_ratio = max( $width_ratio, $height_ratio ); @@ -466,18 +466,22 @@ function wp_constrain_dimensions( $current_width, $current_height, $max_width = $w = max( 1, (int) round( $current_width * $ratio ) ); $h = max( 1, (int) round( $current_height * $ratio ) ); - // Sometimes, due to rounding, we'll end up with a result like this: 465x700 in a 177x177 box is 117x176... a pixel short - // We also have issues with recursive calls resulting in an ever-changing result. Constraining to the result of a constraint should yield the original result. - // Thus we look for dimensions that are one pixel shy of the max value and bump them up + /* + * Sometimes, due to rounding, we'll end up with a result like this: + * 465x700 in a 177x177 box is 117x176... a pixel short. + * We also have issues with recursive calls resulting in an ever-changing result. + * Constraining to the result of a constraint should yield the original result. + * Thus we look for dimensions that are one pixel shy of the max value and bump them up. + */ // Note: $did_width means it is possible $smaller_ratio == $width_ratio. if ( $did_width && $w === $max_width - 1 ) { - $w = $max_width; // Round it up + $w = $max_width; // Round it up. } // Note: $did_height means it is possible $smaller_ratio == $height_ratio. if ( $did_height && $h === $max_height - 1 ) { - $h = $max_height; // Round it up + $h = $max_height; // Round it up. } /** @@ -528,7 +532,7 @@ function image_resize_dimensions( $orig_w, $orig_h, $dest_w, $dest_h, $crop = fa if ( $orig_w <= 0 || $orig_h <= 0 ) { return false; } - // at least one of dest_w or dest_h must be specific + // At least one of $dest_w or $dest_h must be specific. if ( $dest_w <= 0 && $dest_h <= 0 ) { return false; } @@ -571,12 +575,14 @@ function image_resize_dimensions( $orig_w, $orig_h, $dest_w, $dest_h, $crop = fa } if ( $crop ) { - // Crop the largest possible portion of the original image that we can size to $dest_w x $dest_h. - // Note that the requested crop dimensions are used as a maximum bounding box for the original image. - // If the original image's width or height is less than the requested width or height - // only the greater one will be cropped. - // For example when the original image is 600x300, and the requested crop dimensions are 400x400, - // the resulting image will be 400x300. + /* + * Crop the largest possible portion of the original image that we can size to $dest_w x $dest_h. + * Note that the requested crop dimensions are used as a maximum bounding box for the original image. + * If the original image's width or height is less than the requested width or height + * only the greater one will be cropped. + * For example when the original image is 600x300, and the requested crop dimensions are 400x400, + * the resulting image will be 400x300. + */ $aspect_ratio = $orig_w / $orig_h; $new_w = min( $dest_w, $orig_w ); $new_h = min( $dest_h, $orig_h ); @@ -821,7 +827,7 @@ function image_get_intermediate_size( $post_id, $size = 'thumbnail' ) { return false; } - // include the full filesystem path of the intermediate file + // Include the full filesystem path of the intermediate file. if ( empty( $data['path'] ) && ! empty( $data['file'] ) && ! empty( $imagedata['file'] ) ) { $file_url = wp_get_attachment_url( $post_id ); $data['path'] = path_join( dirname( $imagedata['file'] ), $data['file'] ); @@ -944,7 +950,7 @@ function wp_get_registered_image_subsizes() { * @return array|false Returns an array (url, width, height, is_intermediate), or false if no image is available. */ function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) { - // get a thumbnail or intermediate image if there is one + // Get a thumbnail or intermediate image if there is one. $image = image_downsize( $attachment_id, $size ); if ( ! $image ) { $src = false; @@ -1089,7 +1095,7 @@ function _wp_get_attachment_relative_path( $file ) { } if ( false !== strpos( $dirname, 'wp-content/uploads' ) ) { - // Get the directory name relative to the upload directory (back compat for pre-2.7 uploads) + // Get the directory name relative to the upload directory (back compat for pre-2.7 uploads). $dirname = substr( $dirname, strpos( $dirname, 'wp-content/uploads' ) + 18 ); $dirname = ltrim( $dirname, '/' ); } @@ -1740,7 +1746,7 @@ function img_caption_shortcode( $attr, $content = null ) { $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); $html5 = current_theme_supports( 'html5', 'caption' ); - // HTML5 captions never added the extra 10px to the image width + // HTML5 captions never added the extra 10px to the image width. $width = $html5 ? $atts['width'] : ( 10 + $atts['width'] ); /** @@ -2261,7 +2267,7 @@ function wp_playlist_shortcode( $attr ) { return $output; } - $outer = 22; // default padding and border of wrapper + $outer = 22; // Default padding and border of wrapper. $default_width = 640; $default_height = 360; @@ -2271,7 +2277,7 @@ function wp_playlist_shortcode( $attr ) { $data = array( 'type' => $atts['type'], - // don't pass strings to JSON, will be truthy in JS + // Don't pass strings to JSON, will be truthy in JS. 'tracklist' => wp_validate_boolean( $atts['tracklist'] ), 'tracknumbers' => wp_validate_boolean( $atts['tracknumbers'] ), 'images' => wp_validate_boolean( $atts['images'] ), @@ -2601,7 +2607,7 @@ function wp_audio_shortcode( $attr, $content = '' ) { 'style' => $atts['style'], ); - // These ones should just be omitted altogether if they are blank + // These ones should just be omitted altogether if they are blank. foreach ( array( 'loop', 'autoplay', 'preload' ) as $a ) { if ( empty( $html_atts[ $a ] ) ) { unset( $html_atts[ $a ] ); @@ -2754,13 +2760,13 @@ function wp_video_shortcode( $attr, $content = '' ) { $atts = shortcode_atts( $defaults_atts, $attr, 'video' ); if ( is_admin() ) { - // shrink the video so it isn't huge in the admin + // Shrink the video so it isn't huge in the admin. if ( $atts['width'] > $defaults_atts['width'] ) { $atts['height'] = round( ( $atts['height'] * $defaults_atts['width'] ) / $atts['width'] ); $atts['width'] = $defaults_atts['width']; } } else { - // if the video is bigger than the theme + // If the video is bigger than the theme. if ( ! empty( $content_width ) && $atts['width'] > $content_width ) { $atts['height'] = round( ( $atts['height'] * $content_width ) / $atts['width'] ); $atts['width'] = $content_width; @@ -2831,8 +2837,8 @@ function wp_video_shortcode( $attr, $content = '' ) { wp_enqueue_script( 'mediaelement-vimeo' ); } - // Mediaelement has issues with some URL formats for Vimeo and YouTube, so - // update the URL to prevent the ME.js player from breaking. + // MediaElement.js has issues with some URL formats for Vimeo and YouTube, + // so update the URL to prevent the ME.js player from breaking. if ( 'mediaelement' === $library ) { if ( $is_youtube ) { // Remove `feature` query arg and force SSL - see #40866. @@ -2871,7 +2877,7 @@ function wp_video_shortcode( $attr, $content = '' ) { 'preload' => $atts['preload'], ); - // These ones should just be omitted altogether if they are blank + // These ones should just be omitted altogether if they are blank. foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a ) { if ( empty( $html_atts[ $a ] ) ) { unset( $html_atts[ $a ] ); @@ -3131,7 +3137,7 @@ function get_taxonomies_for_attachments( $output = 'names' ) { /** * Create new GD image resource with transparency support * - * @todo: Deprecate if possible. + * @todo Deprecate if possible. * * @since 2.9.0 * @@ -3325,7 +3331,7 @@ function wp_plupload_default_settings() { * and the `flash_swf_url` and `silverlight_xap_url` are not used. */ $defaults = array( - 'file_data_name' => 'async-upload', // key passed to $_FILE. + 'file_data_name' => 'async-upload', // Key passed to $_FILE. 'url' => admin_url( 'async-upload.php', 'relative' ), 'filters' => array( 'max_file_size' => $max_upload_size . 'b', @@ -3333,8 +3339,11 @@ function wp_plupload_default_settings() { ), ); - // Currently only iOS Safari supports multiple files uploading but iOS 7.x has a bug that prevents uploading of videos - // when enabled. See #29602. + /* + * Currently only iOS Safari supports multiple files uploading, + * but iOS 7.x has a bug that prevents uploading of videos when enabled. + * See #29602. + */ if ( wp_is_mobile() && strpos( $_SERVER['HTTP_USER_AGENT'], 'OS 7_' ) !== false && strpos( $_SERVER['HTTP_USER_AGENT'], 'like Mac OS X' ) !== false ) { @@ -3511,10 +3520,12 @@ function wp_prepare_attachment_for_js( $attachment ) { ); unset( $possible_sizes['full'] ); - // Loop through all potential sizes that may be chosen. Try to do this with some efficiency. - // First: run the image_downsize filter. If it returns something, we can use its data. - // If the filter does not return something, then image_downsize() is just an expensive - // way to check the image metadata, which we do second. + /* + * Loop through all potential sizes that may be chosen. Try to do this with some efficiency. + * First: run the image_downsize filter. If it returns something, we can use its data. + * If the filter does not return something, then image_downsize() is just an expensive way + * to check the image metadata, which we do second. + */ foreach ( $possible_sizes as $size => $label ) { /** This filter is documented in wp-includes/media.php */ @@ -3669,9 +3680,9 @@ function wp_enqueue_media( $args = array() ) { unset( $tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library'] ); $props = array( - 'link' => get_option( 'image_default_link_type' ), // db default is 'file' - 'align' => get_option( 'image_default_align' ), // empty default - 'size' => get_option( 'image_default_size' ), // empty default + 'link' => get_option( 'image_default_link_type' ), // DB default is 'file'. + 'align' => get_option( 'image_default_align' ), // Empty default. + 'size' => get_option( 'image_default_size' ), // Empty default. ); $exts = array_merge( wp_get_audio_extensions(), wp_get_video_extensions() ); @@ -3840,7 +3851,7 @@ function wp_enqueue_media( $args = array() ) { } $strings = array( - // Generic + // Generic. 'mediaFrameDefaultTitle' => __( 'Media' ), 'url' => __( 'URL' ), 'addMedia' => __( 'Add Media' ), @@ -3859,11 +3870,11 @@ function wp_enqueue_media( $args = array() ) { 'selected' => __( '%d selected' ), 'dragInfo' => __( 'Drag and drop to reorder media files.' ), - // Upload + // Upload. 'uploadFilesTitle' => __( 'Upload Files' ), 'uploadImagesTitle' => __( 'Upload Images' ), - // Library + // Library. 'mediaLibraryTitle' => __( 'Media Library' ), 'insertMediaTitle' => __( 'Add Media' ), 'createNewGallery' => __( 'Create a new gallery' ), @@ -3889,24 +3900,24 @@ function wp_enqueue_media( $args = array() ) { 'filterByDate' => __( 'Filter by date' ), 'filterByType' => __( 'Filter by type' ), 'searchLabel' => __( 'Search' ), - 'searchMediaLabel' => __( 'Search Media' ), // backwards compatibility pre-5.3 - 'searchMediaPlaceholder' => __( 'Search media items...' ), // placeholder (no ellipsis), backwards compatibility pre-5.3 + 'searchMediaLabel' => __( 'Search Media' ), // Backward compatibility pre-5.3. + 'searchMediaPlaceholder' => __( 'Search media items...' ), // Placeholder (no ellipsis), backward compatibility pre-5.3. 'mediaFound' => __( 'Number of media items found: %d' ), 'mediaFoundHasMoreResults' => __( 'Number of media items displayed: %d. Scroll the page for more results.' ), 'noMedia' => __( 'No media items found.' ), 'noMediaTryNewSearch' => __( 'No media items found. Try a different search.' ), - // Library Details + // Library Details. 'attachmentDetails' => __( 'Attachment Details' ), - // From URL + // From URL. 'insertFromUrlTitle' => __( 'Insert from URL' ), - // Featured Images + // Featured Images. 'setFeaturedImageTitle' => $post_type_object->labels->featured_image, 'setFeaturedImage' => $post_type_object->labels->set_featured_image, - // Gallery + // Gallery. 'createGalleryTitle' => __( 'Create Gallery' ), 'editGalleryTitle' => __( 'Edit Gallery' ), 'cancelGalleryTitle' => __( '← Cancel Gallery' ), @@ -3916,13 +3927,13 @@ function wp_enqueue_media( $args = array() ) { 'addToGalleryTitle' => __( 'Add to Gallery' ), 'reverseOrder' => __( 'Reverse order' ), - // Edit Image + // Edit Image. 'imageDetailsTitle' => __( 'Image Details' ), 'imageReplaceTitle' => __( 'Replace Image' ), 'imageDetailsCancel' => __( 'Cancel Edit' ), 'editImage' => __( 'Edit Image' ), - // Crop Image + // Crop Image. 'chooseImage' => __( 'Choose Image' ), 'selectAndCrop' => __( 'Select and Crop' ), 'skipCropping' => __( 'Skip Cropping' ), @@ -3933,13 +3944,13 @@ function wp_enqueue_media( $args = array() ) { 'suggestedDimensions' => __( 'Suggested image dimensions: %1$s by %2$s pixels.' ), 'cropError' => __( 'There has been an error cropping your image.' ), - // Edit Audio + // Edit Audio. 'audioDetailsTitle' => __( 'Audio Details' ), 'audioReplaceTitle' => __( 'Replace Audio' ), 'audioAddSourceTitle' => __( 'Add Audio Source' ), 'audioDetailsCancel' => __( 'Cancel Edit' ), - // Edit Video + // Edit Video. 'videoDetailsTitle' => __( 'Video Details' ), 'videoReplaceTitle' => __( 'Replace Video' ), 'videoAddSourceTitle' => __( 'Add Video Source' ), @@ -3947,7 +3958,7 @@ function wp_enqueue_media( $args = array() ) { 'videoSelectPosterImageTitle' => __( 'Select Poster Image' ), 'videoAddTrackTitle' => __( 'Add Subtitles' ), - // Playlist + // Playlist. 'playlistDragInfo' => __( 'Drag and drop to reorder tracks.' ), 'createPlaylistTitle' => __( 'Create Audio Playlist' ), 'editPlaylistTitle' => __( 'Edit Audio Playlist' ), @@ -3957,7 +3968,7 @@ function wp_enqueue_media( $args = array() ) { 'addToPlaylist' => __( 'Add to audio playlist' ), 'addToPlaylistTitle' => __( 'Add to Audio Playlist' ), - // Video Playlist + // Video Playlist. 'videoPlaylistDragInfo' => __( 'Drag and drop to reorder videos.' ), 'createVideoPlaylistTitle' => __( 'Create Video Playlist' ), 'editVideoPlaylistTitle' => __( 'Edit Video Playlist' ), @@ -3967,7 +3978,7 @@ function wp_enqueue_media( $args = array() ) { 'addToVideoPlaylist' => __( 'Add to video playlist' ), 'addToVideoPlaylistTitle' => __( 'Add to Video Playlist' ), - // Headings + // Headings. 'filterAttachments' => __( 'Filter Media' ), 'attachmentsList' => __( 'Media list' ), ); @@ -3994,8 +4005,8 @@ function wp_enqueue_media( $args = array() ) { $strings['settings'] = $settings; - // Ensure we enqueue media-editor first, that way media-views is - // registered internally before we try to localize it. see #24724. + // Ensure we enqueue media-editor first, that way media-views + // is registered internally before we try to localize it. See #24724. wp_enqueue_script( 'media-editor' ); wp_localize_script( 'media-views', '_wpMediaViewsL10n', $strings ); @@ -4285,7 +4296,7 @@ function attachment_url_to_postid( $url ) { $site_url = parse_url( $dir['url'] ); $image_path = parse_url( $path ); - //force the protocols to match if needed + // Force the protocols to match if needed. if ( isset( $image_path['scheme'] ) && ( $image_path['scheme'] !== $site_url['scheme'] ) ) { $path = str_replace( $image_path['scheme'], $site_url['scheme'], $path ); } @@ -4436,8 +4447,8 @@ function wp_media_personal_data_exporter( $email_address, $page = 1 ) { * @access private */ function _wp_add_additional_image_sizes() { - // 2x medium_large size + // 2x medium_large size. add_image_size( '1536x1536', 1536, 1536 ); - // 2x large size + // 2x large size. add_image_size( '2048x2048', 2048, 2048 ); } diff --git a/src/wp-includes/meta.php b/src/wp-includes/meta.php index c7627fb26e..0d4eabe1ad 100644 --- a/src/wp-includes/meta.php +++ b/src/wp-includes/meta.php @@ -718,7 +718,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = $meta_subtype = get_object_subtype( $meta_type, $object_id ); - // Sanitize the meta + // Sanitize the meta. $_meta_value = $meta_value; $meta_value = sanitize_meta( $meta_key, $meta_value, $meta_type, $meta_subtype ); $meta_value = maybe_serialize( $meta_value ); @@ -794,7 +794,7 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) { return false; } - // object and id columns + // Object and ID columns. $column = sanitize_key( $meta_type . '_id' ); $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; @@ -838,7 +838,7 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) { do_action( "delete_{$meta_type}meta", $meta_id ); } - // Run the query, will return true if deleted, false otherwise + // Run the query, will return true if deleted, false otherwise. $result = (bool) $wpdb->delete( $table, array( $id_column => $meta_id ) ); // Clear the caches. @@ -866,7 +866,7 @@ function delete_metadata_by_mid( $meta_type, $meta_id ) { } - // Meta id was not found. + // Meta ID was not found. return false; } @@ -935,7 +935,7 @@ function update_meta_cache( $meta_type, $object_ids ) { return $cache; } - // Get meta info + // Get meta info. $id_list = join( ',', $ids ); $id_column = 'user' == $meta_type ? 'umeta_id' : 'meta_id'; $meta_list = $wpdb->get_results( "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) ORDER BY $id_column ASC", ARRAY_A ); @@ -946,7 +946,7 @@ function update_meta_cache( $meta_type, $object_ids ) { $mkey = $metarow['meta_key']; $mval = $metarow['meta_value']; - // Force subkeys to be array type: + // Force subkeys to be array type. if ( ! isset( $cache[ $mpid ] ) || ! is_array( $cache[ $mpid ] ) ) { $cache[ $mpid ] = array(); } @@ -954,7 +954,7 @@ function update_meta_cache( $meta_type, $object_ids ) { $cache[ $mpid ][ $mkey ] = array(); } - // Add a value to the current pid/key: + // Add a value to the current pid/key. $cache[ $mpid ][ $mkey ][] = $mval; } } @@ -1160,7 +1160,7 @@ function register_meta( $object_type, $meta_key, $args, $deprecated = null ) { 'show_in_rest' => false, ); - // There used to be individual args for sanitize and auth callbacks + // There used to be individual args for sanitize and auth callbacks. $has_old_sanitize_cb = false; $has_old_auth_cb = false; @@ -1298,7 +1298,7 @@ function unregister_meta_key( $object_type, $meta_key, $object_subtype = '' ) { unset( $wp_meta_keys[ $object_type ][ $object_subtype ][ $meta_key ] ); - // Do some clean up + // Do some clean up. if ( empty( $wp_meta_keys[ $object_type ][ $object_subtype ] ) ) { unset( $wp_meta_keys[ $object_type ][ $object_subtype ] ); } diff --git a/src/wp-includes/ms-blogs.php b/src/wp-includes/ms-blogs.php index 25dbe4b29f..184953b4a8 100644 --- a/src/wp-includes/ms-blogs.php +++ b/src/wp-includes/ms-blogs.php @@ -581,7 +581,7 @@ function restore_current_blog() { if ( $new_blog_id == $prev_blog_id ) { /** This filter is documented in wp-includes/ms-blogs.php */ do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); - // If we still have items in the switched stack, consider ourselves still 'switched' + // If we still have items in the switched stack, consider ourselves still 'switched'. $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); return true; } @@ -616,7 +616,7 @@ function restore_current_blog() { /** This filter is documented in wp-includes/ms-blogs.php */ do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' ); - // If we still have items in the switched stack, consider ourselves still 'switched' + // If we still have items in the switched stack, consider ourselves still 'switched'. $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] ); return true; @@ -760,7 +760,7 @@ function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { global $wpdb; if ( ! empty( $deprecated ) ) { - _deprecated_argument( __FUNCTION__, 'MU' ); // never used + _deprecated_argument( __FUNCTION__, 'MU' ); // Never used. } return $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", get_current_network_id(), $start, $quantity ), ARRAY_A ); diff --git a/src/wp-includes/ms-default-constants.php b/src/wp-includes/ms-default-constants.php index 5caa0479bf..519d908b42 100644 --- a/src/wp-includes/ms-default-constants.php +++ b/src/wp-includes/ms-default-constants.php @@ -23,7 +23,7 @@ function ms_upload_constants() { return; } - // Base uploads dir relative to ABSPATH + // Base uploads dir relative to ABSPATH. if ( ! defined( 'UPLOADBLOGSDIR' ) ) { define( 'UPLOADBLOGSDIR', 'wp-content/blogs.dir' ); } @@ -35,7 +35,7 @@ function ms_upload_constants() { define( 'UPLOADS', UPLOADBLOGSDIR . '/' . $site_id . '/files/' ); - // Uploads dir relative to ABSPATH + // Uploads dir relative to ABSPATH. if ( 'wp-content/blogs.dir' == UPLOADBLOGSDIR && ! defined( 'BLOGUPLOADDIR' ) ) { define( 'BLOGUPLOADDIR', WP_CONTENT_DIR . '/blogs.dir/' . $site_id . '/files/' ); } diff --git a/src/wp-includes/ms-default-filters.php b/src/wp-includes/ms-default-filters.php index a9658398be..0f93d37610 100644 --- a/src/wp-includes/ms-default-filters.php +++ b/src/wp-includes/ms-default-filters.php @@ -15,12 +15,12 @@ add_action( 'init', 'ms_subdomain_constants' ); -// Functions +// Functions. add_action( 'update_option_blog_public', 'update_blog_public', 10, 2 ); add_filter( 'option_users_can_register', 'users_can_register_signup_filter' ); add_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' ); -// Users +// Users. add_filter( 'wpmu_validate_user_signup', 'signup_nonce_check' ); add_action( 'init', 'maybe_add_existing_user_to_blog' ); add_action( 'wpmu_new_user', 'newuser_notify_siteadmin' ); @@ -32,10 +32,10 @@ add_action( 'network_site_users_created_user', 'wp_send_new_user_notifications' add_action( 'network_user_new_created_user', 'wp_send_new_user_notifications' ); add_filter( 'sanitize_user', 'strtolower' ); -// Roles +// Roles. add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 ); -// Blogs +// Blogs. add_filter( 'wpmu_validate_blog_signup', 'signup_nonce_check' ); add_action( 'wpmu_activate_blog', 'wpmu_welcome_notification', 10, 5 ); add_action( 'after_signup_site', 'wpmu_signup_blog_notification', 10, 7 ); @@ -53,7 +53,7 @@ add_action( 'wp_initialize_site', 'newblog_notify_siteadmin', 100, 1 ); add_action( 'wp_uninitialize_site', 'wp_uninitialize_site', 10, 1 ); add_action( 'update_blog_public', 'wp_update_blog_public_option_on_site_update', 1, 2 ); -// Site meta +// Site meta. add_action( 'added_blog_meta', 'wp_cache_set_sites_last_changed' ); add_action( 'updated_blog_meta', 'wp_cache_set_sites_last_changed' ); add_action( 'deleted_blog_meta', 'wp_cache_set_sites_last_changed' ); @@ -66,21 +66,21 @@ add_filter( 'update_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter add_filter( 'delete_blog_metadata_by_mid', 'wp_check_site_meta_support_prefilter' ); add_filter( 'update_blog_metadata_cache', 'wp_check_site_meta_support_prefilter' ); -// Register Nonce +// Register nonce. add_action( 'signup_hidden_fields', 'signup_nonce_fields' ); -// Template +// Template. add_action( 'template_redirect', 'maybe_redirect_404' ); add_filter( 'allowed_redirect_hosts', 'redirect_this_site' ); -// Administration +// Administration. add_filter( 'term_id_filter', 'global_terms', 10, 2 ); add_action( 'delete_post', '_update_posts_count_on_delete' ); add_action( 'delete_post', '_update_blog_date_on_post_delete' ); add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 ); add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 ); -// Counts +// Counts. add_action( 'admin_init', 'wp_schedule_update_network_counts' ); add_action( 'update_network_counts', 'wp_update_network_counts', 10, 0 ); foreach ( array( 'user_register', 'deleted_user', 'wpmu_new_user', 'make_spam_user', 'make_ham_user' ) as $action ) { @@ -91,27 +91,27 @@ foreach ( array( 'make_spam_blog', 'make_ham_blog', 'archive_blog', 'unarchive_b } unset( $action ); -// Files +// Files. add_filter( 'wp_upload_bits', 'upload_is_file_too_big' ); add_filter( 'import_upload_size_limit', 'fix_import_form_size' ); add_filter( 'upload_mimes', 'check_upload_mimes' ); add_filter( 'upload_size_limit', 'upload_size_limit_filter' ); add_action( 'upload_ui_over_quota', 'multisite_over_quota_message' ); -// Mail +// Mail. add_action( 'phpmailer_init', 'fix_phpmailer_messageid' ); -// Disable somethings by default for multisite +// Disable somethings by default for multisite. add_filter( 'enable_update_services_configuration', '__return_false' ); -if ( ! defined( 'POST_BY_EMAIL' ) || ! POST_BY_EMAIL ) { // back compat constant. +if ( ! defined( 'POST_BY_EMAIL' ) || ! POST_BY_EMAIL ) { // Back compat constant. add_filter( 'enable_post_by_email_configuration', '__return_false' ); } -if ( ! defined( 'EDIT_ANY_USER' ) || ! EDIT_ANY_USER ) { // back compat constant. +if ( ! defined( 'EDIT_ANY_USER' ) || ! EDIT_ANY_USER ) { // Back compat constant. add_filter( 'enable_edit_any_user_configuration', '__return_false' ); } add_filter( 'force_filtered_html_on_import', '__return_true' ); -// WP_HOME and WP_SITEURL should not have any effect in MS +// WP_HOME and WP_SITEURL should not have any effect in MS. remove_filter( 'option_siteurl', '_config_wp_siteurl' ); remove_filter( 'option_home', '_config_wp_home' ); @@ -124,5 +124,5 @@ add_action( 'update_option_home', 'clean_site_details_cache', 10, 0 ); // If the network upgrade hasn't run yet, assume ms-files.php rewriting is used. add_filter( 'default_site_option_ms_files_rewriting', '__return_true' ); -// Whitelist multisite domains for HTTP requests +// Whitelist multisite domains for HTTP requests. add_filter( 'http_request_host_is_external', 'ms_allowed_http_request_hosts', 20, 2 ); diff --git a/src/wp-includes/ms-deprecated.php b/src/wp-includes/ms-deprecated.php index 131c6da0cd..80b7f9faef 100644 --- a/src/wp-includes/ms-deprecated.php +++ b/src/wp-includes/ms-deprecated.php @@ -226,7 +226,7 @@ function get_most_active_blogs( $num = 10, $display = true ) { $blog_list = array(); foreach ( (array) $blogs as $key => $details ) { $most_active[ $details['blog_id'] ] = $details['postcount']; - $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys!! + $blog_list[ $details['blog_id'] ] = $details; // array_slice() removes keys! } arsort( $most_active ); reset( $most_active ); @@ -371,10 +371,10 @@ function get_blogaddress_by_domain( $domain, $path ) { if ( $domain != $_SERVER['HTTP_HOST'] ) { $blogname = substr( $domain, 0, strpos( $domain, '.' ) ); $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path; - // we're not installing the main blog + // We're not installing the main blog. if ( $blogname != 'www.' ) $url .= $blogname . '/'; - } else { // main blog + } else { // Main blog. $url = 'http://' . $domain . $path; } } @@ -403,9 +403,11 @@ function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) { if ( domain_exists($domain, $path, $site_id) ) return __( '<strong>ERROR</strong>: Site URL already taken.' ); - // Need to back up wpdb table names, and create a new wp_blogs entry for new blog. - // Need to get blog_id from wp_blogs, and create new table names. - // Must restore table names at the end of function. + /* + * Need to back up wpdb table names, and create a new wp_blogs entry for new blog. + * Need to get blog_id from wp_blogs, and create new table names. + * Must restore table names at the end of function. + */ if ( ! $blog_id = insert_blog($domain, $path, $site_id) ) return __( '<strong>ERROR</strong>: problem creating site entry.' ); @@ -494,7 +496,7 @@ function wp_get_sites( $args = array() ) { $args = wp_parse_args( $args, $defaults ); - // Backwards compatibility + // Backward compatibility. if( is_array( $args['network_id'] ) ){ $args['network__in'] = $args['network_id']; $args['network_id'] = null; @@ -605,7 +607,7 @@ function install_blog( $blog_id, $blog_title = '' ) { _deprecated_function( __FUNCTION__, '5.1.0' ); - // Cast for security + // Cast for security. $blog_id = (int) $blog_id; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); @@ -618,7 +620,7 @@ function install_blog( $blog_id, $blog_title = '' ) { $url = get_blogaddress_by_id( $blog_id ); - // Set everything up + // Set everything up. make_db_current_silent( 'blog' ); populate_options(); populate_roles(); @@ -650,10 +652,10 @@ function install_blog( $blog_id, $blog_title = '' ) { update_option( 'blogname', wp_unslash( $blog_title ) ); update_option( 'admin_email', '' ); - // remove all perms + // Remove all permissions. $table_prefix = $wpdb->get_blog_prefix(); - delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all - delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all + delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // Delete all. + delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // Delete all. } /** diff --git a/src/wp-includes/ms-files.php b/src/wp-includes/ms-files.php index 0f2c0798c8..260ece311c 100644 --- a/src/wp-includes/ms-files.php +++ b/src/wp-includes/ms-files.php @@ -41,12 +41,12 @@ if ( $mime['type'] ) { $mimetype = 'image/' . substr( $file, strrpos( $file, '.' ) + 1 ); } -header( 'Content-Type: ' . $mimetype ); // always send this +header( 'Content-Type: ' . $mimetype ); // Always send this. if ( false === strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS' ) ) { header( 'Content-Length: ' . filesize( $file ) ); } -// Optional support for X-Sendfile and X-Accel-Redirect +// Optional support for X-Sendfile and X-Accel-Redirect. if ( WPMU_ACCEL_REDIRECT ) { header( 'X-Accel-Redirect: ' . str_replace( WP_CONTENT_DIR, '', $file ) ); exit; @@ -61,7 +61,7 @@ header( "Last-Modified: $last_modified GMT" ); header( 'ETag: ' . $etag ); header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + 100000000 ) . ' GMT' ); -// Support for Conditional GET - use stripslashes to avoid formatting.php dependency +// Support for conditional GET - use stripslashes() to avoid formatting.php dependency. $client_etag = isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) ? stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) : false; if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { @@ -69,7 +69,7 @@ if ( ! isset( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) { } $client_last_modified = trim( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ); -// If string is empty, return 0. If not, attempt to parse into a timestamp +// If string is empty, return 0. If not, attempt to parse into a timestamp. $client_modified_timestamp = $client_last_modified ? strtotime( $client_last_modified ) : 0; // Make a timestamp for our most recent modification... @@ -83,6 +83,6 @@ if ( ( $client_last_modified && $client_etag ) exit; } -// If we made it this far, just serve the file +// If we made it this far, just serve the file. readfile( $file ); flush(); diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index 5cb8e328de..9479ace08b 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -62,7 +62,7 @@ function get_active_blog_for_user( $user_id ) { $primary = get_site( $primary_blog ); } } else { - //TODO Review this call to add_user_to_blog too - to get here the user must have a role on this blog? + // TODO: Review this call to add_user_to_blog too - to get here the user must have a role on this blog? $result = add_user_to_blog( $first_blog->userblog_id, $user_id, 'subscriber' ); if ( ! is_wp_error( $result ) ) { @@ -72,7 +72,7 @@ function get_active_blog_for_user( $user_id ) { } if ( ( ! is_object( $primary ) ) || ( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) { - $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs. + $blogs = get_blogs_of_user( $user_id, true ); // If a user's primary blog is shut down, check their other blogs. $ret = false; if ( is_array( $blogs ) && count( $blogs ) > 0 ) { foreach ( (array) $blogs as $blog_id => $blog ) { @@ -273,7 +273,7 @@ function remove_user_from_blog( $user_id, $blog_id = '', $reassign = '' ) { update_user_meta( $user_id, 'source_domain', $new_domain ); } - // wp_revoke_user($user_id); + // wp_revoke_user( $user_id ); $user = get_userdata( $user_id ); if ( ! $user ) { restore_current_blog(); @@ -347,7 +347,7 @@ function get_blog_id_from_url( $domain, $path = '/' ) { $path = strtolower( $path ); $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' ); - if ( $id == -1 ) { // blog does not exist + if ( $id == -1 ) { // Blog does not exist. return 0; } elseif ( $id ) { return (int) $id; @@ -373,7 +373,9 @@ function get_blog_id_from_url( $domain, $path = '/' ) { return $id; } -// Admin functions +// +// Admin functions. +// /** * Checks an email address against a list of banned domains. @@ -507,7 +509,7 @@ function wpmu_validate_user_signup( $user_name, $user_email ) { $errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) ); } - // all numeric? + // All numeric? if ( preg_match( '/^[0-9]*$/', $user_name ) ) { $errors->add( 'user_name', __( 'Sorry, usernames must have letters too!' ) ); } @@ -665,12 +667,12 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { $errors->add( 'blogname', sprintf( _n( 'Site name must be at least %s character.', 'Site name must be at least %s characters.', $minimum_site_name_length ), number_format_i18n( $minimum_site_name_length ) ) ); } - // do not allow users to create a blog that conflicts with a page on the main blog. + // Do not allow users to create a blog that conflicts with a page on the main blog. if ( ! is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( 'SELECT post_name FROM ' . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) { $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) ); } - // all numeric? + // All numeric? if ( preg_match( '/^[0-9]*$/', $blogname ) ) { $errors->add( 'blogname', __( 'Sorry, site names must have letters too!' ) ); } @@ -712,7 +714,8 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { } // Has someone already signed up for this domain? - $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) ); // TODO: Check email too? + // TODO: Check email too? + $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) ); if ( ! empty( $signup ) ) { $diff = time() - mysql2date( 'U', $signup->registered ); // If registered more than two days ago, cancel registration and let this signup go through. @@ -840,7 +843,7 @@ function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = a function wpmu_signup_user( $user, $user_email, $meta = array() ) { global $wpdb; - // Format data + // Format data. $user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) ); $user_email = sanitize_email( $user_email ); $key = substr( md5( time() . wp_rand() . $user_email ), 0, 16 ); @@ -933,7 +936,7 @@ function wpmu_signup_blog_notification( $domain, $path, $title, $user_login, $us if ( ! is_subdomain_install() || get_current_network_id() != 1 ) { $activate_url = network_site_url( "wp-activate.php?key=$key" ); } else { - $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API + $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo Use *_url() API. } $activate_url = esc_url( $activate_url ); @@ -1212,8 +1215,11 @@ function wpmu_activate_signup( $key ) { // TODO: What to do if we create a user but cannot create a blog? if ( is_wp_error( $blog_id ) ) { - // If blog is taken, that means a previous attempt to activate this blog failed in between creating the blog and - // setting the activation flag. Let's just set the active flag and instruct the user to reset their password. + /* + * If blog is taken, that means a previous attempt to activate this blog + * failed in between creating the blog and setting the activation flag. + * Let's just set the active flag and instruct the user to reset their password. + */ if ( 'blog_taken' == $blog_id->get_error_code() ) { $blog_id->add_data( $signup ); $wpdb->update( @@ -1788,18 +1794,20 @@ function get_most_recent_post_of_user( $user_id ) { $most_recent_post = array(); // Walk through each blog and get the most recent post - // published by $user_id + // published by $user_id. foreach ( (array) $user_blogs as $blog ) { $prefix = $wpdb->get_blog_prefix( $blog->userblog_id ); $recent_post = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A ); - // Make sure we found a post + // Make sure we found a post. if ( isset( $recent_post['ID'] ) ) { $post_gmt_ts = strtotime( $recent_post['post_date_gmt'] ); - // If this is the first post checked or if this post is - // newer than the current recent post, make it the new - // most recent post. + /* + * If this is the first post checked + * or if this post is newer than the current recent post, + * make it the new most recent post. + */ if ( ! isset( $most_recent_post['post_gmt_ts'] ) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) { $most_recent_post = array( 'blog_id' => $blog->userblog_id, @@ -1814,7 +1822,9 @@ function get_most_recent_post_of_user( $user_id ) { return $most_recent_post; } -// Misc functions +// +// Misc functions. +// /** * Check an array of MIME types against a whitelist. @@ -1920,7 +1930,7 @@ function global_terms( $term_id, $deprecated = '' ) { return $term_id; } - // prevent a race condition + // Prevent a race condition. $recurse_start = false; if ( $global_terms_recurse === null ) { $recurse_start = true; @@ -2182,7 +2192,7 @@ function add_new_user_to_blog( $user_id, $password, $meta ) { if ( ! empty( $meta['add_to_blog'] ) ) { $blog_id = $meta['add_to_blog']; $role = $meta['new_role']; - remove_user_from_blog( $user_id, get_network()->site_id ); // remove user from main blog. + remove_user_from_blog( $user_id, get_network()->site_id ); // Remove user from main blog. $result = add_user_to_blog( $blog_id, $user_id, $role ); @@ -2316,7 +2326,7 @@ function force_ssl_content( $force = '' ) { */ function filter_SSL( $url ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid if ( ! is_string( $url ) ) { - return get_bloginfo( 'url' ); // Return home blog url with proper scheme + return get_bloginfo( 'url' ); // Return home blog URL with proper scheme. } if ( force_ssl_content() && is_ssl() ) { @@ -2778,7 +2788,7 @@ All at ###SITENAME### 'message' => $email_change_text, 'headers' => '', ); - // get network name + // Get network name. $network_name = wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ); /** diff --git a/src/wp-includes/ms-load.php b/src/wp-includes/ms-load.php index f804551291..4750a420a8 100644 --- a/src/wp-includes/ms-load.php +++ b/src/wp-includes/ms-load.php @@ -45,9 +45,9 @@ function wp_get_active_network_plugins() { sort( $active_plugins ); foreach ( $active_plugins as $plugin ) { - if ( ! validate_file( $plugin ) // $plugin must validate as file - && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php' - && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist + if ( ! validate_file( $plugin ) // $plugin must validate as file. + && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'. + && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist. ) { $plugins[] = WP_PLUGIN_DIR . '/' . $plugin; } @@ -85,7 +85,7 @@ function ms_site_check() { return true; } - // Allow super admins to see blocked sites + // Allow super admins to see blocked sites. if ( is_super_admin() ) { return true; } @@ -221,7 +221,7 @@ function get_site_by_path( $domain, $path, $segments = null ) { /* * @todo - * caching, etc. Consider alternative optimization routes, + * Caching, etc. Consider alternative optimization routes, * perhaps as an opt-in for plugins, rather than using the pre_* filter. * For example: The segments filter can expand or ignore paths. * If persistent caching is enabled, we could query the DB for a path <> '/' @@ -305,7 +305,7 @@ function ms_load_current_site_and_network( $domain, $path, $subdomain = false ) $current_site->path = PATH_CURRENT_SITE; if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) { $current_site->blog_id = BLOG_ID_CURRENT_SITE; - } elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) { // deprecated. + } elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) { // Deprecated. $current_site->blog_id = BLOGID_CURRENT_SITE; } @@ -419,9 +419,11 @@ function ms_load_current_site_and_network( $domain, $path, $subdomain = false ) // For a "subdomain" installation, redirect to the signup form specifically. $destination .= 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); } elseif ( $subdomain ) { - // For a "subdomain" installation, the NOBLOGREDIRECT constant - // can be used to avoid a redirect to the signup form. - // Using the ms_site_not_found action is preferred to the constant. + /* + * For a "subdomain" installation, the NOBLOGREDIRECT constant + * can be used to avoid a redirect to the signup form. + * Using the ms_site_not_found action is preferred to the constant. + */ if ( '%siteurl%' !== NOBLOGREDIRECT ) { $destination = NOBLOGREDIRECT; } diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php index 1ebfb8bfb1..1a9874ad72 100644 --- a/src/wp-includes/ms-settings.php +++ b/src/wp-includes/ms-settings.php @@ -94,13 +94,13 @@ if ( ! isset( $current_site ) || ! isset( $current_blog ) ) { wp_load_core_site_options( $site_id ); } -$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php +$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php. $wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); $table_prefix = $wpdb->get_blog_prefix(); $_wp_switched_stack = array(); $switched = false; -// need to init cache again after blog_id is set +// Need to init cache again after blog_id is set. wp_start_object_cache(); if ( ! $current_site instanceof WP_Network ) { @@ -111,7 +111,7 @@ if ( ! $current_blog instanceof WP_Site ) { $current_blog = new WP_Site( $current_blog ); } -// Define upload directory constants +// Define upload directory constants. ms_upload_constants(); /** diff --git a/src/wp-includes/ms-site.php b/src/wp-includes/ms-site.php index e5f9af4758..947570a05c 100644 --- a/src/wp-includes/ms-site.php +++ b/src/wp-includes/ms-site.php @@ -761,8 +761,8 @@ function wp_initialize_site( $site_id, array $args = array() ) { // Remove all permissions that may exist for the site. $table_prefix = $wpdb->get_blog_prefix(); - delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all - delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all + delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // Delete all. + delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // Delete all. // Install default site content. wp_install_defaults( $args['user_id'] ); @@ -863,7 +863,7 @@ function wp_uninitialize_site( $site_id ) { $index = 0; while ( $index < count( $stack ) ) { - // Get indexed directory from stack + // Get indexed directory from stack. $dir = $stack[ $index ]; // phpcs:disable WordPress.PHP.NoSilencedErrors.Discouraged @@ -889,7 +889,7 @@ function wp_uninitialize_site( $site_id ) { $index++; } - $stack = array_reverse( $stack ); // Last added dirs are deepest + $stack = array_reverse( $stack ); // Last added directories are deepest. foreach ( (array) $stack as $dir ) { if ( $dir != $top_dir ) { @rmdir( $dir ); diff --git a/src/wp-includes/nav-menu-template.php b/src/wp-includes/nav-menu-template.php index e3415de52a..369e2b99dc 100644 --- a/src/wp-includes/nav-menu-template.php +++ b/src/wp-includes/nav-menu-template.php @@ -72,7 +72,7 @@ function wp_nav_menu( $args = array() ) { $args = wp_parse_args( $args, $defaults ); if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { - // invalid value, fall back to default. + // Invalid value, fall back to default. $args['item_spacing'] = $defaults['item_spacing']; } @@ -113,16 +113,16 @@ function wp_nav_menu( $args = array() ) { return $nav_menu; } - // Get the nav menu based on the requested menu + // Get the nav menu based on the requested menu. $menu = wp_get_nav_menu_object( $args->menu ); - // Get the nav menu based on the theme_location + // Get the nav menu based on the theme_location. $locations = get_nav_menu_locations(); if ( ! $menu && $args->theme_location && $locations && isset( $locations[ $args->theme_location ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] ); } - // get the first menu that has items if we still can't find a menu + // Get the first menu that has items if we still can't find a menu. if ( ! $menu && ! $args->theme_location ) { $menus = wp_get_nav_menus(); foreach ( $menus as $menu_maybe ) { @@ -182,7 +182,7 @@ function wp_nav_menu( $args = array() ) { } } - // Set up the $menu_item variables + // Set up the $menu_item variables. _wp_menu_item_classes_by_context( $menu_items ); $sorted_menu_items = array(); @@ -194,7 +194,7 @@ function wp_nav_menu( $args = array() ) { } } - // Add the menu-item-has-children class where applicable + // Add the menu-item-has-children class where applicable. if ( $menu_items_with_children ) { foreach ( $sorted_menu_items as &$menu_item ) { if ( isset( $menu_items_with_children[ $menu_item->ID ] ) ) { @@ -218,7 +218,7 @@ function wp_nav_menu( $args = array() ) { $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args ); unset( $sorted_menu_items ); - // Attributes + // Attributes. if ( ! empty( $args->menu_id ) ) { $wrap_id = $args->menu_id; } else { @@ -389,13 +389,13 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $classes[] = 'menu-item-privacy-policy'; } - // if the menu item corresponds to a taxonomy term for the currently-queried non-hierarchical post object + // If the menu item corresponds to a taxonomy term for the currently queried non-hierarchical post object. if ( $wp_query->is_singular && 'taxonomy' == $menu_item->type && in_array( $menu_item->object_id, $possible_object_parents ) ) { $active_parent_object_ids[] = (int) $menu_item->object_id; $active_parent_item_ids[] = (int) $menu_item->db_id; $active_object = $queried_object->post_type; - // if the menu item corresponds to the currently-queried post or taxonomy object + // If the menu item corresponds to the currently queried post or taxonomy object. } elseif ( $menu_item->object_id == $queried_object_id && ( @@ -416,7 +416,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } if ( 'post_type' == $menu_item->type && 'page' == $menu_item->object ) { - // Back compat classes for pages to match wp_page_menu() + // Back compat classes for pages to match wp_page_menu(). $classes[] = 'page_item'; $classes[] = 'page-item-' . $menu_item->object_id; $classes[] = 'current_page_item'; @@ -426,7 +426,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $active_parent_object_ids[] = (int) $menu_item->post_parent; $active_object = $menu_item->object; - // if the menu item corresponds to the currently-queried post type archive + // If the menu item corresponds to the currently queried post type archive. } elseif ( 'post_type_archive' == $menu_item->type && is_post_type_archive( array( $menu_item->object ) ) @@ -444,11 +444,11 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; - // if the menu item corresponds to the currently-requested URL + // If the menu item corresponds to the currently requested URL. } elseif ( 'custom' == $menu_item->object && isset( $_SERVER['HTTP_HOST'] ) ) { $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); - //if it is the customize page then it will strips the query var off the url before entering the comparison block. + // If it's the customize page then it will strip the query var off the URL before entering the comparison block. if ( is_customize_preview() ) { $_root_relative_current = strtok( untrailingslashit( $_SERVER['REQUEST_URI'] ), '?' ); } @@ -480,14 +480,14 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } if ( in_array( home_url(), array( untrailingslashit( $current_url ), untrailingslashit( $_indexless_current ) ) ) ) { - // Back compat for home link to match wp_page_menu() + // Back compat for home link to match wp_page_menu(). $classes[] = 'current_page_item'; } $active_parent_item_ids[] = (int) $menu_item->menu_item_parent; $active_parent_object_ids[] = (int) $menu_item->post_parent; $active_object = $menu_item->object; - // give front page item current-menu-item class when extra query arguments involved + // Give front page item the 'current-menu-item' class when extra query arguments are involved. } elseif ( $item_url == $front_page_url && is_front_page() ) { $classes[] = 'current-menu-item'; } @@ -497,7 +497,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } } - // back-compat with wp_page_menu: add "current_page_parent" to static home page link for any non-page query + // Back-compat with wp_page_menu(): add "current_page_parent" to static home page link for any non-page query. if ( ! empty( $home_page_id ) && 'post_type' == $menu_item->type && empty( $wp_query->is_page ) && $home_page_id == $menu_item->object_id ) { $classes[] = 'current_page_parent'; } @@ -508,7 +508,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $active_parent_item_ids = array_filter( array_unique( $active_parent_item_ids ) ); $active_parent_object_ids = array_filter( array_unique( $active_parent_object_ids ) ); - // set parent's class + // Set parent's class. foreach ( (array) $menu_items as $key => $parent_item ) { $classes = (array) $parent_item->classes; $menu_items[ $key ]->current_item_ancestor = false; @@ -517,7 +517,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { if ( isset( $parent_item->type ) && ( - // ancestral post object + // Ancestral post object. ( 'post_type' == $parent_item->type && ! empty( $queried_object->post_type ) && @@ -526,7 +526,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $parent_item->object != $queried_object->ID ) || - // ancestral term + // Ancestral term. ( 'taxonomy' == $parent_item->type && isset( $possible_taxonomy_ancestors[ $parent_item->object ] ) && @@ -554,7 +554,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { } if ( 'post_type' == $parent_item->type && 'page' == $parent_item->object ) { - // Back compat classes for pages to match wp_page_menu() + // Back compat classes for pages to match wp_page_menu(). if ( in_array( 'current-menu-parent', $classes ) ) { $classes[] = 'current_page_parent'; } diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index 7474e6629b..1e7db64566 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -324,7 +324,7 @@ function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) { 'slug' => null, ); - // double-check that we're not going to have one menu take the name of another + // Double-check that we're not going to have one menu take the name of another. $_possible_existing = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' ); if ( $_possible_existing && @@ -342,7 +342,7 @@ function wp_update_nav_menu_object( $menu_id = 0, $menu_data = array() ) { ); } - // menu doesn't already exist, so create a new menu + // Menu doesn't already exist, so create a new menu. if ( ! $_menu || is_wp_error( $_menu ) ) { $menu_exists = get_term_by( 'name', $menu_data['menu-name'], 'nav_menu' ); @@ -419,7 +419,7 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item $menu_id = (int) $menu_id; $menu_item_db_id = (int) $menu_item_db_id; - // make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects + // Make sure that we don't convert non-nav_menu_item objects into nav_menu_item objects. if ( ! empty( $menu_item_db_id ) && ! is_nav_menu_item( $menu_item_db_id ) ) { return new WP_Error( 'update_nav_menu_item_failed', __( 'The given object ID is not that of a menu item.' ) ); } @@ -495,13 +495,13 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item $args['menu-item-title'] = ''; } - // hack to get wp to create a post object when too many properties are empty + // Hack to get wp to create a post object when too many properties are empty. if ( '' == $args['menu-item-title'] && '' == $args['menu-item-description'] ) { $args['menu-item-description'] = ' '; } } - // Populate the menu item object + // Populate the menu item object. $post = array( 'menu_order' => $args['menu-item-position'], 'ping_status' => 0, @@ -514,7 +514,7 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item $update = 0 != $menu_item_db_id; - // New menu item. Default is draft status + // New menu item. Default is draft status. if ( ! $update ) { $post['ID'] = 0; $post['post_status'] = 'publish' == $args['menu-item-status'] ? 'publish' : 'draft'; @@ -537,8 +537,8 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item do_action( 'wp_add_nav_menu_item', $menu_id, $menu_item_db_id, $args ); } - // Associate the menu item with the menu term - // Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms() + // Associate the menu item with the menu term. + // Only set the menu term if it isn't set to avoid unnecessary wp_get_object_terms(). if ( $menu_id && ( ! $update || ! is_object_in_term( $menu_item_db_id, 'nav_menu', (int) $menu->term_id ) ) ) { wp_set_object_terms( $menu_item_db_id, array( $menu->term_id ), 'nav_menu' ); } @@ -568,7 +568,7 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item delete_post_meta( $menu_item_db_id, '_menu_item_orphaned' ); } - // Update existing menu item. Default is publish status + // Update existing menu item. Default is publish status. if ( $update ) { $post['ID'] = $menu_item_db_id; $post['post_status'] = 'draft' == $args['menu-item-status'] ? 'draft' : 'publish'; @@ -701,7 +701,7 @@ function wp_get_nav_menu_items( $menu, $args = array() ) { $items = array(); } - // Get all posts and terms at once to prime the caches + // Get all posts and terms at once to prime the caches. if ( empty( $fetched[ $menu->term_id ] ) && ! wp_using_ext_object_cache() ) { $fetched[ $menu->term_id ] = true; $posts = array(); @@ -748,7 +748,7 @@ function wp_get_nav_menu_items( $menu, $args = array() ) { $items = array_map( 'wp_setup_nav_menu_item', $items ); - if ( ! is_admin() ) { // Remove invalid items only in front end + if ( ! is_admin() ) { // Remove invalid items only on front end. $items = array_filter( $items, '_is_valid_nav_menu_item' ); } @@ -1245,11 +1245,11 @@ function wp_map_nav_menu_locations( $new_nav_menu_locations, $old_nav_menu_locat // Go back and check the next new menu location. continue 3; } - } // endforeach ( $slug_group as $slug ) - } // endforeach ( $old_nav_menu_locations as $location => $menu_id ) - } // endforeach foreach ( $registered_nav_menus as $new_location => $name ) - } // endforeach ( $slug_group as $slug ) - } // endforeach ( $common_slug_groups as $slug_group ) + } // End foreach ( $slug_group as $slug ). + } // End foreach ( $old_nav_menu_locations as $location => $menu_id ). + } // End foreach foreach ( $registered_nav_menus as $new_location => $name ). + } // End foreach ( $slug_group as $slug ). + } // End foreach ( $common_slug_groups as $slug_group ). return $new_nav_menu_locations; } diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index fbe1eda4a4..93f375f374 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -69,7 +69,7 @@ function get_option( $option, $default = false ) { $passed_default = func_num_args() > 1; if ( ! wp_installing() ) { - // prevent non-existent options from triggering multiple queries + // Prevent non-existent options from triggering multiple queries. $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( isset( $notoptions[ $option ] ) ) { /** @@ -99,11 +99,11 @@ function get_option( $option, $default = false ) { if ( false === $value ) { $row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) ); - // Has to be get_row instead of get_var because of funkiness with 0, false, null values + // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values. if ( is_object( $row ) ) { $value = $row->option_value; wp_cache_add( $option, $value, 'options' ); - } else { // option does not exist, so we must cache its non-existence + } else { // Option does not exist, so we must cache its non-existence. if ( ! is_array( $notoptions ) ) { $notoptions = array(); } @@ -127,7 +127,7 @@ function get_option( $option, $default = false ) { } } - // If home is not set use siteurl. + // If home is not set, use siteurl. if ( 'home' == $option && '' == $value ) { return get_option( 'siteurl' ); } @@ -479,7 +479,8 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) $value = sanitize_option( $option, $value ); - // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query + // Make sure the option doesn't already exist. + // We can check the 'notoptions' cache before we ask for a DB query. $notoptions = wp_cache_get( 'notoptions', 'options' ); if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { /** This filter is documented in wp-includes/option.php */ @@ -516,8 +517,8 @@ function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) } } - // This option exists now - $notoptions = wp_cache_get( 'notoptions', 'options' ); // yes, again... we need it to be fresh + // This option exists now. + $notoptions = wp_cache_get( 'notoptions', 'options' ); // Yes, again... we need it to be fresh. if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { unset( $notoptions[ $option ] ); wp_cache_set( 'notoptions', $notoptions, 'options' ); @@ -568,7 +569,7 @@ function delete_option( $option ) { wp_protect_special_option( $option ); - // Get the ID, if no ID then return + // Get the ID, if no ID then return. $row = $wpdb->get_row( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s", $option ) ); if ( is_null( $row ) ) { return false; @@ -707,7 +708,7 @@ function get_transient( $transient ) { } else { $transient_option = '_transient_' . $transient; if ( ! wp_installing() ) { - // If option is not in alloptions, it is not autoloaded and thus has a timeout + // If option is not in alloptions, it is not autoloaded and thus has a timeout. $alloptions = wp_load_alloptions(); if ( ! isset( $alloptions[ $transient_option ] ) ) { $transient_timeout = '_transient_timeout_' . $transient; @@ -881,7 +882,7 @@ function delete_expired_transients( $force_db = false ) { ); if ( ! is_multisite() ) { - // non-Multisite stores site transients in the options table. + // Single site stores site transients in the options table. $wpdb->query( $wpdb->prepare( "DELETE a, b FROM {$wpdb->options} a, {$wpdb->options} b @@ -940,7 +941,7 @@ function wp_user_settings() { if ( isset( $_COOKIE[ 'wp-settings-' . $user_id ] ) ) { $cookie = preg_replace( '/[^A-Za-z0-9=&_]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] ); - // No change or both empty + // No change or both empty. if ( $cookie == $settings ) { return; } @@ -948,7 +949,7 @@ function wp_user_settings() { $last_saved = (int) get_user_option( 'user-settings-time', $user_id ); $current = isset( $_COOKIE[ 'wp-settings-time-' . $user_id ] ) ? preg_replace( '/[^0-9]/', '', $_COOKIE[ 'wp-settings-time-' . $user_id ] ) : 0; - // The cookie is newer than the saved value. Update the user_option and leave the cookie as-is + // The cookie is newer than the saved value. Update the user_option and leave the cookie as-is. if ( $current > $last_saved ) { update_user_option( $user_id, 'user-settings', $cookie, false ); update_user_option( $user_id, 'user-settings-time', time() - 5, false ); @@ -1063,7 +1064,7 @@ function get_all_user_settings() { if ( isset( $_COOKIE[ 'wp-settings-' . $user_id ] ) ) { $cookie = preg_replace( '/[^A-Za-z0-9=&_-]/', '', $_COOKIE[ 'wp-settings-' . $user_id ] ); - if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char + if ( strpos( $cookie, '=' ) ) { // '=' cannot be 1st char. parse_str( $cookie, $user_settings ); } } else { @@ -1260,7 +1261,7 @@ function get_network_option( $network_id, $option, $default = false ) { return $pre; } - // prevent non-existent options from triggering multiple queries + // Prevent non-existent options from triggering multiple queries. $notoptions_key = "$network_id:notoptions"; $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); @@ -1294,7 +1295,7 @@ function get_network_option( $network_id, $option, $default = false ) { if ( ! isset( $value ) || false === $value ) { $row = $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $network_id ) ); - // Has to be get_row instead of get_var because of funkiness with 0, false, null values + // Has to be get_row() instead of get_var() because of funkiness with 0, false, null values. if ( is_object( $row ) ) { $value = $row->meta_value; $value = maybe_unserialize( $value ); @@ -1389,7 +1390,8 @@ function add_network_option( $network_id, $option, $value ) { } else { $cache_key = "$network_id:$option"; - // Make sure the option doesn't already exist. We can check the 'notoptions' cache before we ask for a db query + // Make sure the option doesn't already exist. + // We can check the 'notoptions' cache before we ask for a DB query. $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); if ( ! is_array( $notoptions ) || ! isset( $notoptions[ $option ] ) ) { if ( false !== get_network_option( $network_id, $option, false ) ) { @@ -1415,8 +1417,8 @@ function add_network_option( $network_id, $option, $value ) { wp_cache_set( $cache_key, $value, 'site-options' ); - // This option exists now - $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // yes, again... we need it to be fresh + // This option exists now. + $notoptions = wp_cache_get( $notoptions_key, 'site-options' ); // Yes, again... we need it to be fresh. if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) { unset( $notoptions[ $option ] ); wp_cache_set( $notoptions_key, $notoptions, 'site-options' ); diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 2d350d1d5f..b16447073d 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -168,7 +168,7 @@ if ( ! function_exists( 'wp_mail' ) ) : * @return bool Whether the email contents were sent successfully. */ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { - // Compact the input, apply the filters, and extract them back out + // Compact the input, apply the filters, and extract them back out. /** * Filters the wp_mail() arguments. @@ -209,14 +209,14 @@ if ( ! function_exists( 'wp_mail' ) ) : } global $phpmailer; - // (Re)create it, if it's gone missing + // (Re)create it, if it's gone missing. if ( ! ( $phpmailer instanceof PHPMailer ) ) { require_once ABSPATH . WPINC . '/class-phpmailer.php'; require_once ABSPATH . WPINC . '/class-smtp.php'; $phpmailer = new PHPMailer( true ); } - // Headers + // Headers. $cc = array(); $bcc = array(); $reply_to = array(); @@ -225,17 +225,17 @@ if ( ! function_exists( 'wp_mail' ) ) : $headers = array(); } else { if ( ! is_array( $headers ) ) { - // Explode the headers out, so this function can take both - // string headers and an array of headers. + // Explode the headers out, so this function can take + // both string headers and an array of headers. $tempheaders = explode( "\n", str_replace( "\r\n", "\n", $headers ) ); } else { $tempheaders = $headers; } $headers = array(); - // If it's actually got contents + // If it's actually got contents. if ( ! empty( $tempheaders ) ) { - // Iterate through the raw headers + // Iterate through the raw headers. foreach ( (array) $tempheaders as $header ) { if ( strpos( $header, ':' ) === false ) { if ( false !== stripos( $header, 'boundary=' ) ) { @@ -244,15 +244,15 @@ if ( ! function_exists( 'wp_mail' ) ) : } continue; } - // Explode them out + // Explode them out. list( $name, $content ) = explode( ':', trim( $header ), 2 ); - // Cleanup crew + // Cleanup crew. $name = trim( $name ); $content = trim( $content ); switch ( strtolower( $name ) ) { - // Mainly for legacy -- process a From: header if it's there + // Mainly for legacy -- process a "From:" header if it's there. case 'from': $bracket_pos = strpos( $content, '<' ); if ( $bracket_pos !== false ) { @@ -298,7 +298,7 @@ if ( ! function_exists( 'wp_mail' ) ) : $reply_to = array_merge( (array) $reply_to, explode( ',', $content ) ); break; default: - // Add it to our grand headers array + // Add it to our grand headers array. $headers[ trim( $name ) ] = trim( $content ); break; } @@ -306,25 +306,26 @@ if ( ! function_exists( 'wp_mail' ) ) : } } - // Empty out the values that may be set + // Empty out the values that may be set. $phpmailer->clearAllRecipients(); $phpmailer->clearAttachments(); $phpmailer->clearCustomHeaders(); $phpmailer->clearReplyTos(); - // From email and name - // If we don't have a name from the input headers + // Set "From" name and email. + + // If we don't have a name from the input headers. if ( ! isset( $from_name ) ) { $from_name = 'WordPress'; } - /* If we don't have an email from the input headers default to wordpress@$sitename - * Some hosts will block outgoing mail from this address if it doesn't exist but - * there's no easy alternative. Defaulting to admin_email might appear to be another - * option but some hosts may refuse to relay mail from an unknown domain. See - * https://core.trac.wordpress.org/ticket/5007. + /* + * If we don't have an email from the input headers, default to wordpress@$sitename + * Some hosts will block outgoing mail from this address if it doesn't exist, + * but there's no easy alternative. Defaulting to admin_email might appear to be + * another option, but some hosts may refuse to relay mail from an unknown domain. + * See https://core.trac.wordpress.org/ticket/5007. */ - if ( ! isset( $from_email ) ) { // Get the site domain and get rid of www. $sitename = strtolower( $_SERVER['SERVER_NAME'] ); @@ -365,11 +366,11 @@ if ( ! function_exists( 'wp_mail' ) ) : return false; } - // Set mail's subject and body + // Set mail's subject and body. $phpmailer->Subject = $subject; $phpmailer->Body = $message; - // Set destination addresses, using appropriate methods for handling addresses + // Set destination addresses, using appropriate methods for handling addresses. $address_headers = compact( 'to', 'cc', 'bcc', 'reply_to' ); foreach ( $address_headers as $address_header => $addresses ) { @@ -379,7 +380,7 @@ if ( ! function_exists( 'wp_mail' ) ) : foreach ( (array) $addresses as $address ) { try { - // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>" + // Break $recipient into name and address parts if in the format "Foo <bar@baz.com>". $recipient_name = ''; if ( preg_match( '/(.*)<(.+)>/', $address, $matches ) ) { @@ -409,11 +410,12 @@ if ( ! function_exists( 'wp_mail' ) ) : } } - // Set to use PHP's mail() + // Set to use PHP's mail(). $phpmailer->isMail(); - // Set Content-Type and charset - // If we don't have a content-type from the input headers + // Set Content-Type and charset. + + // If we don't have a content-type from the input headers. if ( ! isset( $content_type ) ) { $content_type = 'text/plain'; } @@ -429,12 +431,12 @@ if ( ! function_exists( 'wp_mail' ) ) : $phpmailer->ContentType = $content_type; - // Set whether it's plaintext, depending on $content_type + // Set whether it's plaintext, depending on $content_type. if ( 'text/html' == $content_type ) { $phpmailer->isHTML( true ); } - // If we don't have a charset from the input headers + // If we don't have a charset from the input headers. if ( ! isset( $charset ) ) { $charset = get_bloginfo( 'charset' ); } @@ -537,7 +539,7 @@ if ( ! function_exists( 'wp_authenticate' ) ) : $user = apply_filters( 'authenticate', null, $username, $password ); if ( $user == null ) { - // TODO what should the error message be? (Or would these even happen?) + // TODO: What should the error message be? (Or would these even happen?) // Only needed if all authentication handlers fail to return anything. $user = new WP_Error( 'authentication_failed', __( '<strong>ERROR</strong>: Invalid username, email address or incorrect password.' ) ); } @@ -625,12 +627,12 @@ if ( ! function_exists( 'wp_validate_auth_cookie' ) ) : $expired = $cookie_elements['expiration']; $expiration = $cookie_elements['expiration']; - // Allow a grace period for POST and Ajax requests + // Allow a grace period for POST and Ajax requests. if ( wp_doing_ajax() || 'POST' == $_SERVER['REQUEST_METHOD'] ) { $expired += HOUR_IN_SECONDS; } - // Quick check to see if an honest cookie has expired + // Quick check to see if an honest cookie has expired. if ( $expired < time() ) { /** * Fires once an authentication cookie has expired. @@ -689,7 +691,7 @@ if ( ! function_exists( 'wp_validate_auth_cookie' ) ) : return false; } - // Ajax/POST grace period set above + // Ajax/POST grace period set above. if ( $expiration < time() ) { $GLOBALS['login_grace_period'] = 1; } @@ -966,7 +968,7 @@ if ( ! function_exists( 'wp_clear_auth_cookie' ) ) : return; } - // Auth cookies + // Auth cookies. setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN ); setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN ); @@ -974,23 +976,23 @@ if ( ! function_exists( 'wp_clear_auth_cookie' ) ) : setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); - // Settings cookies + // Settings cookies. setcookie( 'wp-settings-' . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); setcookie( 'wp-settings-time-' . get_current_user_id(), ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH ); - // Old cookies + // Old cookies. setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); - // Even older cookies + // Even older cookies. setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); - // Post password cookie + // Post password cookie. setcookie( 'wp-postpass_' . COOKIEHASH, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); } endif; @@ -1026,8 +1028,6 @@ if ( ! function_exists( 'auth_redirect' ) ) : * @since 1.5.0 */ function auth_redirect() { - // Checks if a user is logged in, if not redirects them to the login page - $secure = ( is_ssl() || force_ssl_admin() ); /** @@ -1039,7 +1039,7 @@ if ( ! function_exists( 'auth_redirect' ) ) : */ $secure = apply_filters( 'secure_auth_redirect', $secure ); - // If https is required and request is http, redirect + // If https is required and request is http, redirect. if ( $secure && ! is_ssl() && false !== strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) ) { if ( 0 === strpos( $_SERVER['REQUEST_URI'], 'http' ) ) { wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); @@ -1081,10 +1081,10 @@ if ( ! function_exists( 'auth_redirect' ) ) : } } - return; // The cookie is good so we're done + return; // The cookie is good, so we're done. } - // The cookie is no good so force login + // The cookie is no good, so force login. nocache_headers(); $redirect = ( strpos( $_SERVER['REQUEST_URI'], '/options.php' ) && wp_get_referer() ) ? wp_get_referer() : set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); @@ -1262,7 +1262,7 @@ if ( ! function_exists( 'wp_redirect' ) ) : $location = wp_sanitize_redirect( $location ); if ( ! $is_IIS && PHP_SAPI != 'cgi-fcgi' ) { - status_header( $status ); // This causes problems on IIS and some FastCGI setups + status_header( $status ); // This causes problems on IIS and some FastCGI setups. } /** @@ -1373,7 +1373,7 @@ if ( ! function_exists( 'wp_safe_redirect' ) ) : */ function wp_safe_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) { - // Need to look at the URL the way it will end up in wp_redirect() + // Need to look at the URL the way it will end up in wp_redirect(). $location = wp_sanitize_redirect( $location ); /** @@ -1408,24 +1408,25 @@ if ( ! function_exists( 'wp_validate_redirect' ) ) : */ function wp_validate_redirect( $location, $default = '' ) { $location = trim( $location, " \t\n\r\0\x08\x0B" ); - // browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//' + // Browsers will assume 'http' is your protocol, and will obey a redirect to a URL starting with '//'. if ( substr( $location, 0, 2 ) == '//' ) { $location = 'http:' . $location; } - // In php 5 parse_url may fail if the URL query part contains http://, bug #38143 + // In PHP 5 parse_url() may fail if the URL query part contains 'http://'. + // See https://bugs.php.net/bug.php?id=38143 $cut = strpos( $location, '?' ); $test = $cut ? substr( $location, 0, $cut ) : $location; // @-operator is used to prevent possible warnings in PHP < 5.3.3. $lp = @parse_url( $test ); - // Give up if malformed URL + // Give up if malformed URL. if ( false === $lp ) { return $default; } - // Allow only http and https schemes. No data:, etc. + // Allow only 'http' and 'https' schemes. No 'data:', etc. if ( isset( $lp['scheme'] ) && ! ( 'http' == $lp['scheme'] || 'https' == $lp['scheme'] ) ) { return $default; } @@ -1439,7 +1440,8 @@ if ( ! function_exists( 'wp_validate_redirect' ) ) : $location = '/' . ltrim( $path . '/', '/' ) . $location; } - // Reject if certain components are set but host is not. This catches urls like https:host.com for which parse_url does not set the host field. + // Reject if certain components are set but host is not. + // This catches URLs like https:host.com for which parse_url() does not set the host field. if ( ! isset( $lp['host'] ) && ( isset( $lp['scheme'] ) || isset( $lp['user'] ) || isset( $lp['pass'] ) || isset( $lp['port'] ) ) ) { return $default; } @@ -1536,22 +1538,22 @@ if ( ! function_exists( 'wp_notify_postauthor' ) ) : */ $notify_author = apply_filters( 'comment_notification_notify_author', false, $comment->comment_ID ); - // The comment was left by the author + // The comment was left by the author. if ( $author && ! $notify_author && $comment->user_id == $post->post_author ) { unset( $emails[ $author->user_email ] ); } - // The author moderated a comment on their own post + // The author moderated a comment on their own post. if ( $author && ! $notify_author && $post->post_author == get_current_user_id() ) { unset( $emails[ $author->user_email ] ); } - // The post author is no longer a member of the blog + // The post author is no longer a member of the blog. if ( $author && ! $notify_author && ! user_can( $post->post_author, 'read_post', $post->ID ) ) { unset( $emails[ $author->user_email ] ); } - // If there's no email to send the comment to, bail, otherwise flip array back around for use below + // If there's no email to send the comment to, bail, otherwise flip array back around for use below. if ( ! count( $emails ) ) { return false; } else { @@ -1565,8 +1567,8 @@ if ( ! function_exists( 'wp_notify_postauthor' ) ) : $comment_author_domain = gethostbyaddr( $comment->comment_author_IP ); } - // The blogname option is escaped with esc_html on the way into the database in sanitize_option - // we want to reverse this for the plain text arena of emails. + // The blogname option is escaped with esc_html() on the way into the database in sanitize_option(). + // We want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $comment_content = wp_specialchars_decode( $comment->comment_content ); @@ -1599,7 +1601,7 @@ if ( ! function_exists( 'wp_notify_postauthor' ) ) : $subject = sprintf( __( '[%1$s] Pingback: "%2$s"' ), $blogname, $post->post_title ); break; - default: // Comments + default: // Comments. /* translators: %s: Post title. */ $notify_message = sprintf( __( 'New comment on your post "%s"' ), $post->post_title ) . "\r\n"; /* translators: 1: Comment author's name, 2: Comment author's IP address, 3: Comment author's hostname. */ @@ -1754,8 +1756,8 @@ if ( ! function_exists( 'wp_notify_moderator' ) ) : $comments_waiting = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'" ); - // The blogname option is escaped with esc_html on the way into the database in sanitize_option - // we want to reverse this for the plain text arena of emails. + // The blogname option is escaped with esc_html() on the way into the database in sanitize_option(). + // We want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $comment_content = wp_specialchars_decode( $comment->comment_content ); @@ -1782,7 +1784,7 @@ if ( ! function_exists( 'wp_notify_moderator' ) ) : $notify_message .= __( 'Pingback excerpt: ' ) . "\r\n" . $comment_content . "\r\n\r\n"; break; - default: // Comments + default: // Comments. /* translators: %s: Post title. */ $notify_message = sprintf( __( 'A new comment on the post "%s" is waiting for your approval' ), $post->post_title ) . "\r\n"; $notify_message .= get_permalink( $comment->comment_post_ID ) . "\r\n\r\n"; @@ -1893,13 +1895,13 @@ if ( ! function_exists( 'wp_password_change_notification' ) ) : * @param WP_User $user User object. */ function wp_password_change_notification( $user ) { - // send a copy of password change notification to the admin - // but check to see if it's the admin whose password we're changing, and skip this + // Send a copy of password change notification to the admin, + // but check to see if it's the admin whose password we're changing, and skip this. if ( 0 !== strcasecmp( $user->user_email, get_option( 'admin_email' ) ) ) { /* translators: %s: User name. */ $message = sprintf( __( 'Password changed for user: %s' ), $user->user_login ) . "\r\n"; - // The blogname option is escaped with esc_html on the way into the database in sanitize_option - // we want to reverse this for the plain text arena of emails. + // The blogname option is escaped with esc_html() on the way into the database in sanitize_option(). + // We want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); $wp_password_change_notification_email = array( @@ -1959,15 +1961,15 @@ if ( ! function_exists( 'wp_new_user_notification' ) ) : _deprecated_argument( __FUNCTION__, '4.3.1' ); } - // Accepts only 'user', 'admin' , 'both' or default '' as $notify + // Accepts only 'user', 'admin' , 'both' or default '' as $notify. if ( ! in_array( $notify, array( 'user', 'admin', 'both', '' ), true ) ) { return; } $user = get_userdata( $user_id ); - // The blogname option is escaped with esc_html on the way into the database in sanitize_option - // we want to reverse this for the plain text arena of emails. + // The blogname option is escaped with esc_html() on the way into the database in sanitize_option(). + // We want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); if ( 'user' !== $notify ) { @@ -2018,7 +2020,7 @@ if ( ! function_exists( 'wp_new_user_notification' ) ) : } } - // `$deprecated was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification. + // `$deprecated` was pre-4.3 `$plaintext_pass`. An empty `$plaintext_pass` didn't sent a user notification. if ( 'admin' === $notify || ( empty( $deprecated ) && empty( $notify ) ) ) { return; } @@ -2138,13 +2140,13 @@ if ( ! function_exists( 'wp_verify_nonce' ) ) : $token = wp_get_session_token(); $i = wp_nonce_tick(); - // Nonce generated 0-12 hours ago + // Nonce generated 0-12 hours ago. $expected = substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); if ( hash_equals( $expected, $nonce ) ) { return 1; } - // Nonce generated 12-24 hours ago + // Nonce generated 12-24 hours ago. $expected = substr( wp_hash( ( $i - 1 ) . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 ); if ( hash_equals( $expected, $nonce ) ) { return 2; @@ -2162,7 +2164,7 @@ if ( ! function_exists( 'wp_verify_nonce' ) ) : */ do_action( 'wp_verify_nonce_failed', $nonce, $action, $user, $token ); - // Invalid nonce + // Invalid nonce. return false; } endif; @@ -2336,7 +2338,7 @@ if ( ! function_exists( 'wp_hash_password' ) ) : if ( empty( $wp_hasher ) ) { require_once( ABSPATH . WPINC . '/class-phpass.php' ); - // By default, use the portable hash from phpass + // By default, use the portable hash from phpass. $wp_hasher = new PasswordHash( 8, true ); } @@ -2392,11 +2394,11 @@ if ( ! function_exists( 'wp_check_password' ) ) : return apply_filters( 'check_password', $check, $password, $hash, $user_id ); } - // If the stored hash is longer than an MD5, presume the - // new style phpass portable hash. + // If the stored hash is longer than an MD5, + // presume the new style phpass portable hash. if ( empty( $wp_hasher ) ) { require_once( ABSPATH . WPINC . '/class-phpass.php' ); - // By default, use the portable hash from phpass + // By default, use the portable hash from phpass. $wp_hasher = new PasswordHash( 8, true ); } @@ -2470,14 +2472,15 @@ if ( ! function_exists( 'wp_rand' ) ) : function wp_rand( $min = 0, $max = 0 ) { global $rnd_value; - // Some misconfigured 32bit environments (Entropy PHP, for example) truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. + // Some misconfigured 32-bit environments (Entropy PHP, for example) + // truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats. $max_random_number = 3000000000 === 2147483647 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff - // We only handle Ints, floats are truncated to their integer value. + // We only handle ints, floats are truncated to their integer value. $min = (int) $min; $max = (int) $max; - // Use PHP's CSPRNG, or a compatible method + // Use PHP's CSPRNG, or a compatible method. static $use_random_int_functionality = true; if ( $use_random_int_functionality ) { try { @@ -2498,8 +2501,8 @@ if ( ! function_exists( 'wp_rand' ) ) : } } - // Reset $rnd_value after 14 uses - // 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value + // Reset $rnd_value after 14 uses. + // 32 (md5) + 40 (sha1) + 40 (sha1) / 8 = 14 random numbers from $rnd_value. if ( strlen( $rnd_value ) < 8 ) { if ( defined( 'WP_SETUP_CONFIG' ) ) { static $seed = ''; @@ -2515,7 +2518,7 @@ if ( ! function_exists( 'wp_rand' ) ) : } } - // Take the first 8 digits for our value + // Take the first 8 digits for our value. $value = substr( $rnd_value, 0, 8 ); // Strip the first eight, leaving the remainder for the next call to wp_rand(). @@ -2523,7 +2526,7 @@ if ( ! function_exists( 'wp_rand' ) ) : $value = abs( hexdec( $value ) ); - // Reduce the value to be within the min - max range + // Reduce the value to be within the min - max range. if ( $max != 0 ) { $value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 ); } diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php index 0ae29413c8..b893b90929 100644 --- a/src/wp-includes/plugin.php +++ b/src/wp-includes/plugin.php @@ -152,19 +152,19 @@ function has_filter( $tag, $function_to_check = false ) { * * Example usage: * - * // The filter callback function + * // The filter callback function. * function example_callback( $string, $arg1, $arg2 ) { - * // (maybe) modify $string + * // (maybe) modify $string. * return $string; * } * add_filter( 'example_filter', 'example_callback', 10, 3 ); * * /* - * * Apply the filters by calling the 'example_callback()' function that's - * * hooked onto `example_filter` above. + * * Apply the filters by calling the 'example_callback()' function + * * that's hooked onto `example_filter` above. * * - * * - 'example_filter' is the filter hook - * * - 'filter me' is the value being filtered + * * - 'example_filter' is the filter hook. + * * - 'filter me' is the value being filtered. * * - $arg1 and $arg2 are the additional arguments passed to the callback. * $value = apply_filters( 'example_filter', 'filter me', $arg1, $arg2 ); * @@ -228,7 +228,7 @@ function apply_filters( $tag, $value ) { function apply_filters_ref_array( $tag, $args ) { global $wp_filter, $wp_current_filter; - // Do 'all' actions first + // Do 'all' actions first. if ( isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $tag; $all_args = func_get_args(); @@ -415,17 +415,17 @@ function add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 * * Example usage: * - * // The action callback function + * // The action callback function. * function example_callback( $arg1, $arg2 ) { - * // (maybe) do something with the args + * // (maybe) do something with the args. * } * add_action( 'example_action', 'example_callback', 10, 2 ); * * /* - * * Trigger the actions by calling the 'example_callback()' function that's - * * hooked onto `example_action` above. + * * Trigger the actions by calling the 'example_callback()' function + * * that's hooked onto `example_action` above. * * - * * - 'example_action' is the action hook + * * - 'example_action' is the action hook. * * - $arg1 and $arg2 are the additional arguments passed to the callback. * $value = do_action( 'example_action', $arg1, $arg2 ); * @@ -450,7 +450,7 @@ function do_action( $tag, ...$arg ) { ++$wp_actions[ $tag ]; } - // Do 'all' actions first + // Do 'all' actions first. if ( isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $tag; $all_args = func_get_args(); @@ -523,7 +523,7 @@ function do_action_ref_array( $tag, $args ) { ++$wp_actions[ $tag ]; } - // Do 'all' actions first + // Do 'all' actions first. if ( isset( $wp_filter['all'] ) ) { $wp_current_filter[] = $tag; $all_args = func_get_args(); @@ -692,7 +692,8 @@ function plugin_basename( $file ) { $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); - $file = preg_replace( '#^' . preg_quote( $plugin_dir, '#' ) . '/|^' . preg_quote( $mu_plugin_dir, '#' ) . '/#', '', $file ); // get relative path from plugins dir + // Get relative path from plugins directory. + $file = preg_replace( '#^' . preg_quote( $plugin_dir, '#' ) . '/|^' . preg_quote( $mu_plugin_dir, '#' ) . '/#', '', $file ); $file = trim( $file, '/' ); return $file; } @@ -717,7 +718,7 @@ function plugin_basename( $file ) { function wp_register_plugin_realpath( $file ) { global $wp_plugin_paths; - // Normalize, but store as static to avoid recalculation of a constant value + // Normalize, but store as static to avoid recalculation of a constant value. static $wp_plugin_path = null, $wpmu_plugin_path = null; if ( ! isset( $wp_plugin_path ) ) { $wp_plugin_path = wp_normalize_path( WP_PLUGIN_DIR ); diff --git a/src/wp-includes/pomo/entry.php b/src/wp-includes/pomo/entry.php index 8c22ae62dc..a1293d4fa5 100644 --- a/src/wp-includes/pomo/entry.php +++ b/src/wp-includes/pomo/entry.php @@ -41,11 +41,11 @@ if ( ! class_exists( 'Translation_Entry', false ) ) : * - flags (array) -- flags like php-format */ function __construct( $args = array() ) { - // if no singular -- empty object + // If no singular -- empty object. if ( ! isset( $args['singular'] ) ) { return; } - // get member variable values from args hash + // Get member variable values from args hash. foreach ( $args as $varname => $value ) { $this->$varname = $value; } @@ -85,9 +85,9 @@ if ( ! class_exists( 'Translation_Entry', false ) ) : return false; } - // Prepend context and EOT, like in MO files + // Prepend context and EOT, like in MO files. $key = ! $this->context ? $this->singular : $this->context . "\4" . $this->singular; - // Standardize on \n line endings + // Standardize on \n line endings. $key = str_replace( array( "\r\n", "\r" ), "\n", $key ); return $key; diff --git a/src/wp-includes/pomo/mo.php b/src/wp-includes/pomo/mo.php index 836af801cd..623726f942 100644 --- a/src/wp-includes/pomo/mo.php +++ b/src/wp-includes/pomo/mo.php @@ -101,7 +101,7 @@ if ( ! class_exists( 'MO', false ) ) : ksort( $entries ); $magic = 0x950412de; $revision = 0; - $total = count( $entries ) + 1; // all the headers are one entry + $total = count( $entries ) + 1; // All the headers are one entry. $originals_lenghts_addr = 28; $translations_lenghts_addr = $originals_lenghts_addr + 8 * $total; $size_of_hash = 0; @@ -122,7 +122,7 @@ if ( ! class_exists( 'MO', false ) ) : ); fseek( $fh, $originals_lenghts_addr ); - // headers' msgid is an empty string + // Headers' msgid is an empty string. fwrite( $fh, pack( 'VV', 0, $current_addr ) ); $current_addr++; $originals_table = "\0"; @@ -133,7 +133,7 @@ if ( ! class_exists( 'MO', false ) ) : $originals_table .= $this->export_original( $entry ) . "\0"; $length = $reader->strlen( $this->export_original( $entry ) ); fwrite( $fh, pack( 'VV', $length, $current_addr ) ); - $current_addr += $length + 1; // account for the NULL byte after + $current_addr += $length + 1; // Account for the NULL byte after. } $exported_headers = $this->export_headers(); @@ -158,7 +158,7 @@ if ( ! class_exists( 'MO', false ) ) : * @return string */ function export_original( $entry ) { - //TODO: warnings for control characters + // TODO: Warnings for control characters. $exported = $entry->singular; if ( $entry->is_plural ) { $exported .= "\0" . $entry->plural; @@ -174,7 +174,7 @@ if ( ! class_exists( 'MO', false ) ) : * @return string */ function export_translations( $entry ) { - //TODO: warnings for control characters + // TODO: Warnings for control characters. return $entry->is_plural ? implode( "\0", $entry->translations ) : $entry->translations[0]; } @@ -194,7 +194,7 @@ if ( ! class_exists( 'MO', false ) ) : * @return string|false */ function get_byteorder( $magic ) { - // The magic is 0x950412de + // The magic is 0x950412de. // bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565 $magic_little = (int) - 1794895138; @@ -228,21 +228,21 @@ if ( ! class_exists( 'MO', false ) ) : return false; } - // parse header + // Parse header. $header = unpack( "{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header ); if ( ! is_array( $header ) ) { return false; } - // support revision 0 of MO format specs, only + // Support revision 0 of MO format specs, only. if ( $header['revision'] != 0 ) { return false; } - // seek to data blocks + // Seek to data blocks. $reader->seekto( $header['originals_lenghts_addr'] ); - // read originals' indices + // Read originals' indices. $originals_lengths_length = $header['translations_lenghts_addr'] - $header['originals_lenghts_addr']; if ( $originals_lengths_length != $header['total'] * 8 ) { return false; @@ -253,7 +253,7 @@ if ( ! class_exists( 'MO', false ) ) : return false; } - // read translations' indices + // Read translations' indices. $translations_lenghts_length = $header['hash_addr'] - $header['translations_lenghts_addr']; if ( $translations_lenghts_length != $header['total'] * 8 ) { return false; @@ -264,11 +264,11 @@ if ( ! class_exists( 'MO', false ) ) : return false; } - // transform raw data into set of indices + // Transform raw data into set of indices. $originals = $reader->str_split( $originals, 8 ); $translations = $reader->str_split( $translations, 8 ); - // skip hash table + // Skip hash table. $strings_addr = $header['hash_addr'] + $header['hash_length'] * 4; $reader->seekto( $strings_addr ); @@ -283,7 +283,7 @@ if ( ! class_exists( 'MO', false ) ) : return false; } - // adjust offset due to reading strings to separate space before + // Adjust offset due to reading strings to separate space before. $o['pos'] -= $strings_addr; $t['pos'] -= $strings_addr; @@ -319,14 +319,14 @@ if ( ! class_exists( 'MO', false ) ) : $original = $parts[1]; $entry->context = $parts[0]; } - // look for plural original + // Look for plural original. $parts = explode( "\0", $original ); $entry->singular = $parts[0]; if ( isset( $parts[1] ) ) { $entry->is_plural = true; $entry->plural = $parts[1]; } - // plural translations are also separated by \0 + // Plural translations are also separated by \0. $entry->translations = explode( "\0", $translation ); return $entry; } diff --git a/src/wp-includes/pomo/plural-forms.php b/src/wp-includes/pomo/plural-forms.php index e18f751fd9..34efc11f41 100644 --- a/src/wp-includes/pomo/plural-forms.php +++ b/src/wp-includes/pomo/plural-forms.php @@ -103,19 +103,19 @@ class Plural_Forms { $next = substr( $str, $pos, 1 ); switch ( $next ) { - // Ignore whitespace + // Ignore whitespace. case ' ': case "\t": $pos++; break; - // Variable (n) + // Variable (n). case 'n': $output[] = array( 'var' ); $pos++; break; - // Parentheses + // Parentheses. case '(': $stack[] = $next; $pos++; @@ -143,7 +143,7 @@ class Plural_Forms { $pos++; break; - // Operators + // Operators. case '|': case '&': case '>': @@ -161,7 +161,7 @@ class Plural_Forms { while ( ! empty( $stack ) ) { $o2 = $stack[ count( $stack ) - 1 ]; - // Ternary is right-associative in C + // Ternary is right-associative in C. if ( $operator === '?:' || $operator === '?' ) { if ( self::$op_precedence[ $operator ] >= self::$op_precedence[ $o2 ] ) { break; @@ -177,7 +177,7 @@ class Plural_Forms { $pos += $end_operator; break; - // Ternary "else" + // Ternary "else". case ':': $found = false; $s_pos = count( $stack ) - 1; @@ -201,7 +201,7 @@ class Plural_Forms { $pos++; break; - // Default - number or invalid + // Default - number or invalid. default: if ( $next >= '0' && $next <= '9' ) { $span = strspn( $str, self::NUM_CHARS, $pos ); diff --git a/src/wp-includes/pomo/po.php b/src/wp-includes/pomo/po.php index c16abf979a..4c2133612e 100644 --- a/src/wp-includes/pomo/po.php +++ b/src/wp-includes/pomo/po.php @@ -48,7 +48,7 @@ if ( ! class_exists( 'PO', false ) ) : * @return string sequence of mgsgid/msgstr PO strings, doesn't containt newline at the end */ function export_entries() { - //TODO sorting + // TODO: Sorting. return implode( "\n\n", array_map( array( 'PO', 'export_entry' ), $this->entries ) ); } @@ -117,12 +117,12 @@ if ( ! class_exists( 'PO', false ) ) : $string = str_replace( array_keys( $replaces ), array_values( $replaces ), $string ); $po = $quote . implode( "${slash}n$quote$newline$quote", explode( $newline, $string ) ) . $quote; - // add empty string on first line for readbility + // Add empty string on first line for readbility. if ( false !== strpos( $string, $newline ) && ( substr_count( $string, $newline ) > 1 || ! ( $newline === substr( $string, -strlen( $newline ) ) ) ) ) { $po = "$quote$quote$newline$po"; } - // remove empty strings + // Remove empty strings. $po = str_replace( "$newline$quote$quote", '', $po ); return $po; } @@ -161,7 +161,7 @@ if ( ! class_exists( 'PO', false ) ) : } } - // Standardise the line endings on imported content, technically PO files shouldn't contain \r + // Standardise the line endings on imported content, technically PO files shouldn't contain \r. $unpoified = str_replace( array( "\r\n", "\r" ), "\n", $unpoified ); return $unpoified; @@ -178,9 +178,11 @@ if ( ! class_exists( 'PO', false ) ) : $lines = explode( "\n", $string ); $append = ''; if ( "\n" === substr( $string, -1 ) && '' === end( $lines ) ) { - // Last line might be empty because $string was terminated - // with a newline, remove it from the $lines array, - // we'll restore state by re-terminating the string at the end + /* + * Last line might be empty because $string was terminated + * with a newline, remove it from the $lines array, + * we'll restore state by re-terminating the string at the end. + */ array_pop( $lines ); $append = "\n"; } @@ -325,8 +327,8 @@ if ( ! class_exists( 'PO', false ) ) : */ function read_entry( $f, $lineno = 0 ) { $entry = new Translation_Entry(); - // where were we in the last step - // can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural + // Where were we in the last step. + // Can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural. $context = ''; $msgstr_index = 0; while ( true ) { @@ -336,7 +338,7 @@ if ( ! class_exists( 'PO', false ) ) : if ( feof( $f ) ) { if ( self::is_final( $context ) ) { break; - } elseif ( ! $context ) { // we haven't read a line and eof came + } elseif ( ! $context ) { // We haven't read a line and EOF came. return null; } else { return false; @@ -350,17 +352,17 @@ if ( ! class_exists( 'PO', false ) ) : } $line = trim( $line ); if ( preg_match( '/^#/', $line, $m ) ) { - // the comment is the start of a new entry + // The comment is the start of a new entry. if ( self::is_final( $context ) ) { PO::read_line( $f, 'put-back' ); $lineno--; break; } - // comments have to be at the beginning + // Comments have to be at the beginning. if ( $context && $context != 'comment' ) { return false; } - // add comment + // Add comment. $this->add_comment_to_entry( $entry, $line ); } elseif ( preg_match( '/^msgctxt\s+(".*")/', $line, $m ) ) { if ( self::is_final( $context ) ) { diff --git a/src/wp-includes/pomo/translations.php b/src/wp-includes/pomo/translations.php index 720f427b0d..cb186e841d 100644 --- a/src/wp-includes/pomo/translations.php +++ b/src/wp-includes/pomo/translations.php @@ -268,7 +268,7 @@ if ( ! class_exists( 'Translations', false ) ) : */ function make_headers( $translation ) { $headers = array(); - // sometimes \ns are used instead of real new lines + // Sometimes \n's are used instead of real new lines. $translation = str_replace( '\n', "\n", $translation ); $lines = explode( "\n", $translation ); foreach ( $lines as $line ) { diff --git a/src/wp-includes/post-formats.php b/src/wp-includes/post-formats.php index 0932010285..5910bae605 100644 --- a/src/wp-includes/post-formats.php +++ b/src/wp-includes/post-formats.php @@ -94,7 +94,7 @@ function set_post_format( $post, $format ) { */ function get_post_format_strings() { $strings = array( - 'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard + 'standard' => _x( 'Standard', 'Post format' ), // Special case. Any value that evals to false will be considered standard. 'aside' => _x( 'Aside', 'Post format' ), 'chat' => _x( 'Chat', 'Post format' ), 'gallery' => _x( 'Gallery', 'Post format' ), diff --git a/src/wp-includes/post-template.php b/src/wp-includes/post-template.php index a4d0d1a9d7..a2a737df48 100644 --- a/src/wp-includes/post-template.php +++ b/src/wp-includes/post-template.php @@ -313,8 +313,10 @@ function get_the_content( $more_link_text = null, $strip_teaser = false, $post = return get_the_password_form( $_post ); } - if ( $elements['page'] > count( $elements['pages'] ) ) { // if the requested page doesn't exist - $elements['page'] = count( $elements['pages'] ); // give them the highest numbered page that DOES exist + // If the requested page doesn't exist. + if ( $elements['page'] > count( $elements['pages'] ) ) { + // Give them the highest numbered page that DOES exist. + $elements['page'] = count( $elements['pages'] ); } $page_no = $elements['page']; @@ -451,7 +453,7 @@ function has_excerpt( $post = 0 ) { * @param int|WP_Post $post_id Optional. Post ID or post object. Defaults to the global `$post`. */ function post_class( $class = '', $post_id = null ) { - // Separates classes with a single space, collates classes for post DIV + // Separates classes with a single space, collates classes for post DIV. echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"'; } @@ -502,7 +504,7 @@ function get_post_class( $class = '', $post_id = null ) { $classes[] = 'type-' . $post->post_type; $classes[] = 'status-' . $post->post_status; - // Post Format + // Post Format. if ( post_type_supports( $post->post_type, 'post-formats' ) ) { $post_format = get_post_format( $post->ID ); @@ -527,7 +529,7 @@ function get_post_class( $class = '', $post_id = null ) { $classes[] = 'has-post-thumbnail'; } - // sticky for Sticky Posts + // Sticky for Sticky Posts. if ( is_sticky( $post->ID ) ) { if ( is_home() && ! is_paged() ) { $classes[] = 'sticky'; @@ -536,10 +538,10 @@ function get_post_class( $class = '', $post_id = null ) { } } - // hentry for hAtom compliance + // hentry for hAtom compliance. $classes[] = 'hentry'; - // All public taxonomies + // All public taxonomies. $taxonomies = get_taxonomies( array( 'public' => true ) ); foreach ( (array) $taxonomies as $taxonomy ) { if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { @@ -587,7 +589,7 @@ function get_post_class( $class = '', $post_id = null ) { * @param string|string[] $class Space-separated string or array of class names to add to the class list. */ function body_class( $class = '' ) { - // Separates class names with a single space, collates class names for body element + // Separates class names with a single space, collates class names for body element. echo 'class="' . join( ' ', get_body_class( $class ) ) . '"'; } @@ -664,7 +666,7 @@ function get_body_class( $class = '' ) { $classes[] = 'single-' . sanitize_html_class( $post->post_type, $post_id ); $classes[] = 'postid-' . $post_id; - // Post Format + // Post Format. if ( post_type_supports( $post->post_type, 'post-formats' ) ) { $post_format = get_post_format( $post->ID ); @@ -878,7 +880,7 @@ function post_password_required( $post = null ) { } // -// Page Template Functions for usage in Themes +// Page Template Functions for usage in Themes. // /** @@ -1123,7 +1125,7 @@ function the_meta() { } // -// Pages +// Pages. // /** @@ -1175,7 +1177,7 @@ function wp_dropdown_pages( $args = '' ) { $pages = get_pages( $parsed_args ); $output = ''; - // Back-compat with old system where both id and name were based on $name argument + // Back-compat with old system where both id and name were based on $name argument. if ( empty( $parsed_args['id'] ) ) { $parsed_args['id'] = $parsed_args['name']; } @@ -1276,17 +1278,17 @@ function wp_list_pages( $args = '' ) { $parsed_args = wp_parse_args( $args, $defaults ); if ( ! in_array( $parsed_args['item_spacing'], array( 'preserve', 'discard' ), true ) ) { - // invalid value, fall back to default. + // Invalid value, fall back to default. $parsed_args['item_spacing'] = $defaults['item_spacing']; } $output = ''; $current_page = 0; - // sanitize, mostly to keep spaces out + // Sanitize, mostly to keep spaces out. $parsed_args['exclude'] = preg_replace( '/[^0-9,]/', '', $parsed_args['exclude'] ); - // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array) + // Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array). $exclude_array = ( $parsed_args['exclude'] ) ? explode( ',', $parsed_args['exclude'] ) : array(); /** @@ -1394,7 +1396,7 @@ function wp_page_menu( $args = array() ) { $args = wp_parse_args( $args, $defaults ); if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ) ) ) { - // invalid value, fall back to default. + // Invalid value, fall back to default. $args['item_spacing'] = $defaults['item_spacing']; } @@ -1421,7 +1423,7 @@ function wp_page_menu( $args = array() ) { $list_args = $args; - // Show Home in the menu + // Show Home in the menu. if ( ! empty( $args['show_home'] ) ) { if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) { $text = __( 'Home' ); @@ -1433,7 +1435,7 @@ function wp_page_menu( $args = array() ) { $class = 'class="current_page_item"'; } $menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>'; - // If the front page is a page, add it to the exclude list + // If the front page is a page, add it to the exclude list. if ( get_option( 'show_on_front' ) == 'page' ) { if ( ! empty( $list_args['exclude'] ) ) { $list_args['exclude'] .= ','; @@ -1457,7 +1459,7 @@ function wp_page_menu( $args = array() ) { if ( $menu ) { - // wp_nav_menu doesn't set before and after + // wp_nav_menu() doesn't set before and after. if ( isset( $args['fallback_cb'] ) && 'wp_page_menu' === $args['fallback_cb'] && 'ul' !== $container ) { @@ -1499,7 +1501,7 @@ function wp_page_menu( $args = array() ) { } // -// Page helpers +// Page helpers. // /** @@ -1543,7 +1545,7 @@ function walk_page_tree( $pages, $depth, $current_page, $r ) { * @return string */ function walk_page_dropdown_tree( ...$args ) { - if ( empty( $args[2]['walker'] ) ) { // the user's options are the third parameter + if ( empty( $args[2]['walker'] ) ) { // The user's options are the third parameter. $walker = new Walker_PageDropdown; } else { $walker = $args[2]['walker']; @@ -1553,7 +1555,7 @@ function walk_page_dropdown_tree( ...$args ) { } // -// Attachments +// Attachments. // /** @@ -1671,7 +1673,7 @@ function prepend_attachment( $content ) { $p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) ); } else { $p = '<p class="attachment">'; - // show the medium sized image representation of the attachment if available, and link to the raw file + // Show the medium sized image representation of the attachment if available, and link to the raw file. $p .= wp_get_attachment_link( 0, 'medium', false ); $p .= '</p>'; } @@ -1691,7 +1693,7 @@ function prepend_attachment( $content ) { } // -// Misc +// Misc. // /** @@ -1916,7 +1918,7 @@ function wp_list_post_revisions( $post_id = 0, $type = 'all' ) { return; } - // $args array with (parent, format, right, left, type) deprecated since 3.6 + // $args array with (parent, format, right, left, type) deprecated since 3.6. if ( is_array( $type ) ) { $type = ! empty( $type['type'] ) ? $type['type'] : $type; _deprecated_argument( __FUNCTION__, '3.6.0' ); diff --git a/src/wp-includes/post.php b/src/wp-includes/post.php index 3799e73e0a..0e09610521 100644 --- a/src/wp-includes/post.php +++ b/src/wp-includes/post.php @@ -7,7 +7,7 @@ */ // -// Post Type Registration +// Post Type registration. // /** @@ -715,7 +715,7 @@ function get_children( $args = '', $output = OBJECT ) { * } */ function get_extended( $post ) { - //Match the new style more links. + // Match the new style more links. if ( preg_match( '/<!--more(.*?)?-->/', $post, $matches ) ) { list($main, $extended) = explode( $matches[0], $post, 2 ); $more_text = $matches[1]; @@ -725,7 +725,7 @@ function get_extended( $post ) { $more_text = ''; } - // leading and trailing whitespace. + // Leading and trailing whitespace. $main = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $main ); $extended = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $extended ); $more_text = preg_replace( '/^[\s]*(.*)[\s]*$/', '\\1', $more_text ); @@ -1416,7 +1416,7 @@ function register_post_type( $post_type, $args = array() ) { $wp_post_types = array(); } - // Sanitize post type name + // Sanitize post type name. $post_type = sanitize_key( $post_type ); if ( empty( $post_type ) || strlen( $post_type ) > 20 ) { @@ -1558,7 +1558,7 @@ function get_post_type_capabilities( $args ) { list( $singular_base, $plural_base ) = $args->capability_type; $default_capabilities = array( - // Meta capabilities + // Meta capabilities. 'edit_post' => 'edit_' . $singular_base, 'read_post' => 'read_' . $singular_base, 'delete_post' => 'delete_' . $singular_base, @@ -2033,7 +2033,7 @@ function get_posts( $args = null ) { } if ( ! empty( $parsed_args['include'] ) ) { $incposts = wp_parse_id_list( $parsed_args['include'] ); - $parsed_args['posts_per_page'] = count( $incposts ); // only the number of posts included + $parsed_args['posts_per_page'] = count( $incposts ); // Only the number of posts included. $parsed_args['post__in'] = $incposts; } elseif ( ! empty( $parsed_args['exclude'] ) ) { $parsed_args['post__not_in'] = wp_parse_id_list( $parsed_args['exclude'] ); @@ -2048,7 +2048,7 @@ function get_posts( $args = null ) { } // -// Post meta functions +// Post meta functions. // /** @@ -2713,7 +2713,7 @@ function wp_count_attachments( $mime_type = '' ) { * @return array List of post mime types. */ function get_post_mime_types() { - $post_mime_types = array( // array( adj, noun ) + $post_mime_types = array( // array( adj, noun ) 'image' => array( __( 'Images' ), __( 'Manage Images' ), @@ -4274,7 +4274,7 @@ function check_and_publish_future_post( $post_id ) { // Uh oh, someone jumped the gun! if ( $time > time() ) { - wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // clear anything else in the system + wp_clear_scheduled_hook( 'publish_future_post', array( $post_id ) ); // Clear anything else in the system. wp_schedule_single_event( $time, 'publish_future_post', array( $post_id ) ); return; } @@ -4832,7 +4832,7 @@ function trackback_url_list( $tb_list, $post_id ) { } // -// Page functions +// Page functions. // /** @@ -5266,7 +5266,7 @@ function get_pages( $args = array() ) { $inclusions = ''; if ( ! empty( $parsed_args['include'] ) ) { - $child_of = 0; //ignore child_of, parent, exclude, meta_key, and meta_value params if using include + $child_of = 0; // Ignore child_of, parent, exclude, meta_key, and meta_value params if using include. $parent = -1; $exclude = ''; $meta_key = ''; @@ -5292,7 +5292,7 @@ function get_pages( $args = array() ) { if ( ! empty( $post_authors ) ) { foreach ( $post_authors as $post_author ) { - //Do we have an author id or an author login? + // Do we have an author id or an author login? if ( 0 == intval( $post_author ) ) { $post_author = get_user_by( 'login', $post_author ); if ( empty( $post_author ) ) { @@ -5321,7 +5321,7 @@ function get_pages( $args = array() ) { if ( '' !== $meta_key || '' !== $meta_value ) { $join = " LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id )"; - // meta_key and meta_value might be slashed + // meta_key and meta_value might be slashed. $meta_key = wp_unslash( $meta_key ); $meta_value = wp_unslash( $meta_value ); if ( '' !== $meta_key ) { @@ -5461,7 +5461,7 @@ function get_pages( $args = array() ) { wp_cache_set( $cache_key, $page_structure, 'posts' ); - // Convert to WP_Post instances + // Convert to WP_Post instances. $pages = array_map( 'get_post', $pages ); /** @@ -5476,7 +5476,7 @@ function get_pages( $args = array() ) { } // -// Attachment functions +// Attachment functions. // /** @@ -5833,7 +5833,7 @@ function wp_get_attachment_url( $attachment_id = 0 ) { // Replace file location with url location. $url = str_replace( $uploads['basedir'], $uploads['baseurl'], $file ); } elseif ( false !== strpos( $file, 'wp-content/uploads' ) ) { - // Get the directory name relative to the basedir (back compat for pre-2.7 uploads) + // Get the directory name relative to the basedir (back compat for pre-2.7 uploads). $url = trailingslashit( $uploads['baseurl'] . '/' . _wp_get_attachment_relative_path( $file ) ) . wp_basename( $file ); } else { // It's a newly-uploaded file, therefore $file is relative to the basedir. @@ -6353,8 +6353,8 @@ function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, $post_status_sql .= " OR post_status = 'private' AND post_author = $id"; } elseif ( $id == (int) $post_author ) { $post_status_sql .= " OR post_status = 'private'"; - } // else none - } // else none + } // Else none. + } // Else none. } $post_type_clauses[] = "( post_type = '" . $post_type . "' AND ( $post_status_sql ) )"; @@ -6712,7 +6712,7 @@ function clean_attachment_cache( $id, $clean_terms = false ) { } // -// Hooks +// Hooks. // /** @@ -6874,7 +6874,7 @@ function wp_check_post_hierarchy_for_loops( $post_parent, $post_ID ) { // Now look for larger loops. $loop = wp_find_hierarchy_loop( 'wp_get_post_parent_id', $post_ID, $post_parent ); if ( ! $loop ) { - return $post_parent; // No loop + return $post_parent; // No loop. } // Setting $post_parent to the given value causes a loop. diff --git a/src/wp-includes/query.php b/src/wp-includes/query.php index 24b97990b0..f1053aac7b 100644 --- a/src/wp-includes/query.php +++ b/src/wp-includes/query.php @@ -998,7 +998,7 @@ function the_comment() { */ function wp_old_slug_redirect() { if ( is_404() && '' !== get_query_var( 'name' ) ) { - // Guess the current post_type based on the query vars. + // Guess the current post type based on the query vars. if ( get_query_var( 'post_type' ) ) { $post_type = get_query_var( 'post_type' ); } elseif ( get_query_var( 'attachment' ) ) { @@ -1016,7 +1016,7 @@ function wp_old_slug_redirect() { $post_type = reset( $post_type ); } - // Do not attempt redirect for hierarchical post types + // Do not attempt redirect for hierarchical post types. if ( is_post_type_hierarchical( $post_type ) ) { return; } @@ -1061,7 +1061,7 @@ function wp_old_slug_redirect() { return; } - wp_redirect( $link, 301 ); // Permanent redirect + wp_redirect( $link, 301 ); // Permanent redirect. exit; } } @@ -1084,8 +1084,8 @@ function _find_post_by_old_slug( $post_type ) { $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_slug' AND meta_value = %s", $post_type, get_query_var( 'name' ) ); - // if year, monthnum, or day have been specified, make our query more precise - // just in case there are multiple identical _wp_old_slug values + // If year, monthnum, or day have been specified, make our query more precise + // just in case there are multiple identical _wp_old_slug values. if ( get_query_var( 'year' ) ) { $query .= $wpdb->prepare( ' AND YEAR(post_date) = %d', get_query_var( 'year' ) ); } @@ -1133,7 +1133,7 @@ function _find_post_by_old_date( $post_type ) { $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta AS pm_date, $wpdb->posts WHERE ID = post_id AND post_type = %s AND meta_key = '_wp_old_date' AND post_name = %s" . $date_query, $post_type, get_query_var( 'name' ) ) ); if ( ! $id ) { - // Check to see if an old slug matches the old date + // Check to see if an old slug matches the old date. $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts, $wpdb->postmeta AS pm_slug, $wpdb->postmeta AS pm_date WHERE ID = pm_slug.post_id AND ID = pm_date.post_id AND post_type = %s AND pm_slug.meta_key = '_wp_old_slug' AND pm_slug.meta_value = %s AND pm_date.meta_key = '_wp_old_date'" . $date_query, $post_type, get_query_var( 'name' ) ) ); } } diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php index 8fbf4b1342..93fef86042 100644 --- a/src/wp-includes/rest-api.php +++ b/src/wp-includes/rest-api.php @@ -73,6 +73,7 @@ function register_rest_route( $namespace, $route, $args = array(), $override = f 'callback' => null, 'args' => array(), ); + foreach ( $args as $key => &$arg_group ) { if ( ! is_numeric( $key ) ) { // Route option, skip here. @@ -360,7 +361,7 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) { $url .= $path; } else { $url = trailingslashit( get_home_url( $blog_id, '', $scheme ) ); - // nginx only allows HTTP/1.0 methods when redirecting from / to /index.php + // nginx only allows HTTP/1.0 methods when redirecting from / to /index.php. // To work around this, we manually add index.php to the URL, avoiding the redirect. if ( 'index.php' !== substr( $url, 9 ) ) { $url .= 'index.php'; @@ -377,10 +378,11 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) { } if ( is_admin() && force_ssl_admin() ) { - // In this situation the home URL may be http:, and `is_ssl()` may be - // false, but the admin is served over https: (one way or another), so - // REST API usage will be blocked by browsers unless it is also served - // over HTTPS. + /* + * In this situation the home URL may be http:, and `is_ssl()` may be false, + * but the admin is served over https: (one way or another), so REST API usage + * will be blocked by browsers unless it is also served over HTTPS. + */ $url = set_url_scheme( $url, 'https' ); } @@ -581,7 +583,7 @@ function rest_send_cors_headers( $value ) { $origin = get_http_origin(); if ( $origin ) { - // Requests from file:// and data: URLs send "Origin: null" + // Requests from file:// and data: URLs send "Origin: null". if ( 'null' !== $origin ) { $origin = esc_url_raw( $origin ); } @@ -632,7 +634,7 @@ function rest_handle_options_request( $response, $handler, $request ) { } foreach ( $endpoints as $endpoint ) { - // Remove the redundant preg_match argument. + // Remove the redundant preg_match() argument. unset( $args[0] ); $request->set_url_params( $args ); @@ -791,18 +793,20 @@ function rest_is_field_included( $field, $fields ) { if ( in_array( $field, $fields, true ) ) { return true; } + foreach ( $fields as $accepted_field ) { // Check to see if $field is the parent of any item in $fields. // A field "parent" should be accepted if "parent.child" is accepted. if ( strpos( $accepted_field, "$field." ) === 0 ) { return true; } - // Conversely, if "parent" is accepted, all "parent.child" fields should - // also be accepted. + // Conversely, if "parent" is accepted, all "parent.child" fields + // should also be accepted. if ( strpos( $field, "$accepted_field." ) === 0 ) { return true; } } + return false; } @@ -979,9 +983,11 @@ function rest_parse_date( $date, $force_utc = false ) { * null on failure. */ function rest_get_date_with_gmt( $date, $is_utc = false ) { - // Whether or not the original date actually has a timezone string - // changes the way we need to do timezone conversion. Store this info - // before parsing the date, and use it later. + /* + * Whether or not the original date actually has a timezone string + * changes the way we need to do timezone conversion. + * Store this info before parsing the date, and use it later. + */ $has_timezone = preg_match( '#(Z|[+-]\d{2}(:\d{2})?)$#', $date ); $date = rest_parse_date( $date ); @@ -990,10 +996,11 @@ function rest_get_date_with_gmt( $date, $is_utc = false ) { return null; } - // At this point $date could either be a local date (if we were passed a - // *local* date without a timezone offset) or a UTC date (otherwise). - // Timezone conversion needs to be handled differently between these two - // cases. + /* + * At this point $date could either be a local date (if we were passed + * a *local* date without a timezone offset) or a UTC date (otherwise). + * Timezone conversion needs to be handled differently between these two cases. + */ if ( ! $is_utc && ! $has_timezone ) { $local = gmdate( 'Y-m-d H:i:s', $date ); $utc = get_gmt_from_date( $local ); @@ -1228,10 +1235,12 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) { if ( ! is_null( $value ) ) { $value = wp_parse_list( $value ); } + if ( ! wp_is_numeric_array( $value ) ) { /* translators: 1: Parameter, 2: Type name. */ return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'array' ) ); } + foreach ( $value as $index => $v ) { $is_valid = rest_validate_value_from_schema( $v, $args['items'], $param . '[' . $index . ']' ); if ( is_wp_error( $is_valid ) ) { @@ -1390,7 +1399,8 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) { */ function rest_sanitize_value_from_schema( $value, $args ) { if ( is_array( $args['type'] ) ) { - // Determine which type the value was validated against, and use that type when performing sanitization + // Determine which type the value was validated against, + // and use that type when performing sanitization. $validated_type = ''; foreach ( $args['type'] as $type ) { @@ -1414,12 +1424,13 @@ function rest_sanitize_value_from_schema( $value, $args ) { if ( empty( $args['items'] ) ) { return (array) $value; } + $value = wp_parse_list( $value ); foreach ( $value as $index => $v ) { $value[ $index ] = rest_sanitize_value_from_schema( $v, $args['items'] ); } - // Normalize to numeric array so nothing unexpected - // is in the keys. + + // Normalize to numeric array so nothing unexpected is in the keys. $value = array_values( $value ); return $value; } @@ -1474,9 +1485,7 @@ function rest_sanitize_value_from_schema( $value, $args ) { return sanitize_text_field( $value ); case 'email': - /* - * sanitize_email() validates, which would be unexpected. - */ + // sanitize_email() validates, which would be unexpected. return sanitize_text_field( $value ); case 'uri': @@ -1505,7 +1514,8 @@ function rest_sanitize_value_from_schema( $value, $args ) { * @return array Modified reduce accumulator. */ function rest_preload_api_request( $memo, $path ) { - // array_reduce() doesn't support passing an array in PHP 5.2, so we need to make sure we start with one. + // array_reduce() doesn't support passing an array in PHP 5.2, + // so we need to make sure we start with one. if ( ! is_array( $memo ) ) { $memo = array(); } diff --git a/src/wp-includes/rest-api/class-wp-rest-request.php b/src/wp-includes/rest-api/class-wp-rest-request.php index 757ab372d6..d6146127ed 100644 --- a/src/wp-includes/rest-api/class-wp-rest-request.php +++ b/src/wp-includes/rest-api/class-wp-rest-request.php @@ -446,7 +446,7 @@ class WP_REST_Request implements ArrayAccess { $params = array(); foreach ( $order as $type ) { - // array_merge / the "+" operator will mess up + // array_merge() / the "+" operator will mess up // numeric keys, so instead do a manual foreach. foreach ( (array) $this->params[ $type ] as $key => $value ) { $params[ $key ] = $value; @@ -674,6 +674,7 @@ class WP_REST_Request implements ArrayAccess { } $this->params['JSON'] = $params; + return true; } @@ -783,10 +784,12 @@ class WP_REST_Request implements ArrayAccess { if ( empty( $this->params[ $type ] ) ) { continue; } + foreach ( $this->params[ $type ] as $key => $value ) { if ( ! isset( $attributes['args'][ $key ] ) ) { continue; } + $param_args = $attributes['args'][ $key ]; // If the arg has a type but no sanitize_callback attribute, default to rest_parse_request_arg. @@ -988,7 +991,7 @@ class WP_REST_Request implements ArrayAccess { $api_url_part = substr( $url, strlen( untrailingslashit( $api_root ) ) ); $route = parse_url( $api_url_part, PHP_URL_PATH ); } elseif ( ! empty( $query_params['rest_route'] ) ) { - // ?rest_route=... set directly + // ?rest_route=... set directly. $route = $query_params['rest_route']; unset( $query_params['rest_route'] ); } diff --git a/src/wp-includes/rest-api/class-wp-rest-response.php b/src/wp-includes/rest-api/class-wp-rest-response.php index b13e923f51..1a077f17ea 100644 --- a/src/wp-includes/rest-api/class-wp-rest-response.php +++ b/src/wp-includes/rest-api/class-wp-rest-response.php @@ -154,6 +154,7 @@ class WP_REST_Response extends WP_HTTP_Response { if ( 'title' === $key ) { $value = '"' . $value . '"'; } + $header .= '; ' . $key . '=' . $value; } $this->header( 'Link', $header, false ); @@ -231,6 +232,7 @@ class WP_REST_Response extends WP_HTTP_Response { if ( is_array( $this->get_data() ) ) { $data = $this->get_data(); $error->add( $data['code'], $data['message'], $data['data'] ); + if ( ! empty( $data['additional_errors'] ) ) { foreach ( $data['additional_errors'] as $err ) { $error->add( $err['code'], $err['message'], $err['data'] ); @@ -285,6 +287,7 @@ class WP_REST_Response extends WP_HTTP_Response { * @param array $additional Additional CURIEs to register with the API. */ $additional = apply_filters( 'rest_response_link_curies', array() ); + return array_merge( $curies, $additional ); } } diff --git a/src/wp-includes/rest-api/class-wp-rest-server.php b/src/wp-includes/rest-api/class-wp-rest-server.php index bbd930051f..c869bdbc05 100644 --- a/src/wp-includes/rest-api/class-wp-rest-server.php +++ b/src/wp-includes/rest-api/class-wp-rest-server.php @@ -414,10 +414,16 @@ class WP_REST_Server { $result = wp_json_encode( $result ); $json_error_message = $this->get_json_last_error(); + if ( $json_error_message ) { - $json_error_obj = new WP_Error( 'rest_encode_error', $json_error_message, array( 'status' => 500 ) ); - $result = $this->error_to_response( $json_error_obj ); - $result = wp_json_encode( $result->data[0] ); + $json_error_obj = new WP_Error( + 'rest_encode_error', + $json_error_message, + array( 'status' => 500 ) + ); + + $result = $this->error_to_response( $json_error_obj ); + $result = wp_json_encode( $result->data[0] ); } if ( $jsonp_callback ) { @@ -428,6 +434,7 @@ class WP_REST_Server { echo $result; } } + return null; } @@ -453,6 +460,7 @@ class WP_REST_Server { // Convert links to part of the data. $data['_links'] = $links; } + if ( $embed ) { // Determine if this is a numeric array. if ( wp_is_numeric_array( $data ) ) { @@ -478,6 +486,7 @@ class WP_REST_Server { */ public static function get_response_links( $response ) { $links = $response->get_links(); + if ( empty( $links ) ) { return array(); } @@ -846,6 +855,7 @@ class WP_REST_Server { } $args = array(); + foreach ( $matches as $param => $value ) { if ( ! is_int( $param ) ) { $args[ $param ] = $value; @@ -866,7 +876,11 @@ class WP_REST_Server { } if ( ! is_callable( $callback ) ) { - $response = new WP_Error( 'rest_invalid_handler', __( 'The handler for the route is invalid' ), array( 'status' => 500 ) ); + $response = new WP_Error( + 'rest_invalid_handler', + __( 'The handler for the route is invalid' ), + array( 'status' => 500 ) + ); } if ( ! is_wp_error( $response ) ) { @@ -923,7 +937,11 @@ class WP_REST_Server { if ( is_wp_error( $permission ) ) { $response = $permission; } elseif ( false === $permission || null === $permission ) { - $response = new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to do that.' ), array( 'status' => rest_authorization_required_code() ) ); + $response = new WP_Error( + 'rest_forbidden', + __( 'Sorry, you are not allowed to do that.' ), + array( 'status' => rest_authorization_required_code() ) + ); } } } @@ -987,7 +1005,13 @@ class WP_REST_Server { } } - return $this->error_to_response( new WP_Error( 'rest_no_route', __( 'No route was found matching the URL and request method' ), array( 'status' => 404 ) ) ); + return $this->error_to_response( + new WP_Error( + 'rest_no_route', + __( 'No route was found matching the URL and request method' ), + array( 'status' => 404 ) + ) + ); } /** @@ -1069,7 +1093,11 @@ class WP_REST_Server { $namespace = $request['namespace']; if ( ! isset( $this->namespaces[ $namespace ] ) ) { - return new WP_Error( 'rest_invalid_namespace', __( 'The specified namespace could not be found.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_invalid_namespace', + __( 'The specified namespace could not be found.' ), + array( 'status' => 404 ) + ); } $routes = $this->namespaces[ $namespace ]; @@ -1186,6 +1214,7 @@ class WP_REST_Server { if ( isset( $callback['args'] ) ) { $endpoint_data['args'] = array(); + foreach ( $callback['args'] as $key => $opts ) { $arg_data = array( 'required' => ! empty( $opts['required'] ), diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index 253b1f86e5..1d78928fc4 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -94,7 +94,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { } if ( ! current_user_can( 'upload_files' ) ) { - return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to upload media on this site.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_cannot_create', + __( 'Sorry, you are not allowed to upload media on this site.' ), + array( 'status' => 400 ) + ); } // Attaching media to a post requires ability to edit said post. @@ -103,7 +107,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $post_parent_type = get_post_type_object( $parent->post_type ); if ( ! current_user_can( $post_parent_type->cap->edit_post, $request['post'] ) ) { - return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to upload media to this post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_edit', + __( 'Sorry, you are not allowed to upload media to this post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } } @@ -119,9 +127,12 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { * @return WP_REST_Response|WP_Error Response object on success, WP_Error object on failure. */ public function create_item( $request ) { - if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) { - return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_param', + __( 'Invalid parent type.' ), + array( 'status' => 400 ) + ); } $insert = $this->insert_attachment( $request ); @@ -213,7 +224,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { // Include image functions to get access to wp_read_image_metadata(). require_once ABSPATH . 'wp-admin/includes/image.php'; - // use image exif/iptc data for title and caption defaults if possible + // Use image exif/iptc data for title and caption defaults if possible. $image_meta = wp_read_image_metadata( $file ); if ( ! empty( $image_meta ) ) { @@ -278,7 +289,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { */ public function update_item( $request ) { if ( ! empty( $request['post'] ) && in_array( get_post_type( $request['post'] ), array( 'revision', 'attachment' ), true ) ) { - return new WP_Error( 'rest_invalid_param', __( 'Invalid parent type.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_param', + __( 'Invalid parent type.' ), + array( 'status' => 400 ) + ); } $response = parent::update_item( $request ); @@ -357,7 +372,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { protected function prepare_item_for_database( $request ) { $prepared_attachment = parent::prepare_item_for_database( $request ); - // Attachment caption (post_excerpt internally) + // Attachment caption (post_excerpt internally). if ( isset( $request['caption'] ) ) { if ( is_string( $request['caption'] ) ) { $prepared_attachment->post_excerpt = $request['caption']; @@ -366,7 +381,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { } } - // Attachment description (post_content internally) + // Attachment description (post_content internally). if ( isset( $request['description'] ) ) { if ( is_string( $request['description'] ) ) { $prepared_attachment->post_content = $request['description']; @@ -539,8 +554,8 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( - 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database() - 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database() + 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database(). + 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database(). ), 'properties' => array( 'raw' => array( @@ -562,8 +577,8 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 'type' => 'object', 'context' => array( 'view', 'edit' ), 'arg_options' => array( - 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database() - 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database() + 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database(). + 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database(). ), 'properties' => array( 'raw' => array( @@ -627,6 +642,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { unset( $schema['properties']['password'] ); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } @@ -641,21 +657,37 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { */ protected function upload_from_data( $data, $headers ) { if ( empty( $data ) ) { - return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_upload_no_data', + __( 'No data supplied.' ), + array( 'status' => 400 ) + ); } if ( empty( $headers['content_type'] ) ) { - return new WP_Error( 'rest_upload_no_content_type', __( 'No Content-Type supplied.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_upload_no_content_type', + __( 'No Content-Type supplied.' ), + array( 'status' => 400 ) + ); } if ( empty( $headers['content_disposition'] ) ) { - return new WP_Error( 'rest_upload_no_content_disposition', __( 'No Content-Disposition supplied.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_upload_no_content_disposition', + __( 'No Content-Disposition supplied.' ), + array( 'status' => 400 ) + ); } $filename = self::get_filename_from_disposition( $headers['content_disposition'] ); if ( empty( $filename ) ) { - return new WP_Error( 'rest_upload_invalid_disposition', __( 'Invalid Content-Disposition supplied. Content-Disposition needs to be formatted as `attachment; filename="image.png"` or similar.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_upload_invalid_disposition', + __( 'Invalid Content-Disposition supplied. Content-Disposition needs to be formatted as `attachment; filename="image.png"` or similar.' ), + array( 'status' => 400 ) + ); } if ( ! empty( $headers['content_md5'] ) ) { @@ -664,7 +696,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $actual = md5( $data ); if ( $expected !== $actual ) { - return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) ); + return new WP_Error( + 'rest_upload_hash_mismatch', + __( 'Content hash did not match expected.' ), + array( 'status' => 412 ) + ); } } @@ -680,7 +716,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $fp = fopen( $tmpfname, 'w+' ); if ( ! $fp ) { - return new WP_Error( 'rest_upload_file_error', __( 'Could not open file handle.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_upload_file_error', + __( 'Could not open file handle.' ), + array( 'status' => 500 ) + ); } fwrite( $fp, $data ); @@ -708,7 +748,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { if ( isset( $sideloaded['error'] ) ) { @unlink( $tmpfname ); - return new WP_Error( 'rest_upload_sideload_error', $sideloaded['error'], array( 'status' => 500 ) ); + return new WP_Error( + 'rest_upload_sideload_error', + $sideloaded['error'], + array( 'status' => 500 ) + ); } return $sideloaded; @@ -824,7 +868,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { */ protected function upload_from_file( $files, $headers ) { if ( empty( $files ) ) { - return new WP_Error( 'rest_upload_no_data', __( 'No data supplied.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_upload_no_data', + __( 'No data supplied.' ), + array( 'status' => 400 ) + ); } // Verify hash, if given. @@ -834,7 +882,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $actual = md5_file( $files['file']['tmp_name'] ); if ( $expected !== $actual ) { - return new WP_Error( 'rest_upload_hash_mismatch', __( 'Content hash did not match expected.' ), array( 'status' => 412 ) ); + return new WP_Error( + 'rest_upload_hash_mismatch', + __( 'Content hash did not match expected.' ), + array( 'status' => 412 ) + ); } } @@ -859,7 +911,11 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $file = wp_handle_upload( $files['file'], $overrides ); if ( isset( $file['error'] ) ) { - return new WP_Error( 'rest_upload_unknown_error', $file['error'], array( 'status' => 500 ) ); + return new WP_Error( + 'rest_upload_unknown_error', + $file['error'], + array( 'status' => 500 ) + ); } return $file; @@ -912,22 +968,36 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { $space_left = get_upload_space_available(); $file_size = filesize( $file['tmp_name'] ); + if ( $space_left < $file_size ) { - /* translators: %s: Required disk space in kilobytes. */ - return new WP_Error( 'rest_upload_limited_space', sprintf( __( 'Not enough space to upload. %s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_upload_limited_space', + /* translators: %s: Required disk space in kilobytes. */ + sprintf( __( 'Not enough space to upload. %s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) ), + array( 'status' => 400 ) + ); } if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { - /* translators: %s: Maximum allowed file size in kilobytes. */ - return new WP_Error( 'rest_upload_file_too_big', sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_upload_file_too_big', + /* translators: %s: Maximum allowed file size in kilobytes. */ + sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) ), + array( 'status' => 400 ) + ); } // Include admin function to get access to upload_is_user_over_quota(). require_once ABSPATH . 'wp-admin/includes/ms.php'; if ( upload_is_user_over_quota( false ) ) { - return new WP_Error( 'rest_upload_user_quota_exceeded', __( 'You have used your space quota. Please delete files before uploading.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_upload_user_quota_exceeded', + __( 'You have used your space quota. Please delete files before uploading.' ), + array( 'status' => 400 ) + ); } + return true; } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php index a72541a1ee..af5f51f74f 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php @@ -161,8 +161,13 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { } $parent_post_type_obj = get_post_type_object( $parent->post_type ); + if ( ! current_user_can( $parent_post_type_obj->cap->edit_post, $parent->ID ) ) { - return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to view autosaves of this post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read', + __( 'Sorry, you are not allowed to view autosaves of this post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -181,8 +186,13 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { */ public function create_item_permissions_check( $request ) { $id = $request->get_param( 'id' ); + if ( empty( $id ) ) { - return new WP_Error( 'rest_post_invalid_id', __( 'Invalid item ID.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_post_invalid_id', + __( 'Invalid item ID.' ), + array( 'status' => 404 ) + ); } return $this->parent_controller->update_item_permissions_check( $request ); @@ -214,7 +224,7 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { if ( ( 'draft' === $post->post_status || 'auto-draft' === $post->post_status ) && $post->post_author == $user_id ) { // Draft posts for the same author: autosaving updates the post and does not create a revision. - // Convert the post object to an array and add slashes, wp_update_post expects escaped array. + // Convert the post object to an array and add slashes, wp_update_post() expects escaped array. $autosave_id = wp_update_post( wp_slash( (array) $prepared_post ), true ); } else { // Non-draft posts: create or update the post autosave. @@ -246,13 +256,21 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { $parent_id = (int) $request->get_param( 'parent' ); if ( $parent_id <= 0 ) { - return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_post_invalid_id', + __( 'Invalid post parent ID.' ), + array( 'status' => 404 ) + ); } $autosave = wp_get_post_autosave( $parent_id ); if ( ! $autosave ) { - return new WP_Error( 'rest_post_no_autosave', __( 'There is no autosave revision for this post.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_post_no_autosave', + __( 'There is no autosave revision for this post.' ), + array( 'status' => 404 ) + ); } $response = $this->prepare_item_for_response( $autosave, $request ); @@ -313,6 +331,7 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { ); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } @@ -357,13 +376,17 @@ class WP_REST_Autosaves_Controller extends WP_REST_Revisions_Controller { if ( ! $autosave_is_different ) { wp_delete_post_revision( $old_autosave->ID ); - return new WP_Error( 'rest_autosave_no_changes', __( 'There is nothing to save. The autosave and the post content are the same.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_autosave_no_changes', + __( 'There is nothing to save. The autosave and the post content are the same.' ), + array( 'status' => 400 ) + ); } /** This filter is documented in wp-admin/post.php */ do_action( 'wp_creating_autosave', $new_autosave ); - // wp_update_post expects escaped array. + // wp_update_post() expects escaped array. return wp_update_post( wp_slash( $new_autosave ) ); } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php index b5b3323b4c..2f901f9230 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php @@ -150,6 +150,7 @@ class WP_REST_Block_Renderer_Controller extends WP_REST_Controller { $data = array( 'rendered' => $block->render( $request->get_param( 'attributes' ) ), ); + return rest_ensure_response( $data ); } @@ -178,6 +179,7 @@ class WP_REST_Block_Renderer_Controller extends WP_REST_Controller { ), ), ); + return $this->schema; } } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index e05f9802ea..fc9f03822b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -127,15 +127,27 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $post = get_post( $post_id ); if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post, $request ) ) { - return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read_post', + __( 'Sorry, you are not allowed to read the post for this comment.' ), + array( 'status' => rest_authorization_required_code() ) + ); } elseif ( 0 === $post_id && ! current_user_can( 'moderate_comments' ) ) { - return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read comments without a post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read', + __( 'Sorry, you are not allowed to read comments without a post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } } } if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to edit comments.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( ! current_user_can( 'edit_posts' ) ) { @@ -322,7 +334,12 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { * @return WP_Comment|WP_Error Comment object if ID is valid, WP_Error otherwise. */ protected function get_comment( $id ) { - $error = new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment ID.' ), array( 'status' => 404 ) ); + $error = new WP_Error( + 'rest_comment_invalid_id', + __( 'Invalid comment ID.' ), + array( 'status' => 404 ) + ); + if ( (int) $id <= 0 ) { return $error; } @@ -335,8 +352,13 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { if ( ! empty( $comment->comment_post_ID ) ) { $post = get_post( (int) $comment->comment_post_ID ); + if ( empty( $post ) ) { - return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_post_invalid_id', + __( 'Invalid post ID.' ), + array( 'status' => 404 ) + ); } } @@ -358,17 +380,29 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } if ( ! empty( $request['context'] ) && 'edit' === $request['context'] && ! current_user_can( 'moderate_comments' ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit comments.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to edit comments.' ), + array( 'status' => rest_authorization_required_code() ) + ); } $post = get_post( $comment->comment_post_ID ); if ( ! $this->check_read_permission( $comment, $request ) ) { - return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to read this comment.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read', + __( 'Sorry, you are not allowed to read this comment.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( $post && ! $this->check_read_post_permission( $post, $request ) ) { - return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read_post', + __( 'Sorry, you are not allowed to read the post for this comment.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -405,7 +439,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { public function create_item_permissions_check( $request ) { if ( ! is_user_logged_in() ) { if ( get_option( 'comment_registration' ) ) { - return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) ); + return new WP_Error( + 'rest_comment_login_required', + __( 'Sorry, you must be logged in to comment.' ), + array( 'status' => 401 ) + ); } /** @@ -421,8 +459,13 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { * response. */ $allow_anonymous = apply_filters( 'rest_allow_anonymous_comments', false, $request ); + if ( ! $allow_anonymous ) { - return new WP_Error( 'rest_comment_login_required', __( 'Sorry, you must be logged in to comment.' ), array( 'status' => 401 ) ); + return new WP_Error( + 'rest_comment_login_required', + __( 'Sorry, you must be logged in to comment.' ), + array( 'status' => 401 ) + ); } } @@ -457,28 +500,53 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } if ( empty( $request['post'] ) ) { - return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) ); + return new WP_Error( + 'rest_comment_invalid_post_id', + __( 'Sorry, you are not allowed to create this comment without a post.' ), + array( 'status' => 403 ) + ); } $post = get_post( (int) $request['post'] ); + if ( ! $post ) { - return new WP_Error( 'rest_comment_invalid_post_id', __( 'Sorry, you are not allowed to create this comment without a post.' ), array( 'status' => 403 ) ); + return new WP_Error( + 'rest_comment_invalid_post_id', + __( 'Sorry, you are not allowed to create this comment without a post.' ), + array( 'status' => 403 ) + ); } if ( 'draft' === $post->post_status ) { - return new WP_Error( 'rest_comment_draft_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) ); + return new WP_Error( + 'rest_comment_draft_post', + __( 'Sorry, you are not allowed to create a comment on this post.' ), + array( 'status' => 403 ) + ); } if ( 'trash' === $post->post_status ) { - return new WP_Error( 'rest_comment_trash_post', __( 'Sorry, you are not allowed to create a comment on this post.' ), array( 'status' => 403 ) ); + return new WP_Error( + 'rest_comment_trash_post', + __( 'Sorry, you are not allowed to create a comment on this post.' ), + array( 'status' => 403 ) + ); } if ( ! $this->check_read_post_permission( $post, $request ) ) { - return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you are not allowed to read the post for this comment.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read_post', + __( 'Sorry, you are not allowed to read the post for this comment.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( ! comments_open( $post->ID ) ) { - return new WP_Error( 'rest_comment_closed', __( 'Sorry, comments are closed for this item.' ), array( 'status' => 403 ) ); + return new WP_Error( + 'rest_comment_closed', + __( 'Sorry, comments are closed for this item.' ), + array( 'status' => 403 ) + ); } return true; @@ -494,12 +562,20 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { */ public function create_item( $request ) { if ( ! empty( $request['id'] ) ) { - return new WP_Error( 'rest_comment_exists', __( 'Cannot create existing comment.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_comment_exists', + __( 'Cannot create existing comment.' ), + array( 'status' => 400 ) + ); } // Do not allow comments to be created with a non-default type. if ( ! empty( $request['type'] ) && 'comment' !== $request['type'] ) { - return new WP_Error( 'rest_invalid_comment_type', __( 'Cannot create a comment with that type.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_comment_type', + __( 'Cannot create a comment with that type.' ), + array( 'status' => 400 ) + ); } $prepared_comment = $this->prepare_item_for_database( $request ); @@ -514,7 +590,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { * comment_content. See wp_handle_comment_submission(). */ if ( empty( $prepared_comment['comment_content'] ) ) { - return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_comment_content_invalid', + __( 'Invalid comment content.' ), + array( 'status' => 400 ) + ); } // Setting remaining values before wp_insert_comment so we can use wp_allow_comment(). @@ -540,7 +620,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { // Honor the discussion setting that requires a name and email address of the comment author. if ( get_option( 'require_name_email' ) ) { if ( empty( $prepared_comment['comment_author'] ) || empty( $prepared_comment['comment_author_email'] ) ) { - return new WP_Error( 'rest_comment_author_data_required', __( 'Creating a comment requires valid author name and email values.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_comment_author_data_required', + __( 'Creating a comment requires valid author name and email values.' ), + array( 'status' => 400 ) + ); } } @@ -557,9 +641,14 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_comment ); + if ( is_wp_error( $check_comment_lengths ) ) { $error_code = $check_comment_lengths->get_error_code(); - return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) ); + return new WP_Error( + $error_code, + __( 'Comment field exceeds maximum length allowed.' ), + array( 'status' => 400 ) + ); } $prepared_comment['comment_approved'] = wp_allow_comment( $prepared_comment, true ); @@ -569,11 +658,19 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $error_message = $prepared_comment['comment_approved']->get_error_message(); if ( 'comment_duplicate' === $error_code ) { - return new WP_Error( $error_code, $error_message, array( 'status' => 409 ) ); + return new WP_Error( + $error_code, + $error_message, + array( 'status' => 409 ) + ); } if ( 'comment_flood' === $error_code ) { - return new WP_Error( $error_code, $error_message, array( 'status' => 400 ) ); + return new WP_Error( + $error_code, + $error_message, + array( 'status' => 400 ) + ); } return $prepared_comment['comment_approved']; @@ -600,7 +697,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) ); if ( ! $comment_id ) { - return new WP_Error( 'rest_comment_failed_create', __( 'Creating comment failed.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_comment_failed_create', + __( 'Creating comment failed.' ), + array( 'status' => 500 ) + ); } if ( isset( $request['status'] ) ) { @@ -676,7 +777,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } if ( ! $this->check_edit_permission( $comment ) ) { - return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this comment.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_edit', + __( 'Sorry, you are not allowed to edit this comment.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -699,7 +804,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $id = $comment->comment_ID; if ( isset( $request['type'] ) && get_comment_type( $id ) !== $request['type'] ) { - return new WP_Error( 'rest_comment_invalid_type', __( 'Sorry, you are not allowed to change the comment type.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_comment_invalid_type', + __( 'Sorry, you are not allowed to change the comment type.' ), + array( 'status' => 404 ) + ); } $prepared_args = $this->prepare_item_for_database( $request ); @@ -710,8 +819,13 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { if ( ! empty( $prepared_args['comment_post_ID'] ) ) { $post = get_post( $prepared_args['comment_post_ID'] ); + if ( empty( $post ) ) { - return new WP_Error( 'rest_comment_invalid_post_id', __( 'Invalid post ID.' ), array( 'status' => 403 ) ); + return new WP_Error( + 'rest_comment_invalid_post_id', + __( 'Invalid post ID.' ), + array( 'status' => 403 ) + ); } } @@ -720,7 +834,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $change = $this->handle_status_param( $request['status'], $id ); if ( ! $change ) { - return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment status failed.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_comment_failed_edit', + __( 'Updating comment status failed.' ), + array( 'status' => 500 ) + ); } } elseif ( ! empty( $prepared_args ) ) { if ( is_wp_error( $prepared_args ) ) { @@ -728,21 +846,34 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } if ( isset( $prepared_args['comment_content'] ) && empty( $prepared_args['comment_content'] ) ) { - return new WP_Error( 'rest_comment_content_invalid', __( 'Invalid comment content.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_comment_content_invalid', + __( 'Invalid comment content.' ), + array( 'status' => 400 ) + ); } $prepared_args['comment_ID'] = $id; $check_comment_lengths = wp_check_comment_data_max_lengths( $prepared_args ); + if ( is_wp_error( $check_comment_lengths ) ) { $error_code = $check_comment_lengths->get_error_code(); - return new WP_Error( $error_code, __( 'Comment field exceeds maximum length allowed.' ), array( 'status' => 400 ) ); + return new WP_Error( + $error_code, + __( 'Comment field exceeds maximum length allowed.' ), + array( 'status' => 400 ) + ); } $updated = wp_update_comment( wp_slash( (array) $prepared_args ) ); if ( false === $updated ) { - return new WP_Error( 'rest_comment_failed_edit', __( 'Updating comment failed.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_comment_failed_edit', + __( 'Updating comment failed.' ), + array( 'status' => 500 ) + ); } if ( isset( $request['status'] ) ) { @@ -796,7 +927,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } if ( ! $this->check_edit_permission( $comment ) ) { - return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this comment.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'Sorry, you are not allowed to delete this comment.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; } @@ -844,12 +979,20 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } else { // If this type doesn't support trashing, error out. if ( ! $supports_trash ) { - /* translators: %s: force=true */ - return new WP_Error( 'rest_trash_not_supported', sprintf( __( "The comment does not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); + return new WP_Error( + 'rest_trash_not_supported', + /* translators: %s: force=true */ + sprintf( __( "The comment does not support trashing. Set '%s' to delete." ), 'force=true' ), + array( 'status' => 501 ) + ); } if ( 'trash' === $comment->comment_approved ) { - return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.' ), array( 'status' => 410 ) ); + return new WP_Error( + 'rest_already_trashed', + __( 'The comment has already been trashed.' ), + array( 'status' => 410 ) + ); } $result = wp_trash_comment( $comment->comment_ID ); @@ -858,7 +1001,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { } if ( ! $result ) { - return new WP_Error( 'rest_cannot_delete', __( 'The comment cannot be deleted.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'The comment cannot be deleted.' ), + array( 'status' => 500 ) + ); } /** @@ -1155,7 +1302,11 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $prepared_comment['comment_author_email'] = $user->user_email; $prepared_comment['comment_author_url'] = $user->user_url; } else { - return new WP_Error( 'rest_comment_author_invalid', __( 'Invalid comment author ID.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_comment_author_invalid', + __( 'Invalid comment author ID.' ), + array( 'status' => 400 ) + ); } } @@ -1247,7 +1398,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { 'context' => array( 'edit' ), 'arg_options' => array( 'sanitize_callback' => array( $this, 'check_comment_author_email' ), - 'validate_callback' => null, // skip built-in validation of 'email'. + 'validate_callback' => null, // Skip built-in validation of 'email'. ), ), 'author_ip' => array( @@ -1283,8 +1434,8 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( - 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database() - 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database() + 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database(). + 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database(). ), 'properties' => array( 'raw' => array( @@ -1352,6 +1503,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $avatar_properties = array(); $avatar_sizes = rest_get_avatar_sizes(); + foreach ( $avatar_sizes as $size ) { $avatar_properties[ $size ] = array( /* translators: %d: Avatar image size in pixels. */ @@ -1374,6 +1526,7 @@ class WP_REST_Comments_Controller extends WP_REST_Controller { $schema['properties']['meta'] = $this->meta->get_field_schema(); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php index 90b97f0f3b..dd40d93d2b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php @@ -44,8 +44,12 @@ abstract class WP_REST_Controller { * @since 4.7.0 */ public function register_routes() { - /* translators: %s: register_routes() */ - _doing_it_wrong( 'WP_REST_Controller::register_routes', sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ), '4.7' ); + _doing_it_wrong( + 'WP_REST_Controller::register_routes', + /* translators: %s: register_routes() */ + sprintf( __( "Method '%s' must be overridden." ), __METHOD__ ), + '4.7' + ); } /** @@ -57,8 +61,12 @@ abstract class WP_REST_Controller { * @return true|WP_Error True if the request has read access, WP_Error object otherwise. */ public function get_items_permissions_check( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -70,8 +78,12 @@ abstract class WP_REST_Controller { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function get_items( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -83,8 +95,12 @@ abstract class WP_REST_Controller { * @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise. */ public function get_item_permissions_check( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -96,8 +112,12 @@ abstract class WP_REST_Controller { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function get_item( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -109,8 +129,12 @@ abstract class WP_REST_Controller { * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise. */ public function create_item_permissions_check( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -122,8 +146,12 @@ abstract class WP_REST_Controller { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function create_item( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -135,8 +163,12 @@ abstract class WP_REST_Controller { * @return true|WP_Error True if the request has access to update the item, WP_Error object otherwise. */ public function update_item_permissions_check( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -148,8 +180,12 @@ abstract class WP_REST_Controller { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function update_item( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -161,8 +197,12 @@ abstract class WP_REST_Controller { * @return true|WP_Error True if the request has access to delete the item, WP_Error object otherwise. */ public function delete_item_permissions_check( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -174,8 +214,12 @@ abstract class WP_REST_Controller { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function delete_item( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -187,8 +231,12 @@ abstract class WP_REST_Controller { * @return object|WP_Error The prepared item, or WP_Error object on failure. */ protected function prepare_item_for_database( $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -201,8 +249,12 @@ abstract class WP_REST_Controller { * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function prepare_item_for_response( $item, $request ) { - /* translators: %s: Method name. */ - return new WP_Error( 'invalid-method', sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), array( 'status' => 405 ) ); + return new WP_Error( + 'invalid-method', + /* translators: %s: Method name. */ + sprintf( __( "Method '%s' not implemented. Must be overridden in subclass." ), __METHOD__ ), + array( 'status' => 405 ) + ); } /** @@ -391,7 +443,6 @@ abstract class WP_REST_Controller { $requested_fields = $this->get_fields_for_response( $request ); foreach ( $additional_fields as $field_name => $field_options ) { - if ( ! $field_options['get_callback'] ) { continue; } @@ -529,6 +580,7 @@ abstract class WP_REST_Controller { $properties = isset( $schema['properties'] ) ? $schema['properties'] : array(); $additional_fields = $this->get_additional_fields(); + foreach ( $additional_fields as $field_name => $field_options ) { // For back-compat, include any field with an empty schema // because it won't be present in $this->get_item_schema(). @@ -572,8 +624,8 @@ abstract class WP_REST_Controller { } // Check for nested fields if $field is not a direct match. $nested_fields = explode( '.', $field ); - // A nested field is included so long as its top-level property is - // present in the schema. + // A nested field is included so long as its top-level property + // is present in the schema. if ( in_array( $nested_fields[0], $fields, true ) ) { $response_fields[] = $field; } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php index ccb44b7b80..fede70d6cf 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php @@ -90,7 +90,11 @@ class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { } } - return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to manage post statuses.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_view', + __( 'Sorry, you are not allowed to manage post statuses.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -135,13 +139,21 @@ class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { $status = get_post_status_object( $request['status'] ); if ( empty( $status ) ) { - return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_status_invalid', + __( 'Invalid status.' ), + array( 'status' => 404 ) + ); } $check = $this->check_read_permission( $status ); if ( ! $check ) { - return new WP_Error( 'rest_cannot_read_status', __( 'Cannot view status.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read_status', + __( 'Cannot view status.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -185,7 +197,11 @@ class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { $obj = get_post_status_object( $request['status'] ); if ( empty( $obj ) ) { - return new WP_Error( 'rest_status_invalid', __( 'Invalid status.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_status_invalid', + __( 'Invalid status.' ), + array( 'status' => 404 ) + ); } $data = $this->prepare_item_for_response( $obj, $request ); @@ -334,6 +350,7 @@ class WP_REST_Post_Statuses_Controller extends WP_REST_Controller { ); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php index 9b079fbf0c..fd9759d79e 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php @@ -89,7 +89,11 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller { } } - return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_view', + __( 'Sorry, you are not allowed to edit posts in this post type.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -131,15 +135,27 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller { $obj = get_post_type_object( $request['type'] ); if ( empty( $obj ) ) { - return new WP_Error( 'rest_type_invalid', __( 'Invalid post type.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_type_invalid', + __( 'Invalid post type.' ), + array( 'status' => 404 ) + ); } if ( empty( $obj->show_in_rest ) ) { - return new WP_Error( 'rest_cannot_read_type', __( 'Cannot view post type.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read_type', + __( 'Cannot view post type.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to edit posts in this post type.' ), + array( 'status' => rest_authorization_required_code() ) + ); } $data = $this->prepare_item_for_response( $obj, $request ); @@ -321,6 +337,7 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller { ); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index ffac007c82..0f27070c3b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -138,7 +138,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $post_type = get_post_type_object( $this->post_type ); if ( 'edit' === $request['context'] && ! current_user_can( $post_type->cap->edit_posts ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to edit posts in this post type.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -156,12 +160,20 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { // Ensure a search string is set in case the orderby is set to 'relevance'. if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) ) { - return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_no_search_term_defined', + __( 'You need to define a search term to order by relevance.' ), + array( 'status' => 400 ) + ); } // Ensure an include parameter is set in case the orderby is set to 'include'. if ( ! empty( $request['orderby'] ) && 'include' === $request['orderby'] && empty( $request['include'] ) ) { - return new WP_Error( 'rest_orderby_include_missing_include', __( 'You need to define an include parameter to order by include.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_orderby_include_missing_include', + __( 'You need to define an include parameter to order by include.' ), + array( 'status' => 400 ) + ); } // Retrieve the list of registered collection query parameters. @@ -337,7 +349,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $max_pages = ceil( $total_posts / (int) $posts_query->query_vars['posts_per_page'] ); if ( $page > $max_pages && $total_posts > 0 ) { - return new WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_post_invalid_page_number', + __( 'The page number requested is larger than the number of pages available.' ), + array( 'status' => 400 ) + ); } $response = rest_ensure_response( $posts ); @@ -377,7 +393,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise. */ protected function get_post( $id ) { - $error = new WP_Error( 'rest_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) ); + $error = new WP_Error( + 'rest_post_invalid_id', + __( 'Invalid post ID.' ), + array( 'status' => 404 ) + ); + if ( (int) $id <= 0 ) { return $error; } @@ -405,13 +426,21 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } if ( 'edit' === $request['context'] && $post && ! $this->check_update_permission( $post ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to edit this post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( $post && ! empty( $request['password'] ) ) { // Check post password, and return error if invalid. if ( ! hash_equals( $post->post_password, $request['password'] ) ) { - return new WP_Error( 'rest_post_incorrect_password', __( 'Incorrect post password.' ), array( 'status' => 403 ) ); + return new WP_Error( + 'rest_post_incorrect_password', + __( 'Incorrect post password.' ), + array( 'status' => 403 ) + ); } } @@ -493,25 +522,45 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { */ public function create_item_permissions_check( $request ) { if ( ! empty( $request['id'] ) ) { - return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_post_exists', + __( 'Cannot create existing post.' ), + array( 'status' => 400 ) + ); } $post_type = get_post_type_object( $this->post_type ); if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) { - return new WP_Error( 'rest_cannot_edit_others', __( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_edit_others', + __( 'Sorry, you are not allowed to create posts as this user.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) { - return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_assign_sticky', + __( 'Sorry, you are not allowed to make posts sticky.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( ! current_user_can( $post_type->cap->create_posts ) ) { - return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create posts as this user.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_create', + __( 'Sorry, you are not allowed to create posts as this user.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( ! $this->check_assign_terms_permission( $request ) ) { - return new WP_Error( 'rest_cannot_assign_term', __( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_assign_term', + __( 'Sorry, you are not allowed to assign the provided terms.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -527,7 +576,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { */ public function create_item( $request ) { if ( ! empty( $request['id'] ) ) { - return new WP_Error( 'rest_post_exists', __( 'Cannot create existing post.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_post_exists', + __( 'Cannot create existing post.' ), + array( 'status' => 400 ) + ); } $prepared_post = $this->prepare_item_for_database( $request ); @@ -650,19 +703,35 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $post_type = get_post_type_object( $this->post_type ); if ( $post && ! $this->check_update_permission( $post ) ) { - return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_edit', + __( 'Sorry, you are not allowed to edit this post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) { - return new WP_Error( 'rest_cannot_edit_others', __( 'Sorry, you are not allowed to update posts as this user.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_edit_others', + __( 'Sorry, you are not allowed to update posts as this user.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( ! empty( $request['sticky'] ) && ! current_user_can( $post_type->cap->edit_others_posts ) && ! current_user_can( $post_type->cap->publish_posts ) ) { - return new WP_Error( 'rest_cannot_assign_sticky', __( 'Sorry, you are not allowed to make posts sticky.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_assign_sticky', + __( 'Sorry, you are not allowed to make posts sticky.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( ! $this->check_assign_terms_permission( $request ) ) { - return new WP_Error( 'rest_cannot_assign_term', __( 'Sorry, you are not allowed to assign the provided terms.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_assign_term', + __( 'Sorry, you are not allowed to assign the provided terms.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -688,7 +757,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { return $post; } - // convert the post object to an array, otherwise wp_update_post will expect non-escaped input. + // Convert the post object to an array, otherwise wp_update_post() will expect non-escaped input. $post_id = wp_update_post( wp_slash( (array) $post ), true ); if ( is_wp_error( $post_id ) ) { @@ -779,7 +848,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } if ( $post && ! $this->check_delete_permission( $post ) ) { - return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'Sorry, you are not allowed to delete this post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -823,7 +896,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $supports_trash = apply_filters( "rest_{$this->post_type}_trashable", $supports_trash, $post ); if ( ! $this->check_delete_permission( $post ) ) { - return new WP_Error( 'rest_user_cannot_delete_post', __( 'Sorry, you are not allowed to delete this post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_user_cannot_delete_post', + __( 'Sorry, you are not allowed to delete this post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } $request->set_param( 'context', 'edit' ); @@ -842,24 +919,36 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } else { // If we don't support trashing for this type, error out. if ( ! $supports_trash ) { - /* translators: %s: force=true */ - return new WP_Error( 'rest_trash_not_supported', sprintf( __( "The post does not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); + return new WP_Error( + 'rest_trash_not_supported', + /* translators: %s: force=true */ + sprintf( __( "The post does not support trashing. Set '%s' to delete." ), 'force=true' ), + array( 'status' => 501 ) + ); } // Otherwise, only trash if we haven't already. if ( 'trash' === $post->post_status ) { - return new WP_Error( 'rest_already_trashed', __( 'The post has already been deleted.' ), array( 'status' => 410 ) ); + return new WP_Error( + 'rest_already_trashed', + __( 'The post has already been deleted.' ), + array( 'status' => 410 ) + ); } - // (Note that internally this falls through to `wp_delete_post` if - // the trash is disabled.) + // (Note that internally this falls through to `wp_delete_post()` + // if the trash is disabled.) $result = wp_trash_post( $id ); $post = get_post( $id ); $response = $this->prepare_item_for_response( $post, $request ); } if ( ! $result ) { - return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'The post cannot be deleted.' ), + array( 'status' => 500 ) + ); } /** @@ -1064,7 +1153,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $user_obj = get_userdata( $post_author ); if ( ! $user_obj ) { - return new WP_Error( 'rest_invalid_author', __( 'Invalid author ID.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_author', + __( 'Invalid author ID.' ), + array( 'status' => 400 ) + ); } } @@ -1077,18 +1170,30 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { if ( '' !== $request['password'] ) { if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) { - return new WP_Error( 'rest_invalid_field', __( 'A post can not be sticky and have a password.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_field', + __( 'A post can not be sticky and have a password.' ), + array( 'status' => 400 ) + ); } if ( ! empty( $prepared_post->ID ) && is_sticky( $prepared_post->ID ) ) { - return new WP_Error( 'rest_invalid_field', __( 'A sticky post can not be password protected.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_field', + __( 'A sticky post can not be password protected.' ), + array( 'status' => 400 ) + ); } } } if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) { if ( ! empty( $prepared_post->ID ) && post_password_required( $prepared_post->ID ) ) { - return new WP_Error( 'rest_invalid_field', __( 'A password protected post can not be set to sticky.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_field', + __( 'A password protected post can not be set to sticky.' ), + array( 'status' => 400 ) + ); } } @@ -1098,9 +1203,15 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $prepared_post->post_parent = 0; } else { $parent = get_post( (int) $request['parent'] ); + if ( empty( $parent ) ) { - return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent ID.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_post_invalid_id', + __( 'Invalid post parent ID.' ), + array( 'status' => 400 ) + ); } + $prepared_post->post_parent = (int) $parent->ID; } } @@ -1157,13 +1268,21 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { break; case 'private': if ( ! current_user_can( $post_type->cap->publish_posts ) ) { - return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to create private posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_publish', + __( 'Sorry, you are not allowed to create private posts in this post type.' ), + array( 'status' => rest_authorization_required_code() ) + ); } break; case 'publish': case 'future': if ( ! current_user_can( $post_type->cap->publish_posts ) ) { - return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to publish posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_publish', + __( 'Sorry, you are not allowed to publish posts in this post type.' ), + array( 'status' => rest_authorization_required_code() ) + ); } break; default: @@ -1193,7 +1312,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { if ( $result ) { return true; } else { - return new WP_Error( 'rest_invalid_featured_media', __( 'Invalid featured media ID.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_featured_media', + __( 'Invalid featured media ID.' ), + array( 'status' => 400 ) + ); } } else { return delete_post_thumbnail( $post_id ); @@ -1234,8 +1357,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { return true; } - /* translators: 1: Parameter, 2: List of valid values. */ - return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not one of %2$s.' ), 'template', implode( ', ', array_keys( $allowed_templates ) ) ) ); + return new WP_Error( + 'rest_invalid_param', + /* translators: 1: Parameter, 2: List of valid values. */ + sprintf( __( '%1$s is not one of %2$s.' ), 'template', implode( ', ', array_keys( $allowed_templates ) ) ) + ); } /** @@ -1463,10 +1589,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } if ( rest_is_field_included( 'date_gmt', $fields ) ) { - // For drafts, `post_date_gmt` may not be set, indicating that the - // date of the draft should be updated each time it is saved (see - // #38883). In this case, shim the value based on the `post_date` - // field with the site's timezone offset applied. + /* + * For drafts, `post_date_gmt` may not be set, indicating that the date + * of the draft should be updated each time it is saved (see #38883). + * In this case, shim the value based on the `post_date` field + * with the site's timezone offset applied. + */ if ( '0000-00-00 00:00:00' === $post->post_date_gmt ) { $post_date_gmt = get_gmt_from_date( $post->post_date ); } else { @@ -1488,10 +1616,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } if ( rest_is_field_included( 'modified_gmt', $fields ) ) { - // For drafts, `post_modified_gmt` may not be set (see - // `post_date_gmt` comments above). In this case, shim the value - // based on the `post_modified` field with the site's timezone - // offset applied. + /* + * For drafts, `post_modified_gmt` may not be set (see `post_date_gmt` comments + * above). In this case, shim the value based on the `post_modified` field + * with the site's timezone offset applied. + */ if ( '0000-00-00 00:00:00' === $post->post_modified_gmt ) { $post_modified_gmt = gmdate( 'Y-m-d H:i:s', strtotime( $post->post_modified ) - ( get_option( 'gmt_offset' ) * 3600 ) ); } else { @@ -2078,8 +2207,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( - 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database() - 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database() + 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database(). + 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database(). ), 'properties' => array( 'raw' => array( @@ -2103,8 +2232,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { 'type' => 'object', 'context' => array( 'view', 'edit' ), 'arg_options' => array( - 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database() - 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database() + 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database(). + 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database(). ), 'properties' => array( 'raw' => array( @@ -2148,8 +2277,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { 'type' => 'object', 'context' => array( 'view', 'edit', 'embed' ), 'arg_options' => array( - 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database() - 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database() + 'sanitize_callback' => null, // Note: sanitization implemented in self::prepare_item_for_database(). + 'validate_callback' => null, // Note: validation implemented in self::prepare_item_for_database(). ), 'properties' => array( 'raw' => array( @@ -2241,6 +2370,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { ); $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); + foreach ( $taxonomies as $taxonomy ) { $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name; @@ -2277,6 +2407,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } @@ -2622,7 +2753,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { public function sanitize_post_statuses( $statuses, $request, $parameter ) { $statuses = wp_parse_slug_list( $statuses ); - // The default status is different in WP_REST_Attachments_Controller + // The default status is different in WP_REST_Attachments_Controller. $attributes = $request->get_attributes(); $default_status = $attributes['args']['status']['default']; @@ -2639,7 +2770,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { return $result; } } else { - return new WP_Error( 'rest_forbidden_status', __( 'Status is forbidden.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_status', + __( 'Status is forbidden.' ), + array( 'status' => rest_authorization_required_code() ) + ); } } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php index cffeda5e9a..c676882d97 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php @@ -138,7 +138,11 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { * @return WP_Post|WP_Error Post object if ID is valid, WP_Error otherwise. */ protected function get_parent( $parent ) { - $error = new WP_Error( 'rest_post_invalid_parent', __( 'Invalid post parent ID.' ), array( 'status' => 404 ) ); + $error = new WP_Error( + 'rest_post_invalid_parent', + __( 'Invalid post parent ID.' ), + array( 'status' => 404 ) + ); if ( (int) $parent <= 0 ) { return $error; } @@ -166,8 +170,13 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { } $parent_post_type_obj = get_post_type_object( $parent->post_type ); + if ( ! current_user_can( $parent_post_type_obj->cap->edit_post, $parent->ID ) ) { - return new WP_Error( 'rest_cannot_read', __( 'Sorry, you are not allowed to view revisions of this post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_read', + __( 'Sorry, you are not allowed to view revisions of this post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -182,7 +191,12 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { * @return WP_Post|WP_Error Revision post object if ID is valid, WP_Error otherwise. */ protected function get_revision( $id ) { - $error = new WP_Error( 'rest_post_invalid_id', __( 'Invalid revision ID.' ), array( 'status' => 404 ) ); + $error = new WP_Error( + 'rest_post_invalid_id', + __( 'Invalid revision ID.' ), + array( 'status' => 404 ) + ); + if ( (int) $id <= 0 ) { return $error; } @@ -211,12 +225,20 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { // Ensure a search string is set in case the orderby is set to 'relevance'. if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) ) { - return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_no_search_term_defined', + __( 'You need to define a search term to order by relevance.' ), + array( 'status' => 400 ) + ); } // Ensure an include parameter is set in case the orderby is set to 'include'. if ( ! empty( $request['orderby'] ) && 'include' === $request['orderby'] && empty( $request['include'] ) ) { - return new WP_Error( 'rest_orderby_include_missing_include', __( 'You need to define an include parameter to order by include.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_orderby_include_missing_include', + __( 'You need to define an include parameter to order by include.' ), + array( 'status' => 400 ) + ); } if ( wp_revisions_enabled( $parent ) ) { @@ -281,9 +303,17 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { if ( $total_revisions > 0 ) { if ( $offset >= $total_revisions ) { - return new WP_Error( 'rest_revision_invalid_offset_number', __( 'The offset number requested is larger than or equal to the number of available revisions.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_revision_invalid_offset_number', + __( 'The offset number requested is larger than or equal to the number of available revisions.' ), + array( 'status' => 400 ) + ); } elseif ( ! $offset && $page > $max_pages ) { - return new WP_Error( 'rest_revision_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_revision_invalid_page_number', + __( 'The page number requested is larger than the number of pages available.' ), + array( 'status' => 400 ) + ); } } } else { @@ -294,6 +324,7 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { } $response = array(); + foreach ( $revisions as $revision ) { $data = $this->prepare_item_for_response( $revision, $request ); $response[] = $this->prepare_response_for_collection( $data ); @@ -354,8 +385,13 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { } $parent_post_type = get_post_type_object( $parent->post_type ); + if ( ! current_user_can( $parent_post_type->cap->delete_post, $parent->ID ) ) { - return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete revisions of this post.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'Sorry, you are not allowed to delete revisions of this post.' ), + array( 'status' => rest_authorization_required_code() ) + ); } $revision = $this->get_revision( $request['id'] ); @@ -394,7 +430,11 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { $post_type = get_post_type_object( 'revision' ); if ( ! current_user_can( $post_type->cap->delete_post, $revision->ID ) ) { - return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this revision.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'Sorry, you are not allowed to delete this revision.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -418,8 +458,12 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { // We don't support trashing for revisions. if ( ! $force ) { - /* translators: %s: force=true */ - return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Revisions do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); + return new WP_Error( + 'rest_trash_not_supported', + /* translators: %s: force=true */ + sprintf( __( "Revisions do not support trashing. Set '%s' to delete." ), 'force=true' ), + array( 'status' => 501 ) + ); } $previous = $this->prepare_item_for_response( $revision, $request ); @@ -439,7 +483,11 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { do_action( 'rest_delete_revision', $result, $request ); if ( ! $result ) { - return new WP_Error( 'rest_cannot_delete', __( 'The post cannot be deleted.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'The post cannot be deleted.' ), + array( 'status' => 500 ) + ); } $response = new WP_REST_Response(); @@ -701,6 +749,7 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller { } $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php index b657311edd..b3e9db72b7 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php @@ -68,9 +68,12 @@ class WP_REST_Search_Controller extends WP_REST_Controller { foreach ( $search_handlers as $search_handler ) { if ( ! $search_handler instanceof WP_REST_Search_Handler ) { - - /* translators: %s: PHP class name. */ - _doing_it_wrong( __METHOD__, sprintf( __( 'REST search handlers must extend the %s class.' ), 'WP_REST_Search_Handler' ), '5.0.0' ); + _doing_it_wrong( + __METHOD__, + /* translators: %s: PHP class name. */ + sprintf( __( 'REST search handlers must extend the %s class.' ), 'WP_REST_Search_Handler' ), + '5.0.0' + ); continue; } @@ -130,12 +133,17 @@ class WP_REST_Search_Controller extends WP_REST_Controller { $result = $handler->search_items( $request ); if ( ! isset( $result[ WP_REST_Search_Handler::RESULT_IDS ] ) || ! is_array( $result[ WP_REST_Search_Handler::RESULT_IDS ] ) || ! isset( $result[ WP_REST_Search_Handler::RESULT_TOTAL ] ) ) { - return new WP_Error( 'rest_search_handler_error', __( 'Internal search handler error.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_search_handler_error', + __( 'Internal search handler error.' ), + array( 'status' => 500 ) + ); } $ids = array_map( 'absint', $result[ WP_REST_Search_Handler::RESULT_IDS ] ); $results = array(); + foreach ( $ids as $id ) { $data = $this->prepare_item_for_response( $id, $request ); $results[] = $this->prepare_response_for_collection( $data ); @@ -147,7 +155,11 @@ class WP_REST_Search_Controller extends WP_REST_Controller { $max_pages = ceil( $total / $per_page ); if ( $page > $max_pages && $total > 0 ) { - return new WP_Error( 'rest_search_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_search_invalid_page_number', + __( 'The page number requested is larger than the number of pages available.' ), + array( 'status' => 400 ) + ); } $response = rest_ensure_response( $results ); @@ -217,6 +229,7 @@ class WP_REST_Search_Controller extends WP_REST_Controller { $types = array(); $subtypes = array(); + foreach ( $this->search_handlers as $search_handler ) { $types[] = $search_handler->get_type(); $subtypes = array_merge( $subtypes, $search_handler->get_subtypes() ); @@ -267,6 +280,7 @@ class WP_REST_Search_Controller extends WP_REST_Controller { ); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } @@ -280,6 +294,7 @@ class WP_REST_Search_Controller extends WP_REST_Controller { public function get_collection_params() { $types = array(); $subtypes = array(); + foreach ( $this->search_handlers as $search_handler ) { $types[] = $search_handler->get_type(); $subtypes = array_merge( $subtypes, $search_handler->get_subtypes() ); @@ -356,7 +371,11 @@ class WP_REST_Search_Controller extends WP_REST_Controller { $type = $request->get_param( self::PROP_TYPE ); if ( ! $type || ! isset( $this->search_handlers[ $type ] ) ) { - return new WP_Error( 'rest_search_invalid_type', __( 'Invalid type parameter.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_search_invalid_type', + __( 'Invalid type parameter.' ), + array( 'status' => 400 ) + ); } return $this->search_handlers[ $type ]; diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php index c5cf1a7a4b..0fbdb4f5c9 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php @@ -131,6 +131,7 @@ class WP_REST_Settings_Controller extends WP_REST_Controller { if ( is_wp_error( rest_validate_value_from_schema( $value, $schema ) ) ) { return null; } + return rest_sanitize_value_from_schema( $value, $schema ); } @@ -294,6 +295,7 @@ class WP_REST_Settings_Controller extends WP_REST_Controller { } $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } @@ -315,6 +317,7 @@ class WP_REST_Settings_Controller extends WP_REST_Controller { if ( is_null( $value ) ) { return $value; } + return rest_parse_request_arg( $value, $request, $param ); } @@ -336,6 +339,7 @@ class WP_REST_Settings_Controller extends WP_REST_Controller { foreach ( $schema['properties'] as $key => $child_schema ) { $schema['properties'][ $key ] = $this->set_additional_properties_to_false( $child_schema ); } + $schema['additionalProperties'] = false; break; case 'array': diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php index bc2a82e965..89544b9365 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.php @@ -87,13 +87,20 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller { } else { $taxonomies = get_taxonomies( '', 'objects' ); } + foreach ( $taxonomies as $taxonomy ) { if ( ! empty( $taxonomy->show_in_rest ) && current_user_can( $taxonomy->cap->assign_terms ) ) { return true; } } - return new WP_Error( 'rest_cannot_view', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) ); + + return new WP_Error( + 'rest_cannot_view', + __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), + array( 'status' => rest_authorization_required_code() ) + ); } + return true; } @@ -115,11 +122,14 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller { } else { $taxonomies = get_taxonomies( '', 'objects' ); } + $data = array(); + foreach ( $taxonomies as $tax_type => $value ) { if ( empty( $value->show_in_rest ) || ( 'edit' === $request['context'] && ! current_user_can( $value->cap->assign_terms ) ) ) { continue; } + $tax = $this->prepare_item_for_response( $value, $request ); $tax = $this->prepare_response_for_collection( $tax ); $data[ $tax_type ] = $tax; @@ -149,8 +159,13 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller { if ( empty( $tax_obj->show_in_rest ) ) { return false; } + if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->assign_terms ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to manage terms in this taxonomy.' ), + array( 'status' => rest_authorization_required_code() ) + ); } } @@ -167,10 +182,17 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller { */ public function get_item( $request ) { $tax_obj = get_taxonomy( $request['taxonomy'] ); + if ( empty( $tax_obj ) ) { - return new WP_Error( 'rest_taxonomy_invalid', __( 'Invalid taxonomy.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_taxonomy_invalid', + __( 'Invalid taxonomy.' ), + array( 'status' => 404 ) + ); } + $data = $this->prepare_item_for_response( $tax_obj, $request ); + return rest_ensure_response( $data ); } @@ -379,6 +401,7 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller { ); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php index cbbf175738..63cede1080 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php @@ -144,12 +144,19 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { */ public function get_items_permissions_check( $request ) { $tax_obj = get_taxonomy( $this->taxonomy ); + if ( ! $tax_obj || ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) { return false; } + if ( 'edit' === $request['context'] && ! current_user_can( $tax_obj->cap->edit_terms ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to edit terms in this taxonomy.' ), + array( 'status' => rest_authorization_required_code() ) + ); } + return true; } @@ -258,7 +265,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { $total_terms = wp_count_terms( $this->taxonomy, $count_args ); - // wp_count_terms can return a falsy value when the term has no children. + // wp_count_terms() can return a falsy value when the term has no children. if ( ! $total_terms ) { $total_terms = 0; } @@ -312,7 +319,11 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { * @return WP_Term|WP_Error Term object if ID is valid, WP_Error otherwise. */ protected function get_term( $id ) { - $error = new WP_Error( 'rest_term_invalid', __( 'Term does not exist.' ), array( 'status' => 404 ) ); + $error = new WP_Error( + 'rest_term_invalid', + __( 'Term does not exist.' ), + array( 'status' => 404 ) + ); if ( ! $this->check_is_taxonomy_allowed( $this->taxonomy ) ) { return $error; @@ -340,13 +351,19 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { */ public function get_item_permissions_check( $request ) { $term = $this->get_term( $request['id'] ); + if ( is_wp_error( $term ) ) { return $term; } if ( 'edit' === $request['context'] && ! current_user_can( 'edit_term', $term->term_id ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to edit this term.' ), + array( 'status' => rest_authorization_required_code() ) + ); } + return true; } @@ -384,11 +401,16 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { } $taxonomy_obj = get_taxonomy( $this->taxonomy ); + if ( ( is_taxonomy_hierarchical( $this->taxonomy ) && ! current_user_can( $taxonomy_obj->cap->edit_terms ) ) || ( ! is_taxonomy_hierarchical( $this->taxonomy ) && ! current_user_can( $taxonomy_obj->cap->assign_terms ) ) ) { - return new WP_Error( 'rest_cannot_create', __( 'Sorry, you are not allowed to create new terms.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_create', + __( 'Sorry, you are not allowed to create new terms.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -405,13 +427,21 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { public function create_item( $request ) { if ( isset( $request['parent'] ) ) { if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) { - return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_taxonomy_not_hierarchical', + __( 'Cannot set parent term, taxonomy is not hierarchical.' ), + array( 'status' => 400 ) + ); } $parent = get_term( (int) $request['parent'], $this->taxonomy ); if ( ! $parent ) { - return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_term_invalid', + __( 'Parent term does not exist.' ), + array( 'status' => 400 ) + ); } } @@ -502,12 +532,17 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { */ public function update_item_permissions_check( $request ) { $term = $this->get_term( $request['id'] ); + if ( is_wp_error( $term ) ) { return $term; } if ( ! current_user_can( 'edit_term', $term->term_id ) ) { - return new WP_Error( 'rest_cannot_update', __( 'Sorry, you are not allowed to edit this term.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_update', + __( 'Sorry, you are not allowed to edit this term.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -529,13 +564,21 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { if ( isset( $request['parent'] ) ) { if ( ! is_taxonomy_hierarchical( $this->taxonomy ) ) { - return new WP_Error( 'rest_taxonomy_not_hierarchical', __( 'Cannot set parent term, taxonomy is not hierarchical.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_taxonomy_not_hierarchical', + __( 'Cannot set parent term, taxonomy is not hierarchical.' ), + array( 'status' => 400 ) + ); } $parent = get_term( (int) $request['parent'], $this->taxonomy ); if ( ! $parent ) { - return new WP_Error( 'rest_term_invalid', __( 'Parent term does not exist.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_term_invalid', + __( 'Parent term does not exist.' ), + array( 'status' => 400 ) + ); } } @@ -590,12 +633,17 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { */ public function delete_item_permissions_check( $request ) { $term = $this->get_term( $request['id'] ); + if ( is_wp_error( $term ) ) { return $term; } if ( ! current_user_can( 'delete_term', $term->term_id ) ) { - return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete this term.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'Sorry, you are not allowed to delete this term.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -619,8 +667,12 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { // We don't support trashing for terms. if ( ! $force ) { - /* translators: %s: force=true */ - return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Terms do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); + return new WP_Error( + 'rest_trash_not_supported', + /* translators: %s: force=true */ + sprintf( __( "Terms do not support trashing. Set '%s' to delete." ), 'force=true' ), + array( 'status' => 501 ) + ); } $request->set_param( 'context', 'view' ); @@ -630,7 +682,11 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { $retval = wp_delete_term( $term->term_id, $term->taxonomy ); if ( ! $retval ) { - return new WP_Error( 'rest_cannot_delete', __( 'The term cannot be deleted.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'The term cannot be deleted.' ), + array( 'status' => 500 ) + ); } $response = new WP_REST_Response(); @@ -929,6 +985,7 @@ class WP_REST_Terms_Controller extends WP_REST_Controller { $schema['properties']['meta'] = $this->meta->get_field_schema(); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php index 47491e7774..1d86d9938a 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php @@ -59,7 +59,11 @@ class WP_REST_Themes_Controller extends WP_REST_Controller { */ public function get_items_permissions_check( $request ) { if ( ! is_user_logged_in() || ! current_user_can( 'edit_posts' ) ) { - return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to view themes.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_user_cannot_view', + __( 'Sorry, you are not allowed to view themes.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -182,6 +186,7 @@ class WP_REST_Themes_Controller extends WP_REST_Controller { ); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php index 301d41dbf6..19e745a415 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php @@ -173,7 +173,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { return false; } - return new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_invalid_param', + __( 'Invalid user parameter(s).' ), + array( 'status' => 400 ) + ); } /** @@ -187,15 +191,27 @@ class WP_REST_Users_Controller extends WP_REST_Controller { public function get_items_permissions_check( $request ) { // Check if roles is specified in GET request and if user can list users. if ( ! empty( $request['roles'] ) && ! current_user_can( 'list_users' ) ) { - return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to filter users by role.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_user_cannot_view', + __( 'Sorry, you are not allowed to filter users by role.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) { - return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_context', + __( 'Sorry, you are not allowed to list users.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( in_array( $request['orderby'], array( 'email', 'registered_date' ), true ) && ! current_user_can( 'list_users' ) ) { - return new WP_Error( 'rest_forbidden_orderby', __( 'Sorry, you are not allowed to order users by this parameter.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_orderby', + __( 'Sorry, you are not allowed to order users by this parameter.' ), + array( 'status' => rest_authorization_required_code() ) + ); } if ( 'authors' === $request['who'] ) { @@ -208,7 +224,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { } } - return new WP_Error( 'rest_forbidden_who', __( 'Sorry, you are not allowed to query users by this parameter.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_forbidden_who', + __( 'Sorry, you are not allowed to query users by this parameter.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -358,7 +378,12 @@ class WP_REST_Users_Controller extends WP_REST_Controller { * @return WP_User|WP_Error True if ID is valid, WP_Error otherwise. */ protected function get_user( $id ) { - $error = new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); + $error = new WP_Error( + 'rest_user_invalid_id', + __( 'Invalid user ID.' ), + array( 'status' => 404 ) + ); + if ( (int) $id <= 0 ) { return $error; } @@ -396,9 +421,17 @@ class WP_REST_Users_Controller extends WP_REST_Controller { } if ( 'edit' === $request['context'] && ! current_user_can( 'list_users' ) ) { - return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_user_cannot_view', + __( 'Sorry, you are not allowed to list users.' ), + array( 'status' => rest_authorization_required_code() ) + ); } elseif ( ! count_user_posts( $user->ID, $types ) && ! current_user_can( 'edit_user', $user->ID ) && ! current_user_can( 'list_users' ) ) { - return new WP_Error( 'rest_user_cannot_view', __( 'Sorry, you are not allowed to list users.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_user_cannot_view', + __( 'Sorry, you are not allowed to list users.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -436,7 +469,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $current_user_id = get_current_user_id(); if ( empty( $current_user_id ) ) { - return new WP_Error( 'rest_not_logged_in', __( 'You are not currently logged in.' ), array( 'status' => 401 ) ); + return new WP_Error( + 'rest_not_logged_in', + __( 'You are not currently logged in.' ), + array( 'status' => 401 ) + ); } $user = wp_get_current_user(); @@ -457,7 +494,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { public function create_item_permissions_check( $request ) { if ( ! current_user_can( 'create_users' ) ) { - return new WP_Error( 'rest_cannot_create_user', __( 'Sorry, you are not allowed to create new users.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_create_user', + __( 'Sorry, you are not allowed to create new users.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -473,7 +514,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { */ public function create_item( $request ) { if ( ! empty( $request['id'] ) ) { - return new WP_Error( 'rest_user_exists', __( 'Cannot create existing user.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_exists', + __( 'Cannot create existing user.' ), + array( 'status' => 400 ) + ); } $schema = $this->get_item_schema(); @@ -492,12 +537,19 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $ret = wpmu_validate_user_signup( $user->user_login, $user->user_email ); if ( is_wp_error( $ret['errors'] ) && $ret['errors']->has_errors() ) { - $error = new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) ); + $error = new WP_Error( + 'rest_invalid_param', + __( 'Invalid user parameter(s).' ), + array( 'status' => 400 ) + ); + foreach ( $ret['errors']->errors as $code => $messages ) { foreach ( $messages as $message ) { $error->add( $code, $message ); } + $error_data = $error->get_error_data( $code ); + if ( $error_data ) { $error->add_data( $error_data, $code ); } @@ -510,7 +562,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $user_id = wpmu_create_user( $user->user_login, $user->user_pass, $user->user_email ); if ( ! $user_id ) { - return new WP_Error( 'rest_user_create', __( 'Error creating new user.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_user_create', + __( 'Error creating new user.' ), + array( 'status' => 500 ) + ); } $user->ID = $user_id; @@ -602,7 +658,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { if ( ! empty( $request['roles'] ) ) { if ( ! current_user_can( 'promote_user', $user->ID ) ) { - return new WP_Error( 'rest_cannot_edit_roles', __( 'Sorry, you are not allowed to edit roles of this user.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_edit_roles', + __( 'Sorry, you are not allowed to edit roles of this user.' ), + array( 'status' => rest_authorization_required_code() ) + ); } $request_params = array_keys( $request->get_params() ); @@ -615,7 +675,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { } if ( ! current_user_can( 'edit_user', $user->ID ) ) { - return new WP_Error( 'rest_cannot_edit', __( 'Sorry, you are not allowed to edit this user.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_cannot_edit', + __( 'Sorry, you are not allowed to edit this user.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -638,21 +702,37 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $id = $user->ID; if ( ! $user ) { - return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); + return new WP_Error( + 'rest_user_invalid_id', + __( 'Invalid user ID.' ), + array( 'status' => 404 ) + ); } $owner_id = email_exists( $request['email'] ); if ( $owner_id && $owner_id !== $id ) { - return new WP_Error( 'rest_user_invalid_email', __( 'Invalid email address.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_email', + __( 'Invalid email address.' ), + array( 'status' => 400 ) + ); } if ( ! empty( $request['username'] ) && $request['username'] !== $user->user_login ) { - return new WP_Error( 'rest_user_invalid_argument', __( "Username isn't editable." ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_argument', + __( "Username isn't editable." ), + array( 'status' => 400 ) + ); } if ( ! empty( $request['slug'] ) && $request['slug'] !== $user->user_nicename && get_user_by( 'slug', $request['slug'] ) ) { - return new WP_Error( 'rest_user_invalid_slug', __( 'Invalid slug.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_slug', + __( 'Invalid slug.' ), + array( 'status' => 400 ) + ); } if ( ! empty( $request['roles'] ) ) { @@ -754,7 +834,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { } if ( ! current_user_can( 'delete_user', $user->ID ) ) { - return new WP_Error( 'rest_user_cannot_delete', __( 'Sorry, you are not allowed to delete this user.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_user_cannot_delete', + __( 'Sorry, you are not allowed to delete this user.' ), + array( 'status' => rest_authorization_required_code() ) + ); } return true; @@ -771,9 +855,15 @@ class WP_REST_Users_Controller extends WP_REST_Controller { public function delete_item( $request ) { // We don't support delete requests in multisite. if ( is_multisite() ) { - return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 501 ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'The user cannot be deleted.' ), + array( 'status' => 501 ) + ); } + $user = $this->get_user( $request['id'] ); + if ( is_wp_error( $user ) ) { return $user; } @@ -784,13 +874,21 @@ class WP_REST_Users_Controller extends WP_REST_Controller { // We don't support trashing for users. if ( ! $force ) { - /* translators: %s: force=true */ - return new WP_Error( 'rest_trash_not_supported', sprintf( __( "Users do not support trashing. Set '%s' to delete." ), 'force=true' ), array( 'status' => 501 ) ); + return new WP_Error( + 'rest_trash_not_supported', + /* translators: %s: force=true */ + sprintf( __( "Users do not support trashing. Set '%s' to delete." ), 'force=true' ), + array( 'status' => 501 ) + ); } if ( ! empty( $reassign ) ) { if ( $reassign === $id || ! get_userdata( $reassign ) ) { - return new WP_Error( 'rest_user_invalid_reassign', __( 'Invalid user ID for reassignment.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_reassign', + __( 'Invalid user ID for reassignment.' ), + array( 'status' => 400 ) + ); } } @@ -804,7 +902,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $result = wp_delete_user( $id, $reassign ); if ( ! $result ) { - return new WP_Error( 'rest_cannot_delete', __( 'The user cannot be deleted.' ), array( 'status' => 500 ) ); + return new WP_Error( + 'rest_cannot_delete', + __( 'The user cannot be deleted.' ), + array( 'status' => 500 ) + ); } $response = new WP_REST_Response(); @@ -1000,7 +1102,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $schema = $this->get_item_schema(); - // required arguments. + // Required arguments. if ( isset( $request['email'] ) && ! empty( $schema['properties']['email'] ) ) { $prepared_user->user_email = $request['email']; } @@ -1013,7 +1115,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $prepared_user->user_pass = $request['password']; } - // optional arguments. + // Optional arguments. if ( isset( $request['id'] ) ) { $prepared_user->ID = absint( $request['id'] ); } @@ -1050,7 +1152,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $prepared_user->locale = $request['locale']; } - // setting roles will be handled outside of this function. + // Setting roles will be handled outside of this function. if ( isset( $request['roles'] ) ) { $prepared_user->role = false; } @@ -1082,8 +1184,12 @@ class WP_REST_Users_Controller extends WP_REST_Controller { foreach ( $roles as $role ) { if ( ! isset( $wp_roles->role_objects[ $role ] ) ) { - /* translators: %s: Role key. */ - return new WP_Error( 'rest_user_invalid_role', sprintf( __( 'The role %s does not exist.' ), $role ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_role', + /* translators: %s: Role key. */ + sprintf( __( 'The role %s does not exist.' ), $role ), + array( 'status' => 400 ) + ); } $potential_role = $wp_roles->role_objects[ $role ]; @@ -1097,7 +1203,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { && get_current_user_id() === $user_id && ! $potential_role->has_cap( 'edit_users' ) ) { - return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => rest_authorization_required_code() ) ); + return new WP_Error( + 'rest_user_invalid_role', + __( 'Sorry, you are not allowed to give users that role.' ), + array( 'status' => rest_authorization_required_code() ) + ); } /** Include admin functions to get access to get_editable_roles() */ @@ -1107,7 +1217,11 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $editable_roles = get_editable_roles(); if ( empty( $editable_roles[ $role ] ) ) { - return new WP_Error( 'rest_user_invalid_role', __( 'Sorry, you are not allowed to give users that role.' ), array( 'status' => 403 ) ); + return new WP_Error( + 'rest_user_invalid_role', + __( 'Sorry, you are not allowed to give users that role.' ), + array( 'status' => 403 ) + ); } } @@ -1130,14 +1244,22 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $username = (string) $value; if ( ! validate_username( $username ) ) { - return new WP_Error( 'rest_user_invalid_username', __( 'Username contains invalid characters.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_username', + __( 'Username contains invalid characters.' ), + array( 'status' => 400 ) + ); } /** This filter is documented in wp-includes/user.php */ $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); if ( in_array( strtolower( $username ), array_map( 'strtolower', $illegal_logins ), true ) ) { - return new WP_Error( 'rest_user_invalid_username', __( 'Sorry, that username is not allowed.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_username', + __( 'Sorry, that username is not allowed.' ), + array( 'status' => 400 ) + ); } return $username; @@ -1159,11 +1281,19 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $password = (string) $value; if ( empty( $password ) ) { - return new WP_Error( 'rest_user_invalid_password', __( 'Passwords cannot be empty.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_password', + __( 'Passwords cannot be empty.' ), + array( 'status' => 400 ) + ); } if ( false !== strpos( $password, '\\' ) ) { - return new WP_Error( 'rest_user_invalid_password', __( 'Passwords cannot contain the "\\" character.' ), array( 'status' => 400 ) ); + return new WP_Error( + 'rest_user_invalid_password', + __( 'Passwords cannot contain the "\\" character.' ), + array( 'status' => 400 ) + ); } return $password; @@ -1338,6 +1468,7 @@ class WP_REST_Users_Controller extends WP_REST_Controller { $schema['properties']['meta'] = $this->meta->get_field_schema(); $this->schema = $schema; + return $this->add_additional_fields_schema( $this->schema ); } diff --git a/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php b/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php index a59ee7f90a..a897d13c1b 100644 --- a/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php +++ b/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php @@ -79,15 +79,18 @@ abstract class WP_REST_Meta_Fields { foreach ( $fields as $meta_key => $args ) { $name = $args['name']; $all_values = get_metadata( $this->get_meta_type(), $object_id, $meta_key, false ); + if ( $args['single'] ) { if ( empty( $all_values ) ) { $value = $args['schema']['default']; } else { $value = $all_values[0]; } + $value = $this->prepare_value_for_response( $value, $request, $args ); } else { $value = array(); + foreach ( $all_values as $row ) { $value[] = $this->prepare_value_for_response( $row, $request, $args ); } @@ -132,6 +135,7 @@ abstract class WP_REST_Meta_Fields { */ public function update_value( $meta, $object_id ) { $fields = $this->get_registered_fields(); + foreach ( $fields as $meta_key => $args ) { $name = $args['name']; if ( ! array_key_exists( $name, $meta ) ) { @@ -210,6 +214,7 @@ abstract class WP_REST_Meta_Fields { */ protected function delete_meta_value( $object_id, $meta_key, $name ) { $meta_type = $this->get_meta_type(); + if ( ! current_user_can( "delete_{$meta_type}_meta", $object_id, $meta_key ) ) { return new WP_Error( 'rest_cannot_delete', @@ -251,6 +256,7 @@ abstract class WP_REST_Meta_Fields { */ protected function update_multi_meta_value( $object_id, $meta_key, $name, $values ) { $meta_type = $this->get_meta_type(); + if ( ! current_user_can( "edit_{$meta_type}_meta", $object_id, $meta_key ) ) { return new WP_Error( 'rest_cannot_update', @@ -286,9 +292,11 @@ abstract class WP_REST_Meta_Fields { unset( $to_add[ $add_key ] ); } - // `delete_metadata` removes _all_ instances of the value, so only call once. Otherwise, - // `delete_metadata` will return false for subsequent calls of the same value. - // Use serialization to produce a predictable string that can be used by array_unique. + /* + * `delete_metadata` removes _all_ instances of the value, so only call once. Otherwise, + * `delete_metadata` will return false for subsequent calls of the same value. + * Use serialization to produce a predictable string that can be used by array_unique. + */ $to_remove = array_map( 'maybe_unserialize', array_unique( array_map( 'maybe_serialize', $to_remove ) ) ); foreach ( $to_remove as $value ) { @@ -335,6 +343,7 @@ abstract class WP_REST_Meta_Fields { */ protected function update_meta_value( $object_id, $meta_key, $name, $value ) { $meta_type = $this->get_meta_type(); + if ( ! current_user_can( "edit_{$meta_type}_meta", $object_id, $meta_key ) ) { return new WP_Error( 'rest_cannot_update', @@ -494,7 +503,6 @@ abstract class WP_REST_Meta_Fields { * @return mixed Value prepared for output. If a non-JsonSerializable object, null. */ public static function prepare_value( $value, $request, $args ) { - if ( $args['single'] ) { $schema = $args['schema']; } else { diff --git a/src/wp-includes/revision.php b/src/wp-includes/revision.php index da038a21be..77fd8e98ac 100644 --- a/src/wp-includes/revision.php +++ b/src/wp-includes/revision.php @@ -29,7 +29,7 @@ function _wp_post_revision_fields( $post = array(), $deprecated = false ) { } if ( is_null( $fields ) ) { - // Allow these to be versioned + // Allow these to be versioned. $fields = array( 'post_title' => __( 'Title' ), 'post_content' => __( 'Content' ), @@ -55,7 +55,7 @@ function _wp_post_revision_fields( $post = array(), $deprecated = false ) { */ $fields = apply_filters( '_wp_post_revision_fields', $fields, $post ); - // WP uses these internally either in versioning or elsewhere - they cannot be versioned + // WP uses these internally either in versioning or elsewhere - they cannot be versioned. foreach ( array( 'ID', 'post_name', 'post_parent', 'post_date', 'post_date_gmt', 'post_status', 'post_type', 'comment_count', 'post_author' ) as $protect ) { unset( $fields[ $protect ] ); } @@ -90,7 +90,7 @@ function _wp_post_revision_data( $post = array(), $autosave = false ) { $revision_data['post_parent'] = $post['ID']; $revision_data['post_status'] = 'inherit'; $revision_data['post_type'] = 'revision'; - $revision_data['post_name'] = $autosave ? "$post[ID]-autosave-v1" : "$post[ID]-revision-v1"; // "1" is the revisioning system version + $revision_data['post_name'] = $autosave ? "$post[ID]-autosave-v1" : "$post[ID]-revision-v1"; // "1" is the revisioning system version. $revision_data['post_date'] = isset( $post['post_modified'] ) ? $post['post_modified'] : ''; $revision_data['post_date_gmt'] = isset( $post['post_modified_gmt'] ) ? $post['post_modified_gmt'] : ''; @@ -130,12 +130,14 @@ function wp_save_post_revision( $post_id ) { return; } - // Compare the proposed update with the last stored revision verifying that - // they are different, unless a plugin tells us to always save regardless. - // If no previous revisions, save one + /* + * Compare the proposed update with the last stored revision verifying that + * they are different, unless a plugin tells us to always save regardless. + * If no previous revisions, save one. + */ $revisions = wp_get_post_revisions( $post_id ); if ( $revisions ) { - // grab the last revision, but not an autosave + // Grab the last revision, but not an autosave. foreach ( $revisions as $revision ) { if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) { $last_revision = $revision; @@ -180,7 +182,7 @@ function wp_save_post_revision( $post_id ) { */ $post_has_changed = (bool) apply_filters( 'wp_save_post_revision_post_has_changed', $post_has_changed, $last_revision, $post ); - //don't save revision if post unchanged + // Don't save revision if post unchanged. if ( ! $post_has_changed ) { return; } @@ -311,7 +313,7 @@ function _wp_put_post_revision( $post = null, $autosave = false ) { } $post = _wp_post_revision_data( $post, $autosave ); - $post = wp_slash( $post ); //since data is from db + $post = wp_slash( $post ); // Since data is from DB. $revision_id = wp_insert_post( $post ); if ( is_wp_error( $revision_id ) ) { @@ -397,14 +399,14 @@ function wp_restore_post_revision( $revision_id, $fields = null ) { $update['ID'] = $revision['post_parent']; - $update = wp_slash( $update ); //since data is from db + $update = wp_slash( $update ); // Since data is from DB. $post_id = wp_update_post( $update ); if ( ! $post_id || is_wp_error( $post_id ) ) { return $post_id; } - // Update last edit user + // Update last edit user. update_post_meta( $post_id, '_edit_last', get_current_user_id() ); /** @@ -623,7 +625,7 @@ function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { } else { $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ); if ( $term ) { - $terms = array( $term ); // Can only have one post format + $terms = array( $term ); // Can only have one post format. } } @@ -703,25 +705,25 @@ function _wp_get_post_revision_version( $revision ) { function _wp_upgrade_revisions_of_post( $post, $revisions ) { global $wpdb; - // Add post option exclusively + // Add post option exclusively. $lock = "revision-upgrade-{$post->ID}"; $now = time(); $result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'no') /* LOCK */", $lock, $now ) ); if ( ! $result ) { - // If we couldn't get a lock, see how old the previous lock is + // If we couldn't get a lock, see how old the previous lock is. $locked = get_option( $lock ); if ( ! $locked ) { // Can't write to the lock, and can't read the lock. - // Something broken has happened + // Something broken has happened. return false; } if ( $locked > $now - 3600 ) { - // Lock is not too old: some other process may be upgrading this post. Bail. + // Lock is not too old: some other process may be upgrading this post. Bail. return false; } - // Lock is too old - update it (below) and continue + // Lock is too old - update it (below) and continue. } // If we could get a lock, re-"add" the option to fire all the correct filters. @@ -736,7 +738,7 @@ function _wp_upgrade_revisions_of_post( $post, $revisions ) { $this_revision_version = _wp_get_post_revision_version( $this_revision ); - // Something terrible happened + // Something terrible happened. if ( false === $this_revision_version ) { continue; } @@ -748,14 +750,16 @@ function _wp_upgrade_revisions_of_post( $post, $revisions ) { continue; } - // Always update the revision version + // Always update the revision version. $update = array( 'post_name' => preg_replace( '/^(\d+-(?:autosave|revision))[\d-]*$/', '$1-v1', $this_revision->post_name ), ); - // If this revision is the oldest revision of the post, i.e. no $prev_revision, - // the correct post_author is probably $post->post_author, but that's only a good guess. - // Update the revision version only and Leave the author as-is. + /* + * If this revision is the oldest revision of the post, i.e. no $prev_revision, + * the correct post_author is probably $post->post_author, but that's only a good guess. + * Update the revision version only and Leave the author as-is. + */ if ( $prev_revision ) { $prev_revision_version = _wp_get_post_revision_version( $prev_revision ); @@ -765,7 +769,7 @@ function _wp_upgrade_revisions_of_post( $post, $revisions ) { } } - // Upgrade this revision + // Upgrade this revision. $result = $wpdb->update( $wpdb->posts, $update, array( 'ID' => $this_revision->ID ) ); if ( $result ) { diff --git a/src/wp-includes/rewrite.php b/src/wp-includes/rewrite.php index a01b88b9dc..aa7d22371b 100644 --- a/src/wp-includes/rewrite.php +++ b/src/wp-includes/rewrite.php @@ -157,7 +157,7 @@ function add_rewrite_rule( $regex, $query, $after = 'bottom' ) { * @param string $query Optional. String to append to the rewritten query. Must end in '='. Default empty. */ function add_rewrite_tag( $tag, $regex, $query = '' ) { - // validate the tag's name + // Validate the tag's name. if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen( $tag ) - 1 ] != '%' ) { return; } @@ -253,7 +253,7 @@ function add_feed( $feedname, $function ) { $hook = 'do_feed_' . $feedname; - // Remove default function hook + // Remove default function hook. remove_action( $hook, $hook ); add_action( $hook, $function, 10, 2 ); @@ -420,7 +420,7 @@ function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) { } elseif ( 'monthnum' === $compare && isset( $query_vars['day'] ) ) { $maybe_page = $query_vars['day']; } - // Bug found in #11694 - 'page' was returning '/4' + // Bug found in #11694 - 'page' was returning '/4'. $maybe_page = (int) trim( $maybe_page, '/' ); $post_page_count = substr_count( $post->post_content, '<!--nextpage-->' ) + 1; @@ -485,7 +485,7 @@ function url_to_postid( $url ) { return 0; } - // First, check to see if there is a 'p=N' or 'page_id=N' to match against + // First, check to see if there is a 'p=N' or 'page_id=N' to match against. if ( preg_match( '#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values ) ) { $id = absint( $values[2] ); if ( $id ) { @@ -493,11 +493,11 @@ function url_to_postid( $url ) { } } - // Get rid of the #anchor + // Get rid of the #anchor. $url_split = explode( '#', $url ); $url = $url_split[0]; - // Get rid of URL ?query=string + // Get rid of URL ?query=string. $url_split = explode( '?', $url ); $url = $url_split[0]; @@ -505,12 +505,12 @@ function url_to_postid( $url ) { $scheme = parse_url( home_url(), PHP_URL_SCHEME ); $url = set_url_scheme( $url, $scheme ); - // Add 'www.' if it is absent and should be there + // Add 'www.' if it is absent and should be there. if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) { $url = str_replace( '://', '://www.', $url ); } - // Strip 'www.' if it is present and shouldn't be + // Strip 'www.' if it is present and shouldn't be. if ( false === strpos( home_url(), '://www.' ) ) { $url = str_replace( '://www.', '://', $url ); } @@ -523,30 +523,30 @@ function url_to_postid( $url ) { } } - // Check to see if we are using rewrite rules + // Check to see if we are using rewrite rules. $rewrite = $wp_rewrite->wp_rewrite_rules(); - // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options + // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options. if ( empty( $rewrite ) ) { return 0; } - // Strip 'index.php/' if we're not using path info permalinks + // Strip 'index.php/' if we're not using path info permalinks. if ( ! $wp_rewrite->using_index_permalinks() ) { $url = str_replace( $wp_rewrite->index . '/', '', $url ); } if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) { - // Chop off http://domain.com/[path] + // Chop off http://domain.com/[path]. $url = str_replace( home_url(), '', $url ); } else { - // Chop off /path/to/blog + // Chop off /path/to/blog. $home_path = parse_url( home_url( '/' ) ); $home_path = isset( $home_path['path'] ) ? $home_path['path'] : ''; $url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) ); } - // Trim leading and lagging slashes + // Trim leading and lagging slashes. $url = trim( $url, '/' ); $request = $url; @@ -562,8 +562,8 @@ function url_to_postid( $url ) { $request_match = $request; foreach ( (array) $rewrite as $match => $query ) { - // If the requesting file is the anchor of the match, prepend it - // to the path info. + // If the requesting file is the anchor of the match, + // prepend it to the path info. if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) { $request_match = $url . '/' . $request; } @@ -591,7 +591,7 @@ function url_to_postid( $url ) { // Substitute the substring matches into the query. $query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) ); - // Filter out non-public query vars + // Filter out non-public query vars. global $wp; parse_str( $query, $query_vars ); $query = array(); @@ -608,7 +608,7 @@ function url_to_postid( $url ) { // Resolve conflicts between posts with numeric slugs and date archive queries. $query = wp_resolve_numeric_slug_conflicts( $query ); - // Do the query + // Do the query. $query = new WP_Query( $query ); if ( ! empty( $query->posts ) && $query->is_singular ) { return $query->post->ID; diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 018cb777af..f45471d7e1 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -51,8 +51,8 @@ function wp_register_tinymce_scripts( &$scripts, $force_uncompressed = false ) { $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed; - // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) or - // tinymce.min.js (when SCRIPT_DEBUG is true). + // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) + // or tinymce.min.js (when SCRIPT_DEBUG is true). if ( $compressed ) { $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version ); } else { @@ -198,9 +198,11 @@ function wp_get_script_polyfill( &$scripts, $tests ) { $polyfill .= ( // Test presence of feature... '( ' . $test . ' ) || ' . - // ...appending polyfill on any failures. Cautious viewers may balk - // at the `document.write`. Its caveat of synchronous mid-stream - // blocking write is exactly the behavior we need though. + /* + * ...appending polyfill on any failures. Cautious viewers may balk + * at the `document.write`. Its caveat of synchronous mid-stream + * blocking write is exactly the behavior we need though. + */ 'document.write( \'<script src="' . $src . '"></scr\' + \'ipt>\' );' @@ -593,7 +595,8 @@ function wp_scripts_get_suffix( $type = '' ) { static $suffixes; if ( $suffixes === null ) { - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version + // Include an unmodified $wp_version. + include( ABSPATH . WPINC . '/version.php' ); $develop_src = false !== strpos( $wp_version, '-src' ); @@ -795,15 +798,15 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'scriptaculous-controls', 'https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js', array( 'scriptaculous-root' ), '1.9.0' ); $scripts->add( 'scriptaculous', false, array( 'scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls' ) ); - // not used in core, replaced by Jcrop.js + // Not used in core, replaced by Jcrop.js. $scripts->add( 'cropper', '/wp-includes/js/crop/cropper.js', array( 'scriptaculous-dragdrop' ) ); - // jQuery + // jQuery. $scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.12.4-wp' ); $scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.12.4-wp' ); $scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '1.4.1' ); - // full jQuery UI + // Full jQuery UI. $scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 ); $scripts->add( 'jquery-effects-core', "/wp-includes/js/jquery/ui/effect$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 ); @@ -844,7 +847,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'jquery-ui-tooltip', "/wp-includes/js/jquery/ui/tooltip$dev_suffix.js", array( 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position' ), '1.11.4', 1 ); $scripts->add( 'jquery-ui-widget', "/wp-includes/js/jquery/ui/widget$dev_suffix.js", array( 'jquery' ), '1.11.4', 1 ); - // Strings for 'jquery-ui-autocomplete' live region messages + // Strings for 'jquery-ui-autocomplete' live region messages. did_action( 'init' ) && $scripts->localize( 'jquery-ui-autocomplete', 'uiAutocompleteL10n', @@ -858,10 +861,10 @@ function wp_default_scripts( &$scripts ) { ) ); - // deprecated, not used in core, most functionality is included in jQuery 1.3 + // Deprecated, not used in core, most functionality is included in jQuery 1.3. $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array( 'jquery' ), '4.2.1', 1 ); - // jQuery plugins + // jQuery plugins. $scripts->add( 'jquery-color', '/wp-includes/js/jquery/jquery.color.min.js', array( 'jquery' ), '2.1.2', 1 ); $scripts->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array( 'jquery' ), '20m', 1 ); $scripts->add( 'jquery-query', '/wp-includes/js/jquery/jquery.query.js', array( 'jquery' ), '2.1.7', 1 ); @@ -942,7 +945,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'wp-plupload', "/wp-includes/js/plupload/wp-plupload$suffix.js", array( 'plupload', 'jquery', 'json2', 'media-models' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-plupload', 'pluploadL10n', $uploader_l10n ); - // keep 'swfupload' for back-compat. + // Keep 'swfupload' for back-compat. $scripts->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', array(), '2201-20110113' ); $scripts->add( 'swfupload-all', false, array( 'swfupload' ), '2201' ); $scripts->add( 'swfupload-handlers', "/wp-includes/js/swfupload/handlers$suffix.js", array( 'swfupload-all', 'jquery' ), '2201-20110524' ); @@ -1105,7 +1108,8 @@ function wp_default_scripts( &$scripts ) { /* translators: %d: Error count. */ 'singular' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 1 ), /* translators: %d: Error count. */ - 'plural' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. + 'plural' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 2 ), + // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. ), ) ) @@ -1232,20 +1236,22 @@ function wp_default_scripts( &$scripts ) { /* translators: %s: URL to the Customizer to load the autosaved version. */ 'autosaveNotice' => __( 'There is a more recent autosave of your changes than the one you are previewing. <a href="%s">Restore the autosave</a>' ), 'videoHeaderNotice' => __( 'This theme doesn’t support video headers on this page. Navigate to the front page or another page that supports video headers.' ), - // Used for overriding the file types allowed in plupload. + // Used for overriding the file types allowed in Plupload. 'allowedFiles' => __( 'Allowed Files' ), 'customCssError' => array( /* translators: %d: Error count. */ 'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ), /* translators: %d: Error count. */ - 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. + 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), + // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. ), 'pageOnFrontError' => __( 'Homepage and posts page must be different.' ), 'saveBlockedError' => array( /* translators: %s: Number of invalid settings. */ 'singular' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 1 ), /* translators: %s: Number of invalid settings. */ - 'plural' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. + 'plural' => _n( 'Unable to save due to %s invalid setting.', 'Unable to save due to %s invalid settings.', 2 ), + // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. ), 'scheduleDescription' => __( 'Schedule your customization changes to publish ("go live") at a future date.' ), 'themePreviewUnavailable' => __( 'Sorry, you can’t preview new themes when you have changes scheduled or saved as a draft. Please publish your changes, or wait until they publish to preview new themes.' ), @@ -1524,9 +1530,9 @@ function wp_default_scripts( &$scripts ) { /* translators: %s: Error string for a failed installation. */ 'installFailed' => __( 'Installation failed: %s' ), /* translators: %s: Plugin name and version. */ - 'pluginInstallingLabel' => _x( 'Installing %s...', 'plugin' ), // no ellipsis + 'pluginInstallingLabel' => _x( 'Installing %s...', 'plugin' ), // No ellipsis. /* translators: %s: Theme name and version. */ - 'themeInstallingLabel' => _x( 'Installing %s...', 'theme' ), // no ellipsis + 'themeInstallingLabel' => _x( 'Installing %s...', 'theme' ), // No ellipsis. /* translators: %s: Plugin name and version. */ 'pluginInstalledLabel' => _x( '%s installed!', 'plugin' ), /* translators: %s: Theme name and version. */ @@ -1616,7 +1622,7 @@ function wp_default_scripts( &$scripts ) { 'setPostThumbnailL10n', array( 'setThumbnail' => __( 'Use as featured image' ), - 'saving' => __( 'Saving...' ), // no ellipsis + 'saving' => __( 'Saving...' ), // No ellipsis. 'error' => __( 'Could not set that as the thumbnail image. Try a different attachment.' ), 'done' => __( 'Done' ), ) @@ -1662,7 +1668,8 @@ function wp_default_scripts( &$scripts ) { * @param WP_Styles $styles */ function wp_default_styles( &$styles ) { - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version + // Include an unmodified $wp_version. + include( ABSPATH . WPINC . '/version.php' ); if ( ! defined( 'SCRIPT_DEBUG' ) ) { define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) ); @@ -1704,7 +1711,7 @@ function wp_default_styles( &$styles ) { $subsets .= ',vietnamese'; } - // Hotlink Open Sans, for now + // Hotlink Open Sans, for now. $open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets&display=fallback"; } @@ -1713,7 +1720,7 @@ function wp_default_styles( &$styles ) { $suffix = SCRIPT_DEBUG ? '' : '.min'; - // Admin CSS + // Admin CSS. $styles->add( 'common', "/wp-admin/css/common$suffix.css" ); $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" ); $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" ); @@ -1743,11 +1750,11 @@ function wp_default_styles( &$styles ) { $styles->add( 'ie', "/wp-admin/css/ie$suffix.css" ); $styles->add_data( 'ie', 'conditional', 'lte IE 7' ); - // Common dependencies + // Common dependencies. $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" ); $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" ); - // Includes CSS + // Includes CSS. $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array( 'dashicons' ) ); $styles->add( 'wp-auth-check', "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) ); $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) ); @@ -1757,7 +1764,7 @@ function wp_default_styles( &$styles ) { $styles->add( 'wp-embed-template-ie', "/wp-includes/css/wp-embed-template-ie$suffix.css" ); $styles->add_data( 'wp-embed-template-ie', 'conditional', 'lte IE 8' ); - // External libraries and friends + // External libraries and friends. $styles->add( 'imgareaselect', '/wp-includes/js/imgareaselect/imgareaselect.css', array(), '0.9.8' ); $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array( 'dashicons' ) ); $styles->add( 'mediaelement', '/wp-includes/js/mediaelement/mediaelementplayer-legacy.min.css', array(), '4.2.13-9993131' ); @@ -1765,14 +1772,14 @@ function wp_default_styles( &$styles ) { $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css', array( 'dashicons' ) ); $styles->add( 'wp-codemirror', '/wp-includes/js/codemirror/codemirror.min.css', array(), '5.29.1-alpha-ee20357' ); - // Deprecated CSS + // Deprecated CSS. $styles->add( 'deprecated-media', "/wp-admin/css/deprecated-media$suffix.css" ); $styles->add( 'farbtastic', "/wp-admin/css/farbtastic$suffix.css", array(), '1.3u1' ); $styles->add( 'jcrop', '/wp-includes/js/jcrop/jquery.Jcrop.min.css', array(), '0.9.12' ); $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle. - $styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6 + $styles->add( 'open-sans', $open_sans_font_url ); // No longer used in core as of 4.6. - // Packages styles + // Packages styles. $fonts_url = ''; /* @@ -1832,9 +1839,9 @@ function wp_default_styles( &$styles ) { $styles->add( $handle, $path, $dependencies ); } - // RTL CSS + // RTL CSS. $rtl_styles = array( - // Admin CSS + // Admin CSS. 'common', 'forms', 'admin-menu', @@ -1858,7 +1865,7 @@ function wp_default_styles( &$styles ) { 'ie', 'login', 'site-health', - // Includes CSS + // Includes CSS. 'buttons', 'admin-bar', 'wp-auth-check', @@ -1866,7 +1873,7 @@ function wp_default_styles( &$styles ) { 'media-views', 'wp-pointer', 'wp-jquery-ui-dialog', - // Package styles + // Package styles. 'wp-block-library-theme', 'wp-edit-blocks', 'wp-block-editor', @@ -1877,7 +1884,7 @@ function wp_default_styles( &$styles ) { 'wp-format-library', 'wp-list-reusable-blocks', 'wp-nux', - // Deprecated CSS + // Deprecated CSS. 'deprecated-media', 'farbtastic', ); @@ -1991,7 +1998,7 @@ function wp_localize_jquery_ui_datepicker() { 'n', 'm', // Month. 'Y', - 'y', // Year. + 'y', // Year. ), array( 'dd', @@ -2250,7 +2257,7 @@ function _print_scripts() { if ( $concat ) { if ( ! empty( $wp_scripts->print_code ) ) { echo "\n<script{$type_attr}>\n"; - echo "/* <![CDATA[ */\n"; // not needed in HTML 5 + echo "/* <![CDATA[ */\n"; // Not needed in HTML 5. echo $wp_scripts->print_code; echo "/* ]]> */\n"; echo "</script>\n"; @@ -2293,7 +2300,7 @@ function wp_print_head_scripts() { global $wp_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { - return array(); // no need to run if nothing is queued + return array(); // No need to run if nothing is queued. } return print_head_scripts(); } diff --git a/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php index ecf1aeba39..5c425bc64a 100644 --- a/src/wp-includes/shortcodes.php +++ b/src/wp-includes/shortcodes.php @@ -217,7 +217,7 @@ function do_shortcode( $content, $ignore_html = false ) { $pattern = get_shortcode_regex( $tagnames ); $content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $content ); - // Always restore square braces so we don't break things like <!--[if IE ]> + // Always restore square braces so we don't break things like <!--[if IE ]>. $content = unescape_invalid_shortcodes( $content ); return $content; @@ -254,39 +254,39 @@ function get_shortcode_regex( $tagnames = null ) { } $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) ); - // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag() + // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag(). // Also, see shortcode_unautop() and shortcode.js. // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation return - '\\[' // Opening bracket - . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]] - . "($tagregexp)" // 2: Shortcode name - . '(?![\\w-])' // Not followed by word character or hyphen - . '(' // 3: Unroll the loop: Inside the opening shortcode tag - . '[^\\]\\/]*' // Not a closing bracket or forward slash + '\\[' // Opening bracket. + . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]]. + . "($tagregexp)" // 2: Shortcode name. + . '(?![\\w-])' // Not followed by word character or hyphen. + . '(' // 3: Unroll the loop: Inside the opening shortcode tag. + . '[^\\]\\/]*' // Not a closing bracket or forward slash. . '(?:' - . '\\/(?!\\])' // A forward slash not followed by a closing bracket - . '[^\\]\\/]*' // Not a closing bracket or forward slash + . '\\/(?!\\])' // A forward slash not followed by a closing bracket. + . '[^\\]\\/]*' // Not a closing bracket or forward slash. . ')*?' . ')' . '(?:' - . '(\\/)' // 4: Self closing tag ... - . '\\]' // ... and closing bracket + . '(\\/)' // 4: Self closing tag... + . '\\]' // ...and closing bracket. . '|' - . '\\]' // Closing bracket + . '\\]' // Closing bracket. . '(?:' - . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags - . '[^\\[]*+' // Not an opening bracket + . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags. + . '[^\\[]*+' // Not an opening bracket. . '(?:' - . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag - . '[^\\[]*+' // Not an opening bracket + . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag. + . '[^\\[]*+' // Not an opening bracket. . ')*+' . ')' - . '\\[\\/\\2\\]' // Closing shortcode tag + . '\\[\\/\\2\\]' // Closing shortcode tag. . ')?' . ')' - . '(\\]?)'; // 6: Optional second closing brocket for escaping shortcodes: [[tag]] + . '(\\]?)'; // 6: Optional second closing brocket for escaping shortcodes: [[tag]]. // phpcs:enable } @@ -306,7 +306,7 @@ function get_shortcode_regex( $tagnames = null ) { function do_shortcode_tag( $m ) { global $shortcode_tags; - // allow [[foo]] syntax for escaping a tag + // Allow [[foo]] syntax for escaping a tag. if ( $m[1] == '[' && $m[6] == ']' ) { return substr( $m[0], 1, -1 ); } @@ -396,14 +396,14 @@ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { if ( $noopen || $noclose ) { // This element does not contain shortcodes. if ( $noopen xor $noclose ) { - // Need to encode stray [ or ] chars. + // Need to encode stray '[' or ']' chars. $element = strtr( $element, $trans ); } continue; } if ( $ignore_html || '<!--' === substr( $element, 0, 4 ) || '<![CDATA[' === substr( $element, 0, 9 ) ) { - // Encode all [ and ] chars. + // Encode all '[' and ']' chars. $element = strtr( $element, $trans ); continue; } @@ -415,12 +415,12 @@ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { $element = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $element ); } - // Looks like we found some crazy unfiltered HTML. Skipping it for sanity. + // Looks like we found some crazy unfiltered HTML. Skipping it for sanity. $element = strtr( $element, $trans ); continue; } - // Get element name + // Get element name. $front = array_shift( $attributes ); $back = array_pop( $attributes ); $matches = array(); @@ -432,18 +432,20 @@ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { $open = strpos( $attr, '[' ); $close = strpos( $attr, ']' ); if ( false === $open || false === $close ) { - continue; // Go to next attribute. Square braces will be escaped at end of loop. + continue; // Go to next attribute. Square braces will be escaped at end of loop. } $double = strpos( $attr, '"' ); $single = strpos( $attr, "'" ); if ( ( false === $single || $open < $single ) && ( false === $double || $open < $double ) ) { - // $attr like '[shortcode]' or 'name = [shortcode]' implies unfiltered_html. - // In this specific situation we assume KSES did not run because the input - // was written by an administrator, so we should avoid changing the output - // and we do not need to run KSES here. + /* + * $attr like '[shortcode]' or 'name = [shortcode]' implies unfiltered_html. + * In this specific situation we assume KSES did not run because the input + * was written by an administrator, so we should avoid changing the output + * and we do not need to run KSES here. + */ $attr = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $attr ); } else { - // $attr like 'name = "[shortcode]"' or "name = '[shortcode]'" + // $attr like 'name = "[shortcode]"' or "name = '[shortcode]'". // We do not know if $content was unfiltered. Assume KSES ran before shortcodes. $count = 0; $new_attr = preg_replace_callback( "/$pattern/", 'do_shortcode_tag', $attr, -1, $count ); @@ -459,7 +461,7 @@ function do_shortcodes_in_html_tags( $content, $ignore_html, $tagnames ) { } $element = $front . implode( '', $attributes ) . $back; - // Now encode any remaining [ or ] chars. + // Now encode any remaining '[' or ']' chars. $element = strtr( $element, $trans ); } @@ -646,7 +648,7 @@ function strip_shortcodes( $content ) { $pattern = get_shortcode_regex( $tagnames ); $content = preg_replace_callback( "/$pattern/", 'strip_shortcode_tag', $content ); - // Always restore square braces so we don't break things like <!--[if IE ]> + // Always restore square braces so we don't break things like <!--[if IE ]>. $content = unescape_invalid_shortcodes( $content ); return $content; @@ -661,7 +663,7 @@ function strip_shortcodes( $content ) { * @return string|false The content stripped of the tag, otherwise false. */ function strip_shortcode_tag( $m ) { - // allow [[foo]] syntax for escaping a tag + // Allow [[foo]] syntax for escaping a tag. if ( $m[1] == '[' && $m[6] == ']' ) { return substr( $m[0], 1, -1 ); } diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index a6adef3035..f161a71818 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -7,7 +7,7 @@ */ // -// Taxonomy Registration +// Taxonomy registration. // /** @@ -680,7 +680,7 @@ function unregister_taxonomy_for_object_type( $taxonomy, $object_type ) { } // -// Term API +// Term API. // /** @@ -977,7 +977,7 @@ function get_term_by( $field, $value, $taxonomy = '', $output = OBJECT, $filter $term = array_shift( $terms ); - // In the case of 'term_taxonomy_id', override the provided `$taxonomy` with whatever we find in the db. + // In the case of 'term_taxonomy_id', override the provided `$taxonomy` with whatever we find in the DB. if ( 'term_taxonomy_id' === $field ) { $taxonomy = $term->taxonomy; } @@ -1595,7 +1595,7 @@ function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) { */ $value = apply_filters( "pre_{$taxonomy}_{$field}", $value ); - // Back compat filters + // Back compat filters. if ( 'slug' === $field ) { /** * Filters the category nicename before it is sanitized. @@ -1692,7 +1692,7 @@ function wp_count_terms( $taxonomy, $args = array() ) { ); $args = wp_parse_args( $args, $defaults ); - // backward compatibility + // Backward compatibility. if ( isset( $args['ignore_empty'] ) ) { $args['hide_empty'] = $args['ignore_empty']; unset( $args['ignore_empty'] ); @@ -1776,7 +1776,7 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) { if ( 'category' === $taxonomy ) { $defaults['default'] = (int) get_option( 'default_category' ); if ( $defaults['default'] === $term ) { - return 0; // Don't delete the default category + return 0; // Don't delete the default category. } } @@ -1803,7 +1803,7 @@ function wp_delete_term( $term, $taxonomy, $args = array() ) { */ do_action( 'pre_delete_term', $term, $taxonomy ); - // Update children to point to new parent + // Update children to point to new parent. if ( is_taxonomy_hierarchical( $taxonomy ) ) { $term_obj = get_term( $term, $taxonomy ); if ( is_wp_error( $term_obj ) ) { @@ -2269,7 +2269,7 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) { $term_id = (int) $wpdb->insert_id; - // Seems unreachable, However, Is used in the case that a term name is provided, which sanitizes to an empty string. + // Seems unreachable. However, is used in the case that a term name is provided, which sanitizes to an empty string. if ( empty( $slug ) ) { $slug = sanitize_title( $slug, $term_id ); @@ -2817,7 +2817,7 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) { $term_id = (int) $term_id; - // First, get all of the original args + // First, get all of the original args. $term = get_term( $term_id, $taxonomy ); if ( is_wp_error( $term ) ) { @@ -2911,7 +2911,7 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) { */ $parent = (int) apply_filters( 'wp_update_term_parent', $args['parent'], $term_id, $taxonomy, $parsed_args, $args ); - // Check for duplicate slug + // Check for duplicate slug. $duplicate = get_term_by( 'slug', $slug, $taxonomy ); if ( $duplicate && $duplicate->term_id !== $term_id ) { // If an empty slug was passed or the parent changed, reset the slug to something unique. @@ -3068,7 +3068,7 @@ function wp_defer_term_counting( $defer = null ) { if ( is_bool( $defer ) ) { $_defer = $defer; - // flush any deferred counts + // Flush any deferred counts. if ( ! $defer ) { wp_update_term_count( null, null, true ); } @@ -3148,10 +3148,10 @@ function wp_update_term_count_now( $terms, $taxonomy ) { } if ( $object_types == array_filter( $object_types, 'post_type_exists' ) ) { - // Only post types are attached to this taxonomy + // Only post types are attached to this taxonomy. _update_post_term_count( $terms, $taxonomy ); } else { - // Default count updater + // Default count updater. _update_generic_term_count( $terms, $taxonomy ); } } @@ -3162,7 +3162,7 @@ function wp_update_term_count_now( $terms, $taxonomy ) { } // -// Cache +// Cache. // /** @@ -3452,7 +3452,7 @@ function update_term_cache( $terms, $taxonomy = '' ) { } // -// Private +// Private. // /** @@ -3669,7 +3669,7 @@ function _prime_term_caches( $term_ids, $update_meta_cache = true ) { } // -// Default callbacks +// Default callbacks. // /** @@ -4237,7 +4237,8 @@ function get_term_link( $term, $taxonomy = '' ) { } $termlink = home_url( user_trailingslashit( $termlink, 'category' ) ); } - // Back Compat filters. + + // Back compat filters. if ( 'post_tag' === $taxonomy ) { /** @@ -4569,7 +4570,7 @@ function wp_get_term_taxonomy_parent_id( $term_id, $taxonomy ) { * @return int The new parent for the term. */ function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) { - // Nothing fancy here - bail + // Nothing fancy here - bail. if ( ! $parent ) { return 0; } @@ -4582,7 +4583,7 @@ function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) { // Now look for larger loops. $loop = wp_find_hierarchy_loop( 'wp_get_term_taxonomy_parent_id', $term_id, $parent, array( $taxonomy ) ); if ( ! $loop ) { - return $parent; // No loop + return $parent; // No loop. } // Setting $parent to the given value causes a loop. diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php index cd94f1ded3..ffaa336e69 100644 --- a/src/wp-includes/template.php +++ b/src/wp-includes/template.php @@ -428,7 +428,8 @@ function get_page_template() { $pagename = get_query_var( 'pagename' ); if ( ! $pagename && $id ) { - // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object + // If a static page is set as the front page, $pagename will not be set. + // Retrieve it from the queried object. $post = get_queried_object(); if ( $post ) { $pagename = $post->post_name; diff --git a/src/wp-includes/theme-compat/comments.php b/src/wp-includes/theme-compat/comments.php index bd58af2a2a..d5aa5c928d 100644 --- a/src/wp-includes/theme-compat/comments.php +++ b/src/wp-includes/theme-compat/comments.php @@ -15,7 +15,7 @@ _deprecated_file( sprintf( __( 'Please include a %s template in your theme.' ), basename( __FILE__ ) ) ); -// Do not delete these lines +// Do not delete these lines. if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && 'comments.php' == basename( $_SERVER['SCRIPT_FILENAME'] ) ) { die( 'Please do not load this page directly. Thanks!' ); } @@ -62,12 +62,12 @@ if ( post_password_required() ) { ?> <div class="alignleft"><?php previous_comments_link(); ?></div> <div class="alignright"><?php next_comments_link(); ?></div> </div> -<?php else : // this is displayed if there are no comments so far ?> +<?php else : // This is displayed if there are no comments so far. ?> <?php if ( comments_open() ) : ?> <!-- If comments are open, but there are no comments. --> - <?php else : // comments are closed ?> + <?php else : // Comments are closed. ?> <!-- If comments are closed. --> <p class="nocomments"><?php _e( 'Comments are closed.' ); ?></p> diff --git a/src/wp-includes/theme-compat/header.php b/src/wp-includes/theme-compat/header.php index 461a85aec8..9aef7e98c0 100644 --- a/src/wp-includes/theme-compat/header.php +++ b/src/wp-includes/theme-compat/header.php @@ -30,11 +30,11 @@ _deprecated_file( <style type="text/css" media="screen"> <?php - // Checks to see whether it needs a sidebar + // Checks to see whether it needs a sidebar. if ( empty( $withcomments ) && ! is_single() ) { ?> #page { background: url("<?php bloginfo( 'stylesheet_directory' ); ?>/images/kubrickbg-<?php bloginfo( 'text_direction' ); ?>.jpg") repeat-y top; border: none; } -<?php } else { // No sidebar ?> +<?php } else { // No sidebar. ?> #page { background: url("<?php bloginfo( 'stylesheet_directory' ); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } <?php } ?> diff --git a/src/wp-includes/theme.php b/src/wp-includes/theme.php index 2cf95313a5..1820769691 100644 --- a/src/wp-includes/theme.php +++ b/src/wp-includes/theme.php @@ -398,9 +398,9 @@ function register_theme_directory( $directory ) { global $wp_theme_directories; if ( ! file_exists( $directory ) ) { - // Try prepending as the theme directory could be relative to the content directory + // Try prepending as the theme directory could be relative to the content directory. $directory = WP_CONTENT_DIR . '/' . $directory; - // If this directory does not exist, return and do not register + // If this directory does not exist, return and do not register. if ( ! file_exists( $directory ) ) { return false; } @@ -446,9 +446,11 @@ function search_theme_directories( $force = false ) { $wp_theme_directories = (array) $wp_theme_directories; $relative_theme_roots = array(); - // Set up maybe-relative, maybe-absolute array of theme directories. - // We always want to return absolute, but we need to cache relative - // to use in get_theme_root(). + /* + * Set up maybe-relative, maybe-absolute array of theme directories. + * We always want to return absolute, but we need to cache relative + * to use in get_theme_root(). + */ foreach ( $wp_theme_directories as $theme_root ) { if ( 0 === strpos( $theme_root, WP_CONTENT_DIR ) ) { $relative_theme_roots[ str_replace( WP_CONTENT_DIR, '', $theme_root ) ] = $theme_root; @@ -482,10 +484,10 @@ function search_theme_directories( $force = false ) { return $found_themes; } if ( ! is_int( $cache_expiration ) ) { - $cache_expiration = 1800; // half hour + $cache_expiration = 30 * MINUTE_IN_SECONDS; } } else { - $cache_expiration = 1800; // half hour + $cache_expiration = 30 * MINUTE_IN_SECONDS; } /* Loop the registered theme directories and extract all themes */ @@ -503,7 +505,7 @@ function search_theme_directories( $force = false ) { } if ( file_exists( $theme_root . '/' . $dir . '/style.css' ) ) { // wp-content/themes/a-single-theme - // wp-content/themes is $theme_root, a-single-theme is $dir + // wp-content/themes is $theme_root, a-single-theme is $dir. $found_themes[ $dir ] = array( 'theme_file' => $dir . '/style.css', 'theme_root' => $theme_root, @@ -511,7 +513,7 @@ function search_theme_directories( $force = false ) { } else { $found_theme = false; // wp-content/themes/a-folder-of-themes/* - // wp-content/themes is $theme_root, a-folder-of-themes is $dir, then themes are $sub_dirs + // wp-content/themes is $theme_root, a-folder-of-themes is $dir, then themes are $sub_dirs. $sub_dirs = @ scandir( $theme_root . '/' . $dir ); if ( ! $sub_dirs ) { trigger_error( "$theme_root/$dir is not readable", E_USER_NOTICE ); @@ -675,7 +677,7 @@ function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) { $theme_root = false; - // If requesting the root for the current theme, consult options to avoid calling get_theme_roots() + // If requesting the root for the current theme, consult options to avoid calling get_theme_roots(). if ( ! $skip_cache ) { if ( get_option( 'stylesheet' ) == $stylesheet_or_template ) { $theme_root = get_option( 'stylesheet_root' ); @@ -1277,7 +1279,7 @@ function header_image() { function get_uploaded_header_images() { $header_images = array(); - // @todo caching + // @todo Caching. $headers = get_posts( array( 'post_type' => 'attachment', @@ -1984,7 +1986,7 @@ function remove_editor_styles() { */ function get_editor_stylesheets() { $stylesheets = array(); - // load editor_style.css if the current theme supports it + // Load editor_style.css if the current theme supports it. if ( ! empty( $GLOBALS['editor_styles'] ) && is_array( $GLOBALS['editor_styles'] ) ) { $editor_styles = $GLOBALS['editor_styles']; @@ -2121,7 +2123,7 @@ function get_theme_starter_content() { 'title' => _x( 'Home', 'Theme starter content' ), 'url' => home_url( '/' ), ), - 'page_home' => array( // Deprecated in favor of link_home. + 'page_home' => array( // Deprecated in favor of 'link_home'. 'type' => 'post_type', 'object' => 'page', 'object_id' => '{{home}}', @@ -2301,7 +2303,8 @@ function get_theme_starter_content() { } break; - // All that's left now are posts (besides attachments). Not a default case for the sake of clarity and future work. + // All that's left now are posts (besides attachments). + // Not a default case for the sake of clarity and future work. case 'posts': foreach ( $config[ $type ] as $id => $item ) { if ( is_array( $item ) ) { @@ -2491,11 +2494,13 @@ function add_theme_support( $feature, ...$args ) { $args[0] = wp_parse_args( $args[0], $defaults ); } - // If a constant was defined, use that value. Otherwise, define the constant to ensure - // the constant is always accurate (and is not defined later, overriding our value). - // As stated above, the first value wins. - // Once we get to wp_loaded (just-in-time), define any constants we haven't already. - // Constants are lame. Don't reference them. This is just for backward compatibility. + /* + * If a constant was defined, use that value. Otherwise, define the constant to ensure + * the constant is always accurate (and is not defined later, overriding our value). + * As stated above, the first value wins. + * Once we get to wp_loaded (just-in-time), define any constants we haven't already. + * Constants are lame. Don't reference them. This is just for backward compatibility. + */ if ( defined( 'NO_HEADER_TEXT' ) ) { $args[0]['header-text'] = ! NO_HEADER_TEXT; @@ -2828,16 +2833,18 @@ function current_theme_supports( $feature, ...$args ) { return false; } - // If no args passed then no extra checks need be performed + // If no args passed then no extra checks need be performed. if ( ! $args ) { return true; } switch ( $feature ) { case 'post-thumbnails': - // post-thumbnails can be registered for only certain content/post types by passing - // an array of types to add_theme_support(). If no array was passed, then - // any type is accepted + /* + * post-thumbnails can be registered for only certain content/post types + * by passing an array of types to add_theme_support(). + * If no array was passed, then any type is accepted. + */ if ( true === $_wp_theme_features[ $feature ] ) { // Registered for all types return true; } @@ -2846,11 +2853,12 @@ function current_theme_supports( $feature, ...$args ) { case 'html5': case 'post-formats': - // specific post formats can be registered by passing an array of types to - // add_theme_support() - - // Specific areas of HTML5 support *must* be passed via an array to add_theme_support() - + /* + * Specific post formats can be registered by passing an array of types + * to add_theme_support(). + * + * Specific areas of HTML5 support *must* be passed via an array to add_theme_support(). + */ $type = $args[0]; return in_array( $type, $_wp_theme_features[ $feature ][0] ); @@ -2941,7 +2949,7 @@ function check_theme_switched() { if ( $stylesheet ) { $old_theme = wp_get_theme( $stylesheet ); - // Prevent widget & menu mapping from running since Customizer already called it up front + // Prevent widget & menu mapping from running since Customizer already called it up front. if ( get_option( 'theme_switched_via_customizer' ) ) { remove_action( 'after_switch_theme', '_wp_menus_changed' ); remove_action( 'after_switch_theme', '_wp_sidebars_changed' ); @@ -3013,10 +3021,16 @@ function _wp_customize_include() { ); $theme = null; - $changeset_uuid = false; // Value false indicates UUID should be determined after_setup_theme to either re-use existing saved changeset or else generate a new UUID if none exists. - $messenger_channel = null; $autosaved = null; - $branching = false; // Set initially fo false since defaults to true for back-compat; can be overridden via the customize_changeset_branching filter. + $messenger_channel = null; + + // Value false indicates UUID should be determined after_setup_theme + // to either re-use existing saved changeset or else generate a new UUID if none exists. + $changeset_uuid = false; + + // Set initially fo false since defaults to true for back-compat; + // can be overridden via the customize_changeset_branching filter. + $branching = false; if ( $is_customize_admin_page && isset( $input_vars['changeset_uuid'] ) ) { $changeset_uuid = sanitize_key( $input_vars['changeset_uuid'] ); @@ -3249,7 +3263,7 @@ function wp_customize_support_script() { <?php endif; ?> b[c] = b[c].replace( rcs, ' ' ); - // The customizer requires postMessage and CORS (if the site is cross domain) + // The customizer requires postMessage and CORS (if the site is cross domain). b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs; }()); </script> diff --git a/src/wp-includes/update.php b/src/wp-includes/update.php index dfb27b2aad..125a6e3084 100644 --- a/src/wp-includes/update.php +++ b/src/wp-includes/update.php @@ -27,14 +27,14 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) { } global $wpdb, $wp_local_package; - // include an unmodified $wp_version + // Include an unmodified $wp_version. include( ABSPATH . WPINC . '/version.php' ); $php_version = phpversion(); $current = get_site_transient( 'update_core' ); $translations = wp_get_installed_translations( 'core' ); - // Invalidate the transient when $wp_version changes + // Invalidate the transient when $wp_version changes. if ( is_object( $current ) && $wp_version != $current->version_checked ) { $current = false; } @@ -49,8 +49,8 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) { $force_check = true; } - // Wait 60 seconds between multiple version check requests - $timeout = 60; + // Wait 1 minute between multiple version check requests. + $timeout = MINUTE_IN_SECONDS; $time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked ); if ( ! $force_check && $time_not_changed ) { return; @@ -65,7 +65,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) { */ $locale = apply_filters( 'core_version_check_locale', get_locale() ); - // Update last_checked for current to prevent multiple blocking requests if request hangs + // Update last_checked for current to prevent multiple blocking requests if request hangs. $current->last_checked = time(); set_site_transient( 'update_core', $current ); @@ -260,10 +260,10 @@ function wp_update_plugins( $extra_stats = array() ) { return; } - // include an unmodified $wp_version + // Include an unmodified $wp_version. include( ABSPATH . WPINC . '/version.php' ); - // If running blog-side, bail unless we've not checked in the last 12 hours + // If running blog-side, bail unless we've not checked in the last 12 hours. if ( ! function_exists( 'get_plugins' ) ) { require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); } @@ -323,13 +323,13 @@ function wp_update_plugins( $extra_stats = array() ) { } } - // Bail if we've checked recently and if nothing has changed + // Bail if we've checked recently and if nothing has changed. if ( ! $plugin_changed ) { return; } } - // Update last_checked for current to prevent multiple blocking requests if request hangs + // Update last_checked for current to prevent multiple blocking requests if request hangs. $current->last_checked = time(); set_site_transient( 'update_plugins', $current ); @@ -351,7 +351,7 @@ function wp_update_plugins( $extra_stats = array() ) { if ( $doing_cron ) { $timeout = 30; } else { - // Three seconds, plus one extra second for every 10 plugins + // Three seconds, plus one extra second for every 10 plugins. $timeout = 3 + (int) ( count( $plugins ) / 10 ); } @@ -440,7 +440,7 @@ function wp_update_themes( $extra_stats = array() ) { return; } - // include an unmodified $wp_version + // Include an unmodified $wp_version. include( ABSPATH . WPINC . '/version.php' ); $installed_themes = wp_get_themes(); @@ -513,13 +513,13 @@ function wp_update_themes( $extra_stats = array() ) { } } - // Bail if we've checked recently and if nothing has changed + // Bail if we've checked recently and if nothing has changed. if ( ! $theme_changed ) { return; } } - // Update last_checked for current to prevent multiple blocking requests if request hangs + // Update last_checked for current to prevent multiple blocking requests if request hangs. $last_update->last_checked = time(); set_site_transient( 'update_themes', $last_update ); @@ -541,7 +541,7 @@ function wp_update_themes( $extra_stats = array() ) { if ( $doing_cron ) { $timeout = 30; } else { - // Three seconds, plus one extra second for every 10 themes + // Three seconds, plus one extra second for every 10 themes. $timeout = 3 + (int) ( count( $themes ) / 10 ); } @@ -728,7 +728,7 @@ function wp_get_update_data() { * @global string $wp_version */ function _maybe_update_core() { - // include an unmodified $wp_version + // Include an unmodified $wp_version. include( ABSPATH . WPINC . '/version.php' ); $current = get_site_transient( 'update_core' ); diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index a1478679f6..33249b5a53 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -87,7 +87,7 @@ function wp_signon( $credentials = array(), $secure_cookie = '' ) { */ $secure_cookie = apply_filters( 'secure_signon_cookie', $secure_cookie, $credentials ); - global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie + global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie(). $auth_secure_cookie = $secure_cookie; add_filter( 'authenticate', 'wp_authenticate_cookie', 30, 3 ); @@ -208,7 +208,8 @@ function wp_authenticate_email_password( $user, $email, $password ) { $error = new WP_Error(); if ( empty( $email ) ) { - $error->add( 'empty_username', __( '<strong>ERROR</strong>: The email field is empty.' ) ); // Uses 'empty_username' for back-compat with wp_signon() + // Uses 'empty_username' for back-compat with wp_signon(). + $error->add( 'empty_username', __( '<strong>ERROR</strong>: The email field is empty.' ) ); } if ( empty( $password ) ) { @@ -426,7 +427,7 @@ function count_many_users_posts( $users, $post_type = 'post', $public_only = fal } // -// User option functions +// User option functions. // /** @@ -480,9 +481,9 @@ function get_user_option( $option, $user = 0, $deprecated = '' ) { } $prefix = $wpdb->get_blog_prefix(); - if ( $user->has_prop( $prefix . $option ) ) { // Blog specific + if ( $user->has_prop( $prefix . $option ) ) { // Blog-specific. $result = $user->get( $prefix . $option ); - } elseif ( $user->has_prop( $option ) ) { // User specific and cross-blog + } elseif ( $user->has_prop( $option ) ) { // User-specific and cross-blog. $result = $user->get( $option ); } else { $result = false; @@ -599,7 +600,7 @@ function get_blogs_of_user( $user_id, $all = false ) { $user_id = (int) $user_id; - // Logged out users can't have sites + // Logged out users can't have sites. if ( empty( $user_id ) ) { return array(); } @@ -733,8 +734,8 @@ function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) { $user_id = get_current_user_id(); } - // Technically not needed, but does save calls to get_site and get_user_meta - // in the event that the function is called when a user isn't logged in + // Technically not needed, but does save calls to get_site() and get_user_meta() + // in the event that the function is called when a user isn't logged in. if ( empty( $user_id ) ) { return false; } else { @@ -763,7 +764,7 @@ function is_user_member_of_blog( $user_id = 0, $blog_id = 0 ) { return false; } - // no underscore before capabilities in $base_capabilities_key + // No underscore before capabilities in $base_capabilities_key. $base_capabilities_key = $wpdb->base_prefix . 'capabilities'; $site_capabilities_key = $wpdb->base_prefix . $blog_id . '_capabilities'; @@ -875,7 +876,7 @@ function update_user_meta( $user_id, $meta_key, $meta_value, $prev_value = '' ) function count_users( $strategy = 'time', $site_id = null ) { global $wpdb; - // Initialize + // Initialize. if ( ! $site_id ) { $site_id = get_current_blog_id(); } @@ -984,7 +985,7 @@ function count_users( $strategy = 'time', $site_id = null ) { } // -// Private helper functions +// Private helper functions. // /** @@ -1540,11 +1541,11 @@ function wp_insert_user( $userdata ) { return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) ); } - // hashed in wp_update_user(), plaintext if called directly + // hashed in wp_update_user(), plaintext if called directly. $user_pass = ! empty( $userdata['user_pass'] ) ? $userdata['user_pass'] : $old_user_data->user_pass; } else { $update = false; - // Hash the password + // Hash the password. $user_pass = wp_hash_password( $userdata['user_pass'] ); } @@ -1561,7 +1562,7 @@ function wp_insert_user( $userdata ) { */ $pre_user_login = apply_filters( 'pre_user_login', $sanitized_user_login ); - //Remove any non-printable chars from the login string to see if we have ended up with an empty username + // Remove any non-printable chars from the login string to see if we have ended up with an empty username. $user_login = trim( $pre_user_login ); // user_login must be between 0 and 60 characters. @@ -1933,7 +1934,7 @@ function wp_update_user( $userdata ) { return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) ); } - // First, get all of the original fields + // First, get all of the original fields. $user_obj = get_userdata( $ID ); if ( ! $user_obj ) { return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) ); @@ -1941,7 +1942,7 @@ function wp_update_user( $userdata ) { $user = $user_obj->to_array(); - // Add additional custom fields + // Add additional custom fields. foreach ( _get_additional_user_keys( $user_obj ) as $key ) { $user[ $key ] = get_user_meta( $ID, $key, true ); } @@ -1950,7 +1951,7 @@ function wp_update_user( $userdata ) { $user = add_magic_quotes( $user ); if ( ! empty( $userdata['user_pass'] ) && $userdata['user_pass'] !== $user_obj->user_pass ) { - // If password is changing, hash it now + // If password is changing, hash it now. $plaintext_pass = $userdata['user_pass']; $userdata['user_pass'] = wp_hash_password( $userdata['user_pass'] ); @@ -2411,7 +2412,7 @@ function check_password_reset_key( $key, $login ) { if ( $hash_is_correct && $expiration_time && time() < $expiration_time ) { return $user; } elseif ( $hash_is_correct && $expiration_time ) { - // Key has an expiration time that's passed + // Key has an expiration time that's passed. return new WP_Error( 'expired_key', __( 'Invalid key.' ) ); } @@ -2491,7 +2492,7 @@ function register_new_user( $user_login, $user_email ) { */ $user_email = apply_filters( 'user_registration_email', $user_email ); - // Check the username + // Check the username. if ( $sanitized_user_login == '' ) { $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Please enter a username.' ) ); } elseif ( ! validate_username( $user_login ) ) { @@ -2508,7 +2509,7 @@ function register_new_user( $user_login, $user_email ) { } } - // Check the email address + // Check the email address. if ( $user_email == '' ) { $errors->add( 'empty_email', __( '<strong>ERROR</strong>: Please type your email address.' ) ); } elseif ( ! is_email( $user_email ) ) { @@ -2567,7 +2568,7 @@ function register_new_user( $user_login, $user_email ) { return $errors; } - update_user_option( $user_id, 'default_password_nag', true, true ); //Set up the Password change nag. + update_user_option( $user_id, 'default_password_nag', true, true ); // Set up the password change nag. /** * Fires after a new user registration has been recorded. @@ -2728,7 +2729,7 @@ function _wp_get_current_user() { return $current_user; } - // Upgrade stdClass to WP_User + // Upgrade stdClass to WP_User. if ( is_object( $current_user ) && isset( $current_user->ID ) ) { $cur_id = $current_user->ID; $current_user = null; @@ -3405,8 +3406,8 @@ function wp_create_user_request( $email_address = '', $action_name = '', $reques $requests_query = new WP_Query( array( 'post_type' => 'user_request', - 'post_name__in' => array( $action_name ), // Action name stored in post_name column. - 'title' => $email_address, // Email address stored in post_title column. + 'post_name__in' => array( $action_name ), // Action name stored in post_name column. + 'title' => $email_address, // Email address stored in post_title column. 'post_status' => array( 'request-pending', 'request-confirmed', diff --git a/src/wp-includes/vars.php b/src/wp-includes/vars.php index 6a5e112b99..72259b2652 100644 --- a/src/wp-includes/vars.php +++ b/src/wp-includes/vars.php @@ -19,9 +19,9 @@ global $pagenow, $is_lynx, $is_gecko, $is_winIE, $is_macIE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone, $is_IE, $is_edge, $is_apache, $is_IIS, $is_iis7, $is_nginx; -// On which page are we ? +// On which page are we? if ( is_admin() ) { - // wp-admin pages are checked more carefully + // wp-admin pages are checked more carefully. if ( is_network_admin() ) { preg_match( '#/wp-admin/network/?(.*?)$#i', $_SERVER['PHP_SELF'], $self_matches ); } elseif ( is_user_admin() ) { @@ -38,7 +38,7 @@ if ( is_admin() ) { preg_match( '#(.*?)(/|$)#', $pagenow, $self_matches ); $pagenow = strtolower( $self_matches[1] ); if ( '.php' !== substr( $pagenow, -4, 4 ) ) { - $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) + $pagenow .= '.php'; // For `Options +Multiviews`: /wp-admin/themes/index.php (themes.php is queried). } } } else { @@ -50,7 +50,7 @@ if ( is_admin() ) { } unset( $self_matches ); -// Simple browser detection +// Simple browser detection. $is_lynx = false; $is_gecko = false; $is_winIE = false; @@ -106,7 +106,7 @@ if ( $is_safari && stripos( $_SERVER['HTTP_USER_AGENT'], 'mobile' ) !== false ) $is_IE = ( $is_macIE || $is_winIE ); -// Server detection +// Server detection. /** * Whether the server software is Apache or something else @@ -146,7 +146,7 @@ $is_iis7 = $is_IIS && intval( substr( $_SERVER['SERVER_SOFTWARE'], strpos( $_SER function wp_is_mobile() { if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { $is_mobile = false; - } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Mobile' ) !== false // many mobile devices (all iPhone, iPad, etc.) + } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Mobile' ) !== false // Many mobile devices (all iPhone, iPad, etc.) || strpos( $_SERVER['HTTP_USER_AGENT'], 'Android' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Silk/' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Kindle' ) !== false diff --git a/src/wp-includes/widgets.php b/src/wp-includes/widgets.php index 19503bcecf..34efd13e5e 100644 --- a/src/wp-includes/widgets.php +++ b/src/wp-includes/widgets.php @@ -19,7 +19,7 @@ */ // -// Global Variables +// Global Variables. // /** @ignore */ @@ -91,7 +91,7 @@ $GLOBALS['_wp_deprecated_widgets_callbacks'] = array( ); // -// Template tags & API functions +// Template tags & API functions. // /** @@ -186,10 +186,10 @@ function register_sidebars( $number = 1, $args = array() ) { } // Custom specified ID's are suffixed if they exist already. - // Automatically generated sidebar names need to be suffixed regardless starting at -0 + // Automatically generated sidebar names need to be suffixed regardless starting at -0. if ( isset( $args['id'] ) ) { $_args['id'] = $args['id']; - $n = 2; // Start at -2 for conflicting custom ID's + $n = 2; // Start at -2 for conflicting custom IDs. while ( is_registered_sidebar( $_args['id'] ) ) { $_args['id'] = $args['id'] . '-' . $n++; } @@ -529,7 +529,7 @@ function wp_register_widget_control( $id, $name, $control_callback, $options = a $defaults = array( 'width' => 250, 'height' => 200, - ); // height is never used + ); // Height is never used. $options = wp_parse_args( $options, $defaults ); $options['width'] = (int) $options['width']; $options['height'] = (int) $options['height']; @@ -726,7 +726,7 @@ function dynamic_sidebar( $index = 1 ) { (array) $wp_registered_widgets[ $id ]['params'] ); - // Substitute HTML id and class attributes into before_widget + // Substitute HTML `id` and `class` attributes into `before_widget`. $classname_ = ''; foreach ( (array) $wp_registered_widgets[ $id ]['classname'] as $cn ) { if ( is_string( $cn ) ) { @@ -947,7 +947,7 @@ function is_active_sidebar( $index ) { } // -// Internal Functions +// Internal Functions. // /** @@ -1075,7 +1075,7 @@ function wp_convert_widget_settings( $base_name, $option_name, $settings ) { if ( $single ) { $settings = array( 2 => $settings ); - // If loading from the front page, update sidebar in memory but don't save to options + // If loading from the front page, update sidebar in memory but don't save to options. if ( is_admin() ) { $sidebars_widgets = get_option( 'sidebars_widgets' ); } else { @@ -1376,11 +1376,11 @@ function wp_map_sidebars_widgets( $existing_sidebars_widgets ) { // Go back and check the next new sidebar. continue 3; } - } // endforeach ( $slug_group as $slug ) - } // endforeach ( $existing_sidebars_widgets as $sidebar => $widgets ) - } // endforeach foreach ( $wp_registered_sidebars as $new_sidebar => $args ) - } // endforeach ( $slug_group as $slug ) - } // endforeach ( $common_slug_groups as $slug_group ) + } // End foreach ( $slug_group as $slug ). + } // End foreach ( $existing_sidebars_widgets as $sidebar => $widgets ). + } // End foreach ( $wp_registered_sidebars as $new_sidebar => $args ). + } // End foreach ( $slug_group as $slug ). + } // End foreach ( $common_slug_groups as $slug_group ). } // Move any left over widgets to inactive sidebar. @@ -1440,11 +1440,11 @@ function wp_map_sidebars_widgets( $existing_sidebars_widgets ) { // ...otherwise remove it from the old sidebar and keep it in the new one. unset( $old_sidebars_widgets[ $old_sidebar ][ $key ] ); } - } // endif ( $active_key ) - } // endforeach ( $old_widgets as $key => $widget_id ) - } // endforeach ( $new_sidebars_widgets as $new_sidebar => $new_widgets ) - } // endforeach ( $old_sidebars_widgets as $old_sidebar => $old_widgets ) - } // endif ( ! empty( $old_sidebars_widgets ) ) + } // End if ( $active_key ). + } // End foreach ( $old_widgets as $key => $widget_id ). + } // End foreach ( $new_sidebars_widgets as $new_sidebar => $new_widgets ). + } // End foreach ( $old_sidebars_widgets as $old_sidebar => $old_widgets ). + } // End if ( ! empty( $old_sidebars_widgets ) ). // Restore widget settings from when theme was previously active. $new_sidebars_widgets = array_merge( $new_sidebars_widgets, $old_sidebars_widgets ); diff --git a/src/wp-includes/widgets/class-wp-nav-menu-widget.php b/src/wp-includes/widgets/class-wp-nav-menu-widget.php index 8f1a208e41..1edaeac464 100644 --- a/src/wp-includes/widgets/class-wp-nav-menu-widget.php +++ b/src/wp-includes/widgets/class-wp-nav-menu-widget.php @@ -39,7 +39,7 @@ class WP_Nav_Menu_Widget extends WP_Widget { * @param array $instance Settings for the current Navigation Menu widget instance. */ public function widget( $args, $instance ) { - // Get menu + // Get menu. $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; if ( ! $nav_menu ) { @@ -117,7 +117,7 @@ class WP_Nav_Menu_Widget extends WP_Widget { $title = isset( $instance['title'] ) ? $instance['title'] : ''; $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : ''; - // Get menus + // Get menus. $menus = wp_get_nav_menus(); $empty_menus_style = ''; diff --git a/src/wp-includes/widgets/class-wp-widget-categories.php b/src/wp-includes/widgets/class-wp-widget-categories.php index 92f30c0a85..64959b3a2a 100644 --- a/src/wp-includes/widgets/class-wp-widget-categories.php +++ b/src/wp-includes/widgets/class-wp-widget-categories.php @@ -160,7 +160,7 @@ class WP_Widget_Categories extends WP_Widget { * @param array $instance Current settings. */ public function form( $instance ) { - //Defaults + // Defaults. $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); $count = isset( $instance['count'] ) ? (bool) $instance['count'] : false; $hierarchical = isset( $instance['hierarchical'] ) ? (bool) $instance['hierarchical'] : false; diff --git a/src/wp-includes/widgets/class-wp-widget-custom-html.php b/src/wp-includes/widgets/class-wp-widget-custom-html.php index 0d8a67339d..d947aeae8e 100644 --- a/src/wp-includes/widgets/class-wp-widget-custom-html.php +++ b/src/wp-includes/widgets/class-wp-widget-custom-html.php @@ -70,10 +70,12 @@ class WP_Widget_Custom_HTML extends WP_Widget { wp_add_inline_script( 'custom-html-widgets', sprintf( 'wp.customHtmlWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) ); - // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). + // Note that the widgets component in the customizer will also do + // the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); - // Note that the widgets component in the customizer will also do the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). + // Note that the widgets component in the customizer will also do + // the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). add_action( 'admin_footer-widgets.php', array( 'WP_Widget_Custom_HTML', 'render_control_template_scripts' ) ); // Note this action is used to ensure the help text is added to the end. @@ -225,7 +227,8 @@ class WP_Widget_Custom_HTML extends WP_Widget { /* translators: %d: Error count. */ 'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ), /* translators: %d: Error count. */ - 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. + 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), + // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. ), ); wp_add_inline_script( 'custom-html-widgets', sprintf( 'jQuery.extend( wp.customHtmlWidgets.l10n, %s );', wp_json_encode( $l10n ) ), 'after' ); diff --git a/src/wp-includes/widgets/class-wp-widget-links.php b/src/wp-includes/widgets/class-wp-widget-links.php index 92924380ed..c993ed5528 100644 --- a/src/wp-includes/widgets/class-wp-widget-links.php +++ b/src/wp-includes/widgets/class-wp-widget-links.php @@ -124,7 +124,7 @@ class WP_Widget_Links extends WP_Widget { */ public function form( $instance ) { - //Defaults + // Defaults. $instance = wp_parse_args( (array) $instance, array( diff --git a/src/wp-includes/widgets/class-wp-widget-media.php b/src/wp-includes/widgets/class-wp-widget-media.php index 029928f230..bb8976a4ea 100644 --- a/src/wp-includes/widgets/class-wp-widget-media.php +++ b/src/wp-includes/widgets/class-wp-widget-media.php @@ -106,14 +106,16 @@ abstract class WP_Widget_Media extends WP_Widget { } $this->registered = true; - // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). + // Note that the widgets component in the customizer will also do + // the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); if ( $this->is_preview() ) { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) ); } - // Note that the widgets component in the customizer will also do the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). + // Note that the widgets component in the customizer will also do + // the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) ); add_filter( 'display_media_states', array( $this, 'display_media_state' ), 10, 2 ); @@ -274,7 +276,10 @@ abstract class WP_Widget_Media extends WP_Widget { } $value = $new_instance[ $field ]; - // Workaround for rest_validate_value_from_schema() due to the fact that rest_is_boolean( '' ) === false, while rest_is_boolean( '1' ) is true. + /* + * Workaround for rest_validate_value_from_schema() due to the fact that + * rest_is_boolean( '' ) === false, while rest_is_boolean( '1' ) is true. + */ if ( 'boolean' === $field_schema['type'] && '' === $value ) { $value = false; } diff --git a/src/wp-includes/widgets/class-wp-widget-pages.php b/src/wp-includes/widgets/class-wp-widget-pages.php index 380f8cd980..853b39ca9d 100644 --- a/src/wp-includes/widgets/class-wp-widget-pages.php +++ b/src/wp-includes/widgets/class-wp-widget-pages.php @@ -130,7 +130,7 @@ class WP_Widget_Pages extends WP_Widget { * @param array $instance Current settings. */ public function form( $instance ) { - //Defaults + // Defaults. $instance = wp_parse_args( (array) $instance, array( diff --git a/src/wp-includes/widgets/class-wp-widget-recent-comments.php b/src/wp-includes/widgets/class-wp-widget-recent-comments.php index 256a015a2c..a5f21919b0 100644 --- a/src/wp-includes/widgets/class-wp-widget-recent-comments.php +++ b/src/wp-includes/widgets/class-wp-widget-recent-comments.php @@ -49,7 +49,7 @@ class WP_Widget_Recent_Comments extends WP_Widget { * @param bool $active Whether the widget is active. Default true. * @param string $id_base The widget ID. */ - if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876 + if ( ! current_theme_supports( 'widgets' ) // Temp hack #14876. || ! apply_filters( 'show_recent_comments_widget_style', true, $this->id_base ) ) { return; } diff --git a/src/wp-includes/widgets/class-wp-widget-rss.php b/src/wp-includes/widgets/class-wp-widget-rss.php index 570e7bba43..d898836745 100644 --- a/src/wp-includes/widgets/class-wp-widget-rss.php +++ b/src/wp-includes/widgets/class-wp-widget-rss.php @@ -56,7 +56,7 @@ class WP_Widget_RSS extends WP_Widget { return; } - // self-url destruction sequence + // Self-URL destruction sequence. if ( in_array( untrailingslashit( $url ), array( site_url(), home_url() ) ) ) { return; } diff --git a/src/wp-includes/widgets/class-wp-widget-search.php b/src/wp-includes/widgets/class-wp-widget-search.php index d27babe9ab..c7c794b993 100644 --- a/src/wp-includes/widgets/class-wp-widget-search.php +++ b/src/wp-includes/widgets/class-wp-widget-search.php @@ -50,7 +50,7 @@ class WP_Widget_Search extends WP_Widget { echo $args['before_title'] . $title . $args['after_title']; } - // Use current theme search form if it exists + // Use current theme search form if it exists. get_search_form(); echo $args['after_widget']; diff --git a/src/wp-includes/widgets/class-wp-widget-tag-cloud.php b/src/wp-includes/widgets/class-wp-widget-tag-cloud.php index c3c3045686..6542250a37 100644 --- a/src/wp-includes/widgets/class-wp-widget-tag-cloud.php +++ b/src/wp-includes/widgets/class-wp-widget-tag-cloud.php @@ -148,7 +148,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget { switch ( count( $taxonomies ) ) { - // No tag cloud supporting taxonomies found, display error message + // No tag cloud supporting taxonomies found, display error message. case 0: echo '<p>' . __( 'The tag cloud will not be displayed since there are no taxonomies that support the tag cloud widget.' ) . '</p>'; printf( $input, '' ); diff --git a/src/wp-includes/widgets/class-wp-widget-text.php b/src/wp-includes/widgets/class-wp-widget-text.php index 1c4ffa6bbe..0aa320f025 100644 --- a/src/wp-includes/widgets/class-wp-widget-text.php +++ b/src/wp-includes/widgets/class-wp-widget-text.php @@ -61,10 +61,12 @@ class WP_Widget_Text extends WP_Widget { add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) ); } - // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). + // Note that the widgets component in the customizer will also do + // the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); - // Note that the widgets component in the customizer will also do the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). + // Note that the widgets component in the customizer will also do + // the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). add_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) ); } @@ -121,7 +123,7 @@ class WP_Widget_Text extends WP_Widget { $doc = new DOMDocument(); - // Suppress warnings generated by loadHTML + // Suppress warnings generated by loadHTML. $errors = libxml_use_internal_errors( true ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged @$doc->loadHTML( @@ -373,7 +375,7 @@ class WP_Widget_Text extends WP_Widget { 'title' => '', 'text' => '', 'filter' => false, // For back-compat. - 'visual' => null, // Must be explicitly defined. + 'visual' => null, // Must be explicitly defined. ) ); diff --git a/src/wp-includes/wp-db.php b/src/wp-includes/wp-db.php index 1bb7da4e66..81755639f0 100644 --- a/src/wp-includes/wp-db.php +++ b/src/wp-includes/wp-db.php @@ -608,7 +608,7 @@ class wpdb { $this->show_errors(); } - // Use ext/mysqli if it exists unless WP_USE_EXT_MYSQL is defined as true + // Use ext/mysqli if it exists unless WP_USE_EXT_MYSQL is defined as true. if ( function_exists( 'mysqli_connect' ) ) { $this->use_mysqli = true; @@ -1176,7 +1176,7 @@ class wpdb { * Escape data. Works on arrays. * * @uses wpdb::_real_escape() - * @since 2.8.0 + * @since 2.8.0 * * @param string|array $data * @return string|array escaped @@ -1348,7 +1348,7 @@ class wpdb { $query = str_replace( '"%s"', '%s', $query ); // Strip any existing double quotes. $query = preg_replace( '/(?<!%)%s/', "'%s'", $query ); // Quote the strings, avoiding escaped strings like %%s. - $query = preg_replace( "/(?<!%)(%($allowed_format)?f)/", '%\\2F', $query ); // Force floats to be locale unaware. + $query = preg_replace( "/(?<!%)(%($allowed_format)?f)/", '%\\2F', $query ); // Force floats to be locale-unaware. $query = preg_replace( "/%(?:%|$|(?!($allowed_format)?[sdF]))/", '%%\\1', $query ); // Escape any unescaped percents. @@ -1464,7 +1464,7 @@ class wpdb { return false; } - // If there is an error then take note of it + // If there is an error then take note of it. if ( is_multisite() ) { $msg = sprintf( "%s [%s]\n%s\n", @@ -1562,12 +1562,12 @@ class wpdb { mysqli_free_result( $this->result ); $this->result = null; - // Sanity check before using the handle + // Sanity check before using the handle. if ( empty( $this->dbh ) || ! ( $this->dbh instanceof mysqli ) ) { return; } - // Clear out any results from a multi-query + // Clear out any results from a multi-query. while ( mysqli_more_results( $this->dbh ) ) { mysqli_next_result( $this->dbh ); } @@ -1794,15 +1794,15 @@ class wpdb { $error_reporting = false; - // Disable warnings, as we don't want to see a multitude of "unable to connect" messages + // Disable warnings, as we don't want to see a multitude of "unable to connect" messages. if ( WP_DEBUG ) { $error_reporting = error_reporting(); error_reporting( $error_reporting & ~E_WARNING ); } for ( $tries = 1; $tries <= $this->reconnect_retries; $tries++ ) { - // On the last try, re-enable warnings. We want to see a single instance of the - // "unable to connect" message on the bail() screen, if it appears. + // On the last try, re-enable warnings. We want to see a single instance + // of the "unable to connect" message on the bail() screen, if it appears. if ( $this->reconnect_retries === $tries && WP_DEBUG ) { error_reporting( $error_reporting ); } @@ -1852,7 +1852,8 @@ class wpdb { // We weren't able to reconnect, so we better bail. $this->bail( $message, 'db_connect_fail' ); - // Call dead_db() if bail didn't die, because this database is no more. It has ceased to be (at least temporarily). + // Call dead_db() if bail didn't die, because this database is no more. + // It has ceased to be (at least temporarily). dead_db(); } @@ -1887,7 +1888,7 @@ class wpdb { $this->flush(); - // Log how the function was called + // Log how the function was called. $this->func_call = "\$db->query(\"$query\")"; // If we're writing to the database, make sure the query will write safely. @@ -1971,7 +1972,7 @@ class wpdb { } else { $this->rows_affected = mysql_affected_rows( $this->dbh ); } - // Take note of the insert_id + // Take note of the insert_id. if ( preg_match( '/^\s*(insert|replace)\s/i', $query ) ) { if ( $this->use_mysqli ) { $this->insert_id = mysqli_insert_id( $this->dbh ); @@ -1979,7 +1980,7 @@ class wpdb { $this->insert_id = mysql_insert_id( $this->dbh ); } } - // Return number of rows affected + // Return number of rows affected. $return_val = $this->rows_affected; } else { $num_rows = 0; @@ -1996,7 +1997,7 @@ class wpdb { } // Log number of rows the query returned - // and return number of rows selected + // and return number of rows selected. $this->num_rows = $num_rows; $return_val = $num_rows; } @@ -2528,12 +2529,12 @@ class wpdb { $this->query( $query ); } - // Extract var out of cached results based x,y vals + // Extract var out of cached results based x,y vals. if ( ! empty( $this->last_result[ $y ] ) ) { $values = array_values( get_object_vars( $this->last_result[ $y ] ) ); } - // If there is a value return it else return null + // If there is a value return it else return null. return ( isset( $values[ $x ] ) && $values[ $x ] !== '' ) ? $values[ $x ] : null; } @@ -2574,7 +2575,7 @@ class wpdb { } elseif ( $output == ARRAY_N ) { return $this->last_result[ $y ] ? array_values( get_object_vars( $this->last_result[ $y ] ) ) : null; } elseif ( strtoupper( $output ) === OBJECT ) { - // Back compat for OBJECT being previously case insensitive. + // Back compat for OBJECT being previously case-insensitive. return $this->last_result[ $y ] ? $this->last_result[ $y ] : null; } else { $this->print_error( ' $db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N' ); @@ -2604,7 +2605,7 @@ class wpdb { } $new_array = array(); - // Extract the column values + // Extract the column values. if ( $this->last_result ) { for ( $i = 0, $j = count( $this->last_result ); $i < $j; $i++ ) { $new_array[ $i ] = $this->get_var( null, $x, $i ); @@ -2643,11 +2644,11 @@ class wpdb { $new_array = array(); if ( $output == OBJECT ) { - // Return an integer-keyed array of row objects + // Return an integer-keyed array of row objects. return $this->last_result; } elseif ( $output == OBJECT_K ) { - // Return an array of row objects with keys from column 1 - // (Duplicates are discarded) + // Return an array of row objects with keys from column 1. + // (Duplicates are discarded.) if ( $this->last_result ) { foreach ( $this->last_result as $row ) { $var_by_ref = get_object_vars( $row ); @@ -2663,17 +2664,17 @@ class wpdb { if ( $this->last_result ) { foreach ( (array) $this->last_result as $row ) { if ( $output == ARRAY_N ) { - // ...integer-keyed row arrays + // ...integer-keyed row arrays. $new_array[] = array_values( get_object_vars( $row ) ); } else { - // ...column name-keyed row arrays + // ...column name-keyed row arrays. $new_array[] = get_object_vars( $row ); } } } return $new_array; } elseif ( strtoupper( $output ) === OBJECT ) { - // Back compat for OBJECT being previously case insensitive. + // Back compat for OBJECT being previously case-insensitive. return $this->last_result; } return null; @@ -3037,9 +3038,11 @@ class wpdb { $truncate_by_byte_length = 'byte' === $value['length']['type']; } else { $length = false; - // Since we have no length, we'll never truncate. - // Initialize the variable to false. true would take us - // through an unnecessary (for this case) codepath below. + /* + * Since we have no length, we'll never truncate. + * Initialize the variable to false. true would take us + * through an unnecessary (for this case) codepath below. + */ $truncate_by_byte_length = false; } @@ -3195,7 +3198,7 @@ class wpdb { return $charset; } - // We can't reliably strip text from tables containing binary/blob columns + // We can't reliably strip text from tables containing binary/blob columns. if ( 'binary' === $charset ) { return $query; } @@ -3296,11 +3299,13 @@ class wpdb { return $maybe[2]; } - // SHOW TABLE STATUS LIKE and SHOW TABLES LIKE 'wp\_123\_%' - // This quoted LIKE operand seldom holds a full table name. - // It is usually a pattern for matching a prefix so we just - // strip the trailing % and unescape the _ to get 'wp_123_' - // which drop-ins can use for routing these SQL statements. + /* + * SHOW TABLE STATUS LIKE and SHOW TABLES LIKE 'wp\_123\_%' + * This quoted LIKE operand seldom holds a full table name. + * It is usually a pattern for matching a prefix so we just + * strip the trailing % and unescape the _ to get 'wp_123_' + * which drop-ins can use for routing these SQL statements. + */ if ( preg_match( '/^\s*SHOW\s+(?:TABLE\s+STATUS|(?:FULL\s+)?TABLES)\s+(?:WHERE\s+Name\s+)?LIKE\s*("|\')((?:[\\\\0-9a-zA-Z$_.-]|[\xC2-\xDF][\x80-\xBF])+)%?\\1/is', $query, $maybe ) ) { return str_replace( '\\_', '_', $maybe[2] ); } @@ -3490,7 +3495,7 @@ class wpdb { */ public function check_database_version() { global $wp_version, $required_mysql_version; - // Make sure the server has the required MySQL version + // Make sure the server has the required MySQL version. if ( version_compare( $this->db_version(), $required_mysql_version, '<' ) ) { /* translators: 1: WordPress version number, 2: Minimum required MySQL version number. */ return new WP_Error( 'database_version', sprintf( __( '<strong>ERROR</strong>: WordPress %1$s requires MySQL %2$s or higher' ), $wp_version, $required_mysql_version ) ); diff --git a/src/wp-load.php b/src/wp-load.php index 2b8830b580..97e1aa908e 100644 --- a/src/wp-load.php +++ b/src/wp-load.php @@ -43,7 +43,7 @@ if ( file_exists( ABSPATH . 'wp-config.php' ) ) { } else { - // A config file doesn't exist + // A config file doesn't exist. define( 'WPINC', 'wp-includes' ); require_once( ABSPATH . WPINC . '/load.php' ); diff --git a/src/wp-login.php b/src/wp-login.php index db739eddad..fabc0cb2e8 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -41,7 +41,7 @@ if ( force_ssl_admin() && ! is_ssl() ) { function login_header( $title = 'Log In', $message = '', $wp_error = null ) { global $error, $interim_login, $action; - // Don't index any of these forms + // Don't index any of these forms. add_action( 'login_head', 'wp_sensitive_page_meta' ); add_action( 'login_head', 'wp_login_viewport_meta' ); @@ -268,7 +268,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = null ) { echo '<p class="message">' . apply_filters( 'login_messages', $messages ) . "</p>\n"; } } -} // End of login_header() +} // End of login_header(). /** * Outputs the footer for the login page. @@ -300,7 +300,7 @@ function login_footer( $input_id = '' ) { } ?> - </div><?php // End of <div id="login"> ?> + </div><?php // End of <div id="login">. ?> <?php @@ -507,7 +507,7 @@ nocache_headers(); header( 'Content-Type: ' . get_bloginfo( 'html_type' ) . '; charset=' . get_bloginfo( 'charset' ) ); -if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set +if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set. if ( isset( $_SERVER['PATH_INFO'] ) && ( $_SERVER['PATH_INFO'] !== $_SERVER['PHP_SELF'] ) ) { $_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] ); } @@ -519,7 +519,7 @@ if ( defined( 'RELOCATE' ) && RELOCATE ) { // Move flag is set } } -//Set a cookie now to see if they are supported by the browser. +// Set a cookie now to see if they are supported by the browser. $secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) ); setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); @@ -560,9 +560,11 @@ $login_link_separator = apply_filters( 'login_link_separator', ' | ' ); switch ( $action ) { case 'confirm_admin_email': - // Note that `is_user_logged_in()` will return false immediately after logging in - // as the current user is not set, see wp-includes/pluggable.php. - // However this action runs on a redirect after logging in. + /* + * Note that `is_user_logged_in()` will return false immediately after logging in + * as the current user is not set, see wp-includes/pluggable.php. + * However this action runs on a redirect after logging in. + */ if ( ! is_user_logged_in() ) { wp_safe_redirect( wp_login_url() ); exit; @@ -1210,7 +1212,7 @@ switch ( $action ) { ) ); } elseif ( isset( $_POST['testcookie'] ) && empty( $_COOKIE[ TEST_COOKIE ] ) ) { - // If cookies are disabled we can't log in even with a valid user+pass + // If cookies are disabled, we can't log in even with a valid user and password. $user = new WP_Error( 'test_cookie', sprintf( diff --git a/src/wp-mail.php b/src/wp-mail.php index 25d2e58bed..1faa685d3e 100644 --- a/src/wp-mail.php +++ b/src/wp-mail.php @@ -33,7 +33,7 @@ require_once( ABSPATH . WPINC . '/class-pop3.php' ); /** Only check at this interval for new messages. */ if ( ! defined( 'WP_MAIL_INTERVAL' ) ) { - define( 'WP_MAIL_INTERVAL', 300 ); // 5 minutes + define( 'WP_MAIL_INTERVAL', 5 * MINUTE_IN_SECONDS ); } $last_checked = get_transient( 'mailserver_last_checked' ); @@ -109,7 +109,7 @@ for ( $i = 1; $i <= $count; $i++ ) { if ( preg_match( '/Subject: /i', $line ) ) { $subject = trim( $line ); $subject = substr( $subject, 9, strlen( $subject ) - 9 ); - // Captures any text in the subject before $phone_delim as the subject + // Captures any text in the subject before $phone_delim as the subject. if ( function_exists( 'iconv_mime_decode' ) ) { $subject = iconv_mime_decode( $subject, 2, get_option( 'blog_charset' ) ); } else { @@ -141,9 +141,10 @@ for ( $i = 1; $i <= $count; $i++ ) { } } - if ( preg_match( '/Date: /i', $line ) ) { // of the form '20 Mar 2002 20:32:37 +0100' - $ddate = str_replace( 'Date: ', '', trim( $line ) ); - $ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); // remove parenthesised timezone string if it exists, as this confuses strtotime + if ( preg_match( '/Date: /i', $line ) ) { // Of the form '20 Mar 2002 20:32:37 +0100'. + $ddate = str_replace( 'Date: ', '', trim( $line ) ); + // Remove parenthesised timezone string if it exists, as this confuses strtotime(). + $ddate = preg_replace( '!\s*\(.+\)\s*$!', '', $ddate ); $ddate_timestamp = strtotime( $ddate ); $post_date = gmdate( 'Y-m-d H:i:s', $ddate_timestamp + $time_difference ); $post_date_gmt = gmdate( 'Y-m-d H:i:s', $ddate_timestamp ); @@ -151,7 +152,7 @@ for ( $i = 1; $i <= $count; $i++ ) { } } - // Set $post_status based on $author_found and on author's publish_posts capability + // Set $post_status based on $author_found and on author's publish_posts capability. if ( $author_found ) { $user = new WP_User( $post_author ); $post_status = ( $user->has_cap( 'publish_posts' ) ) ? 'publish' : 'pending'; @@ -195,7 +196,7 @@ for ( $i = 1; $i <= $count; $i++ ) { $content = iconv( $charset, get_option( 'blog_charset' ), $content ); } - // Captures any text in the body after $phone_delim as the body + // Captures any text in the body after $phone_delim as the body. $content = explode( $phone_delim, $content ); $content = empty( $content[1] ) ? $content[0] : $content[1]; diff --git a/src/wp-settings.php b/src/wp-settings.php index cf4fffc6e7..efae63bb11 100644 --- a/src/wp-settings.php +++ b/src/wp-settings.php @@ -87,7 +87,7 @@ if ( WP_CACHE && apply_filters( 'enable_loading_advanced_cache_dropin', true ) & // For an advanced caching plugin to use. Uses a static drop-in because you would only want one. include( WP_CONTENT_DIR . '/advanced-cache.php' ); - // Re-initialize any hooks added manually by advanced-cache.php + // Re-initialize any hooks added manually by advanced-cache.php. if ( $wp_filter ) { $wp_filter = WP_Hook::build_preinitialized_hooks( $wp_filter ); } @@ -330,7 +330,7 @@ if ( is_multisite() ) { // Define constants after multisite is loaded. wp_cookie_constants(); -// Define and enforce our SSL constants +// Define and enforce our SSL constants. wp_ssl_constants(); // Create common globals. @@ -343,7 +343,7 @@ create_initial_post_types(); wp_start_scraping_edited_file_errors(); -// Register the default theme directory root +// Register the default theme directory root. register_theme_directory( get_theme_root() ); if ( ! is_multisite() ) { @@ -397,7 +397,7 @@ do_action( 'plugins_loaded' ); // Define constants which affect functionality if not already defined. wp_functionality_constants(); -// Add magic quotes and set up $_REQUEST ( $_GET + $_POST ) +// Add magic quotes and set up $_REQUEST ( $_GET + $_POST ). wp_magic_quotes(); /** @@ -525,7 +525,7 @@ $GLOBALS['wp']->init(); */ do_action( 'init' ); -// Check site status +// Check site status. if ( is_multisite() ) { $file = ms_site_check(); if ( true !== $file ) { diff --git a/src/wp-signup.php b/src/wp-signup.php index 0c50e98880..97aee29d8e 100644 --- a/src/wp-signup.php +++ b/src/wp-signup.php @@ -39,7 +39,7 @@ if ( ! is_main_site() ) { die(); } -// Fix for page title +// Fix for page title. $wp_query->is_404 = false; /** @@ -139,7 +139,7 @@ function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) { ); } - // Blog Title + // Site Title. ?> <label for="blog_title"><?php _e( 'Site Title:' ); ?></label> <?php @@ -253,7 +253,7 @@ function show_user_form( $user_name = '', $user_email = '', $errors = '' ) { $errors = new WP_Error(); } - // User name + // Username. echo '<label for="user_name">' . __( 'Username:' ) . '</label>'; $errmsg = $errors->get_error_message( 'user_name' ); if ( $errmsg ) { @@ -887,7 +887,7 @@ function signup_get_available_languages() { return array_intersect_assoc( $languages, get_available_languages() ); } -// Main +// Main. $active_signup = get_site_option( 'registration', 'none' ); /** diff --git a/src/xmlrpc.php b/src/xmlrpc.php index b36b21e951..885fc26bd1 100644 --- a/src/xmlrpc.php +++ b/src/xmlrpc.php @@ -21,7 +21,7 @@ if ( ! isset( $HTTP_RAW_POST_DATA ) ) { $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' ); } -// fix for mozBlog and other cases where '<?xml' isn't on the very first line +// Fix for mozBlog and other cases where '<?xml' isn't on the very first line. if ( isset( $HTTP_RAW_POST_DATA ) ) { $HTTP_RAW_POST_DATA = trim( $HTTP_RAW_POST_DATA ); } @@ -82,7 +82,7 @@ $post_default_title = ''; $wp_xmlrpc_server_class = apply_filters( 'wp_xmlrpc_server_class', 'wp_xmlrpc_server' ); $wp_xmlrpc_server = new $wp_xmlrpc_server_class; -// Fire off the request +// Fire off the request. $wp_xmlrpc_server->serve_request(); exit; |