<?php 

/*
== ------------------------------------------------------------------- ==
== @@ Page/Post Layout Metabox
== ------------------------------------------------------------------- ==
*/

add_action('admin_init', 'invicta_add_page_post_metaboxes' );

function invicta_add_page_post_metaboxes() {
	
	// available layouts
	
	$layouts = array(
		'default' => __( 'Default (set in Theme Options)', 'invicta_dictionary' ),
		'no_sidebar' => __( 'No Sidebar', 'invicta_dictionary' ),
		'right_sidebar' => __( 'Right Sidebar', 'invicta_dictionary' ),
		'left_sidebar' => __( 'Left Sidebar', 'invicta_dictionary' )
	);
	
	// available sidebars
	
	$sidebars = array();
	$sidebars['default'] = __( 'Default', 'invicta_dictionary' );
	global $wp_registered_sidebars;
	foreach ( $wp_registered_sidebars as $sidebar ) {
		if ( $sidebar['name'] != 'Global Sidebar') {
			$sidebars[ $sidebar['name'] ] = $sidebar['name'];
		}
	}
	
	// metabox arguments
	
	$args = array(
		'id'			=> '_invicta_layout',
		'title' 		=> __( 'Page Layout', 'invicta_dictionary' ),
		'post_types' 	=> array( 'post', 'page' ),
		'context' 		=> 'side',
		'priority'		=> 'default',
		'fields'		=> array(
			array(
				'id' 			=> '_invicta_layout_layout',
				'name' 			=> __( 'Layout', 'invicta_dictionary' ),
				'description'	=> __( 'Select the desired Page layout', 'invicta_dictionary' ),
				'default'		=> '',
				'type'			=> 'select',
				'options'		=> $layouts
			),
			array(
				'id' 			=> '_invicta_layout_sidebar',
				'name' 			=> __( 'Sidebar', 'invicta_dictionary' ),
				'description'	=> __( 'Select a custom sidebar for this entry', 'invicta_dictionary' ),
				'default'		=> '',
				'type'			=> 'select',
				'options'		=> $sidebars
			)
		)
	);
	
	// metabox creation

	new invicta_metabox($args);

}

	
?>