ID, 'abcbiz_themebuilder_select', true); $display_condition_value = get_post_meta($post->ID, 'abcbiz_display_condition_select', true); $specific_item_value = get_post_meta($post->ID, 'abcbiz_specific_item_value', true); // New field for specific options // Start table layout echo ''; // Row for Template Type echo ''; echo ''; echo ''; echo ''; // Row for Display Condition with optgroup echo ''; echo ''; echo ''; echo ''; // End table layout echo '
'; echo ''; echo '
'; echo '
'; } public function save_meta_box_data($post_id) { // Check nonce validity if (!isset($_POST['abcbiz_custom_box_nonce']) || !wp_verify_nonce($_POST['abcbiz_custom_box_nonce'], 'abcbiz_custom_box')) { return $post_id; } // Check the user's permissions. if ('primekitlibrary' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } else { if (!current_user_can('edit_post', $post_id)) { return $post_id; } } // Save or Update the meta box field values $new_template_value = (isset($_POST['abcbiz_themebuilder_select']) ? sanitize_text_field($_POST['abcbiz_themebuilder_select']) : ''); $new_display_condition_value = (isset($_POST['abcbiz_display_condition_select']) ? sanitize_text_field($_POST['abcbiz_display_condition_select']) : ''); $new_specific_item_value = (isset($_POST['abcbiz_specific_item_value']) ? sanitize_text_field($_POST['abcbiz_specific_item_value']) : ''); update_post_meta($post_id, 'abcbiz_themebuilder_select', $new_template_value); update_post_meta($post_id, 'abcbiz_display_condition_select', $new_display_condition_value); // Only save specific item value if one of the specific options is selected if (in_array($new_display_condition_value, ['category_specific', 'post_specific', 'page_specific'])) { update_post_meta($post_id, 'abcbiz_specific_item_value', $new_specific_item_value); } else { delete_post_meta($post_id, 'abcbiz_specific_item_value'); } } }