Make WordPress Core

Ticket #41072: media.js.patch

File media.js.patch, 14.0 KB (added by jipmoors, 6 years ago)

Documented media.js

  • src/wp-admin/includes/class-wp-community-events.php

    diff --git src/wp-admin/includes/class-wp-community-events.php src/wp-admin/includes/class-wp-community-events.php
    index cfe12fd52c..211d37ea5e 100644
    class WP_Community_Events { 
    107107                } elseif ( 200 !== $response_code ) {
    108108                        $response_error = new WP_Error(
    109109                                'api-error',
    110                                 /* translators: %s is a numeric HTTP status code; e.g., 400, 403, 500, 504, etc. */
     110                                /* translators: %d: numeric HTTP status code, e.g. 400, 403, 500, 504, etc. */
    111111                                sprintf( __( 'Invalid API response code (%d)' ), $response_code )
    112112                        );
    113113                } elseif ( ! isset( $response_body['location'], $response_body['events'] ) ) {
  • src/wp-admin/js/comment.js

    diff --git src/wp-admin/js/comment.js src/wp-admin/js/comment.js
    index d194148f60..3541a2f68b 100644
     
    11/* global postboxes, commentL10n */
     2
     3/**
     4 * @summary Binds to the document ready event.
     5 *
     6 * @since 2.5.0
     7 *
     8 * @param {jQuery} $ The jQuery object.
     9 */
    210jQuery(document).ready( function($) {
    311
    412        postboxes.add_postbox_toggles('comment');
    jQuery(document).ready( function($) { 
    917                $timestampwrap = $timestampdiv.find( '.timestamp-wrap' ),
    1018                $edittimestamp = $timestampdiv.siblings( 'a.edit-timestamp' );
    1119
     20        /**
     21         * @summary Adds event that opens the time stamp form if the form is hidden.
     22         *
     23         * @listens $edittimestamp:click
     24         *
     25         * @param {Event} event The event object.
     26         * @returns {void}
     27         */
    1228        $edittimestamp.click( function( event ) {
    1329                if ( $timestampdiv.is( ':hidden' ) ) {
     30                        // Slide down the form and set focus on the first field.
    1431                        $timestampdiv.slideDown( 'fast', function() {
    1532                                $( 'input, select', $timestampwrap ).first().focus();
    1633                        } );
    jQuery(document).ready( function($) { 
    1936                event.preventDefault();
    2037        });
    2138
     39        /**
     40         * @summary Resets the time stamp values when the cancel button is clicked.
     41         *
     42         * @listens .cancel-timestamp:click
     43         *
     44         * @param {Event} event The event object.
     45         * @returns {void}
     46         */
     47
    2248        $timestampdiv.find('.cancel-timestamp').click( function( event ) {
    2349                // Move focus back to the Edit link.
    2450                $edittimestamp.show().focus();
    jQuery(document).ready( function($) { 
    3258                event.preventDefault();
    3359        });
    3460
     61        /**
     62         * @summary Sets the time stamp values when the ok button is clicked.
     63         *
     64         * @listens .save-timestamp:click
     65         *
     66         * @param {Event} event The event object.
     67         * @returns {void}
     68         */
    3569        $timestampdiv.find('.save-timestamp').click( function( event ) { // crazyhorse - multiple ok cancels
    3670                var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(),
    3771                        newD = new Date( aa, mm - 1, jj, hh, mn );
  • src/wp-admin/js/custom-background.js

    diff --git src/wp-admin/js/custom-background.js src/wp-admin/js/custom-background.js
    index c3f4e294f1..9e96015e75 100644
     
    11/* global ajaxurl */
     2
     3/**
     4 * @summary Registers all events for customizing the background.
     5 *
     6 * @since 3.0.0
     7 *
     8 * @requires jQuery
     9 */
    210(function($) {
    311        $(document).ready(function() {
    412                var frame,
    513                        bgImage = $( '#custom-background-image' );
    614
     15                /**
     16                 * @summary Instantiates the WordPress color picker and binds the change and clear events.
     17                 *
     18                 * @since 3.5.0
     19                 *
     20                 * @returns {void}
     21                 */
    722                $('#background-color').wpColorPicker({
    823                        change: function( event, ui ) {
    924                                bgImage.css('background-color', ui.color.toString());
     
    1328                        }
    1429                });
    1530
     31                /**
     32                 * @summary Alters the background size CSS property whenever the background size input has changed.
     33                 *
     34                 * @since 4.7.0
     35                 *
     36                 * @returns {void}
     37                 */
    1638                $( 'select[name="background-size"]' ).change( function() {
    1739                        bgImage.css( 'background-size', $( this ).val() );
    1840                });
    1941
     42                /**
     43                 * @summary Alters the background position CSS property whenever the background position input has changed.
     44                 *
     45                 * @since 4.7.0
     46                 *
     47                 * @returns {void}
     48                 */
    2049                $( 'input[name="background-position"]' ).change( function() {
    2150                        bgImage.css( 'background-position', $( this ).val() );
    2251                });
    2352
     53                /**
     54                 * @summary Alters the background repeat CSS property whenever the background repeat input has changed.
     55                 *
     56                 * @since 3.0.0
     57                 *
     58                 * @returns {void}
     59                 */
    2460                $( 'input[name="background-repeat"]' ).change( function() {
    2561                        bgImage.css( 'background-repeat', $( this ).is( ':checked' ) ? 'repeat' : 'no-repeat' );
    2662                });
    2763
     64                /**
     65                 * @summary Alters the background attachment CSS property whenever the background attachment input has changed.
     66                 *
     67                 * @since 4.7.0
     68                 *
     69                 * @returns {void}
     70                 */
    2871                $( 'input[name="background-attachment"]' ).change( function() {
    2972                        bgImage.css( 'background-attachment', $( this ).is( ':checked' ) ? 'scroll' : 'fixed' );
    3073                });
    3174
     75                /**
     76                 * @summary Binds the event for opening the WP Media dialog.
     77                 *
     78                 * @since 3.5.0
     79                 *
     80                 * @returns {void}
     81                 */
    3282                $('#choose-from-library-link').click( function( event ) {
    3383                        var $el = $(this);
    3484
     
    54104                                button: {
    55105                                        // Set the text of the button.
    56106                                        text: $el.data('update'),
    57                                         // Tell the button not to close the modal, since we're
    58                                         // going to refresh the page when the image is selected.
     107                                        /*
     108                                         * Tell the button not to close the modal, since we're
     109                                         * going to refresh the page when the image is selected.
     110                                         */
    59111                                        close: false
    60112                                }
    61113                        });
    62114
    63                         // When an image is selected, run a callback.
     115                        /**
     116                         * @summary When an image is selected, run a callback.
     117                         *
     118                         * @since 3.5.0
     119                         *
     120                         * @returns {void}
     121                         */
    64122                        frame.on( 'select', function() {
    65123                                // Grab the selected attachment.
    66124                                var attachment = frame.state().get('selection').first();
  • src/wp-admin/js/media.js

    diff --git src/wp-admin/js/media.js src/wp-admin/js/media.js
    index e23adebb17..4c1dc58fc3 100644
     
    11/* global ajaxurl, attachMediaBoxL10n, _wpMediaGridSettings, showNotice */
    22
     3/**
     4 * @summary Creates a dialog containing posts that can have a particular media attached to it.
     5 *
     6 * @since 2.7.0
     7 *
     8 * @global
     9 * @namespace
     10 *
     11 * @requires jQuery
     12 */
    313var findPosts;
     14
    415( function( $ ){
    516        findPosts = {
     17                /**
     18                 * @summary Opens a dialog to attach media to a post.
     19                 *
     20                 * Adds an overlay prior to retrieving a list of posts to attach the media to.
     21                 *
     22                 * @since 2.7.0
     23                 *
     24                 * @memberOf findPosts
     25                 *
     26                 * @param {string} af_name The name of the affected element.
     27                 * @param {string} af_val The value of the affected post element.
     28                 *
     29                 * @returns {boolean} Always returns false.
     30                 */
    631                open: function( af_name, af_val ) {
    732                        var overlay = $( '.ui-find-overlay' );
    833
    var findPosts; 
    1439                        overlay.show();
    1540
    1641                        if ( af_name && af_val ) {
     42                                // #affected is a hidden input field in the dialog that keeps track of which media should be attached.
    1743                                $( '#affected' ).attr( 'name', af_name ).val( af_val );
    1844                        }
    1945
    2046                        $( '#find-posts' ).show();
    2147
     48                        // Close the dialog when the escape key is pressed.
    2249                        $('#find-posts-input').focus().keyup( function( event ){
    2350                                if ( event.which == 27 ) {
    2451                                        findPosts.close();
    25                                 } // close on Escape
     52                                }
    2653                        });
    2754
    28                         // Pull some results up by default
     55                        // Retrieves a list of applicable posts for media attachment and shows them.
    2956                        findPosts.send();
    3057
    3158                        return false;
    3259                },
    3360
     61                /**
     62                 * @summary Clears the found posts lists before hiding the attach media dialog.
     63                 *
     64                 * @since 2.7.0
     65                 *
     66                 * @memberOf findPosts
     67                 *
     68                 * @returns {void}
     69                 */
    3470                close: function() {
    3571                        $('#find-posts-response').empty();
    3672                        $('#find-posts').hide();
    3773                        $( '.ui-find-overlay' ).hide();
    3874                },
    3975
     76                /**
     77                 * @summary Binds a click event listener to the overlay which closes the attach media dialog.
     78                 *
     79                 * @since 3.5.0
     80                 *
     81                 * @memberOf findPosts
     82                 *
     83                 * @returns {void}
     84                 */
    4085                overlay: function() {
    4186                        $( '.ui-find-overlay' ).on( 'click', function () {
    4287                                findPosts.close();
    4388                        });
    4489                },
    4590
     91                /**
     92                 * @summary Retrieves and displays posts based on the search term.
     93                 *
     94                 * Sends a post request to the admin_ajax.php, requesting posts based on the search term provided by the user.
     95                 * Defaults to all posts if no search term is provided.
     96                 *
     97                 * @since 2.7.0
     98                 *
     99                 * @memberOf findPosts
     100                 *
     101                 * @returns {void}
     102                 */
    46103                send: function() {
    47104                        var post = {
    48105                                        ps: $( '#find-posts-input' ).val(),
    var findPosts; 
    53110
    54111                        spinner.addClass( 'is-active' );
    55112
     113                        /**
     114                         * Send a POST request to admin_ajax.php, hide the spinner and replace the list of posts with the response data.
     115                         * If an error occurs, display it.
     116                         */
    56117                        $.ajax( ajaxurl, {
    57118                                type: 'POST',
    58119                                data: post,
    var findPosts; 
    71132                }
    72133        };
    73134
     135        /**
     136         * @summary Initializes the file once the DOM is fully loaded and attaches events to the various form elements.
     137         *
     138         * @returns {void}
     139         */
    74140        $( document ).ready( function() {
    75141                var settings, $mediaGridWrap = $( '#wp-media-grid' );
    76142
    77                 // Open up a manage media frame into the grid.
     143                // Opens a manage media frame into the grid.
    78144                if ( $mediaGridWrap.length && window.wp && window.wp.media ) {
    79145                        settings = _wpMediaGridSettings;
    80146
    var findPosts; 
    85151                        }).open();
    86152                }
    87153
     154                // Prevents form submission if no post has been selected.
    88155                $( '#find-posts-submit' ).click( function( event ) {
    89156                        if ( ! $( '#find-posts-response input[type="radio"]:checked' ).length )
    90157                                event.preventDefault();
    91158                });
     159
     160                // Submits the search query when hitting the enter key in the search input.
    92161                $( '#find-posts .find-box-search :input' ).keypress( function( event ) {
    93162                        if ( 13 == event.which ) {
    94163                                findPosts.send();
    95164                                return false;
    96165                        }
    97166                });
     167
     168                // Binds the click event to the search button.
    98169                $( '#find-posts-search' ).click( findPosts.send );
     170
     171                // Binds the close dialog click event.
    99172                $( '#find-posts-close' ).click( findPosts.close );
     173
     174                // Binds the bulk action events to the submit buttons.
    100175                $( '#doaction, #doaction2' ).click( function( event ) {
     176
     177                        /*
     178                         * Retrieves all select elements for bulk actions that have a name starting with `action`
     179                         * and handle its action based on its value.
     180                         */
    101181                        $( 'select[name^="action"]' ).each( function() {
    102182                                var optionValue = $( this ).val();
    103183
    var findPosts; 
    112192                        });
    113193                });
    114194
    115                 // Enable whole row to be clicked
     195                /**
     196                 * @summary Enables clicking on the entire table row.
     197                 *
     198                 * @returns {void}
     199                 */
    116200                $( '.find-box-inside' ).on( 'click', 'tr', function() {
    117201                        $( this ).find( '.found-radio input' ).prop( 'checked', true );
    118202                });
  • src/wp-content/themes/twentysixteen/inc/template-tags.php

    diff --git src/wp-content/themes/twentysixteen/inc/template-tags.php src/wp-content/themes/twentysixteen/inc/template-tags.php
    index eb87203062..fa1ad8efed 100644
    function twentysixteen_categorized_blog() { 
    213213                set_transient( 'twentysixteen_categories', $all_the_cool_cats );
    214214        }
    215215
    216         if ( $all_the_cool_cats > 1 ) {
     216        if ( $all_the_cool_cats > 1 || is_preview() ) {
    217217                // This blog has more than 1 category so twentysixteen_categorized_blog should return true.
    218218                return true;
    219219        } else {
  • src/wp-includes/class-wp-editor.php

    diff --git src/wp-includes/class-wp-editor.php src/wp-includes/class-wp-editor.php
    index 8879797914..73de84de2b 100644
    final class _WP_Editors { 
    144144         * @static
    145145         * @param string $content The initial content of the editor.
    146146         * @param string $editor_id ID for the textarea and TinyMCE and Quicktags instances (can contain only ASCII letters and numbers).
    147          * @param array $settings See the _parse_settings() method for description.
     147         * @param array $settings See _WP_Editors()::parse_settings() for description.
    148148         */
    149149        public static function editor( $content, $editor_id, $settings = array() ) {
    150150                $set = self::parse_settings( $editor_id, $settings );
  • src/wp-includes/class-wp-query.php

    diff --git src/wp-includes/class-wp-query.php src/wp-includes/class-wp-query.php
    index baefec75b4..e20d574409 100644
    class WP_Query { 
    24052405                         *
    24062406                         * @since 1.5.0
    24072407                         *
    2408                          * @param string   $where The JOIN clause of the query.
     2408                         * @param string   $join The JOIN clause of the query.
    24092409                         * @param WP_Query &$this The WP_Query instance (passed by reference).
    24102410                         */
    24112411                        $join = apply_filters_ref_array( 'posts_join', array( $join, &$this ) );
  • src/wp-includes/functions.php

    diff --git src/wp-includes/functions.php src/wp-includes/functions.php
    index 966dcd8265..828f123491 100644
    function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { 
    158158 *
    159159 * @since 4.4.0
    160160 *
     161 * @global WP_Locale $wp_locale
     162 *
    161163 * @param string $date Formatted date string.
    162164 * @return string The date, declined if locale specifies it.
    163165 */
  • src/wp-includes/vars.php

    diff --git src/wp-includes/vars.php src/wp-includes/vars.php
    index 2e97c9a0ae..89b3532327 100644
    function wp_is_mobile() { 
    139139                $is_mobile = false;
    140140        }
    141141
    142         return $is_mobile;
     142        /**
     143         * Filters whether the request should be treated as coming from a mobile device or not.
     144         *
     145         * @since 4.9.0
     146         *
     147         * @param bool $is_mobile Whether the request is from a mobile device or not.
     148         */
     149        return apply_filters( 'wp_is_mobile', $is_mobile );
    143150}
  • src/wp-includes/wp-db.php

    diff --git src/wp-includes/wp-db.php src/wp-includes/wp-db.php
    index 74dedd5130..2c9cceabf7 100644
    class wpdb { 
    32683268         *
    32693269         * @param string $db_cap The feature to check for. Accepts 'collation',
    32703270         *                       'group_concat', 'subqueries', 'set_charset',
    3271          *                       or 'utf8mb4'.
     3271         *                       'utf8mb4', or 'utf8mb4_520'.
    32723272         * @return int|false Whether the database feature is supported, false otherwise.
    32733273         */
    32743274        public function has_cap( $db_cap ) {