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(
'menu-1' => esc_html__( 'Primary', 'ample-shop' ),
'cat-id' => esc_html__( 'Categories Menu', 'ample-shop' ),
) );
/*
* 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_image_size( 'ample-magazine-shop', 801, 801 );
// Set up the WordPress core custom background feature.
add_theme_support( 'custom-background', apply_filters( 'ample_shop_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,
) );
}
endif;
add_action( 'after_setup_theme', 'ample_shop_setup' );
/**
* 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
*/
function ample_shop_content_width() {
// 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( 'ample_shop_content_width', 640 );
}
add_action( 'after_setup_theme', 'ample_shop_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function ample_shop_widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Shop Sidebar Widgets', 'ample-shop' ),
'id' => 'shop-widget',
'description' => esc_html__( 'Add widgets For Shop Front Page Area.', 'ample-shop' ),
'before_widget' => '',
'before_title' => '
'
) );
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'ample-shop' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'ample-shop' ),
'before_widget' => '',
'before_title' => ''
) );
register_sidebar( array(
'name' => esc_html__( 'HomePage Section with No Sidebar ', 'ample-shop' ),
'id' => 'home-sections-1',
'description' => esc_html__( 'Add widgets here what you want in home widgets.', 'ample-shop' ),
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'HomePage Section ', 'ample-shop' ),
'id' => 'home-sections',
'description' => esc_html__( 'Add widgets here what you want in home widgets.', 'ample-shop' ),
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'HomePage Section with No Sidebar ', 'ample-shop' ),
'id' => 'home-sections-2',
'description' => esc_html__( 'Add widgets here what you want in home widgets.', 'ample-shop' ),
'before_widget' => '',
'before_title' => '',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Area Section 1 ', 'ample-shop' ),
'id' => 'footer-1',
'description' => esc_html__( 'Add widgets here what you want in home widgets.', 'ample-shop' ),
'before_widget' => '',
'before_title' => ''
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Area Section 2 ', 'ample-shop' ),
'id' => 'footer-2',
'description' => esc_html__( 'Add widgets here what you want in home widgets.', 'ample-shop' ),
'before_widget' => '',
'before_title' => ''
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Area Section 3 ', 'ample-shop' ),
'id' => 'footer-3',
'description' => esc_html__( 'Add widgets here what you want in home widgets.', 'ample-shop' ),
'before_widget' => '',
'before_title' => ''
) );
}
add_action( 'widgets_init', 'ample_shop_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function ample_shop_scripts() {
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/assets/css/bootstrap.min.css' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/css/font-awesome.min.css' );
wp_enqueue_style( 'slick', get_template_directory_uri().'/assets/css/slick.css' );
wp_enqueue_style( 'slick-theme', get_template_directory_uri().'/assets/css/slick-theme.css' );
wp_enqueue_style( 'owl.carousel.min', get_template_directory_uri().'/assets/css/owl.carousel.min.css' );
wp_enqueue_style( 'owl.theme.default', get_template_directory_uri().'/assets/css/owl.theme.default.css' );
wp_enqueue_style( 'owl.transitions', get_template_directory_uri().'/assets/css/owl.transitions.css' );
wp_enqueue_style( 'animate', get_template_directory_uri().'/assets/css/animate.css' );
wp_enqueue_style( 'ample-shop-style', get_stylesheet_uri() );
wp_enqueue_style( 'ample-shop-media', get_template_directory_uri().'/assets/css/media.css' );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array('jquery'), '20151215', true );
wp_enqueue_script( 'slick', get_template_directory_uri() . '/assets/js/slick.min.js', array('jquery'), '20151215', true );
wp_enqueue_script( 'owl.carousel', get_template_directory_uri() . '/assets/js/owl.carousel.min.js', array('jquery'), '20151215', true );
wp_enqueue_script( 'theia-sticky-sidebar', get_template_directory_uri() . '/assets/js/theia-sticky-sidebar.js', array('jquery'), '4.5.0' );
wp_enqueue_script( 'wow', get_template_directory_uri() . '/assets/js/wow.min.js', array('jquery'), '20151215', true );
wp_enqueue_script( 'ample-shop-main', get_template_directory_uri() . '/assets/js/main.js', array('jquery'), '20151215', true );
wp_enqueue_script( 'ample-shop-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'ample-shop-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'ample_shop_scripts' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
//File loader
require get_template_directory() . '/inc/file-loader.php';
/**
* Load Jetpack compatibility file.
*/
if ( defined( 'JETPACK__VERSION' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}
/**
* Load WooCommerce compatibility file.
*/
if ( class_exists( 'WooCommerce' ) ) {
require get_template_directory() . '/inc/woocommerce.php';
}
if (!function_exists('ample_shop_widgets_backend_enqueue')) :
function ample_shop_widgets_backend_enqueue($hook)
{
if ('widgets.php' != $hook) {
return;
}
wp_register_script('ample-shop-custom-widgets', get_template_directory_uri() . '/assets/js/widgets.js', array('jquery'), true);
wp_enqueue_media();
wp_enqueue_script('ample-shop-custom-widgets');
wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/css/font-awesome.min.css' );
wp_enqueue_style( 'ample-shop-style-admin', get_template_directory_uri() . '/assets/css/repeater-admin.css');
}
add_action('admin_enqueue_scripts', 'ample_shop_widgets_backend_enqueue');
endif;
/* =============================hook for breadcumb ==================================================*/
if (!function_exists('ample_shop_breadcrumb_type')) :
function ample_shop_breadcrumb_type($post_id)
{
if (function_exists('bcn_display')) {
?>
classes[] = 'first-menu';
$items[count($items)]->classes[] = 'last-menu';
return $items;
}
add_filter('wp_nav_menu_objects', 'ample_shop_first_and_last_menu_class');
/*for description highlight in menu */
/**
* Add arrows to menu items
* @author Bill Erickson
* @link http://www.billerickson.net/code/add-arrows-to-menu-items/
*
* @param string $item_output, HTML output for the menu item
* @param object $item, menu item object
* @param int $depth, depth in menu structure
* @param object $args, arguments passed to wp_nav_menu()
* @return string $item_output
*/
if (!function_exists('ample_shop_add_menu_description')) :
function ample_shop_add_menu_description( $item_output, $item, $depth, $args ) {
if( 'menu-1' == $args->theme_location && $item->description )
$item_output = str_replace( '', '', $item_output );
return $item_output;
}
endif;
add_filter( 'walker_nav_menu_start_el', 'ample_shop_add_menu_description', 10, 4 );
/*theme activation plugins*/
require get_template_directory() . '/library/TGM/class-tgm-plugin-activation.php';
require get_template_directory() . '/library/TGM/plugin-slug.php';
/**
* Run ajax request.
*/
if ( ! function_exists('ample_shop_wp_pages_plucker') ) :
/**
* Sending pages with ids
*/
function ample_shop_wp_pages_plucker()
{
$pages = get_pages(
array (
'parent' => 0, // replaces 'depth' => 1,
)
);
$ids = wp_list_pluck( $pages, 'post_title', 'ID' );
return wp_send_json($ids);
}
endif;
add_action( 'wp_ajax_ample_shop_wp_pages_plucker', 'ample_shop_wp_pages_plucker' );
add_action( 'wp_ajax_nopriv_ample_shop_wp_pages_plucker', 'ample_shop_wp_pages_plucker' );