WordPress.org

Make WordPress Core

Changeset 44617


Ignore:
Timestamp:
01/16/2019 06:00:23 AM (3 years ago)
Author:
pento
Message:

Plugin Editor: Disable the documentation look up button when no function is selected.

Props xkon.
Fixes #41143.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/theme-plugin-editor.js

    r43347 r44617  
    5454        component.textarea.on( 'change', component.onChange );
    5555        component.warning = $( '.file-editor-warning' );
     56        component.docsLookUpButton = component.form.find( '#docs-lookup' );
     57        component.docsLookUpList = component.form.find( '#docs-list' );
    5658
    5759        if ( component.warning.length > 0 ) {
     
    7779            }
    7880            return undefined;
     81        } );
     82
     83        component.docsLookUpList.on( 'change', function() {
     84            var option = $( this ).val();
     85            if ( '' === option ) {
     86                component.docsLookUpButton.prop( 'disabled', true );
     87            } else {
     88                component.docsLookUpButton.prop( 'disabled', false );
     89            }
    7990        } );
    8091    };
  • trunk/src/wp-admin/plugin-editor.php

    r44331 r44617  
    266266        </div>
    267267        <?php if ( ! empty( $docs_select ) ) : ?>
    268         <div id="documentation" class="hide-if-no-js"><label for="docs-list"><?php _e( 'Documentation:' ); ?></label> <?php echo $docs_select; ?> <input 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() ) + '&amp;locale=<?php echo urlencode( get_user_locale() ); ?>&amp;version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&amp;redirect=true'); }" /></div>
     268        <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() ) + '&amp;locale=<?php echo urlencode( get_user_locale() ); ?>&amp;version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&amp;redirect=true'); }" /></div>
    269269        <?php endif; ?>
    270270<?php if ( is_writeable( $real_file ) ) : ?>
  • trunk/src/wp-admin/theme-editor.php

    r43571 r44617  
    286286        <label for="docs-list"><?php _e( 'Documentation:' ); ?></label>
    287287        <?php echo $docs_select; ?>
    288         <input 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() ) + '&amp;locale=<?php echo urlencode( get_user_locale() ); ?>&amp;version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&amp;redirect=true'); }" />
     288        <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() ) + '&amp;locale=<?php echo urlencode( get_user_locale() ); ?>&amp;version=<?php echo urlencode( get_bloginfo( 'version' ) ); ?>&amp;redirect=true'); }" />
    289289        </div>
    290290    <?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.