361 lines
14 KiB
PHP
361 lines
14 KiB
PHP
<?php
|
|
|
|
/**
|
|
* MetaBoxes for Upstudy Theme
|
|
*/
|
|
namespace Upstudy;
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // If this file is called directly, abort.
|
|
|
|
/**
|
|
* Metaboxes Class
|
|
*/
|
|
class Metaboxes {
|
|
|
|
public static function init() {
|
|
add_filter( 'cmb2_admin_init', array( __CLASS__, 'page_metabox' ) );
|
|
|
|
}
|
|
|
|
public static function page_metabox() {
|
|
|
|
global $wp_registered_sidebars;
|
|
$sidebars = array();
|
|
if ( ! empty( $wp_registered_sidebars ) ) :
|
|
foreach ( $wp_registered_sidebars as $sidebar ) :
|
|
$sidebars[$sidebar['id']] = $sidebar['name'];
|
|
endforeach;
|
|
endif;
|
|
|
|
$headers = array_merge( array( 'global' => __( 'Global Setting', 'upstudy' ) ), upstudy_fetch_header_layouts(), array( 'none' => __( 'None', 'upstudy' ) ) );
|
|
$footers = array_merge( array( 'global' => __( 'Global Setting', 'upstudy' ) ), upstudy_get_footer_layouts(), array( 'none' => __( 'None', 'upstudy' ) ) );
|
|
$prefix = 'upstudy_page_';
|
|
$prefix_upstudy = '_upstudy_';
|
|
|
|
$page_meta = new_cmb2_box( array(
|
|
'id' => $prefix_upstudy . 'page_metabox',
|
|
'title' => __( 'Page Settings', 'upstudy' ),
|
|
'object_types' => array( 'page' ), // Post type
|
|
'context' => 'normal', // 'normal', 'advanced', or 'side'
|
|
'priority' => 'high', // 'high', 'core', 'default' or 'low'
|
|
'show_names' => true, // Show field names on the left
|
|
'vertical_tabs' => true, // Set vertical tabs, default false
|
|
'tabs' => array(
|
|
|
|
array(
|
|
'id' => 'tab-page',
|
|
'icon' => 'dashicons-align-left',
|
|
'title' => 'Page Layout',
|
|
'fields' => array(
|
|
$prefix_upstudy . 'page_container',
|
|
$prefix_upstudy . 'page_content_layout',
|
|
$prefix_upstudy . 'page_sidebar_id',
|
|
$prefix_upstudy . 'page_sidebar_width',
|
|
$prefix_upstudy . 'page_sidebar_sticky',
|
|
),
|
|
),
|
|
array(
|
|
'id' => 'tab-header',
|
|
'icon' => 'dashicons-heading',
|
|
'title' => 'Page Header',
|
|
'fields' => array(
|
|
$prefix_upstudy . 'tpc_mb_elementor_header',
|
|
$prefix_upstudy . 'page_header_top_show',
|
|
$prefix_upstudy . 'page_header_top_bar_style',
|
|
$prefix_upstudy . 'page_top_bg_color',
|
|
$prefix_upstudy . 'page_header_sticky',
|
|
$prefix_upstudy . 'page_header_transparent',
|
|
$prefix_upstudy . 'page_transparent_logo',
|
|
$prefix_upstudy . 'page_transparent_header_color',
|
|
$prefix_upstudy . 'page_dark_header',
|
|
),
|
|
),
|
|
array(
|
|
'id' => 'tab-page',
|
|
'icon' => 'dashicons-archive',
|
|
'title' => 'Page Title',
|
|
'fields' => array(
|
|
$prefix_upstudy . 'page_header_enable',
|
|
$prefix_upstudy . 'header_img',
|
|
$prefix_upstudy . 'custom_page_title',
|
|
$prefix_upstudy . 'custom_page_breadcrumb',
|
|
$prefix_upstudy . 'page_title_style',
|
|
$prefix_upstudy . 'page_title_bg_color',
|
|
),
|
|
),
|
|
array(
|
|
'id' => 'tab-colors',
|
|
'icon' => 'dashicons-art',
|
|
'title' => 'Page Colors',
|
|
'fields' => array(
|
|
$prefix_upstudy . 'page_primary_color',
|
|
$prefix_upstudy . 'page_secondary_color',
|
|
$prefix_upstudy . 'page_bg_color',
|
|
),
|
|
),
|
|
array(
|
|
'id' => 'tab-footer',
|
|
'icon' => 'dashicons-align-full-width',
|
|
'title' => 'Page Footer',
|
|
'fields' => array(
|
|
$prefix_upstudy . 'mb_elementor_footer',
|
|
),
|
|
),
|
|
// array(
|
|
// 'id' => 'tab-advanced',
|
|
// 'icon' => 'dashicons-shortcode',
|
|
// 'title' => 'Advanced',
|
|
// 'fields' => array(
|
|
// $prefix_upstudy . 'page_extra_class',
|
|
// ),
|
|
// ),
|
|
)
|
|
|
|
) );
|
|
|
|
// ======== Page Title =======
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_header_enable',
|
|
'type' => 'radio_inline',
|
|
'name' => __( 'Page Title', 'upstudy' ),
|
|
'default' => 'default',
|
|
'options' => array(
|
|
'default' => __( 'Default', 'upstudy' ),
|
|
'enable' => __( 'Enable', 'upstudy' ),
|
|
'disable' => __( 'Disable', 'upstudy' )
|
|
),
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_title_style',
|
|
'type' => 'select',
|
|
'name' => __( 'Page Title Style', 'upstudy' ),
|
|
'default' => 'global',
|
|
'options' => array(
|
|
'global' => __( 'Global Settings', 'upstudy' ),
|
|
'default' => __( 'Default', 'upstudy' ),
|
|
'1' => 'Style 01',
|
|
'2' => 'Style 02'
|
|
),
|
|
'description' => __( 'Here the global setting means the theme option setting. ', 'upstudy' )
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'custom_page_title',
|
|
'type' => 'text',
|
|
'name' => __( 'Custom Page Title', 'upstudy' ),
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'custom_page_breadcrumb',
|
|
'type' => 'text',
|
|
'name' => __( 'Custom Page Breadcrumb', 'upstudy' ),
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_title_bg_color',
|
|
'type' => 'colorpicker',
|
|
'name' => __( 'Page Title Color', 'upstudy' )
|
|
) );
|
|
$page_meta->add_field( array(
|
|
'name' => __('Page Title Background Image', 'upstudy'),
|
|
'id' => $prefix_upstudy . 'header_img',
|
|
'type' => 'file',
|
|
// 'default' => ''
|
|
) );
|
|
// ======== Page Header =======
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'tpc_mb_elementor_header',
|
|
'type' => 'select',
|
|
'name' => __( 'Header Layout Type', 'upstudy' ),
|
|
'options' => $headers,
|
|
'default' => 'global',
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_header_top_show',
|
|
'name' => 'Header Top Bar',
|
|
'type' => 'radio_inline',
|
|
'default' => 'default',
|
|
'options' => array(
|
|
'default' => __( 'Global Settings', 'upstudy' ),
|
|
'enable' => __( 'Enable', 'upstudy' ),
|
|
'disable' => __( 'Disable', 'upstudy' ),
|
|
),
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_header_top_bar_style',
|
|
'type' => 'select',
|
|
'name' => __( 'Header Top bar Style', 'upstudy' ),
|
|
'default' => 'global',
|
|
'options' => array(
|
|
'global' => __( 'Global Settings', 'upstudy' ),
|
|
'1' => 'Style 01',
|
|
'2' => 'Style 02',
|
|
'3' => 'Style 03'
|
|
),
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'name' => __('Header Top bar Background Color', 'upstudy'),
|
|
'id' => $prefix_upstudy . 'page_top_bg_color',
|
|
'type' => 'colorpicker',
|
|
'default' => ''
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_header_sticky',
|
|
'name' => 'Header Sticky',
|
|
'type' => 'radio_inline',
|
|
'default' => 'default',
|
|
'options' => array(
|
|
'default' => __( 'Global Settings', 'upstudy' ),
|
|
'enable' => __( 'Enable', 'upstudy' )
|
|
),
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_header_transparent',
|
|
'name' => 'Header Transparent',
|
|
'type' => 'radio_inline',
|
|
'default' => 'disable',
|
|
'options' => array(
|
|
'enable' => __( 'Enable', 'upstudy' ),
|
|
'disable' => __( 'Disable', 'upstudy' )
|
|
)
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_transparent_logo',
|
|
'name' => 'Enable Transparent Logo',
|
|
'type' => 'radio_inline',
|
|
'default' => 'disable',
|
|
'options' => array(
|
|
'enable' => __( 'Enable', 'upstudy' ),
|
|
'disable' => __( 'Disable', 'upstudy' )
|
|
),
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_transparent_header_color',
|
|
'name' => 'Transparent Header White Color',
|
|
'type' => 'radio_inline',
|
|
'default' => 'disable',
|
|
'options' => array(
|
|
'enable' => __( 'Enable', 'upstudy' ),
|
|
'disable' => __( 'Disable', 'upstudy' )
|
|
),
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_dark_header',
|
|
'name' => 'Dark Header',
|
|
'type' => 'radio_inline',
|
|
'default' => 'disable',
|
|
'options' => array(
|
|
'enable' => __( 'Enable', 'upstudy' ),
|
|
'disable' => __( 'Disable', 'upstudy' )
|
|
),
|
|
) );
|
|
|
|
// ======== Page Colors =======
|
|
$page_meta->add_field( array(
|
|
'name' => __('Page Primary Color', 'upstudy'),
|
|
'id' => $prefix_upstudy . 'page_primary_color',
|
|
'type' => 'colorpicker',
|
|
'default' => ''
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'name' => __('Page Secondary Color', 'upstudy'),
|
|
'id' => $prefix_upstudy . 'page_secondary_color',
|
|
'type' => 'colorpicker',
|
|
'default' => ''
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'name' => __('Page Background', 'upstudy'),
|
|
'id' => $prefix_upstudy . 'page_bg_color',
|
|
'type' => 'colorpicker',
|
|
'default' => ''
|
|
) );
|
|
|
|
|
|
// ======== Page Footer =======
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'mb_elementor_footer',
|
|
'type' => 'select',
|
|
'name' => __( 'Footer Layout Type', 'upstudy' ),
|
|
'description' => __( 'Choose a footer for your website.', 'upstudy' ),
|
|
'options' => $footers,
|
|
'default' => 'global',
|
|
'description' => __( 'Global Settings means it will get the value which is selected from Theme Options > Footer Settings > Footer Layout Type.', 'upstudy' )
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_container',
|
|
'type' => 'select',
|
|
'name' => __( 'Container', 'upstudy' ),
|
|
'default' => 'boxed',
|
|
'options' => array(
|
|
'boxed' => __( 'Boxed', 'upstudy' ),
|
|
'full-width' => __( 'Full Width', 'upstudy' )
|
|
)
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_content_layout',
|
|
'type' => 'select',
|
|
'name' => __( 'Content Layout', 'upstudy' ),
|
|
'default' => 'full-width',
|
|
'options' => array(
|
|
'no-sidebar' => __( 'No Sidebar (Only Content)', 'upstudy' ),
|
|
'left-sidebar' => __( 'Left Sidebar', 'upstudy' ),
|
|
'right-sidebar' => __( 'Right Sidebar', 'upstudy' )
|
|
),
|
|
'description' => __( 'This option will not function if you select container <b>Full Width</b>.', 'upstudy' )
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_sidebar_id',
|
|
'type' => 'select',
|
|
'name' => __( 'Sidebar', 'upstudy' ),
|
|
'options' => $sidebars,
|
|
'description' => __( 'This option will not function if you select container <b> Full Width</b> or <b>No Sidebar (Only Content )</b> option.', 'upstudy' )
|
|
) );
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_sidebar_width',
|
|
'type' => 'select',
|
|
'name' => __( 'Sidebar Width', 'upstudy' ),
|
|
'default' => '3',
|
|
'options' => array(
|
|
'3' => __( '25%', 'upstudy' ),
|
|
'4' => __( '33%', 'upstudy' ),
|
|
),
|
|
'description' => __( 'This option will not function if you select container <b>Full Width</b>.', 'upstudy' )
|
|
) );
|
|
|
|
|
|
$page_meta->add_field( array(
|
|
'id' => $prefix_upstudy . 'page_sidebar_sticky',
|
|
'name' => 'Sidebar Sticky',
|
|
'type' => 'radio_inline',
|
|
'default' => 'disable',
|
|
'options' => array(
|
|
'enable' => __( 'Enable', 'upstudy' ),
|
|
'disable' => __( 'Disable', 'upstudy' )
|
|
),
|
|
'description' => __( 'This option will not function if you select container <b>Full Width</b>.', 'upstudy' )
|
|
) );
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
Metaboxes::init(); |