'Default', 'one-col' => 'One Column', 'two-col-left' => 'Two Column Left', 'two-col-right' => 'Two Column Right' ); $optarrange = array( 'ASC' => 'Ascending', 'DESC' => 'Descending' ); $imagepath = get_template_directory_uri() . '/images/'; $optlayoutimg = array( 'default' => $imagepath.'mb-default.png', 'one-col' => $imagepath.'mb-1c.png', 'two-col-left' => $imagepath.'mb-2cl.png', 'two-col-right' => $imagepath.'mb-2cr.png' ); // Create meta box slider global $meta_boxes; $meta_boxes[] = array( 'id' => 'postlayout-option-meta-box', 'title' => __('Post Options','klasik'), 'page' => 'post', 'showbox' => 'meta_option_show_box', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => __('Layout','klasik'), 'desc' => ''.__('Select the layout you want on this specific post/page. Overrides default site layout.','klasik').'', 'options' => $optlayoutimg, 'id' => 'klasik_layout', 'type' => 'selectimage', 'std' => '' ), array( 'name' => __('Feature on Homepage Slider','klasik'), 'desc' => ''.__('Checked this checkbox if you want to show this post as Homepage Slider.','klasik').'', 'id' => 'klasik_slider_post', 'type' => 'checkbox', 'std' => '' ), array( 'name' => __('Disable Blog Info on Single','klasik'), 'desc' => ''.__('Checked this checkbox if you want to disable the meta and author information on single page (date, author, categories, etc).','klasik').'', 'id' => 'klasik_disable_meta', 'type' => 'checkbox', 'std' => '' ) ) ); $meta_boxes[] = array( 'id' => 'pagelayout-option-meta-box', 'title' => __('Layout Settings','klasik'), 'page' => 'page', 'showbox' => 'meta_option_show_box', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => __('Layout','klasik'), 'desc' => ''.__('Select the layout you want on this specific post/page. Overrides default site layout.','klasik').'', 'options' => $optlayoutimg, 'id' => 'klasik_layout', 'type' => 'selectimage', 'std' => '' ) ) ); $meta_boxes[] = array( 'id' => 'page-option-meta-box', 'title' => __('Page Settings','klasik'), 'page' => 'page', 'showbox' => 'meta_option_show_box', 'context' => 'normal', 'priority' => 'high', 'fields' => array( array( 'name' => __('Page Title','klasik'), 'desc' => ''.__('Enter your custom page title to show on heading.','klasik').'', 'id' => 'page-title', 'type' => 'text', 'std' => '' ), array( 'name' => __('Page Description','klasik'), 'desc' => ''.__('Enter your custom page description to show on heading.','klasik').'', 'id' => 'page-desc', 'type' => 'text', 'std' => '' ) ) ); add_action('add_meta_boxes', 'mytheme_add_box'); // Add meta box function mytheme_add_box() { global $meta_boxes; foreach($meta_boxes as $meta_box){ $metaargs = array( 'meta_array' => $meta_box ); add_meta_box($meta_box['id'], $meta_box['title'], $meta_box['showbox'], $meta_box['page'], $meta_box['context'], $meta_box['priority'], $metaargs); } } function meta_option_show_box($post, $metaargs) { global $meta_boxes; $meta_array = $metaargs['args']['meta_array']; // Use nonce for verification echo ''; echo mytheme_create_metabox($meta_array); } // Create Metabox Form Table function mytheme_create_metabox($meta_box){ global $post; $returnstring = ""; $returnstring .=' '; $returnstring .= '
'. ' | ';
switch ($field['type']) {
//If Text
case 'text':
$textvalue = $meta ? $meta : $field['std'];
$widthinput = "97%";
$prefixinput = "";
$postfixinput = "";
if(isset($field['class'])){
if($field['class']=="mini"){
$widthinput = "20%";
}
}
if(isset($field['prefix'])){
$prefixinput = stripslashes(trim($field['prefix']));
}
if(isset($field['postfix'])){
$postfixinput = stripslashes(trim($field['postfix']));
}
$returnstring .= $prefixinput.' '.$postfixinput.
' '.$field['desc']; break; //If Text Area case 'textarea': $textvalue = $meta ? $meta : $field['std']; $returnstring .= ''. ' '.$field['desc']; break; //If Select Combobox case 'select': $optvalue = $meta ? $meta : $field['std']; $returnstring .= ''; $returnstring .= ' '.$field['desc']; break; case 'select-blog-category': $optvalue = $meta ? $meta : $field['std']; // Pull all the categories into an array $options_categories = array(); $options_categories_obj = get_categories(); $options_categories["allcategories"] =__('Select The Category','klasik'); foreach ($options_categories_obj as $category) { $options_categories[$category->slug] = $category->cat_name; } $returnstring .= ''; $returnstring .= ' '.$field['desc']; break; case 'checkbox-blog-categories': $chkvalue = $meta ? $meta : $field['std']; $chkvalue = explode(",",$chkvalue); $portcategories = get_categories(); foreach($portcategories as $category){ $checkedstr=""; if(in_array($category->slug,$chkvalue)){ $checkedstr = 'checked="checked"'; } $returnstring .= ' ';
$returnstring .= 'name . '" '.$checkedstr.' /> '. $category->name;
$returnstring .= ' ';
}
$returnstring .= ''.$field['desc']; break; //If Select Slider Combobox case 'select-slider-category': $optvalue = $meta ? $meta : $field['std']; // Pull all the slider categories into an array $options_pcategory = array(); $options_pcategory_obj = get_terms('slider-category'); $options_categories[""] =__('Select Category','klasik'); if($options_pcategory_obj){ foreach ($options_pcategory_obj as $pcategory) { $options_pcategory[$pcategory->slug] = $pcategory->name; } } $returnstring .= ''; $returnstring .= ' '.$field['desc']; break; //If Select Slider Combobox case 'select-portfolio-category': $optvalue = $meta ? $meta : $field['std']; // Pull all the slider categories into an array $options_pcategory = array(); $options_pcategory_obj = get_terms('portfolio-category'); $options_categories[""] =__('Select Category','klasik'); if($options_pcategory_obj){ foreach ($options_pcategory_obj as $pcategory) { $options_pcategory[$pcategory->slug] = $pcategory->name; } } $returnstring .= ''; $returnstring .= ' '.$field['desc']; break; //If Checkbox for Portfolio Categories case 'checkbox-portfolio-categories': $chkvalue = $meta ? $meta : $field['std']; $chkvalue = explode(",",$chkvalue); $args = array( "type" => "portfolio", "taxonomy" => "portfolio-category" ); $portcategories = get_categories($args); foreach($portcategories as $category){ $checkedstr=""; if(in_array($category->slug,$chkvalue)){ $checkedstr = 'checked="checked"'; } $returnstring .= ' ';
$returnstring .= 'name . '" '.$checkedstr.' /> '. $category->name;
$returnstring .= ' ';
}
$returnstring .= ''.$field['desc']; break; //If Select Image case 'selectimage': $optvalue = $meta ? $meta : $field['std']; foreach ($field['options'] as $option => $val){ $selectedstr = ($optvalue==$option)? 'optselected' : ''; $checkedstr = ($optvalue==$option)? 'checked="checked"' : ''; $returnstring .= ''; $returnstring .= ''; } $returnstring .= ' '.$field['desc']; break; //If Checkbox case 'checkbox': $chkvalue = $meta ? true : $field['std']; $checkedstr = ($chkvalue)? 'checked="checked"' : ''; $returnstring .= ''; $returnstring .= ' '.$field['desc']; break; //If Button case 'button': $buttonvalue = $meta ? $meta : $field['std'] ; $returnstring .= ''; $returnstring .= ' '.$field['desc']; break; } $returnstring .= ' | '.
'
---|