tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
add_theme_support('custom-logo');
add_theme_support( 'lifterlms-sidebars' );
add_theme_support( 'editor-color-palette', [
[
'name' => __( 'Palette Color 1', 'blocksy' ),
'slug' => 'palette-color-1',
'color' => 'var(--paletteColor1)',
],
[
'name' => __( 'Palette Color 2', 'blocksy' ),
'slug' => 'palette-color-2',
'color' => 'var(--paletteColor2)',
],
[
'name' => __( 'Palette Color 3', 'blocksy' ),
'slug' => 'palette-color-3',
'color' => 'var(--paletteColor3)',
],
[
'name' => __( 'Palette Color 4', 'blocksy' ),
'slug' => 'palette-color-4',
'color' => 'var(--paletteColor4)',
],
[
'name' => __( 'Palette Color 5', 'blocksy' ),
'slug' => 'palette-color-5',
'color' => 'var(--paletteColor5)',
]
]);
/*
* 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', ['post']);
add_theme_support('woocommerce');
add_post_type_support('page', 'excerpt');
if (get_theme_mod('has_product_single_lightbox', 'no') === 'yes') {
add_theme_support( 'wc-product-gallery-lightbox' );
}
$all_menus = [];
if (blocksy_has_i18n_plugin()) {
$all_menus['footer'] = esc_html__( 'Footer Menu', 'blocksy' );
$all_menus['menu_1'] = esc_html__( 'Header Menu 1', 'blocksy' );
$all_menus['menu_2'] = esc_html__( 'Header Menu 2', 'blocksy' );
$all_menus['menu_mobile'] = esc_html__( 'Mobile Menu', 'blocksy' );
}
// This theme uses wp_nav_menu() in one location.
if (! empty($all_menus)) {
register_nav_menus($all_menus);
}
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
[
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
]
);
// Registers support for Gutenberg wide images
add_theme_support( 'align-wide' );
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
});
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
add_action('after_setup_theme', function () {
// This variable is intended to be overruled from themes.
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$GLOBALS['content_width'] = apply_filters( 'blocksy_content_width', 640 );
}, 0);
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
add_action(
'widgets_init',
function () {
$sidebar_title_tag = get_theme_mod('widgets_title_wrapper', 'h2');
register_sidebar(
[
'name' => esc_html__( 'Main Sidebar', 'blocksy' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'blocksy' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '<' . $sidebar_title_tag . ' class="widget-title">',
'after_title' => '' . $sidebar_title_tag . '>',
]
);
$number_of_sidebars = 4;
for ( $i = 1; $i <= $number_of_sidebars; $i++ ) {
register_sidebar(
[
'id' => 'ct-footer-sidebar-' . $i,
'name' => "Footer Column $i",
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
]
);
}
}
);
add_action('wp_enqueue_scripts', function () {
$theme = blocksy_get_wp_parent_theme();
$m = new Blocksy_Fonts_Manager();
$m->load_dynamic_google_fonts();
wp_register_script(
'ct-events',
get_template_directory_uri() . '/static/bundle/events.js',
[],
$theme->get('Version'),
true
);
/*
wp_enqueue_style(
'ct-style',
get_stylesheet_uri(),
[],
$theme->get( 'Version' )
);
*/
wp_enqueue_style(
'ct-main-styles',
get_template_directory_uri() . '/static/bundle/main.css',
[],
$theme->get('Version')
);
if (class_exists('Forminator')) {
wp_enqueue_style(
'ct-forminator-styles',
get_template_directory_uri() . '/static/bundle/forminator.css',
['ct-main-styles'],
$theme->get('Version')
);
}
wp_enqueue_script(
'ct-scripts',
get_template_directory_uri() . '/static/bundle/main.js',
['ct-events'],
$theme->get('Version'),
true
);
$data = [
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'ct-ajax-nonce' ),
'public_url' => get_template_directory_uri() . '/static/bundle/',
'rest_url' => get_rest_url(),
'search_url' => get_search_link( 'QUERY_STRING' ),
'show_more_text' => __( 'Show more', 'blocksy' ),
'more_text' => __( 'More', 'blocksy' ),
];
ob_start();
get_template_part('template-parts/internet', 'explorer');
$data['internet_explorer_template'] = ob_get_clean();
if ( is_customize_preview() ) {
$data['customizer_sync'] = blocksy_customizer_sync_data();
}
wp_localize_script(
'ct-scripts',
'ct_localizations',
$data
);
if (defined('WP_DEBUG') && WP_DEBUG) {
wp_localize_script(
'ct-scripts',
'WP_DEBUG',
['debug' => true]
);
}
if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script( 'comment-reply' );
}
});
add_action(
'enqueue_block_editor_assets',
function () {
$theme = blocksy_get_wp_parent_theme();
global $post;
$m = new Blocksy_Fonts_Manager();
$m->load_editor_fonts();
$options = blocksy_get_options('meta/' . get_post_type($post));
if (! $options) {
$options = blocksy_get_options('meta/default');
}
wp_enqueue_style(
'ct-main-editor-styles',
get_template_directory_uri() . '/static/bundle/editor.css',
[],
$theme->get('Version')
);
wp_enqueue_script(
'ct-main-editor-scripts',
get_template_directory_uri() . '/static/bundle/editor.js',
['wp-plugins', 'wp-edit-post', 'wp-element', 'ct-options-scripts'],
$theme->get('Version')
);
$page_structure = get_post_type($post) === 'page' ? get_theme_mod(
'single_page_structure', 'type-4'
) : get_theme_mod(
'single_blog_post_structure', 'type-3'
);
$localize = [
'post_options' => $options,
'default_page_structure' => $page_structure === 'type-4' ? 'normal' : 'narrow'
];
wp_localize_script(
'ct-main-editor-scripts',
'ct_editor_localizations',
$localize
);
}
);
require get_template_directory() . '/inc/helpers.php';
require get_template_directory() . '/inc/classes/theme-db-versioning.php';
require get_template_directory() . '/inc/classes/customizer-builder.php';
require get_template_directory() . '/inc/i18n.php';
require get_template_directory() . '/inc/global-scripts.php';
require blocksy_locate_theme_path('/inc/schema-org.php');
require blocksy_locate_theme_path('/inc/classes/class-ct-css-injector.php');
require blocksy_locate_theme_path('/inc/classes/class-ct-attributes-parser.php');
require blocksy_locate_theme_path('/inc/excerpt.php');
require blocksy_locate_theme_path('/inc/inline-svgs.php');
require blocksy_locate_theme_path('/inc/css-helpers.php');
require blocksy_locate_theme_path('/inc/css/box-shadow-option.php');
require blocksy_locate_theme_path('/inc/dynamic-css.php');
require blocksy_locate_theme_path('/inc/pagination.php');
require blocksy_locate_theme_path('/inc/sidebar.php');
require blocksy_locate_theme_path('/inc/sidebar-render.php');
require blocksy_locate_theme_path('/inc/post-meta.php');
require blocksy_locate_theme_path('/inc/images.php');
require blocksy_locate_theme_path('/inc/single-helpers.php');
require blocksy_locate_theme_path('/inc/options-logic.php');
require blocksy_locate_theme_path('/inc/comments-helpers.php');
require blocksy_locate_theme_path('/inc/comments.php');
require blocksy_locate_theme_path('/inc/social-box.php');
require blocksy_locate_theme_path('/inc/menus.php');
require blocksy_locate_theme_path('/inc/footer.php');
require blocksy_locate_theme_path('/inc/visibility.php');
require blocksy_locate_theme_path('/inc/header-helpers.php');
require blocksy_locate_theme_path('/inc/elementor-integration.php');
require blocksy_locate_theme_path('/inc/meta-boxes.php');
require blocksy_locate_theme_path('/inc/hero-section.php');
require blocksy_locate_theme_path('/inc/woocommerce-integration.php');
require blocksy_locate_theme_path('/inc/posts-listing.php');
require blocksy_locate_theme_path('/inc/gallery.php');
require blocksy_locate_theme_path('/inc/backgrounds.php');
require blocksy_locate_theme_path('/inc/typography/core.php');
require blocksy_locate_theme_path('/inc/trending-posts.php');
require blocksy_locate_theme_path('/template-parts/content-helpers.php');
/**
* Custom template tags for this theme.
*/
require blocksy_locate_theme_path('/inc/template-tags.php');
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
// Emergency code
if (
class_exists('EDD_SL_Plugin_Updater')
&&
function_exists('\Blocksy\blc_fs')
&&
defined('BLOCKSY__FILE__')
&&
version_compare(
get_plugin_data(BLOCKSY__FILE__)['Version'],
'1.6.5',
'<'
)
) {
$blocksy_companion_data = get_plugin_data(BLOCKSY__FILE__);
new \EDD_SL_Plugin_Updater(
'https://creativethemes.com/',
BLOCKSY__FILE__,
[
'version' => $blocksy_companion_data['Version'],
'license' => '123',
'item_id' => 515,
'author' => 'CreativeThemes',
'beta' => false,
]
);
}
if (is_admin()) {
require get_template_directory() . '/admin/init.php';
}
if (!is_admin()) {
add_filter('script_loader_tag', function ($tag, $handle) {
$scripts = apply_filters('blocksy-async-scripts-handles', [
'ct-scripts'
]);
if (in_array($handle, $scripts)) {
return str_replace('