<?php
/**
 * Add meta box
 *
 */
function effectsingle_add_meta_boxes( $post ){
	add_meta_box( 'food_meta_box', __( '<span class="dashicons dashicons-layout"></span> Post Layout Select [Pro Only]', 'effect' ), 'effectsingle_build_meta_box', 'post', 'side', 'high' );
}
add_action( 'add_meta_boxes', 'effectsingle_add_meta_boxes' );
/**
 * Build custom field meta box
 *
 * @param post $post The post object
 */
function effectsingle_build_meta_box( $post ){
	// make sure the form request comes from WordPress
	wp_nonce_field( basename( __FILE__ ), 'effectsinglemeta_meta_box_nonce' );
	// retrieve the _food_effectsinglemeta current value
	$current_effectsinglemeta = get_post_meta( $post->ID, '_food_effectsinglemeta', true );
$upgradetopro = 'Layout Select for current post only - for website layout please choose from theme options <a href="' . esc_url('http://www.insertcart.com/product/effect-wp-theme/','effect') . '" target="_blank">' . esc_attr__( 'Get Effect Pro', 'effect' ) . '</a>';

	?>
	<div class='inside'>

		<h4><?php echo $upgradetopro; ?></h4>
		<p>
			<input type="radio" name="effectsinglemeta" value="rsd" <?php checked( $current_effectsinglemeta, 'rsd' ); ?> /> <?php _e('Right Sidebar - Default','effect'); ?><br />
			<input type="radio" name="effectsinglemeta" value="ls" <?php checked( $current_effectsinglemeta, 'ls' ); ?> /> <?php _e('Left Sidebar','effect'); ?><br/>
			<input type="radio" name="effectsinglemeta" value="lr" <?php checked( $current_effectsinglemeta, 'lr' ); ?> /> <?php _e('Left - Right Sidebars','effect'); ?> <br/>
			<input type="radio" name="effectsinglemeta" value="fc" <?php checked( $current_effectsinglemeta, 'fc' ); ?> /> <?php _e('Full Content - No Sidebar','effect'); ?>
		</p>

		

	</div>
	<?php
}
/**
 * Store custom field meta box data
 *
 * @param int $post_id The post ID.
 * @link https://codex.wordpress.org/Plugin_API/Action_Reference/save_post
 */
function food_save_meta_box_data( $post_id ){
	// verify meta box nonce
	if ( !isset( $_POST['effectsinglemeta_meta_box_nonce'] ) || !wp_verify_nonce( $_POST['effectsinglemeta_meta_box_nonce'], basename( __FILE__ ) ) ){
		return;
	}
	// return if autosave
	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
		return;
	}
  // Check the user's permissions.
	if ( ! current_user_can( 'edit_post', $post_id ) ){
		return;
	}
	// store custom fields values
	// effectsinglemeta string
	if ( isset( $_REQUEST['effectsinglemeta'] ) ) {
		update_post_meta( $post_id, '_food_effectsinglemeta', sanitize_text_field( $_POST['effectsinglemeta'] ) );
	}

}
add_action( 'save_post', 'food_save_meta_box_data' );