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' );
/*
* Add support for selective refresh.
*/
add_theme_support( 'customize-selective-refresh-widgets' );
/*
* Set default thumbnail size.
*/
set_post_thumbnail_size( 720, 330, true );
/*
* Image size used for products thumbnails.
*/
add_image_size( 'capri-featured-products-image', 500, 500, true );
/*
* Image size used for categories section on front page.
*/
add_image_size( 'capri-frontpage-categories', 615, 580, true );
/*
* Image size used for testimonials section on About page
*/
add_image_size( 'capri-jetpack-testimonial-thumbnail', 265, 265, true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'primary' => esc_html__( 'Primary', 'capri-lite' ),
)
);
/*
* 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',
)
);
// Set up the WordPress core custom background feature.
add_theme_support(
'custom-background', apply_filters(
'capri_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
// Add theme support for custom logo
add_theme_support(
'custom-logo', array(
'height' => 300,
'width' => 600,
'flex-width' => true,
)
);
// Add theme support for custom header
$defaults = array(
'flex-height' => true,
'flex-width' => true,
);
add_theme_support( 'custom-header', $defaults );
}
endif;
add_action( 'after_setup_theme', 'capri_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
* @since 1.0.0
* @access public
*/
function capri_content_width() {
$GLOBALS['content_width'] = apply_filters( 'capri_content_width', 640 );
}
add_action( 'after_setup_theme', 'capri_content_width', 0 );
/**
* Register widget areas.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*
* @since 1.0.0
* @access public
*/
function capri_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'capri-lite' ),
'id' => 'sidebar-1',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
)
);
register_sidebars(
3, array(
'name' =>
/* translators: %d is Footer id */
esc_html__( 'Footer %d', 'capri-lite' ),
'id' => 'capri-footer-widget-area',
'class' => 'col-sm-4',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
if ( class_exists( 'WooCommerce' ) ) {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar Shop', 'capri-lite' ),
'id' => 'sidebar-shop',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
)
);
}
register_sidebar(
array(
'name' => esc_html__( 'Ribbon area', 'capri-lite' ),
'id' => 'ribbon-area',
'class' => 'ribbon-area',
'before_widget' => '',
'before_title' => '',
)
);
register_widget( 'capri_ribbon_widget' );
}
add_action( 'widgets_init', 'capri_widgets_init' );
/**
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
* a 'Continue reading' link.
*
* @since 1.0.0
* @access public
* @return string 'Continue reading' link prepended with an ellipsis.
*/
function capri_excerpt_more() {
$link =
/* translators: %1$s : Permalink, %2$s : Continue reading text */
sprintf(
' %2$s',
esc_url( get_permalink( get_the_ID() ) ),
sprintf(
wp_kses(
/* translators: %s: Name of current post */
__( 'Continue reading "%s"', 'capri-lite' ), array(
'span' => array(
'class' => array( '' ),
),
)
), get_the_title( get_the_ID() )
)
);
return '… ' . $link;
}
add_filter( 'excerpt_more', 'capri_excerpt_more' );
/**
* Register Fonts
*
* @since 1.0.0
* @access public
* @return string Link to google font.
*/
function capri_fonts_url() {
$fonts_url = '';
/**
* Translators: If there are characters in your language that are not
* supported by Bitter and Arimo, translate this to 'off'. Do not translate
* into your own language.
*/
$bitter = _x( 'on', 'Bitter font: on or off', 'capri-lite' );
$arimo = _x( 'on', 'Arimo font: on or off', 'capri-lite' );
if ( 'off' !== $bitter || 'off' !== $arimo ) {
$font_families = array();
if ( 'off' !== $bitter ) {
$font_families[] = 'Bitter:400';
}
if ( 'off' !== $arimo ) {
$font_families[] = 'Arimo:400,700';
}
$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'subset' => urlencode( 'latin,latin-ext' ),
);
$fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
* @access public
*/
function capri_scripts() {
wp_enqueue_style( 'capri-fonts', capri_fonts_url(), array(), null );
wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/assets/bootstrap/css/bootstrap.min.css', array(), '3.3.6', 'all' );
wp_enqueue_style( 'capri-style', get_stylesheet_uri(), array(), CAPRI_VERSION );
wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '4.5.0' );
wp_enqueue_script( 'capri-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array(), CAPRI_VERSION, true );
wp_localize_script(
'capri-navigation', 'capriScreenReaderText', array(
'expand' => '' . esc_html__( 'expand child menu', 'capri-lite' ) . '',
'collapse' => '' . esc_html__( 'collapse child menu', 'capri-lite' ) . '',
)
);
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap.min.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'capri-functions', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'capri-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', 'capri_scripts' );
/**
* Implement the Custom Header feature.
*/
require CAPRI_PHP_INCLUDE . 'custom-header.php';
/**
* Custom template tags for this theme.
*/
require CAPRI_PHP_INCLUDE . 'template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require CAPRI_PHP_INCLUDE . 'extras.php';
/**
* Customizer additions.
*/
require CAPRI_PHP_INCLUDE . 'customizer.php';
/**
* Load Jetpack compatibility file.
*/
require CAPRI_PHP_INCLUDE . 'jetpack.php';
/**
* Woocommerce integration functions.
*/
require CAPRI_PHP_INCLUDE . 'woocommerce/functions.php';
/**
* Add Placehoder in comment Form Fields (Name, Email, Website)
*
* @since 1.0.0
* @access public
*/
function capri_comment_placeholders( $fields ) {
$fields['author'] = str_replace(
'