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 Thumbnail Support.
add_image_size( 'best-simple-grid-thumbnail', 384, 250, true );
add_image_size( 'best-simple-left-right-thumbnail', 804, 300, true );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'primary-menu' => esc_html__( 'Primary Menu', 'best-simple' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5', array(
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
// Set up the WordPress core custom background feature.
add_theme_support(
'custom-background', apply_filters(
'best_simple_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' => 65,
'width' => 300,
'flex-width' => true,
'flex-height' => true,
)
);
}
endif;
add_action( 'after_setup_theme', 'best_simple_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 best_simple_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( 'best_simple_content_width', 640 );
}
add_action( 'after_setup_theme', 'best_simple_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function best_simple_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'best-simple' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'best-simple' ),
'before_widget' => '',
'before_title' => '
',
)
);
}
add_action( 'widgets_init', 'best_simple_widgets_init' );
/**
* Above Header -- Hero Banner.
*/
function best_simple_homepage_hero_widget() {
register_sidebar(
array(
'name' => esc_html__( 'Hero Section', 'best-simple' ),
'id' => 'home-hero',
'description' => esc_html__( 'Add widgets here.', 'best-simple' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => '
',
)
);
}
add_action( 'widgets_init', 'best_simple_homepage_hero_widget' );
/**
* Enqueue scripts and styles.
*/
function best_simple_scripts() {
wp_enqueue_style( 'best-simple-style', get_stylesheet_uri() );
// Loading Handpicked Fonts For Best Simple Theme.
wp_enqueue_style( 'best-simple-icons', get_stylesheet_directory_uri() . '/assets/css/simple.css' );
// Loading Google Web Font
wp_enqueue_style( 'best-simple-google-font', '//fonts.googleapis.com/css?family=Merriweather|Nunito+Sans:700' );
wp_enqueue_script( 'best-simple-navigation', get_template_directory_uri() . '/assets/js/navigation.js', array( 'jquery' ), '20151215', true );
wp_localize_script(
'best-simple-navigation', 'best_simple_ScreenReaderText', array(
'expand' => __( 'Expand child menu', 'best-simple' ),
'collapse' => __( 'Collapse child menu', 'best-simple' ),
)
);
wp_enqueue_script( 'best-simple-skip-link-focus-fix', get_template_directory_uri() . '/assets/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', 'best_simple_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';
/**
* Load Jetpack compatibility file.
*/
if ( defined( 'JETPACK__VERSION' ) ) {
require get_template_directory() . '/inc/jetpack.php';
}
/**
* Modify the given HTML
*
* @param String $template - Comment Pagination Template HTML.
* @param String $class - Passed HTML Class Attribute.
*
* @return String $template - Return Modified HTML
*/
function change_reader_heading( $template, $class ) {
if ( ! empty( $class ) && false !== strpos( $class, 'pagination' ) ) {
$template = str_replace( '';
echo '' . esc_html( sprintf( __( 'Home', 'best-simple' ) ) );
echo '›';
if ( is_single() ) {
$categories = get_the_category();
if ( $categories ) {
$level = 0;
$hierarchy_arr = array();
foreach ( $categories as $cat ) {
$anc = get_ancestors( $cat->term_id, 'category' );
$count_anc = count( $anc );
if ( 0 < $count_anc && $level < $count_anc ) {
$level = $count_anc;
$hierarchy_arr = array_reverse( $anc );
array_push( $hierarchy_arr, $cat->term_id );
}
}
if ( empty( $hierarchy_arr ) ) {
$category = $categories[0];
echo '' . esc_html( $category->name ) . '›';
} else {
foreach ( $hierarchy_arr as $cat_id ) {
$category = get_term_by( 'id', $cat_id, 'category' );
echo '' . esc_html( $category->name ) . '›';
}
}
}
} elseif ( is_page() ) {
$parent_id = wp_get_post_parent_id( get_the_ID() );
if ( $parent_id ) {
$breadcrumbs = array();
while ( $parent_id ) {
$page = get_page( $parent_id );
$breadcrumbs[] = '' . esc_html( get_the_title( $page->ID ) ) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse( $breadcrumbs );
foreach ( $breadcrumbs as $crumb ) {
echo esc_attr( $crumb ); }
}
echo '';
the_title();
echo '';
} elseif ( is_category() ) {
global $best_simple_wp_query;
$cat_obj = $best_simple_wp_query->get_queried_object();
$this_cat_id = $cat_obj->term_id;
$hierarchy_arr = get_ancestors( $this_cat_id, 'category' );
if ( $hierarchy_arr ) {
$hierarchy_arr = array_reverse( $hierarchy_arr );
foreach ( $hierarchy_arr as $cat_id ) {
$category = get_term_by( 'id', $cat_id, 'category' );
echo '' . esc_html( $category->name ) . '';
}
}
echo '';
single_cat_title();
echo '';
} elseif ( is_author() ) {
echo '';
if ( get_query_var( 'author_name' ) ) :
$curauth = get_user_by( 'slug', get_query_var( 'author_name' ) );
else :
$curauth = get_userdata( get_query_var( 'author' ) );
endif;
echo esc_html( $curauth->nickname );
echo '';
} elseif ( is_search() ) {
echo '';
the_search_query();
echo '';
} elseif ( is_tag() ) {
echo '';
single_tag_title();
echo '';
}
}
}