<?php

/**

 * Registering meta boxes

 *

 * All the definitions of meta boxes are listed below with comments.

 * Please read them CAREFULLY.

 *

 * You also should read the changelog to know what has been changed before updating.

 *

 * For more information, please visit:

 * @link http://metabox.io/docs/registering-meta-boxes/

 */


 

add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );



/**

 * Register meta boxes

 *

 * Remember to change "your_prefix" to actual prefix in your project

 *

 * @param array $meta_boxes List of meta boxes

 *

 * @return array

 */



function your_prefix_register_meta_boxes( $meta_boxes )
{

	/**

	 * prefix of meta keys (optional)

	 * Use underscore (_) at the beginning to make keys hidden

	 * Alt.: You also can make prefix empty to disable it

	 */

	// Better has an underscore as last sign

	$prefix = 'st_';
	
	$args = array(
		'post_type' => 'committee',
		'posts_per_page' => -1,
		 'orderby' => 'menu_order',
		 'order' => 'ASC',
	);

	$committee_list = get_posts($args);

	
	$committee[] = 'Select One';
	
	foreach($committee_list as $c)
	{
		$committee[$c->ID] = $c->post_title;
	}
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'working_group' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Initiative', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}code",
				'type'  => 'textarea',
				'rows' 	=> 10,
			),
		
			array(
				'name'            => 'Belong to which Committee',
				'id'              => $prefix . 'committee',
				'type'            => 'select',
				// Array of 'value' => 'Label' pairs
				'options'         => $committee,
				
			),
		
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	for($i=1;$i<=10;$i++)
	{
		$member_list[] = array(
				// Field name - Will be used as label
				'name'  => __( 'Member '.$i.' - Name', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}name".$i,
				'type'  => 'text',
				'size' 	=> 80,
			);
		
		$member_list[] = array(
				// Field name - Will be used as label
				'name'  => __( 'Member '.$i.' - Designation', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}title".$i,
				'type'  => 'text',
				'size' 	=> 80,
			);
		
		$member_list[] = array(
				// Field name - Will be used as label
				'name'  => __( 'Member '.$i.' - Content', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}content".$i,
				'type'  => 'textarea',
				'rows' 	=> 10,
			);
		
		
		$member_list[] = array(
				// Field name - Will be used as label
				'name'  => __( 'Member '.$i.' - Photo', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}photo".$i,
				'type'  => 'image',
				'max_file_uploads'	=> 1,
			);
		
	
	}
	
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard2',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Members', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'working_group' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => $member_list,		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'committee' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Initiative', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}code",
				'type'  => 'textarea',
				'rows' 	=> 10,
			),
		
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	for($i=1;$i<=10;$i++)
	{
		$member_list2[] = array(
				// Field name - Will be used as label
				'name'  => __( 'Member '.$i.' - Name', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}name".$i,
				'type'  => 'text',
				'size' 	=> 80,
			);
		
		$member_list2[] = array(
				// Field name - Will be used as label
				'name'  => __( 'Member '.$i.' - Designation', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}title".$i,
				'type'  => 'text',
				'size' 	=> 80,
			);
		
		$member_list2[] = array(
				// Field name - Will be used as label
				'name'  => __( 'Member '.$i.' - Content', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}content".$i,
				'type'  => 'textarea',
				'rows' 	=> 10,
			);
		
		$member_list2[] = array(
				// Field name - Will be used as label
				'name'  => __( 'Member '.$i.' - Designation', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}photo".$i,
				'type'  => 'image',
				'max_file_uploads'	=> 1,
			);
		
	
	}
	
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard2',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Members', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'committee' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => $member_list2,		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	// 1st meta box
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'events_block' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,


		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Event Date', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}date",
				'type'  => 'date',
				'size' 	=> 30,
			),	
			array(
				'name' => 'Is Featured?',
				'id'   => "{$prefix}featured",
				'type' => 'checkbox',
				'std'  => 0, // 0 or 1
			),
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	// 1st meta box
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'working_groups' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Initiative', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}code",
				'type'  => 'textarea',
				'rows' 	=> 10,
			),		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Member 1 - Name', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}name1",
				'type'  => 'text',
				'size' 	=> 80,
			),
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Member 1 - Designation', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}title1",
				'type'  => 'text',
				'size' 	=> 80,
			),
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Member 1 - Content', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}content",
				'type'  => 'textarea',
				'rows' 	=> 10,
			),	
		
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	

	// 1st meta box
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'webinars' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Embed Code', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}code",
				'type'  => 'textarea',
				'sanitize_callback'  => 'none',
				'size'  => 80,
				'rows' 	=> 10,
			),		
		
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	

	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'home_block' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Banner Link', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}link",
				'type'  => 'text',
				'size'  => 80,
			),		
		
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	

	// 1st meta box

	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'gallery' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Photos', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}image_advanced",
				'type'  => 'image',
				'size'  => 80,
			),	
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Date', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}date",
				'type'  => 'text',
				'size'  => 80,
			),		
			
		
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'press_releases' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'News Date', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}date",
				'type'  => 'date',
				'size'  => 80,
			),		
		
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'home_banner' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Mobile Banner (750px by 820px)', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}image",
				'type'  => 'image',
				'max_file_uploads'	=> 1
			
			),	
			
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'URL', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}url",
				'type'  => 'text',
				'size'  => 80,
			),	
			array(
				'name'            => 'Open New Window',
				'id'              => $prefix . 'newwindow',
				'type'            => 'select',
				// Array of 'value' => 'Label' pairs
				'options'         => array(
					'_self' => 'No',
					'_blank'       => 'Yes',
				),
			),

		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	
	
	$meta_boxes[] = array(

		// Meta box id, UNIQUE per meta box. Optional since 4.1.5

		'id'         => 'standard',



		// Meta box title - Will appear at the drag and drop handle bar. Required.

		'title'      => __( 'Standard Fields', 'meta-box' ),



		// Post types, accept custom post types as well - DEFAULT is 'post'. Can be array (multiple post types) or string (1 post type). Optional.

		'post_types' => array( 'page' ),



		// Where the meta box appear: normal (default), advanced, side. Optional.

		'context'    => 'advanced',



		// Order of meta box: high (default), low. Optional.

		'priority'   => 'high',



		// Auto save: true, false (default). Optional.

		'autosave'   => true,



		// List of meta fields

		'fields'     => array(
		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Parent ID', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}fixed_parent_id",
				'type'  => 'text',
				'size'  => 80,
			),		
			// TEXT		
			array(
				// Field name - Will be used as label
				'name'  => __( 'Restricted Page', 'meta-box' ),	
				// Field ID, i.e. the meta key
				'id'    => "{$prefix}restricted",
				'type'  => 'checkbox',
				'value'  => 1,
			),		
		
		
		),		

		'validation' => array(
			'rules'    => array(
				"{$prefix}date" => array(
					'required'  => true,
				),
				"{$prefix}pdf" => array(
					'required'  => true,
				),
			),

			// optional override of default jquery.validate messages

			'messages' => array(

				"{$prefix}password" => array(

					'required'  => __( 'Password is required', 'meta-box' ),

					'minlength' => __( 'Password must be at least 7 characters', 'meta-box' ),

				),

			)

		)

	);
	return $meta_boxes;

}