' .
'| ' .
'' . ' | ' .
'';
}
switch ($field['type']) {
case 'tab_start':
echo '';
break;
case 'content_start':
echo '';
break;
case 'tabs':
echo '';
break;
case 'text':
echo '' .
' ' .
'' . $field['desc'] . '';
break;
case 'textcode':
echo '' .
' ' .
'' . $field['desc'] . '';
break;
case 'text_long':
echo '' .
' ' .
'' . $field['desc'] . '';
break;
case 'number':
echo '' .
'' . $field['desc'] . '';
break;
case 'range':
echo '' .
'' .
'' . $field['desc'] . '';
break;
case 'textarea':
echo ' | ' .
'
';
}
}
}
function cleanora_save_custom_meta($post_id) {
$custom_all_meta_fields = cleanora_get_custom_all_meta_fields();
if (!isset($_POST['custom_meta_box_nonce']) || !wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) {
return $post_id;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}
if ($_POST['post_type'] == 'page') {
if (!current_user_can('edit_page', $post_id)) {
return $post_id;
}
} elseif (!current_user_can('edit_post', $post_id)) {
return $post_id;
}
foreach ($custom_all_meta_fields as $field) {
if (
$field['type'] != 'tabs' &&
$field['type'] != 'tab_start' &&
$field['type'] != 'tab_finish' &&
$field['type'] != 'content_start' &&
$field['type'] != 'content_finish'
) {
$old = get_post_meta($post_id, $field['id'], true);
if (isset($_POST[$field['id']])) {
$new = $_POST[$field['id']];
} else {
$new = '';
}
if ($field['type'] == 'checkbox' && $new === '') {
$new = 'false';
}
if (isset($new) && $new !== $old) {
update_post_meta($post_id, $field['id'], $new);
} elseif (isset($old) && $new === '') {
delete_post_meta($post_id, $field['id'], $old);
}
}
}
}
add_action('save_post', 'cleanora_save_custom_meta');
function cleanora_add_custom_meta_box() {
$args = array(
'public' => true
);
$screens = get_post_types($args);
foreach ($screens as $screen) {
add_meta_box(
'cmsmasters_custom_meta_box',
esc_html__('Theme Options', 'cleanora'),
'cleanora_show_meta_box',
$screen,
'normal',
'high'
);
}
}
add_action('add_meta_boxes', 'cleanora_add_custom_meta_box');