extend Meta Box / Document Panel
extend Meta Box / Document Panel
extend Meta Box / Document Panel
The fileurl should look like this: fileurl = $(‘a’, html).attr(‘href’); It’s a pretty simple fix. I would do some validation on this: if(/\.mp3\b/.test(fileurl)){ //Do something awesome }else{ alert(‘The file you selected is not an MP3.’); } Cheers!
I’m pretty sure you could use JavaScript to do this for you very simply. I’d try this out: function convert_root_cats_to_radio() { global $post_type; if ( ‘post’ != $post_type ) return; ?> <script type=”text/javascript”> jQuery(“#categorychecklist>li>label input”).each(function(){ this.type=”radio”; }); </script> <?php } add_action( ‘admin_footer-post.php’, ‘convert_root_cats_to_radio’ ); add_action( ‘admin_footer-post-new.php’, ‘convert_root_cats_to_radio’ ); What this does is loops through the … Read more
I see your problem in the javascript. I’ve done something similar using the “on close” event of the wp.media object. You can use the “select event”, as you are actually doing, but I would use “on select” event mainly for events within the modal window (but it is just preference, you can use the “on … Read more
Normally it should be enough to simply enqueue the postsbox script on a page where you want to have sortable meta boxes. Simply do the following: add_action( ‘admin_enqueue_scripts’, ‘wpse112022_postbox_enqueue’ ); function wpse112022_postbox_enqueue( $hook_suffix ) { // uncomment the next line to see what the $hook_suffix of your desired page is # var_dump( $hook_suffix ); if … Read more
The short answer is that there isn’t any straightforward way to do this, since the custom field metabox was not written with extensibility in mind. You could add the additional field using JavaScript and hijack the Add button to send the data to your custom AJAX handler that would store them as you want.
There’s a plugin written specifically to fix this ‘feature’ of WordPress, it’s called Category Checklist Tree. Despite the name, it works on custom taxonomies too.
Here is a function that you can pass either a single post id or an array of ids. Call this function in your function that adds the meta boxes. If the id or ids don’t match the meta boxes will not display on that post or page. function check_id( $id ) { // Get the … Read more
In this example of repeatable custom fields, we can see that the following jQuery is needed: $(‘#repeatable-fieldset-one tbody’).sortable({ opacity: 0.6, revert: true, cursor: ‘move’, handle: ‘.sort’ }); And the HTML it controls is (simplified): <table id=”repeatable-fieldset-one” width=”100%”> <thead> <tr> <th width=”2%”></th> <th width=”30%”>Name</th> <th width=”60%”>URL</th> <th width=”2%”></th> </tr> </thead> <tbody> <?php if ( $repeatable_fields ) … Read more
this is how I do to create upload button in metabox: FILE: template_dir/functions.php add this lines: wp_enqueue_script(‘custom-js’, get_template_directory_uri().’/js/custom-js.js’); // Add the Meta Box function add_custom_meta_box() { add_meta_box( ‘custom_meta_box’, // $id ‘Custom Meta Box’, // $title ‘show_custom_meta_box’, // $callback ‘post’, // $page ‘normal’, // $context ‘high’); // $priority } add_action(‘add_meta_boxes’, ‘add_custom_meta_box’); // Field Array $prefix = … Read more