Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @version 1.0
- * @package WR_Theme
- * @author WooRockets Team <support@woorockets.com>
- * @copyright Copyright (C) 2014 WooRockets.com. All Rights Reserved.
- * @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
- *
- * Websites: http://www.woorockets.com
- */
- /**
- * Plug additional meta boxes into WordPress.
- *
- * @package WR_Theme
- * @since 1.0
- */
- class WR_Nitro_Meta_Box extends RW_Meta_Box {
- /**
- * Variable to hold the initialization state.
- *
- * @var boolean
- */
- protected static $initialized = false;
- /**
- * Initialize pluggable functions.
- *
- * @return void
- */
- public static function initialize() {
- // Do nothing if pluggable functions already initialized.
- if ( self::$initialized ) {
- return;
- }
- // Remove original RW Meta Box init action.
- remove_action( 'admin_init', 'rwmb_register_meta_boxes' );
- // Add action to init RW Meta Box.
- add_action( 'admin_init', array( __CLASS__, 'register_meta_boxes' ) );
- // Register necessary actions / filters to hook WR Nitro meta boxes into WordPress.
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_admin_assets' ) );
- add_filter( 'rwmb_meta_boxes' , array( __CLASS__, 'meta_boxes' ) );
- add_filter( 'rwmb_outside_conditions', array( __CLASS__, 'outside_conditions' ) );
- // Register filter to verify page option values before saving.
- add_filter( 'update_post_metadata', array( __CLASS__, 'verify' ), 10, 5 );
- // Register filter to synchronize default option values with current theme customizer values.
- add_filter( 'rwmb_field_meta', array( __CLASS__, 'get_meta' ), 10, 3 );
- // State that initialization completed.
- self::$initialized = true;
- }
- /**
- * Initialize RW Meta Box.
- *
- * @return void
- */
- public static function register_meta_boxes() {
- // Get meta boxes to register.
- $meta_boxes = apply_filters( 'rwmb_meta_boxes', array() );
- if ( is_array( $meta_boxes ) ) {
- // Load all custom fields.
- static $loaded;
- if ( ! isset( $loaded ) ) {
- foreach ( glob( dirname( __FILE__ ) . '/fields/*.php' ) as $file ) {
- include_once $file;
- }
- $loaded = true;
- }
- // Instantiate all meta boxes.
- foreach ( $meta_boxes as $meta_box ) {
- $meta_box = new self( $meta_box );
- }
- }
- }
- /**
- * Enqueue required admin assets.
- *
- * @return void
- */
- public static function enqueue_admin_assets() {
- global $post;
- // Enqueue scripts and styles for registered pages (post types) only
- $types = array( 'post', 'page', 'nitro-portfolio', 'masonry-builder' );
- if ( isset( $post->post_type ) && in_array( $post->post_type, $types ) ) {
- // Load custom style.
- wp_enqueue_style( 'wr-metabox', get_template_directory_uri() . '/assets/woorockets/css/admin/meta-box.css' );
- }
- }
- /**
- * Register additional meta boxes.
- *
- * @param array $meta_boxes Current meta boxes.
- *
- * @return array
- */
- public static function meta_boxes( $meta_boxes ) {
- $posts = array(
- 'posts_per_page' => -1,
- 'offset' => 0,
- 'orderby' => 'date',
- 'order' => 'DESC',
- 'post_type' => 'header_builder',
- 'post_status' => array( 'header_normal', 'header_default' ),
- 'suppress_filters' => true,
- );
- $posts = get_posts( $posts );
- $header_layout = array();
- global $wr_nitro_options;
- // Style of list product
- $shop_layout = $wr_nitro_options['wc_archive_style'];
- foreach ( $posts as $key => $value ) {
- $header_layout[ $value->ID ] = $value->post_title;
- }
- // Additional meta box for post.
- $meta_boxes[] = array(
- 'id' => 'wr_post_option',
- 'post_types' => array( 'post' ),
- 'title' => WR_Nitro::_( 'Post Settings' ),
- 'context' => 'normal',
- 'priority' => 'high',
- 'autosave' => true,
- 'fields' => array(
- array(
- 'name' => WR_Nitro::_( 'Enable large post' ),
- 'id' => 'masonry_large',
- 'type' => 'checkbox',
- 'desc' => WR_Nitro::_( '<br /><i>Support Masonry layout only</i>' ),
- 'std' => 0,
- ),
- array(
- 'name' => WR_Nitro::_( 'Add image gallery' ),
- 'id' => 'format_gallery',
- 'type' => 'image_advanced',
- ),
- array(
- 'name' => WR_Nitro::_( 'Video Source' ),
- 'id' => 'format_video',
- 'type' => 'select',
- 'options' => array(
- 'link' => WR_Nitro::_( 'Video Link' ),
- 'file' => WR_Nitro::_( 'Video Upload File' ),
- ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Video Link' ),
- 'id' => 'format_video_url',
- 'desc' => WR_Nitro::_( '(Support Youtube and Vimeo video)' ),
- 'type' => 'oembed',
- 'visible' => array( 'format_video', '=', 'link' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Upload video' ),
- 'id' => 'format_video_file',
- 'desc' => WR_Nitro::_( 'Support .mp4 file format only' ),
- 'type' => 'file_advanced',
- 'max_file_uploads' => 1,
- 'mime_type' => 'video',
- 'visible' => array( 'format_video', '=', 'file' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Audio Source' ),
- 'id' => 'format_audio',
- 'type' => 'select',
- 'options' => array(
- 'link' => WR_Nitro::_( 'Soundcloud Link' ),
- 'file' => WR_Nitro::_( 'Upload audio' ),
- ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Soundcloud Link' ),
- 'id' => 'format_audio_url',
- 'type' => 'oembed',
- 'visible' => array( 'format_audio', '=', 'link' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Upload Audio' ),
- 'id' => 'format_audio_file',
- 'desc' => WR_Nitro::_( 'Support .mp3 file format only' ),
- 'type' => 'file_advanced',
- 'max_file_uploads' => 1,
- 'mime_type' => 'audio',
- 'visible' => array( 'format_audio', '=', 'file' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Quote content' ),
- 'desc' => WR_Nitro::_( 'You can write the Quote content here.' ),
- 'id' => 'format_quote_content',
- 'type' => 'textarea',
- 'cols' => '30',
- 'rows' => '6',
- ),
- array(
- 'name' => WR_Nitro::_( 'Quote author' ),
- 'id' => 'format_quote_author',
- 'type' => 'text',
- 'clone' => false,
- ),
- array(
- 'name' => WR_Nitro::_( 'Link to' ),
- 'id' => 'format_link_url',
- 'type' => 'text',
- ),
- )
- );
- // Additional meta box for page.
- $meta_boxes[] = array(
- 'id' => 'wr_page_option',
- 'post_types' => array( 'page' ),
- 'title' => WR_Nitro::_( 'Page Settings' ),
- 'context' => 'normal',
- 'priority' => 'high',
- 'autosave' => true,
- 'fields' => array(
- array(
- 'name' => WR_Nitro::_( 'Use Global Settings' ),
- 'id' => 'global_opt',
- 'type' => 'toggle',
- 'std' => 1,
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Stretch Row And Content' ),
- 'id' => 'wr_layout_stretch',
- 'type' => 'toggle',
- 'std' => 0,
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Boxed Layout' ),
- 'id' => 'wr_layout_boxed',
- 'type' => 'toggle',
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'std' => 0,
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Color' ),
- 'id' => 'wr_layout_boxed_bg_color',
- 'type' => 'colors',
- 'hidden' => array( 'wr_layout_boxed', '=', 0 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Image' ),
- 'id' => 'wr_layout_boxed_bg_image',
- 'type' => 'image_advanced',
- 'max_file_uploads' => 1,
- 'hidden' => array( 'wr_layout_boxed', '=', 0 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Position' ),
- 'id' => 'wr_layout_boxed_bg_image_position',
- 'type' => 'select',
- 'options' => array(
- 'left top' => WR_Nitro::_( 'Left Top' ),
- 'left center' => WR_Nitro::_( 'Left Center' ),
- 'left bottom' => WR_Nitro::_( 'Left Bottom' ),
- 'right top' => WR_Nitro::_( 'Right Top' ),
- 'right center' => WR_Nitro::_( 'Right Center' ),
- 'right bottom' => WR_Nitro::_( 'Right Bottom' ),
- 'center top' => WR_Nitro::_( 'Center Top' ),
- 'center center' => WR_Nitro::_( 'Center Center' ),
- 'center bottom' => WR_Nitro::_( 'Center Bottom' ),
- ),
- 'visible' => array( 'wr_layout_boxed_bg_image', '>', 0 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Repeat' ),
- 'id' => 'wr_layout_boxed_bg_image_repeat',
- 'type' => 'select',
- 'options' => array(
- 'no-repeat' => WR_Nitro::_( 'No Repeat' ),
- 'repeat' => WR_Nitro::_( 'Repeat' ),
- 'repeat-x' => WR_Nitro::_( 'Repeat X' ),
- 'repeat-y' => WR_Nitro::_( 'Repeat Y' ),
- ),
- 'visible' => array( 'wr_layout_boxed_bg_image', '>', 0 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Size' ),
- 'id' => 'wr_layout_boxed_bg_image_size',
- 'type' => 'select',
- 'options' => array(
- 'auto' => WR_Nitro::_( 'auto' ),
- 'cover' => WR_Nitro::_( 'Cover' ),
- 'contain' => WR_Nitro::_( 'Contain' ),
- 'initial' => WR_Nitro::_( 'Initial' ),
- ),
- 'visible' => array( 'wr_layout_boxed_bg_image', '>', 0 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Attachment' ),
- 'id' => 'wr_layout_boxed_bg_image_attachment',
- 'type' => 'select',
- 'options' => array(
- 'scroll' => WR_Nitro::_( 'Scroll' ),
- 'fixed' => WR_Nitro::_( 'Fixed' ),
- ),
- 'visible' => array( 'wr_layout_boxed_bg_image', '>', 0 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Parallax Background' ),
- 'id' => 'wr_layout_boxed_bg_parallax',
- 'type' => 'toggle',
- 'std' => 0,
- 'visible' => array( 'wr_layout_boxed_bg_image', '>', 0 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Mask Overlay Color' ),
- 'id' => 'wr_layout_boxed_bg_mask_color',
- 'type' => 'colors',
- 'std' => '#000',
- 'hidden' => array( 'wr_layout_boxed', '=', 0 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Choose Header Layout' ),
- 'id' => 'header_layout',
- 'type' => 'select',
- 'options' => $header_layout,
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'type' => 'divider',
- 'id' => 'divider_01',
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Page Layout' ),
- 'id' => 'page_layout',
- 'type' => 'image_select',
- 'options' => array(
- 'left-sidebar' => get_template_directory_uri() . '/assets/woorockets/images/admin/lc.png',
- 'no-sidebar' => get_template_directory_uri() . '/assets/woorockets/images/admin/c.png',
- 'right-sidebar' => get_template_directory_uri() . '/assets/woorockets/images/admin/cr.png',
- ),
- 'std' => 'no-sidebar',
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Select Sidebar' ),
- 'id' => 'page_layout_sidebar',
- 'type' => 'select',
- 'options' => WR_Nitro_Helper::get_sidebars(),
- 'std' => 'primary-sidebar',
- 'hidden' => array( 'page_layout', '=', 'no-sidebar' ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Sidebar Width' ),
- 'id' => 'page_layout_sidebar_width',
- 'type' => 'slider',
- 'suffix' => WR_Nitro::_( ' Columns' ),
- 'js_options' => array(
- 'min' => 2,
- 'max' => 6,
- 'step' => 1,
- ),
- 'std' => 3,
- 'hidden' => array( 'page_layout', '=', 'no-sidebar' ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'type' => 'divider',
- 'id' => 'divider_02',
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Content Width' ),
- 'id' => 'wr_layout_content_width_unit',
- 'type' => 'radio',
- 'options' => array(
- 'pixel' => WR_Nitro::_( 'px' ),
- 'percentage' => WR_Nitro::_( '%' ),
- ),
- 'std' => 'pixel',
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => ' ',
- 'id' => 'wr_layout_content_width',
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 760,
- 'max' => 1920,
- 'step' => 10,
- ),
- 'std' => 1170,
- 'hidden' => array( 'wr_layout_content_width_unit', '!=', 'pixel' ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => ' ',
- 'id' => 'wr_layout_content_width_percentage',
- 'type' => 'slider',
- 'suffix' => '%',
- 'js_options' => array(
- 'min' => 20,
- 'max' => 100,
- 'step' => 1,
- ),
- 'std' => 100,
- 'hidden' => array( 'wr_layout_content_width_unit', '!=', 'percentage' ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Gutter Width' ),
- 'id' => 'wr_layout_gutter_width',
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 20,
- 'max' => 60,
- 'step' => 10,
- ),
- 'std' => 30,
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Offset Width' ),
- 'id' => 'wr_layout_offset',
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 0,
- 'max' => 100,
- 'step' => 5,
- ),
- 'std' => 0,
- 'hidden' => array( 'wr_layout_boxed', '=', 1 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Offset Background Color' ),
- 'id' => 'wr_layout_offset_color',
- 'type' => 'colors',
- 'std' => '#000',
- 'hidden' => array( 'wr_layout_boxed', '=', 1 ),
- 'tab' => WR_Nitro::_( 'General' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Enable Title Of Page' ),
- 'id' => 'wr_page_title',
- 'type' => 'toggle',
- 'std' => 1,
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Page Title Layout' ),
- 'id' => 'wr_page_title_layout',
- 'type' => 'select',
- 'options' => array(
- '1' => WR_Nitro::_( 'Layout 1' ),
- '2' => WR_Nitro::_( 'Layout 2' ),
- ),
- 'std' => '1',
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Full Section' ),
- 'id' => 'wr_page_title_fullscreen',
- 'type' => 'toggle',
- 'std' => 0,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Show Breadcrumb' ),
- 'id' => 'wr_page_title_breadcrumbs',
- 'type' => 'toggle',
- 'std' => 0,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Link Color' ),
- 'id' => 'wr_page_title_link_colors',
- 'type' => 'colors',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'options' => array(
- 'normal' => WR_Nitro::_( 'Normal State' ),
- 'hover' => WR_Nitro::_( 'Hover State' ),
- ),
- 'std' => array(
- 'normal' => '#d6aa74',
- 'hover' => '#d6aa74',
- ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Content Alignment' ),
- 'id' => 'wr_page_title_align',
- 'type' => 'radio',
- 'options' => array(
- 'left' => WR_Nitro::_( 'Left' ),
- 'center' => WR_Nitro::_( 'Center' ),
- 'right' => WR_Nitro::_( 'Right' ),
- ),
- 'std' => 'left',
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Separator Color' ),
- 'id' => 'wr_page_title_sep_color',
- 'type' => 'colors',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'std' => '#e9e9e9',
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Min Height' ),
- 'id' => 'wr_page_title_min_height',
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 225,
- 'max' => 500,
- 'step' => 50,
- ),
- 'std' => 225,
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'type' => 'divider',
- 'id' => 'divider_03',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Color' ),
- 'id' => 'wr_page_title_bg_color',
- 'type' => 'colors',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Image' ),
- 'id' => 'wr_page_title_bg_image',
- 'type' => 'image_advanced',
- 'max_file_uploads' => 1,
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Position' ),
- 'id' => 'wr_page_title_bg_image_position',
- 'type' => 'select',
- 'options' => array(
- 'left top' => WR_Nitro::_( 'Left Top' ),
- 'left center' => WR_Nitro::_( 'Left Center' ),
- 'left bottom' => WR_Nitro::_( 'Left Bottom' ),
- 'right top' => WR_Nitro::_( 'Right Top' ),
- 'right center' => WR_Nitro::_( 'Right Center' ),
- 'right bottom' => WR_Nitro::_( 'Right Bottom' ),
- 'center top' => WR_Nitro::_( 'Center Top' ),
- 'center center' => WR_Nitro::_( 'Center Center' ),
- 'center bottom' => WR_Nitro::_( 'Center Bottom' ),
- ),
- 'hidden' => array( 'wr_page_title_bg_image', 0 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Repeat' ),
- 'id' => 'wr_page_title_bg_image_repeat',
- 'type' => 'select',
- 'options' => array(
- 'no-repeat' => WR_Nitro::_( 'No Repeat' ),
- 'repeat' => WR_Nitro::_( 'Repeat' ),
- 'repeat-x' => WR_Nitro::_( 'Repeat X' ),
- 'repeat-y' => WR_Nitro::_( 'Repeat Y' ),
- ),
- 'hidden' => array( 'wr_page_title_bg_image', 0 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Size' ),
- 'id' => 'wr_page_title_bg_image_size',
- 'type' => 'select',
- 'options' => array(
- 'auto' => WR_Nitro::_( 'auto' ),
- 'cover' => WR_Nitro::_( 'Cover' ),
- 'contain' => WR_Nitro::_( 'Contain' ),
- 'initial' => WR_Nitro::_( 'Initial' ),
- ),
- 'hidden' => array( 'wr_page_title_bg_image', 0 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Background Attachment' ),
- 'id' => 'wr_page_title_bg_image_attachment',
- 'type' => 'select',
- 'options' => array(
- 'scroll' => WR_Nitro::_( 'Scroll' ),
- 'fixed' => WR_Nitro::_( 'Fixed' ),
- ),
- 'hidden' => array( 'wr_page_title_bg_image', 0 ),
- 'tab' => WR_Nitro::_( 'Page Title' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Mask Overlay Color' ),
- 'id' => 'wr_page_title_mask_color',
- 'type' => 'colors',
- 'std' => 'rgba(0, 0, 0, 0)',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Parallax Background' ),
- 'id' => 'wr_page_title_parallax',
- 'type' => 'toggle',
- 'std' => 1,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'type' => 'divider',
- 'id' => 'divider_04',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Heading Fonts' ),
- 'id' => 'wr_page_title_heading_font',
- 'type' => 'typography',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'std' => array(
- 'family' => 'Lato',
- 'bold' => 0,
- 'italic' => 0,
- 'underline' => 0,
- 'uppercase' => 0,
- 'color' => '#646464',
- ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Heading Text Size' ),
- 'id' => 'wr_page_title_heading_font_size',
- 'desc' => WR_Nitro::_( '' ),
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 10,
- 'max' => 100,
- 'step' => 1,
- ),
- 'std' => 44,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Heading Line Height' ),
- 'id' => 'wr_page_title_heading_line_height',
- 'desc' => WR_Nitro::_( '' ),
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 10,
- 'max' => 100,
- 'step' => 1,
- ),
- 'std' => 24,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Heading Letter Spacing' ),
- 'id' => 'wr_page_title_heading_letter_spacing',
- 'desc' => WR_Nitro::_( '' ),
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 0,
- 'max' => 10,
- 'step' => 1,
- ),
- 'std' => 0,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'type' => 'divider',
- 'id' => 'divider_05',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Sub Heading Fonts' ),
- 'id' => 'wr_page_title_sub_heading_font',
- 'type' => 'typography',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'std' => array(
- 'family' => 'Lato',
- 'bold' => 0,
- 'italic' => 0,
- 'underline' => 0,
- 'uppercase' => 0,
- 'color' => '#646464',
- ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Sub Heading Text Size' ),
- 'id' => 'wr_page_title_sub_heading_font_size',
- 'desc' => WR_Nitro::_( 'Select grid to display sidebar.' ),
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 10,
- 'max' => 100,
- 'step' => 1,
- ),
- 'std' => 44,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Sub Heading Line Height' ),
- 'id' => 'wr_page_title_sub_heading_line_height',
- 'desc' => WR_Nitro::_( 'Select grid to display sidebar.' ),
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 10,
- 'max' => 100,
- 'step' => 1,
- ),
- 'std' => 24,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Sub Heading Letter Spacing' ),
- 'id' => 'wr_page_title_sub_heading_letter_spacing',
- 'desc' => WR_Nitro::_( 'Select grid to display sidebar.' ),
- 'type' => 'slider',
- 'suffix' => 'px',
- 'js_options' => array(
- 'min' => 0,
- 'max' => 10,
- 'step' => 1,
- ),
- 'std' => 0,
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'type' => 'divider',
- 'id' => 'divider_06',
- 'tab' => WR_Nitro::_( 'Page Title' ),
- 'hidden' => array( 'wr_page_title', '=', 0 ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Enable Page Scroll Effects' ),
- 'id' => 'page_scroll',
- 'type' => 'toggle',
- 'std' => 0,
- 'hidden' => array( 'global_opt', '=', 1 ),
- 'tab' => WR_Nitro::_( 'Page Scroll Effects' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Enable Navigation' ),
- 'id' => 'page_scroll_navigation',
- 'type' => 'toggle',
- 'std' => 1,
- 'hidden' => array( 'page_scroll', '=', 0 ),
- 'tab' => WR_Nitro::_( 'Page Scroll Effects' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Hijacking' ),
- 'id' => 'page_scroll_hijacking',
- 'type' => 'toggle',
- 'std' => 1,
- 'hidden' => array( 'page_scroll', '=', 0 ),
- 'tab' => WR_Nitro::_( 'Page Scroll Effects' ),
- ),
- array(
- 'name' => WR_Nitro::_( 'Effects' ),
- 'id' => 'page_scroll_effect',
- 'type' => 'select',
- 'options' => array(
- 'none' => WR_Nitro::_( 'None' ),
- 'scaleDown' => WR_Nitro::_( 'Scale Down' ),
- 'gallery' => WR_Nitro::_( 'Gallery' ),
- 'rotate' => WR_Nitro::_( 'Rotate' ),
- 'opacity' => WR_Nitro::_( 'Opacity' ),
- 'fixed' => WR_Nitro::_( 'Fixed' ),
- ),
- 'hidden' => array( 'page_scroll', '=', 0 ),
- 'tab' => WR_Nitro::_( 'Page Scroll Effects' ),
- ),
- )
- );
- // Get current theme customize options.
- $theme_options = WR_Nitro_Customize::get_theme_options();
- // Apply current theme customize options as default values for page options.
- foreach ( $meta_boxes as $i => $meta_box ) {
- if ( isset( $meta_box['fields'] ) ) {
- foreach ( $meta_box['fields'] as $k => $field ) {
- if ( isset( $field['id'] ) && isset( $theme_options[ $field['id'] ] ) ) {
- if ( is_bool( $theme_options[ $field['id'] ] ) ) {
- $meta_boxes[ $i ]['fields'][ $k ]['std'] = $theme_options[ $field['id'] ] ? 1 : 0;
- } else {
- $meta_boxes[ $i ]['fields'][ $k ]['std'] = $theme_options[ $field['id'] ];
- }
- }
- }
- }
- }
- return $meta_boxes;
- }
- /**
- * Visible paramameter of post format.
- *
- * @param array $conditions Current conditions.
- *
- * @return array
- */
- public static function outside_conditions( $conditions ) {
- // Format gallery
- $conditions['format_gallery'] = array(
- 'visible' => array( 'post_format', 'gallery' ),
- );
- // Format video
- $conditions['format_video'] = array(
- 'visible' => array( 'post_format', 'video' ),
- );
- // Format audio
- $conditions['format_audio'] = array(
- 'visible' => array( 'post_format', 'audio' ),
- );
- // Format quote
- $conditions['format_quote_content'] = array(
- 'visible' => array( 'post_format', 'quote' ),
- );
- $conditions['format_quote_author'] = array(
- 'visible' => array( 'post_format', 'quote' ),
- );
- // Format link
- $conditions['format_link_url'] = array(
- 'visible' => array( 'post_format', 'link' ),
- );
- return $conditions;
- }
- /**
- * Method to verify page option values before saving.
- *
- * @param null|bool $check Whether to allow updating metadata for the given type.
- * @param int $object_id Object ID.
- * @param string $meta_key Meta key.
- * @param mixed $meta_value Meta value. Must be serializable if non-scalar.
- * @param mixed $prev_value Optional. If specified, only update existing metadata entries with the specified value.
- * Otherwise, update all entries.
- *
- * @return mixed
- */
- public static function verify( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
- // Get current theme customize options.
- $theme_options = WR_Nitro_Customize::get_theme_options();
- if ( isset( $theme_options[ $meta_key ] ) ) {
- if ( is_bool( $theme_options[ $meta_key ] ) ) {
- if ( $meta_value == ( $theme_options[ $meta_key ] ? 1 : 0 ) ) {
- $check = false;
- }
- } elseif ( is_array( $theme_options[ $meta_key ] ) ) {
- if ( ! count( array_diff( $theme_options[ $meta_key ], ( array ) $meta_value ) ) ) {
- $check = false;
- }
- } elseif ( $meta_value == $theme_options[ $meta_key ] ) {
- $check = false;
- }
- }
- if ( false === $check ) {
- // Remove meta data.
- delete_post_meta( $object_id, $meta_key );
- }
- return $check;
- }
- /**
- * Method to synchronize default options values with current theme customizer values.
- *
- * @param mixed $meta Whether to allow updating metadata for the given type.
- * @param array $field Object ID.
- * @param boolean $saved Meta key.
- *
- * @return mixed
- */
- public static function get_meta( $meta, $field, $saved ) {
- if ( '' == $meta ) {
- // Get current theme customize options.
- $theme_options = WR_Nitro_Customize::get_theme_options();
- if ( isset( $theme_options[ $field['id'] ] ) ) {
- $meta = $theme_options[ $field['id'] ];
- }
- }
- return $meta;
- }
- /**
- * Callback function to show fields in meta box.
- *
- * @return void
- */
- function show() {
- global $post;
- $saved = self::has_been_saved( $post->ID, $this->fields );
- // Container
- printf(
- '<div class="rwmb-meta-box" data-autosave="%s">',
- $this->meta_box['autosave'] ? 'true' : 'false'
- );
- wp_nonce_field( "rwmb-save-{$this->meta_box['id']}", "nonce_{$this->meta_box['id']}" );
- // Allow users to add custom code before meta box content
- // 1st action applies to all meta boxes
- // 2nd action applies to only current meta box
- do_action( 'rwmb_before', $this );
- do_action( "rwmb_before_{$this->meta_box['id']}", $this );
- // Print HTML code for all fields
- $current_tab = null;
- $tab_heading = $tab_body = '';
- foreach ( $this->fields as $field ) {
- if ( isset( $field['tab'] ) && $current_tab != $field['tab'] ) {
- $tab_id = sanitize_key( $field['tab'] );
- // Update tab heading.
- $tab_heading .= '
- <li class="' . ( empty( $current_tab ) ? 'active' : '' ) . '">
- <a href="#' . $tab_id . '">' . $field['tab'] . '</a>
- </li>';
- // Update tab body.
- $tab_body .= ( empty( $current_tab ) ? '' : '</div>' ) . '
- <div id="' . $tab_id . '" class="wr-nitro-tabs-content ' . ( empty( $current_tab ) ? '' : 'hidden' ) . '">';
- $current_tab = $field['tab'];
- }
- // Start output buffering to hold field output.
- ob_start();
- call_user_func( array( self::get_class_name( $field ), 'show' ), $field, $saved );
- $tab_body .= ob_get_contents();
- ob_end_clean();
- }
- if ( ! empty( $tab_heading ) ) {
- echo '
- <div class="wr-nitro-tabs" id="' . $this->meta_box['id'] . '">
- <ul class="wr-nitro-tabs-nav">' . $tab_heading . '</ul>
- ' . $tab_body . '</div>
- </div>
- <script>
- (function($) {
- $("#' . $this->meta_box['id'] . '").on("click", ".wr-nitro-tabs-nav a", function() {
- $("#' . $this->meta_box['id'] . ' .wr-nitro-tabs-nav li").removeClass("active");
- $(this).parent().addClass("active");
- $("#' . $this->meta_box['id'] . ' .wr-nitro-tabs-content").addClass("hidden").filter($(this).attr("href")).removeClass("hidden");
- });
- })(jQuery);
- </script>';
- } else {
- echo '' . $tab_body;
- }
- // Include validation settings for this meta-box
- if ( isset( $this->validation ) && $this->validation ) {
- echo '
- <script>
- if ( typeof rwmb == "undefined" )
- {
- var rwmb = {
- validationOptions : jQuery.parseJSON( \'' , json_encode( $this->validation ) , '\' ),
- summaryMessage : "' , esc_js( __( 'Please correct the errors highlighted below and try again.', 'meta-box' ) ) , '"
- };
- }
- else
- {
- var tempOptions = jQuery.parseJSON( \'' , json_encode( $this->validation ) . '\' );
- jQuery.extend( true, rwmb.validationOptions, tempOptions );
- }
- </script>
- ';
- }
- // Allow users to add custom code after meta box content
- // 1st action applies to all meta boxes
- // 2nd action applies to only current meta box
- do_action( 'rwmb_after', $this );
- do_action( "rwmb_after_{$this->meta_box['id']}", $this );
- // End container
- echo '</div>';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement