Taxonomy Quick Edit field – Display logic with JavaScript
/**
* Front-end stuff for pulling in user-input values dynamically
* into our input field.
*/
function gwp_quickedit_category_javascript() {
$current_screen = get_current_screen();
if ( $current_screen->id != 'edit-edition' || $current_screen->taxonomy != 'edition' ) {
return;
}
// Ensure jQuery library is loaded
wp_enqueue_script( 'jquery' );
?>
<script type="text/javascript">
/*global jQuery*/
jQuery(function($) {
$('#the-list').on( 'click', 'a.editinline', function( e ) {
e.preventDefault();
var $tr = $(this).closest('tr');
var val = $tr.find('td.first-appeared').text();
// Update field
$('tr.inline-edit-row :input[name="first-appeared"]').val(val ? val : '');
});
});
</script>
<?php
}
add_action( 'admin_print_footer_scripts-edit-tags.php', 'gwp_quickedit_category_javascript' );