Skip to content

Instantly share code, notes, and snippets.

@LeoLopesWeb
Last active February 24, 2023 14:30
Show Gist options
  • Select an option

  • Save LeoLopesWeb/097cd43a2e93ce955476e6f19220df9a to your computer and use it in GitHub Desktop.

Select an option

Save LeoLopesWeb/097cd43a2e93ce955476e6f19220df9a to your computer and use it in GitHub Desktop.
// create a text field that takes the value of the chosen taxonomy via javascript
// functiom.php
function webroom_add_custom_js_file_to_admin( $hook ) {
wp_enqueue_script( 'admin-js', get_stylesheet_directory_uri() . '/assets/js/admin-js.js' );
}
add_action('admin_enqueue_scripts', 'webroom_add_custom_js_file_to_admin');
// admin-js.js
(function ($) {
$(document).ready(function (e) {
$("div[data-name='formato_escolhido'] input").attr("readonly", true);
$("div[data-name='formato'] label").each(function () {
$(this).click(function () {
var label = $(this).find("span").text();
//console.log(label);
$("div[data-name='formato_escolhido'] input").val(label).trigger("change");
});
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment