Making WordPress.org

Changeset 7462


Ignore:
Timestamp:
07/13/2018 10:59:06 AM (8 years ago)
Author:
Otto42
Message:

Plugins: Make inline code for upload button an inline script attached to jQuery, to move it to the footer as well

File:
1 edited

Legend:

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

    r6807 r7462  
    174174                                        </p>
    175175                                </form>
    176                                 <script>
     176                <?php
     177                        wp_enqueue_script( 'jquery' );
     178                        wp_add_inline_script( 'jquery-migrate', '
    177179                                        ( function ( $ ) {
    178                                                 var $label    = $( 'label.button' ),
     180                                                var $label = $( "label.button" ),
    179181                                                        labelText = $label.text();
    180 
    181                                                 $( '#zip_file' )
    182                                                         .on( 'change', function( event ) {
    183                                                                 var fileName = event.target.value.split( '\\' ).pop();
    184 
     182                                                $( "#zip_file" )
     183                                                        .on( "change", function( event ) {
     184                                                                var fileName = event.target.value.split( "\\\\" ).pop();
    185185                                                                fileName ? $label.text( fileName ) : $label.text( labelText );
    186186                                                        } )
    187                                                         .on( 'focus', function() { $label.addClass( 'focus' ); } )
    188                                                         .on( 'blur', function() { $label.removeClass( 'focus' ); } );
    189                                         } ( window.jQuery ) );
    190                                 </script>
    191 
    192                         <?php endif; // ! $submitted_counts->total ?>
    193 
    194                 <?php else : ?>
    195 
     187                                                        .on( "focus", function() { $label.addClass( "focus" ); } )
     188                                                        .on( "blur", function() { $label.removeClass( "focus" ); } );
     189                                        } ( window.jQuery ) );' );
     190               
     191                endif; // ! $submitted_counts->total
     192
     193                else : ?>
    196194                        <p>
    197195                        <?php
Note: See TracChangeset for help on using the changeset viewer.