%k25u25%fgd5n!
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
if( !class_exists( 'MetaboxPostOptions' ) ) {
class MetaboxPostOptions {
private static $_instance = null;
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
function __construct() {
add_filter( 'cs_metabox_options', array( $this, 'post_options' ) );
add_filter( 'cs_metabox_options', array( $this, 'header_footer_options' ) );
add_action( 'template_redirect', array( $this, 'register_templates' ) );
}
function post_options( $options ) {
$post_types = apply_filters( 'windoor_post_options_post', array( 'post' ) );
$options[] = array(
'id' => '_windoor_post_settings',
'title' => esc_html('Post Options', 'windoor-pro'),
'post_type' => $post_types,
'context' => 'advanced',
'priority' => 'high',
'sections' => array(
array(
'name' => 'post_options_section',
'fields' => array(
array(
'id' => 'single_post_style',
'type' => 'select',
'title' => esc_html__('Post Style', 'windoor-pro'),
'options' => apply_filters( 'windoor_post_styles', array() ),
'class' => 'chosen',
'default' => 'minimal',
'attributes' => array(
'style' => 'width: 25%;'
),
'info' => esc_html__('Choose post style to display single post.', 'windoor-pro')
),
array(
'id' => 'view_count',
'type' => 'number',
'title' => esc_html__('Views', 'windoor-pro' ),
'info' => esc_html__('No.of views of this post.', 'windoor-pro'),
'attributes' => array(
'style' => 'width: 15%;'
),
),
array(
'id' => 'like_count',
'type' => 'number',
'title' => esc_html__('Likes', 'windoor-pro' ),
'info' => esc_html__('No.of likes of this post.', 'windoor-pro'),
'attributes' => array(
'style' => 'width: 15%;'
),
),
array(
'id' => 'post-format-type',
'title' => esc_html__('Type', 'windoor-pro' ),
'type' => 'select',
'default' => 'standard',
'options' => array(
'standard' => esc_html__('Standard', 'windoor-pro'),
'status' => esc_html__('Status','windoor-pro'),
'quote' => esc_html__('Quote','windoor-pro'),
'gallery' => esc_html__('Gallery','windoor-pro'),
'image' => esc_html__('Image','windoor-pro'),
'video' => esc_html__('Video','windoor-pro'),
'audio' => esc_html__('Audio','windoor-pro'),
'link' => esc_html__('Link','windoor-pro'),
'aside' => esc_html__('Aside','windoor-pro'),
'chat' => esc_html__('Chat','windoor-pro')
),
'class' => 'chosen',
'attributes' => array(
'style' => 'width: 25%;'
),
'info' => esc_html__('Post Format & Type should be Same. Check the Post Format from the "Format" Tab, which comes in the Right Side Section.', 'windoor-pro'),
),
array(
'id' => 'post-gallery-items',
'type' => 'gallery',
'title' => esc_html__('Add Images', 'windoor-pro' ),
'add_title' => esc_html__('Add Images', 'windoor-pro' ),
'edit_title' => esc_html__('Edit Images', 'windoor-pro' ),
'clear_title'=> esc_html__('Remove Images', 'windoor-pro' ),
'dependency' => array( 'post-format-type', '==', 'gallery' ),
),
array(
'id' => 'media-type',
'type' => 'select',
'title' => esc_html__('Select Type', 'windoor-pro' ),
'dependency' => array( 'post-format-type', 'any', 'video,audio' ),
'options' => array(
'oembed' => esc_html__('Oembed','windoor-pro'),
'self' => esc_html__('Self Hosted','windoor-pro'),
)
),
array(
'id' => 'media-url',
'type' => 'textarea',
'title' => esc_html__('Media URL', 'windoor-pro' ),
'dependency' => array( 'post-format-type', 'any', 'video,audio' ),
),
array(
'id' => 'fieldset_link',
'type' => 'fieldset',
'title' => esc_html__('Link Values', 'windoor-pro'),
'fields' => array(
array(
'id' => 'fieldset_link_title',
'type' => 'text',
'title' => esc_html__('Link Text', 'windoor-pro'),
),
array(
'id' => 'fieldset_link_url',
'type' => 'text',
'title' => esc_html__('URL', 'windoor-pro'),
),
),
'dependency' => array( 'post-format-type', '==', 'link' ),
),
)
)
)
);
return $options;
}
function header_footer_options( $options ) {
$post_types = apply_filters( 'windoor_header_footer_posts', array( 'post', 'page' ) );
$options[] = array(
'id' => '_windoor_custom_settings',
'title' => esc_html__('Header & Footer', 'windoor-pro'),
'post_type' => $post_types,
'priority' => 'high',
'context' => 'side',
'sections' => array(
array(
'name' => 'header_section',
'title' => esc_html__('Header', 'windoor-pro'),
'icon' => 'fa fa-angle-double-right',
'fields' => array(
array(
'id' => 'show-header',
'type' => 'switcher',
'title' => esc_html__('Show Header', 'windoor-pro'),
'default' => true,
),
array(
'id' => 'header',
'type' => 'select',
'title' => esc_html__('Choose Header', 'windoor-pro'),
'class' => 'chosen',
'options' => 'posts',
'query_args' => array(
'post_type' => 'wdt_headers',
'orderby' => 'ID',
'order' => 'ASC',
'posts_per_page' => -1,
),
'default_option' => esc_attr__('Select Header', 'windoor-pro'),
'attributes' => array( 'style' => 'width:50%' ),
'info' => esc_html__('Select custom header for this page.','windoor-pro'),
'dependency' => array( 'show-header', '==', 'true' )
),
)
),
array(
'name' => 'footer_settings',
'title' => esc_html__('Footer', 'windoor-pro'),
'icon' => 'fa fa-angle-double-right',
'fields' => array(
array(
'id' => 'show-footer',
'type' => 'switcher',
'title' => esc_html__('Show Footer', 'windoor-pro'),
'default' => true,
),
array(
'id' => 'footer',
'type' => 'select',
'title' => esc_html__('Choose Footer', 'windoor-pro'),
'class' => 'chosen',
'options' => 'posts',
'query_args' => array(
'post_type' => 'wdt_footers',
'orderby' => 'ID',
'order' => 'ASC',
'posts_per_page' => -1,
),
'default_option' => esc_attr__('Select Footer', 'windoor-pro'),
'attributes' => array( 'style' => 'width:50%' ),
'info' => esc_html__('Select custom footer for this page.','windoor-pro'),
'dependency' => array( 'show-footer', '==', 'true' )
),
array(
'id' => 'show-fixed-footer',
'type' => 'switcher',
'title' => esc_html__('Show Fixed Footer', 'windoor-pro'),
'default' => false,
'dependency'=> array( 'show-footer', '==', 'true' )
),
)
),
)
);
return $options;
}
function register_templates() {
if( is_singular() ) {
add_filter( 'windoor_header_get_template_part', array( $this, 'register_header_template' ), 50 );
add_filter( 'windoor_footer_get_template_part', array( $this, 'register_footer_template' ), 50 );
}
}
function register_header_template( $template ) {
$header_type = windoor_customizer_settings( 'site_header' );
if( is_singular() ) {
global $post;
$settings = get_post_meta( $post->ID, '_windoor_custom_settings', TRUE );
$settings = is_array( $settings ) ? $settings : array();
if( array_key_exists( 'show-header', $settings ) && ! $settings['show-header'] )
return;
$id = isset( $settings['header'] ) ? $settings['header'] : -1;
if( $id > 0 ) {
return apply_filters( 'windoor_print_header_template', $id );
}
}
return $template;
}
function register_footer_template( $template ) {
$footer_type = windoor_customizer_settings( 'site_footer' );
if( is_singular() ) {
global $post;
$settings = get_post_meta( $post->ID, '_windoor_custom_settings', TRUE );
$settings = is_array( $settings ) ? $settings : array();
if( array_key_exists( 'show-footer', $settings ) && ! $settings['show-footer'] )
return;
$id = isset( $settings['footer'] ) ? $settings['footer'] : -1;
if( $id > 0 ) {
return apply_filters( 'windoor_print_footer_template', $id );
}
}
return $template;
}
}
}
MetaboxPostOptions::instance();