| Server IP : 14.225.204.176 / Your IP : 216.73.216.6 Web Server : nginx/1.24.0 System : Linux nodejs-ybgk 6.8.0-40-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 5 10:34:03 UTC 2024 x86_64 User : root ( 0) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/php/fe2tech/wp-content/themes/contio/inc/ |
Upload File : |
<?php
/**
* Register metabox for posts based on Redux Framework. Supported methods:
* isset_args( $post_type )
* set_args( $post_type, $redux_args, $metabox_args )
* add_section( $post_type, $sections )
* Each post type can contains only one metabox. Pease note that each field id
* leads by an underscore sign ( _ ) in order to not show that into Custom Field
* Metabox from WordPress core feature.
*
* @param CT_Post_Metabox $metabox
*/
function contio_get_nav_menu(){
$menus = array(
'' => esc_html__('Default', 'contio')
);
$obj_menus = wp_get_nav_menus();
foreach ($obj_menus as $obj_menu){
$menus[$obj_menu->term_id] = $obj_menu->name;
}
return $menus;
}
add_action( 'ct_post_metabox_register', 'contio_page_options_register' );
function contio_page_options_register( $metabox ) {
if ( ! $metabox->isset_args( 'post' ) ) {
$metabox->set_args( 'post', array(
'opt_name' => 'post_option',
'display_name' => esc_html__( 'Post Settings', 'contio' ),
'show_options_object' => false,
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
if ( ! $metabox->isset_args( 'product' ) ) {
$metabox->set_args( 'product', array(
'opt_name' => 'product_option',
'display_name' => esc_html__( 'Product Settings', 'contio' ),
'show_options_object' => false,
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
if ( ! $metabox->isset_args( 'page' ) ) {
$metabox->set_args( 'page', array(
'opt_name' => contio_get_page_opt_name(),
'display_name' => esc_html__( 'Page Settings', 'contio' ),
'show_options_object' => false,
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
if ( ! $metabox->isset_args( 'ct_pf_audio' ) ) {
$metabox->set_args( 'ct_pf_audio', array(
'opt_name' => 'post_format_audio',
'display_name' => esc_html__( 'Audio', 'contio' ),
'class' => 'fully-expanded',
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
if ( ! $metabox->isset_args( 'ct_pf_link' ) ) {
$metabox->set_args( 'ct_pf_link', array(
'opt_name' => 'post_format_link',
'display_name' => esc_html__( 'Link', 'contio' )
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
if ( ! $metabox->isset_args( 'ct_pf_quote' ) ) {
$metabox->set_args( 'ct_pf_quote', array(
'opt_name' => 'post_format_quote',
'display_name' => esc_html__( 'Quote', 'contio' )
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
if ( ! $metabox->isset_args( 'ct_pf_video' ) ) {
$metabox->set_args( 'ct_pf_video', array(
'opt_name' => 'post_format_video',
'display_name' => esc_html__( 'Video', 'contio' ),
'class' => 'fully-expanded',
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
if ( ! $metabox->isset_args( 'ct_pf_gallery' ) ) {
$metabox->set_args( 'ct_pf_gallery', array(
'opt_name' => 'post_format_gallery',
'display_name' => esc_html__( 'Gallery', 'contio' ),
'class' => 'fully-expanded',
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
/* Extra Post Type */
if ( ! $metabox->isset_args( 'service' ) ) {
$metabox->set_args( 'service', array(
'opt_name' => 'service_option',
'display_name' => esc_html__( 'Service Settings', 'contio' ),
'show_options_object' => false,
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
if ( ! $metabox->isset_args( 'portfolio' ) ) {
$metabox->set_args( 'portfolio', array(
'opt_name' => 'portfolio_option',
'display_name' => esc_html__( 'Portfolio Settings', 'contio' ),
'show_options_object' => false,
), array(
'context' => 'advanced',
'priority' => 'default'
) );
}
/**
* Config post meta options
*
*/
$metabox->add_section( 'post', array(
'title' => esc_html__( 'Post Settings', 'contio' ),
'icon' => 'el el-refresh',
'fields' => array(
array(
'id' => 'post_content_padding',
'type' => 'spacing',
'output' => array( '.single-post #content' ),
'right' => false,
'left' => false,
'mode' => 'padding',
'units' => array( 'px' ),
'units_extended' => 'false',
'title' => esc_html__( 'Content Padding', 'contio' ),
'subtitle' => esc_html__( 'Content site paddings.', 'contio' ),
'desc' => esc_html__( 'Default: Theme Option.', 'contio' ),
'default' => array(
'padding-top' => '',
'padding-bottom' => '',
'units' => 'px',
)
),
array(
'id' => 'show_sidebar_post',
'type' => 'switch',
'title' => esc_html__( 'Custom Sidebar', 'contio' ),
'default' => false,
'indent' => true
),
array(
'id' => 'sidebar_post_pos',
'type' => 'button_set',
'title' => esc_html__( 'Sidebar Position', 'contio' ),
'options' => array(
'left' => esc_html__('Left', 'contio'),
'right' => esc_html__('Right', 'contio'),
'none' => esc_html__('Disabled', 'contio')
),
'default' => 'right',
'required' => array( 0 => 'show_sidebar_post', 1 => '=', 2 => '1' ),
'force_output' => true
),
)
) );
/**
* Config page meta options
*
*/
$metabox->add_section( 'page', array(
'title' => esc_html__( 'Header', 'contio' ),
'desc' => esc_html__( 'Header settings for the page.', 'contio' ),
'icon' => 'el-icon-website',
'fields' => array(
array(
'id' => 'custom_header',
'type' => 'switch',
'title' => esc_html__( 'Custom Layout', 'contio' ),
'default' => false,
'indent' => true
),
array(
'id' => 'header_layout',
'type' => 'image_select',
'title' => esc_html__( 'Layout', 'contio' ),
'subtitle' => esc_html__( 'Select a layout for header.', 'contio' ),
'options' => array(
'0' => get_template_directory_uri() . '/assets/images/header-layout/h0.jpg',
'1' => get_template_directory_uri() . '/assets/images/header-layout/h1.jpg',
'2' => get_template_directory_uri() . '/assets/images/header-layout/h2.jpg',
'3' => get_template_directory_uri() . '/assets/images/header-layout/h3.jpg',
),
'default' => contio_get_option_of_theme_options( 'header_layout' ),
'required' => array( 0 => 'custom_header', 1 => 'equals', 2 => '1' ),
'force_output' => true
),
array(
'id' => 'p_logo_dark',
'type' => 'media',
'title' => esc_html__('Custom Logo Dark', 'contio'),
'default' => '',
'required' => array( 0 => 'custom_header', 1 => 'equals', 2 => '1' ),
'force_output' => true
),
array(
'id' => 'p_logo_light',
'type' => 'media',
'title' => esc_html__('Custom Logo Light', 'contio'),
'default' => '',
'required' => array( 0 => 'custom_header', 1 => 'equals', 2 => '1' ),
'force_output' => true
),
array(
'id' => 'h_custom_menu',
'type' => 'select',
'title' => esc_html__( 'Custom Menu', 'contio' ),
'subtitle' => esc_html__( 'Custom menu for current page.', 'contio' ),
'options' => contio_get_nav_menu(),
'default' => '',
),
)
) );
$metabox->add_section( 'page', array(
'title' => esc_html__( 'Page Title', 'contio' ),
'icon' => 'el el-indent-left',
'fields' => array(
array(
'id' => 'custom_pagetitle',
'type' => 'button_set',
'title' => esc_html__( 'Page Title', 'contio' ),
'options' => array(
'themeoption' => esc_html__( 'Theme Option', 'contio' ),
'show' => esc_html__( 'Custom', 'contio' ),
'hide' => esc_html__( 'Hide', 'contio' ),
),
'default' => 'themeoption',
),
array(
'id' => 'custom_title',
'type' => 'textarea',
'title' => esc_html__( 'Title', 'contio' ),
'subtitle' => esc_html__( 'Use custom title for this page. The default title will be used on document title.', 'contio' ),
'required' => array( 0 => 'custom_pagetitle', 1 => '=', 2 => 'show' ),
'force_output' => true
),
array(
'id' => 'ptitle_bg',
'type' => 'background',
'background-color' => false,
'background-repeat' => false,
'background-size' => false,
'background-attachment' => false,
'background-position' => false,
'title' => esc_html__('Background', 'contio'),
'subtitle' => esc_html__('Page title background image.', 'contio'),
'required' => array( 0 => 'custom_pagetitle', 1 => '=', 2 => 'show' ),
'force_output' => true
),
array(
'id' => 'ptitle_padding',
'type' => 'spacing',
'output' => array('.site #pagetitle.page-title'),
'right' => false,
'left' => false,
'mode' => 'padding',
'units' => array('px'),
'units_extended' => 'false',
'title' => esc_html__('Page Title Padding', 'contio'),
'default' => array(
'padding-top' => '',
'padding-bottom' => '',
'units' => 'px',
),
'required' => array( 0 => 'custom_pagetitle', 1 => '=', 2 => 'show' ),
'force_output' => true
),
)
) );
$metabox->add_section( 'page', array(
'title' => esc_html__( 'Content', 'contio' ),
'desc' => esc_html__( 'Settings for content area.', 'contio' ),
'icon' => 'el-icon-pencil',
'fields' => array(
array(
'id' => 'content_bg_color',
'type' => 'color_rgba',
'title' => esc_html__( 'Background Color', 'contio' ),
'subtitle' => esc_html__( 'Content background color.', 'contio' ),
'output' => array( 'background-color' => 'body' )
),
array(
'id' => 'content_padding',
'type' => 'spacing',
'output' => array( '#content' ),
'right' => false,
'left' => false,
'mode' => 'padding',
'units' => array( 'px' ),
'units_extended' => 'false',
'title' => esc_html__( 'Content Padding', 'contio' ),
'desc' => esc_html__( 'Default: Theme Option.', 'contio' ),
'default' => array(
'padding-top' => '',
'padding-bottom' => '',
'units' => 'px',
)
),
array(
'id' => 'show_sidebar_page',
'type' => 'switch',
'title' => esc_html__( 'Show Sidebar', 'contio' ),
'default' => false,
'indent' => true
),
array(
'id' => 'sidebar_page_pos',
'type' => 'button_set',
'title' => esc_html__( 'Sidebar Position', 'contio' ),
'options' => array(
'left' => esc_html__( 'Left', 'contio' ),
'right' => esc_html__( 'Right', 'contio' ),
),
'default' => 'right',
'required' => array( 0 => 'show_sidebar_page', 1 => '=', 2 => '1' ),
'force_output' => true
),
)
) );
$metabox->add_section( 'page', array(
'title' => esc_html__( 'Footer', 'contio' ),
'desc' => esc_html__( 'Settings for footer area.', 'contio' ),
'icon' => 'el el-website',
'fields' => array(
array(
'id' => 'custom_footer',
'type' => 'switch',
'title' => esc_html__( 'Custom Layout', 'contio' ),
'default' => false,
'indent' => true
),
array(
'id' => 'footer_layout_custom',
'type' => 'select',
'title' => esc_html__('Layout', 'contio'),
'desc' => sprintf(esc_html__('To use this Option please %sClick Here%s to add your custom footer layout first.','contio'),'<a href="' . esc_url( admin_url( 'edit.php?post_type=footer' ) ) . '">','</a>'),
'options' =>contio_list_post('footer'),
'default' => '',
'required' => array( 0 => 'custom_footer', 1 => 'equals', 2 => '1' ),
'force_output' => true
),
)
) );
/**
* Config post format meta options
*
*/
$metabox->add_section( 'ct_pf_video', array(
'title' => esc_html__( 'Video', 'contio' ),
'fields' => array(
array(
'id' => 'post-video-url',
'type' => 'text',
'title' => esc_html__( 'Video URL', 'contio' ),
'desc' => esc_html__( 'YouTube or Vimeo video URL', 'contio' )
),
array(
'id' => 'post-video-file',
'type' => 'editor',
'title' => esc_html__( 'Video Upload', 'contio' ),
'desc' => esc_html__( 'Upload video file', 'contio' )
),
array(
'id' => 'post-video-html',
'type' => 'textarea',
'title' => esc_html__( 'Embadded video', 'contio' ),
'desc' => esc_html__( 'Use this option when the video does not come from YouTube or Vimeo', 'contio' )
)
)
) );
$metabox->add_section( 'ct_pf_gallery', array(
'title' => esc_html__( 'Gallery', 'contio' ),
'fields' => array(
array(
'id' => 'post-gallery-lightbox',
'type' => 'switch',
'title' => esc_html__( 'Lightbox?', 'contio' ),
'subtitle' => esc_html__( 'Enable lightbox for gallery images.', 'contio' ),
'default' => true
),
array(
'id' => 'post-gallery-images',
'type' => 'gallery',
'title' => esc_html__( 'Gallery Images ', 'contio' ),
'subtitle' => esc_html__( 'Upload images or add from media library.', 'contio' )
)
)
) );
$metabox->add_section( 'ct_pf_audio', array(
'title' => esc_html__( 'Audio', 'contio' ),
'fields' => array(
array(
'id' => 'post-audio-url',
'type' => 'text',
'title' => esc_html__( 'Audio URL', 'contio' ),
'description' => esc_html__( 'Audio file URL in format: mp3, ogg, wav.', 'contio' ),
'validate' => 'url',
'msg' => 'Url error!'
)
)
) );
$metabox->add_section( 'ct_pf_link', array(
'title' => esc_html__( 'Link', 'contio' ),
'fields' => array(
array(
'id' => 'post-link-url',
'type' => 'text',
'title' => esc_html__( 'URL', 'contio' ),
'validate' => 'url',
'msg' => 'Url error!'
)
)
) );
$metabox->add_section( 'ct_pf_quote', array(
'title' => esc_html__( 'Quote', 'contio' ),
'fields' => array(
array(
'id' => 'post-quote-cite',
'type' => 'text',
'title' => esc_html__( 'Cite', 'contio' )
)
)
) );
/**
* Config service meta options
*
*/
$metabox->add_section( 'service', array(
'title' => esc_html__( 'General', 'contio' ),
'icon' => 'el-icon-website',
'fields' => array(
array(
'id' => 'service_icon',
'type' => 'ct_iconpicker',
'title' => esc_html__('Icon', 'contio'),
),
array(
'id' => 'service_except',
'type' => 'textarea',
'title' => esc_html__( 'Except', 'contio' ),
'validate' => 'no_html'
),
array(
'id' => 'service_content_padding',
'type' => 'spacing',
'output' => array( '.single-service #content' ),
'right' => false,
'left' => false,
'mode' => 'padding',
'units' => array( 'px' ),
'units_extended' => 'false',
'title' => esc_html__( 'Content Padding', 'contio' ),
'subtitle' => esc_html__( 'Content site paddings.', 'contio' ),
'desc' => esc_html__( 'Default: Theme Option.', 'contio' ),
'default' => array(
'padding-top' => '',
'padding-bottom' => '',
'units' => 'px',
)
),
)
) );
/**
* Config portfolio meta options
*
*/
$metabox->add_section( 'portfolio', array(
'title' => esc_html__( 'General', 'contio' ),
'icon' => 'el-icon-website',
'fields' => array(
array(
'id' => 'portfolio_sub_title',
'type' => 'text',
'title' => esc_html__( 'Sub Title', 'contio' ),
'validate' => 'no_html'
),
array(
'id' => 'portfolio_content_padding',
'type' => 'spacing',
'output' => array( '.single-portfolio #content' ),
'right' => false,
'left' => false,
'mode' => 'padding',
'units' => array( 'px' ),
'units_extended' => 'false',
'title' => esc_html__( 'Content Padding', 'contio' ),
'subtitle' => esc_html__( 'Content site paddings.', 'contio' ),
'desc' => esc_html__( 'Default: Theme Option.', 'contio' ),
'default' => array(
'padding-top' => '',
'padding-bottom' => '',
'units' => 'px',
)
),
)
) );
/**
* Config product meta options
*
*/
$metabox->add_section('product', array(
'title' => esc_html__('Product Settings', 'contio'),
'icon' => 'el el-briefcase',
'fields' => array(
array(
'id' => 'product_feature',
'type' => 'multi_text',
'title' => esc_html__('Feature', 'contio'),
'validate' => 'html',
),
)
));
}
function contio_get_option_of_theme_options( $key, $default = '' ) {
if ( empty( $key ) ) {
return '';
}
$options = get_option( contio_get_opt_name(), array() );
$value = isset( $options[ $key ] ) ? $options[ $key ] : $default;
return $value;
}