Custom meta box using OOP way doesn’t save data

You method iam_user_can_save is incorrectly used as you are returning nothing to check in that method. Try this (not sure what behaviour you really want, the following code is just a working example from your code): public function iam_user_can_save( $post_id, $nonce ){ // Checks save status $is_autosave = wp_is_post_autosave( $post_id ); $is_revision = wp_is_post_revision( $post_id … Read more

custom metabox nonce verification fails

Ok, I found the answer. It’s a quite stupid copy/paste mistake. The name of my nonce_field was not unique. I had already created another nonce from the same plugin but another file. Therefore the basename(__FILE__) value was different leading to a different nonce. All I had to do was change the the name of the … Read more

jQuery UI Sortable not Working With Metabox

So, after an annoyingly long struggle, I discovered that I needed to have the script enqueued/registered with no dependencies. So in the end, to make it work, I needed this: function add_admin_scripts( $hook ) { global $post; wp_register_script( ‘sectioned_page_script’, get_stylesheet_directory_uri() . ‘/js/sectioned_page.js’ ); if ( $hook == ‘post-new.php’ || $hook == ‘post.php’ ) { if … Read more

Meta Box – Javascript Datatable

Refer to Creating a new PostBox in WordPress. As long as you name the fields the same in render as you do in save then you’re good. RENDER echo ‘<input type=”text” id=”boxpost_meta_field” name=”boxpost_meta_field”‘; SAVE $mydata = sanitize_text_field( $_POST[‘boxpost_meta_field’] ); // Update the meta field. update_post_meta( $post_id, ‘_boxpost_meta_field_value_key’, $mydata ); GET $value = get_post_meta( $post->ID, ‘_boxpost_meta_field_value_key’, … Read more

Resposive admin classes?

I don’t think so, it only have responsiveness to the lateral menu. You will have to create your own HTML and CSS responsive structure.

Is this Edit Post Screen?

I believe you want something like this: EDITED: function function_name( $hook ) { global $post; if ( $hook == ‘post-new.php’ || $hook == ‘post.php’ ) { if ( ‘post’ === $post->post_type ) { // Do stuff } } } Script is hooked via: add_action( ‘admin_enqueue_scripts’, array( $this, ‘function_name’ ) ); Is the metabox you are … Read more