Making WordPress.org

Changeset 7604


Ignore:
Timestamp:
08/11/2018 10:53:13 PM (8 years ago)
Author:
SergeyBiryukov
Message:

Plugins: After [7462], if jQuery happens to be already loaded (e.g. via a plugin on a test install), print the inline script for upload button directly.

Otherwise, keep it attached to jQuery and moved to the footer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-upload.php

    r7462 r7604  
    174174                                        </p>
    175175                                </form>
    176                 <?php
    177                         wp_enqueue_script( 'jquery' );
    178                         wp_add_inline_script( 'jquery-migrate', '
     176
     177                                <?php
     178                                $upload_script = '
    179179                                        ( function ( $ ) {
    180180                                                var $label = $( "label.button" ),
     
    187187                                                        .on( "focus", function() { $label.addClass( "focus" ); } )
    188188                                                        .on( "blur", function() { $label.removeClass( "focus" ); } );
    189                                         } ( window.jQuery ) );' );
     189                                        } ( window.jQuery ) );';
     190
     191                                if ( ! wp_script_is( 'jquery', 'done' ) ) {
     192                                        wp_enqueue_script( 'jquery' );
     193                                        wp_add_inline_script( 'jquery-migrate', $upload_script );
     194                                } else {
     195                                        printf( '<script>%s</script>', $upload_script );
     196                                }
     197                                ?>
    190198               
    191                 endif; // ! $submitted_counts->total
    192 
    193                 else : ?>
     199                        <?php endif; // ! $submitted_counts->total ?>
     200
     201                <?php else : ?>
     202
    194203                        <p>
    195204                        <?php
Note: See TracChangeset for help on using the changeset viewer.