kits_manager->get_active_kit_for_frontend();
$colors = $kit->get_settings_for_display( 'system_colors' );
// Primary color : heading.
$colors[0]['color'] = '#1E2228';
// Text color.
$colors[2]['color'] = '#7E8288';
// Accent Color.
$colors[3]['color'] = '#000080';
\Elementor\Plugin::$instance->kits_manager->update_kit_settings_based_on_option( 'system_colors', $colors );
// Layout.
$layout = $kit->get_settings_for_display( 'container_width' );
$layout['size'] = '1170';
\Elementor\Plugin::$instance->kits_manager->update_kit_settings_based_on_option( 'container_width', $layout );
}
}
add_action( 'after_switch_theme', 'kernel_elementor_setup' );
/**
* Enqueues scripts and styles.
* */
function kernel_theme_scripts() {
// Vendor Styles & Icons.
wp_enqueue_style( 'animate', get_template_directory_uri() . '/assets/css/animate.css', array(), '3.5.2' );
wp_enqueue_style( 'animsition', get_template_directory_uri() . '/assets/css/animsition.css', array(), '4.0.1' );
wp_enqueue_style( 'slick', get_template_directory_uri() . '/assets/css/slick.css', array(), '1.6.0' );
wp_enqueue_style( 'eleganticons', get_template_directory_uri() . '/assets/css/eleganticons.css', array(), '1.0.0' );
wp_enqueue_style( 'pe-icon-7-stroke', get_template_directory_uri() . '/assets/css/pe-icon-7-stroke.css', array(), '1.0.0' );
wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/assets/css/fontawesome.css', array(), '5.13.0' );
// Theme Style.
wp_enqueue_style( 'kernel-theme-style', get_stylesheet_uri(), array(), '1.0.0' );
wp_add_inline_style( 'kernel-theme-style', apply_filters( 'kernel_custom_colors_css', null) );
// Vendor Scripts.
wp_enqueue_script( 'html5shiv', get_template_directory_uri() . '/assets/js/html5shiv.js', array( 'jquery' ), '3.7.3', true );
wp_enqueue_script( 'respond', get_template_directory_uri() . '/assets/js/respond.js', array( 'jquery' ), '1.3.0', true );
wp_enqueue_script( 'matchmedia', get_template_directory_uri() . '/assets/js/matchmedia.js', array( 'jquery' ), '1.0.0', true );
wp_enqueue_script( 'easing', get_template_directory_uri() . '/assets/js/easing.js', array( 'jquery' ), '1.3.0', true );
wp_enqueue_script( 'fitvids', get_template_directory_uri() . '/assets/js/fitvids.js', array( 'jquery' ), '1.1.0', true );
wp_enqueue_script( 'animsition', get_template_directory_uri() . '/assets/js/animsition.js', array( 'jquery' ), '4.0.1', true );
wp_register_script( 'slick', get_template_directory_uri() . '/assets/js/slick.js', array( 'jquery' ), '1.6.0', true );
// Theme Script.
wp_enqueue_script( 'kernel-theme-script', get_template_directory_uri() . '/assets/js/main.js', array( 'jquery' ), '1.0.0', true );
// Comment JS.
if ( is_singular() && comments_open() && get_option( 'thread_comments' )) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'kernel_theme_scripts' );
/**
* Registers a widget areas.
* */
function kernel_sidebars_init() {
// Sidebar for Blog.
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Blog', 'kernel' ),
'id' => 'sidebar-blog',
'description' => esc_html__( 'Add widgets here to appear in Sidebar Blog.', 'kernel' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
)
);
// Sidebar for Pages.
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Page', 'kernel' ),
'id' => 'sidebar-page',
'description' => esc_html__( 'Add widgets here to appear in Sidebar Page', 'kernel' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
// Sidebar for Portfolio.
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Portfolio', 'kernel' ),
'id' => 'sidebar-portfolio',
'description' => esc_html__( 'Add widgets here to appear in Sidebar Portfolio', 'kernel' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
// Sidebar for Shop.
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Shop', 'kernel' ),
'id' => 'sidebar-shop',
'description' => esc_html__( 'Add widgets here to appear in Sidebar Shop', 'kernel' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
// 4 Sidebars for Footer.
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Footer 1', 'kernel' ),
'id' => 'sidebar-footer-1',
'description' => esc_html__( 'Add widgets here to appear in Sidebar Footer 1', 'kernel' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Footer 2', 'kernel' ),
'id' => 'sidebar-footer-2',
'description' => esc_html__( 'Add widgets here to appear in Sidebar Footer 2', 'kernel' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Footer 3', 'kernel' ),
'id' => 'sidebar-footer-3',
'description' => esc_html__( 'Add widgets here to appear in Sidebar Footer 3', 'kernel' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Footer 4', 'kernel' ),
'id' => 'sidebar-footer-4',
'description' => esc_html__( 'Add widgets here to appear in Sidebar Footer 4', 'kernel' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
}
add_action( 'widgets_init', 'kernel_sidebars_init' );
// Include required files.
require( get_template_directory() . '/framework/get-mods.php' );
require( get_template_directory() . '/framework/theme-hooks.php' );
require( get_template_directory() . '/framework/theme-functions.php' );
require( get_template_directory() . '/framework/fonts.php' );
require( get_template_directory() . '/framework/typography.php' );
require( get_template_directory() . '/framework/accent-color.php' );
require( get_template_directory() . '/framework/customizer/customizer.php' );
require( get_template_directory() . '/framework/elementor-options.php' );
require( get_template_directory() . '/framework/metabox-options.php' );
require( get_template_directory() . '/framework/widget-areas.php' );
require( get_template_directory() . '/framework/breadcrumbs.php' );
require( get_template_directory() . '/framework/theme-woocommerce.php' );
/**
* ZOOM Class is used for Color Picker in Customizer
* */
final class ZOOM_Customizer_Reset {
/**
* Instance
*
* @var $instance
*/
private static $instance = null;
/**
* Customizer
*
* @var $wp_customize
*/
private $wp_customize;
/**
* Get Instance
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructer
*/
private function __construct() {
add_action( 'kernal_customize_controls_print_scripts', array( $this, 'kernal_customize_controls_print_scripts' ) );
add_action( 'wp_kernal_ajax_customizer_reset', array( $this, 'kernal_ajax_customizer_reset' ) );
add_action( 'kernal_customize_register', array( $this, 'kernal_customize_register' ) );
}
/**
* Scripts for Customizer
*/
public function kernal_customize_controls_print_scripts() {
wp_enqueue_script( 'customizer-reset', get_template_directory_uri() . '/assets/js/customizer-reset.js', array( 'jquery' ), '20150120' );
wp_localize_script(
'customizer-reset',
'_ZoomCustomizerReset',
array(
'reset' => __( 'Reset', 'kernel' ),
'confirm' => __("Attention! This will remove all customizations ever made via customizer to this theme!\n\nThis action is irreversible!", 'kernel' ),
'nonce' => array(
'reset' => wp_create_nonce( 'customizer-reset' ),
),
)
);
}
/**
* Regsiter Customizer Controls
*
* @param wp_customize for customizer.
*/
public function kernal_customize_register( $wp_customize ) {
$this->wp_customize = $wp_customize;
}
/**
* AJAX function for Customizer
*/
public function kernal_ajax_customizer_reset() {
if ( ! $this->wp_customize->is_preview() ) {
wp_send_json_error( 'not_preview' );
}
if ( ! check_ajax_referer( 'customizer-reset', 'nonce', false ) ) {
wp_send_json_error( 'invalid_nonce' );
}
$this->kernal_reset_customizer();
wp_send_json_success();
}
/**
* Reset function for Customizer
*/
public function kernal_reset_customizer() {
$settings = $this->wp_customize->settings();
// Remove theme_mod settings registered in customizer.
foreach ( $settings as $setting ) {
if ( 'theme_mod' === $setting->type ) {
remove_theme_mod( $setting->id );
}
}
}
}
ZOOM_Customizer_Reset::get_instance();
include get_theme_file_path( 'vendor/autoload.php' );
use WPTRT\Customize\Control\ColorAlpha;
/**
* Header Background Function
*
* @param wp_customize for customizer.
*/
function kernal_header_background_add_colorpicker( $wp_customize ) {
$wp_customize->add_setting(
'header_background_color',
array(
'default' => 'rgba(255,255,255,1)', // Use any HEX or RGBA value.
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control(
new ColorAlpha(
$wp_customize,
'header_background_color',
array(
'label' => __( 'Header Background Color', 'kernel' ),
'section' => 'kernel_header_site',
'settings' => 'header_background_color',
'priority' => '100',
'inline_css' => array(
'target' => '#site-header.fixed-hide',
'alter' => 'background-color',
),
)
)
);
}
add_action( 'kernal_customize_register', 'kernal_header_background_add_colorpicker' );
/**
* Get Elementor Template list
*/
function get_elementor_templates() {
$args = array(
'post_type' => 'elementor_library',
'post_status' => 'publish',
);
$the_query = new WP_Query( $args );
$elementor_posts = array();
if ( $the_query->have_posts() ) :
foreach ( $the_query->posts as $post ) :
$elementor_posts[ $post->ID ] = apply_filters( 'the_title', get_the_title( $post ) );
endforeach;
endif;
return $elementor_posts;
}
/**
* Get Elementor Template listing in Header Tab
*
* @param wp_customize for customizer.
*/
function kernal_header_elementor_template( $wp_customize ) {
$elementor_template_list = get_elementor_templates();
$wp_customize->add_setting(
'header_source_type',
array(
'default' => '', // Use any HEX or RGBA value.
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr',
'default' => 'd',
)
);
$wp_customize->add_control(
'header_source_type',
array(
'type' => 'select',
'section' => 'kernel_header_general', // Add a default or your own section.
'label' => __( 'Header Source Type', 'kernel' ),
'description' => __( 'This is a custom select option.', 'kernel' ),
'choices' => array(
'd' => esc_html__( 'Default', 'kernel' ),
'e' => esc_html__( 'Elementor', 'kernel' ),
),
)
);
$wp_customize->add_setting(
'kernal_header_elementor_templates',
array(
'default' => '', // Use any HEX or RGBA value.
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control(
'kernal_header_elementor_templates',
array(
'type' => 'select',
'section' => 'kernel_header_general', // Add a default or your own section.
'label' => __( 'Header Elementor Templates', 'kernel' ),
'description' => __( 'This is a custom select option.', 'kernel' ),
'choices' => $elementor_template_list,
'required' => array(
'header_source_type', '=', 'e'
),
)
);
}
add_action( 'kernal_customize_register', 'kernal_header_elementor_template' );
/**
* Get Elementor Template listing in Footer Tab
*
* @param wp_customize for customizer.
*/
function kernal_footer_elementor_template( $wp_customize ) {
$elementor_template_list = get_elementor_templates();
$wp_customize->add_setting(
'footer_source_type',
array(
'default' => '', // Use any HEX or RGBA value.
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control(
'footer_source_type',
array(
'type' => 'select',
'section' => 'kernel_footer_general', // Add a default or your own section
'label' => __( 'Footer Source Type', 'kernel' ),
'description' => __( 'This is a custom select option.', 'kernel' ),
'choices' => array(
'd' => esc_html__( 'Default', 'kernel' ),
'e' => esc_html__( 'Elementor', 'kernel' ),
),
'default' => 'd',
)
);
$wp_customize->add_setting(
'kernal_footer_elementor_templates',
array(
'default' => '', // Use any HEX or RGBA value.
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control(
'kernal_footer_elementor_templates',
array(
'type' => 'select',
'section' => 'kernel_footer_general', // Add a default or your own section
'label' => __( 'Footer Elementor Templates', 'kernel' ),
'description' => __( 'This is a custom select option.', 'kernel' ),
'choices' => $elementor_template_list,
'required' => [ 'footer_source_type', '=', 'e' ],
)
);
}
add_action( 'kernal_customize_register', 'kernal_footer_elementor_template' );
/**
* Get Elementor Template listing in Footer Tab
*
* @param wp_customize for customizer.
*/
function kernal_unavailable_page_elementor_template( $wp_customize ) {
$elementor_template_list = get_elementor_templates();
$wp_customize->add_setting(
'404_source_type',
array(
'default' => '', // Use any HEX or RGBA value.
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control(
'404_source_type',
array(
'type' => 'select',
'section' => 'kernel_unavailablepage_general', // Add a default or your own section
'label' => __( '404 Source Type', 'kernel' ),
'description' => __( 'This is a custom select option.', 'kernel' ),
'choices' => array(
'd' => esc_html__( 'Default', 'kernel' ),
'e' => esc_html__( 'Elementor', 'kernel' ),
),
'default' => 'd',
)
);
$wp_customize->add_setting(
'404_elementor_templates',
array(
'default' => '', // Use any HEX or RGBA value.
'transport' => 'refresh',
'sanitize_callback' => 'esc_attr',
)
);
$wp_customize->add_control(
'404_elementor_templates',
array(
'type' => 'select',
'section' => 'kernel_unavailablepage_general', // Add a default or your own section.
'label' => __( '404 Elementor Templates', 'kernel' ),
'description' => __( 'This is a custom select option.', 'kernel' ),
'choices' => $elementor_template_list,
'required' => [ '404_source_type', '=', 'e' ],
)
);
}
add_action( 'kernal_customize_register', 'kernal_unavailable_page_elementor_template' );
add_action( 'customize_controls_print_header_scripts', 'kernal_my_customizer_header_script' );
/**
* Header Scripts for Customizer
*/
function kernal_my_customizer_header_script() {
?>