'',
'Post or Page' => 'Post',
'Shortcode' => 'Shortcode',
'Full Screen Video' => 'YouTube',
'Full Screen Image' => 'Image',
'Insert My Own' => 'Insert',
);
/**
* Access this plugin’s working instance
*
* @since 1.0
* @return object instance of this class
*/
public static function get_instance() {
null === self::$instance and self::$instance = new self;
return self::$instance;
}
/**
* Intentionally left blank
*/
function __construct() {}
/**
* Render Meta Box content.
*
* @param WP_Post $post The post object.
*/
public function split_view_ui( $post ) {
// Add an nonce field so we can check for it later.
wp_nonce_field( 'premise_split_view', 'premise_split_view_nonce' );
?>
Insert the content you would like to display on each side of the Split View.
To insert this Split View anywhere in your site use the following shortcode [pwp_splitview id="ID; ?>"]
select_type( 'left' ); ?>
select_type( 'right' ); ?>
Change the color of the Split View controls.
'wp_color',
'default' => '#1652db', // Default blue.
'name' => 'premise_split_view[color]',
'wrapper_class' => 'span5',
'context' => 'post',
)
); ?>
'post',
'name' => 'premise_split_view['.$side.'][type]',
'options' => $this->type_options,
));
echo '';
$this->insert_content( $side );
echo '
';
}
/**
* Insert content fields
*
* @param string $side the side to load the content for
*
* @return string html for insert content sections.
*/
public function insert_content( $side = 'left' ) {
$_types = array(
'Post' => 'select',
'Shortcode' => 'text',
'YouTube' => 'video',
'Image' => 'wp_media',
'Insert' => 'textarea',
);
$html = '';
foreach ( $_types as $k => $v ) {
$args = array(
'context' => 'post',
'name' => 'premise_split_view['.$side.']['.$k.']',
'type' => $v,
);
if ( 'Post' == $k ) {
$args['options'] = $this->get_post_options();
}
if ( 'YouTube' == $k ) {
$args['placeholder'] = 'Video ID or URL - YouTube, Vimeo or Wistia';
}
$html .= '' : '">';
if ( 'Insert' == $k ) {
$args['class'] = 'premise-hidden';
$html .= '
Edit Content';
}
$html .= pwp_field( $args, false );
$html .= '
';
}
echo $html;
}
/**
* Get a list of all post and pages for our select dropdown
*
* @return array all posts and pages in array format: post_title => id
*/
protected function get_post_options() {
$_posts = get_posts( array(
'post_type' => array( 'post', 'page' ),
'post_status' => 'publish',
'posts_er_page' => -1
) );
$options = array();
$options['Select a Post/Page..'] = '';
foreach ( $_posts as $k => $v ) {
$options[ $v->post_title ] = $v->ID;
}
return $options;
}
/**
* Insert the modal usede to insert content using the WYSIWYG editor in the aplit view.
*
* @return string the html for the modal
*/
public function insert_footer() {
global $post;
$post_types = array( 'premise_split_view' );
$html = '';
if ( $post
&& in_array( $post->post_type, $post_types ) ) {
ob_start();
?>
'pwpsv-insert-content', 'wrapper_class' => 'premise-inline-block premise-float-left' ) ); ?>
'pwpsv-insert-cancel', 'value' => 'cancel', 'wrapper_class' => 'premise-inline-block premise-float-right' ) ); ?>