post_type) ? $screen->post_type : $screen->id)) { wp_enqueue_style( 'asia_garden-icons', asia_garden_get_file_url('css/font-icons/css/fontello-embedded.css') ); wp_enqueue_script( 'jquery-ui-tabs', false, array('jquery', 'jquery-ui-core'), null, true ); wp_enqueue_script( 'jquery-ui-accordion', false, array('jquery', 'jquery-ui-core'), null, true ); wp_enqueue_script( 'asia_garden-options', asia_garden_get_file_url('theme-options/theme.options.js'), array('jquery'), null, true ); wp_localize_script( 'asia_garden-options', 'asia_garden_dependencies', asia_garden_get_theme_dependencies() ); } } } // Check if meta box is allow if (!function_exists('asia_garden_allow_meta_box')) { function asia_garden_allow_meta_box($post_type) { return apply_filters('asia_garden_filter_allow_meta_box', in_array($post_type, array('page', 'post')), $post_type); } } // Add meta box if (!function_exists('asia_garden_add_meta_box')) { //Handler of the add_action('add_meta_boxes', 'asia_garden_add_meta_box'); function asia_garden_add_meta_box() { global $post_type; if (asia_garden_allow_meta_box($post_type)) { add_meta_box(sprintf('asia_garden_meta_box_%s', $post_type), esc_html__('Theme Options', 'asia-garden'), 'asia_garden_show_meta_box', $post_type, $post_type=='post' ? 'side' : 'advanced', 'default'); } } } // Callback function to show fields in meta box if (!function_exists('asia_garden_show_meta_box')) { function asia_garden_show_meta_box() { global $post, $post_type; if (asia_garden_allow_meta_box($post_type)) { // Load saved options $meta = get_post_meta($post->ID, 'asia_garden_options', true); $tabs_titles = $tabs_content = array(); global $ASIA_GARDEN_STORAGE; // Refresh linked data if this field is controller for the another (linked) field // Do this before show fields to refresh data in the $ASIA_GARDEN_STORAGE foreach ($ASIA_GARDEN_STORAGE['options'] as $k=>$v) { if (!isset($v['override']) || strpos($v['override']['mode'], $post_type)===false) continue; if (!empty($v['linked'])) { $v['val'] = isset($meta[$k]) ? $meta[$k] : 'inherit'; if (!empty($v['val']) && !asia_garden_is_inherit($v['val'])) asia_garden_refresh_linked_data($v['val'], $v['linked']); } } // Show fields foreach ($ASIA_GARDEN_STORAGE['options'] as $k=>$v) { if (!isset($v['override']) || strpos($v['override']['mode'], $post_type)===false) continue; if (empty($v['override']['section'])) $v['override']['section'] = esc_html__('General', 'asia-garden'); if (!isset($tabs_titles[$v['override']['section']])) { $tabs_titles[$v['override']['section']] = $v['override']['section']; $tabs_content[$v['override']['section']] = ''; } $v['val'] = isset($meta[$k]) ? $meta[$k] : 'inherit'; $tabs_content[$v['override']['section']] .= asia_garden_options_show_field($k, $v, $post_type); } if (count($tabs_titles) > 0) { ?>
$v) { $cnt++; ?>
$post_type), 'objects' ); if (!empty($post_types) && is_array($post_types)) { foreach ($post_types as $type) { $capability = $type->capability_type; break; } } if (!current_user_can('edit_'.($capability), $post_id)) { return $post_id; } // Save meta $meta = array(); $options = asia_garden_storage_get('options'); foreach ($options as $k=>$v) { // Skip not overriden options if (!isset($v['override']) || strpos($v['override']['mode'], $post_type)===false) continue; // Skip inherited options if (!empty($_POST['asia_garden_options_inherit_' . $k])) continue; // Get option value from POST $meta[$k] = isset($_POST['asia_garden_options_field_' . $k]) ? asia_garden_get_value_gp('asia_garden_options_field_' . $k) : ($v['type']=='checkbox' ? 0 : ''); } update_post_meta($post_id, 'asia_garden_options', $meta); // Save separate meta options to search template pages if ($post_type=='page' && !empty($_POST['page_template']) && $_POST['page_template']=='blog.php') { update_post_meta($post_id, 'asia_garden_options_post_type', isset($meta['post_type']) ? $meta['post_type'] : 'post'); update_post_meta($post_id, 'asia_garden_options_parent_cat', isset($meta['parent_cat']) ? $meta['parent_cat'] : 0); } } } ?>