'php']); wp_enqueue_script('jquery-ui-tabs'); }); } add_action('add_meta_boxes', function () { add_meta_box('hefo', __('Head and Footer', 'header-footer'), 'hefo_meta_boxes_callback', ['post', 'page']); }); add_action('save_post', 'hefo_save_post'); function hefo_meta_boxes_callback($post) { // Use nonce for verification wp_nonce_field(plugin_basename(__FILE__), 'hefo'); // The actual fields for data entry // Use get_post_meta to retrieve an existing value from the database and use the value for the form $before = get_post_meta($post->ID, 'hefo_before', true); $after = get_post_meta($post->ID, 'hefo_after', true); echo ' '; echo '
'; echo ' '; } function hefo_save_post($post_id) { if (!isset($_POST['hefo'])) return; // First we need to check if the current user is authorised to do this action. if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) return; } else { if (!current_user_can('edit_post', $post_id)) return; } // Secondly we need to check if the user intended to change this value. if (!wp_verify_nonce($_POST['hefo'], plugin_basename(__FILE__))) return; update_post_meta($post_id, 'hefo_before', isset($_REQUEST['hefo_before']) ? 1 : 0); update_post_meta($post_id, 'hefo_after', isset($_REQUEST['hefo_after']) ? 1 : 0); }