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

Props xkon.
Fixes #41143.



git-svn-id: https://develop.svn.wordpress.org/trunk@44617 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2019-01-16 06:00:23 +00:00
parent cd7d022ae0
commit 267c79a518
3 changed files with 13 additions and 2 deletions

View File

@ -53,6 +53,8 @@ wp.themePluginEditor = (function( $ ) {
component.textarea = component.form.find( '#newcontent' );
component.textarea.on( 'change', component.onChange );
component.warning = $( '.file-editor-warning' );
component.docsLookUpButton = component.form.find( '#docs-lookup' );
component.docsLookUpList = component.form.find( '#docs-list' );
if ( component.warning.length > 0 ) {
component.showWarning();
@ -77,6 +79,15 @@ wp.themePluginEditor = (function( $ ) {
}
return undefined;
} );
component.docsLookUpList.on( 'change', function() {
var option = $( this ).val();
if ( '' === option ) {
component.docsLookUpButton.prop( 'disabled', true );
} else {
component.docsLookUpButton.prop( 'disabled', false );
}
} );
};
/**

View File

@ -265,7 +265,7 @@ foreach ( $plugins as $plugin_key => $a_plugin ) {
<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 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>
<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>
<?php endif; ?>
<?php if ( is_writeable( $real_file ) ) : ?>
<div class="editor-notices">

View File

@ -285,7 +285,7 @@ else :
<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'); }" />
<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>
<?php endif; ?>