action_hooks();
}
public function action_hooks()
{
add_action( 'init', array( $this, 'session_start' ), 1 );
add_action( 'after_setup_theme', array( $this, 'theme_setup' ) );
add_action( 'widgets_init', array( $this, 'widgets_init' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'admin_init', array( $this, 'add_editor_styles' ) );
}
public function session_start()
{
if ( !session_id() ) {
session_start();
}
}
function add_editor_styles()
{
add_editor_style( 'assets/css/editor-style.css' );
}
public function theme_setup()
{
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on adela, use a find and replace
* to change 'adela' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'adela', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary', 'adela' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'wc-product-gallery-zoom' );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background',
apply_filters( 'adela_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
$GLOBALS['content_width'] = apply_filters( 'adela_content_width', 1170 );
add_theme_support( 'custom-header', apply_filters( 'adela_custom_header_args', array(
'default-image' => '',
'default-text-color' => '000000',
'width' => 1000,
'height' => 250,
'flex-height' => true,
'wp-head-callback' => 'adela_header_style',
)
)
);
}
public function widgets_init()
{
register_sidebar( array(
'name' => esc_html__( 'Main Sidebar', 'adela' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Single Post Sidebar', 'adela' ),
'id' => 'single-post-sidebar',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Shop Sidebar', 'adela' ),
'id' => 'shop-sidebar',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Single Product Sidebar', 'adela' ),
'id' => 'single-product-sidebar',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Template "No Title" Sidebar', 'adela' ),
'id' => 'temple-notitle-sidebar',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
/** Footer sidebar **/
register_sidebar( array(
'name' => esc_html__( 'Footer Row 1 - Col 1 Sidebar', 'adela' ),
'id' => 'footer-row1-col1',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Footer Row 1 - Col 2 Sidebar', 'adela' ),
'id' => 'footer-row1-col2',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Footer Row 1 - Col 3 Sidebar', 'adela' ),
'id' => 'footer-row1-col3',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Footer Row 1 - Col 4 Sidebar', 'adela' ),
'id' => 'footer-row1-col4',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Footer Row 2', 'adela' ),
'id' => 'footer-row2',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
register_sidebar( array(
'name' => esc_html__( 'Footer Row 3', 'adela' ),
'id' => 'footer-row3',
'description' => esc_html__( 'Add widgets here.', 'adela' ),
'before_widget' => '',
'before_title' => '',
)
);
}
public function google_fonts()
{
$fonts_url = '';
$font_families = array();
$font_families[] = 'Roboto:100,100i,300,300i,400,400i,500,500i,700,700i';
$font_families[] = 'Montserrat:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i';
$query_args = array(
'family' => implode( '|', $font_families ),
'subset' => 'latin,latin-ext',
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
return esc_url_raw( $fonts_url );
}
public function enqueue_scripts()
{
wp_enqueue_style( 'adela-googlefonts', $this->google_fonts(), array(), null );
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.css', array(), '3.3.7' );
wp_enqueue_style( 'adela-style-custom', get_template_directory_uri() . '/assets/css/style.css', array(), '1.0.0' );
wp_register_style( 'animate', get_template_directory_uri() . '/assets/css/animate.min.css', array(), '3.5.1' );
wp_register_style( 'owl-carousel', get_template_directory_uri() . '/assets/css/owl.carousel.min.css', array(), '2.1.1' );
wp_enqueue_style( 'scrollbar', get_template_directory_uri() . '/assets/css/jquery.scrollbar.min.css', array(), '1.0.0' );
wp_enqueue_style( 'yith-wcwl-font-awesome-css', get_template_directory_uri() . '/assets/css/font-awesome.min.css', array(), '4.7.0' );
wp_register_script( 'owl-carousel', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array(), '2.1.1', true );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), '3.3.7', true );
wp_enqueue_script( 'scrollbar', get_template_directory_uri() . '/assets/js/jquery.scrollbar.min.js', array(), '1.0.0', true );
if ( function_exists( 'is_product' ) && is_product() ) {
wp_enqueue_style( 'slick', get_template_directory_uri() . '/assets/css/slick.css', array(), '1.8.0' );
wp_enqueue_script( 'slick', get_template_directory_uri() . '/assets/js/slick.js', array(), '1.8.0', true );
wp_enqueue_style( 'owl-carousel' );
wp_enqueue_script( 'owl-carousel' );
}
if ( function_exists( 'is_cart' ) && is_cart() ) {
wp_enqueue_style( 'owl-carousel' );
wp_enqueue_script( 'owl-carousel' );
}
wp_enqueue_style( 'adela-style', get_stylesheet_uri() );
wp_enqueue_script( 'adela-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), '1.0.0', true );
wp_enqueue_script( 'adela-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix.js', array(), '1.0.0', true );
wp_enqueue_script( 'adela-functions', get_template_directory_uri() . '/assets/js/functions.js', array( 'jquery' ), '1.0.0', true );
wp_localize_script( 'adela-functions', 'adela_ajax_frontend', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'security' => wp_create_nonce( 'adela_ajax_security' ),
)
);
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
$blog_display_style = adela_get_option( 'blog_display_style', 'list' );
if( $blog_display_style == 'masonry'){
wp_enqueue_script( 'isotope-pkgd', get_theme_file_uri( 'assets/js/isotope.pkgd.min.js' ), array('jquery'), '1.0' );
wp_enqueue_script( 'imagesloaded-pkgd', get_theme_file_uri( 'assets/js/imagesloaded.pkgd.min.js' ), array('jquery'), '1.0' );
}
}
public function admin_enqueue_scripts()
{
wp_register_style( 'select2', get_template_directory_uri() . '/assets/css/select2.min.css', array(), '4.0.6' );
wp_register_script( 'select2', get_template_directory_uri() . '/assets/js/select2.min.js', array(), '4.0.6', true );
wp_enqueue_style( 'adela-admin-style', get_template_directory_uri() . '/assets/css/admin.css', array(), '1.0.0' );
wp_enqueue_script( 'adela-admin-js', get_template_directory_uri() . '/assets/js/admin.js', array(), '1.0.0', true );
wp_localize_script( 'adela-admin-js', 'adela_admin_data', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'security' => wp_create_nonce( 'adela_admin_ajax_security' ),
'siteurl' => site_url( '/' ),
)
);
}
}
new Adela_Theme_Settup();
/**
* Our framework
*/
require get_template_directory() . '/framework/framework.php';