'FFF',
'default-image' => get_template_directory_uri() . '/img/bg.jpg'
));*/
// Add Support for Custom Header - Uncomment below if you're going to use.
/*add_theme_support('custom-header', array(
'default-image' => get_template_directory_uri() . '/img/headers/default.jpg',
'header-text' => false,
'default-text-color' => '000',
'width' => 1000,
'height' => 198,
'random-default' => false,
'wp-head-callback' => $wphead_cb,
'admin-head-callback' => $adminhead_cb,
'admin-preview-callback' => $adminpreview_cb
));*/
// Enables post and comment RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
// Enable HTML5 support.
add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption' ) );
add_theme_support( 'rank-math-breadcrumbs' );
// Localisation Support.
load_theme_textdomain( 'html5blank', get_template_directory() . '/languages' );
}
/*------------------------------------*\
Functions
\*------------------------------------*/
// HTML5 Blank navigation
function html5blank_nav() {
wp_nav_menu(
array(
'theme_location' => 'header-menu',
'menu' => '',
'container' => 'div',
'container_class' => 'menu-{menu slug}-container',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '
',
'depth' => 0,
'walker' => '',
)
);
}
// Load HTML5 Blank scripts (header.php)
function html5blank_header_scripts() {
if ( $GLOBALS['pagenow'] != 'wp-login.php' && ! is_admin() ) {
if ( HTML5_DEBUG ) {
// Custom scripts
wp_register_script(
'scripts',
get_template_directory_uri() . '/js/scripts.js',
array(
// 'conditionizr',
// 'modernizr',
// 'jquery'
),
filemtime( get_template_directory() . '/js/scripts.js' ) );
// Enqueue Scripts
wp_enqueue_script( 'scripts' );
// If production
} else {
// Scripts minify
wp_register_script( 'scripts-min', get_template_directory_uri() . '/js/scripts.js', array(), filemtime( get_template_directory() . '/js/scripts.js' ) );
// Enqueue Scripts
wp_enqueue_script( 'scripts-min' );
}
}
}
// Load HTML5 Blank conditional scripts
function html5blank_conditional_scripts() {
if ( is_page( 'pagenamehere' ) ) {
// Conditional script(s)
wp_register_script( 'scriptname', get_template_directory_uri() . '/js/scriptname.js', array( 'jquery' ), '1.0.0' );
wp_enqueue_script( 'scriptname' );
}
}
// Load HTML5 Blank styles
function stylestheme() {
if ( HTML5_DEBUG ) {
// normalize-css
wp_register_style( 'normalize', get_template_directory_uri() . '/css/lib/normalize.css', array(), '7.0.0' );
// Custom CSS
wp_register_style( 'stylestheme', get_template_directory_uri() . '/style.css', array(), filemtime( get_template_directory() . '/style.css' ) );
// Register CSS
wp_enqueue_style( 'stylestheme' );
} else {
// Custom CSS
wp_register_style( 'html5blankcssmin', get_template_directory_uri() . '/style.css', array(), filemtime( get_template_directory() . '/style.css' ) );
// Register CSS
wp_enqueue_style( 'html5blankcssmin' );
}
}
// Register HTML5 Blank Navigation
function register_html5_menu() {
register_nav_menus( array( // Using array to specify more menus if needed
'header-menu' => esc_html( 'Header Menu', 'html5blank' ), // Main Navigation
'extra-menu' => esc_html( 'Extra Menu', 'html5blank' ) // Extra Navigation if needed (duplicate as many as you need!)
) );
}
// Remove the surrounding the dynamic navigation to cleanup markup
function my_wp_nav_menu_args( $args = '' ) {
$args['container'] = false;
return $args;
}
// Remove Injected classes, ID's and Page ID's from Navigation
items
function my_css_attributes_filter( $var ) {
return is_array( $var ) ? array() : '';
}
// Remove invalid rel attribute values in the categorylist
function remove_category_rel_from_category_list( $thelist ) {
return str_replace( 'rel="category tag"', 'rel="tag"', $thelist );
}
// Add page slug to body class, love this - Credit: Starkers Wordpress Theme
function add_slug_to_body_class( $classes ) {
global $post;
if ( is_front_page() ) {
$classes[] = 'front-page';
}
if ( is_home() ) {
$key = array_search( 'blog', $classes, true );
if ( $key > -1 ) {
unset( $classes[$key] );
}
} elseif ( is_page() ) {
$classes[] = sanitize_html_class( $post->post_name );
} elseif ( is_singular() ) {
$classes[] = sanitize_html_class( $post->post_name );
}
return $classes;
}
function turquesa_the_breadcrumbs() {
if ( is_front_page() ) {
return;
}
if ( function_exists( 'rank_math_the_breadcrumbs' ) ) {
rank_math_the_breadcrumbs();
return;
}
echo do_shortcode( '[rank_math_breadcrumb]' );
}
add_filter( 'rank_math/frontend/breadcrumb/args', 'turquesa_rank_math_breadcrumb_args' );
function turquesa_rank_math_breadcrumb_args( $args ) {
$args['separator'] = '/';
$args['wrap_before'] = '';
$args['wrap_after'] = '
';
return $args;
}
add_filter( 'rank_math/frontend/breadcrumb/strings', 'turquesa_rank_math_breadcrumb_strings' );
function turquesa_rank_math_breadcrumb_strings( $strings ) {
$strings['home'] = 'Inicio';
return $strings;
}
// Remove the width and height attributes from inserted images
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
// If Dynamic Sidebar Exists
if ( function_exists( 'register_sidebar' ) ) {
// Define Sidebar Widget Area 1
register_sidebar( array(
'name' => esc_html( 'Widget Area 1', 'html5blank' ),
'description' => esc_html( 'Description for this widget-area...', 'html5blank' ),
'id' => 'widget-area-1',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => ' ',
) );
// Define Sidebar Widget Area 2
register_sidebar( array(
'name' => esc_html( 'Widget Area 2', 'html5blank' ),
'description' => esc_html( 'Description for this widget-area...', 'html5blank' ),
'id' => 'widget-area-2',
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
'after_title' => ' ',
) );
}
// Remove wp_head() injected Recent Comment styles
function my_remove_recent_comments_style() {
global $wp_widget_factory;
if ( isset( $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ) ) {
remove_action( 'wp_head', array(
$wp_widget_factory->widgets['WP_Widget_Recent_Comments'],
'recent_comments_style'
) );
}
}
// Pagination for paged posts, Page 1, Page 2, Page 3, with Next and Previous Links, No plugin
function html5wp_pagination() {
global $wp_query;
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var( 'paged' ) ),
'total' => $wp_query->max_num_pages,
) );
}
// Create 20 Word Callback for Index page Excerpts, call using html5wp_excerpt('html5wp_index');
function html5wp_index( $length ) {
return 20;
}
// Create 40 Word Callback for Custom Post Excerpts, call using html5wp_excerpt('html5wp_custom_post');
function html5wp_custom_post( $length ) {
return 40;
}
// Create the Custom Excerpts callback
function html5wp_excerpt( $length_callback = '', $more_callback = '' ) {
global $post;
if ( function_exists( $length_callback ) ) {
add_filter( 'excerpt_length', $length_callback );
}
if ( function_exists( $more_callback ) ) {
add_filter( 'excerpt_more', $more_callback );
}
$output = get_the_excerpt();
$output = apply_filters( 'wptexturize', $output );
$output = apply_filters( 'convert_chars', $output );
$output = '' . $output . '
';
echo esc_html( $output );
}
// Custom View Article link to Post
function html5_blank_view_article( $more ) {
global $post;
if ( isset( $post->post_type ) && 'page' === $post->post_type ) {
return '';
}
$permalink = isset( $post->ID ) ? get_permalink( $post->ID ) : '';
return '... ' . esc_html__( 'View Article', 'html5blank' ) . ' ';
}
// Remove Admin bar
function remove_admin_bar() {
return false;
}
// Remove 'text/css' from our enqueued stylesheet
function html5_style_remove( $tag ) {
return preg_replace( '~\s+type=["\'][^"\']++["\']~', '', $tag );
}
// Remove thumbnail width and height dimensions that prevent fluid images in the_thumbnail
function remove_thumbnail_dimensions( $html ) {
$html = preg_replace( '/(width|height)=\"\d*\"\s/', '', $html );
return $html;
}
// Custom Gravatar in Settings > Discussion
function html5blankgravatar ( $avatar_defaults ) {
$myavatar = get_template_directory_uri() . '/img/gravatar.jpg';
$avatar_defaults[$myavatar] = 'Custom Gravatar';
return $avatar_defaults;
}
// Threaded Comments
function enable_threaded_comments() {
if ( ! is_admin() ) {
if ( is_singular() AND comments_open() AND ( get_option( 'thread_comments' ) == 1 ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
}
// Custom Comments Callback
function html5blankcomments( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
extract( $args, EXTR_SKIP );
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
< id="comment-">
Discussion
add_filter( 'body_class', 'add_slug_to_body_class' ); // Add slug to body class (Starkers build)
add_filter( 'widget_text', 'do_shortcode' ); // Allow shortcodes in Dynamic Sidebar
add_filter( 'widget_text', 'shortcode_unautop' ); // Remove tags in Dynamic Sidebars (better!)
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' ); // Remove surrounding
from WP Navigation
// add_filter( 'nav_menu_css_class', 'my_css_attributes_filter', 100, 1 ); // Remove Navigation
injected classes (Commented out by default)
// add_filter( 'nav_menu_item_id', 'my_css_attributes_filter', 100, 1 ); // Remove Navigation injected ID (Commented out by default)
// add_filter( 'page_css_class', 'my_css_attributes_filter', 100, 1 ); // Remove Navigation Page ID's (Commented out by default)
add_filter( 'the_category', 'remove_category_rel_from_category_list' ); // Remove invalid rel attribute
add_filter( 'the_excerpt', 'shortcode_unautop' ); // Remove auto tags in Excerpt (Manual Excerpts only)
add_filter( 'the_excerpt', 'do_shortcode' ); // Allows Shortcodes to be executed in Excerpt (Manual Excerpts only)
add_filter( 'excerpt_more', 'html5_blank_view_article' ); // Add 'View Article' button instead of [...] for Excerpts
add_filter( 'show_admin_bar', 'remove_admin_bar' ); // Remove Admin bar
add_filter( 'style_loader_tag', 'html5_style_remove' ); // Remove 'text/css' from enqueued stylesheet
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 ); // Remove width and height dynamic attributes to thumbnails
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 ); // Remove width and height dynamic attributes to post images
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 ); // Remove width and height dynamic attributes to post images
// Remove Filters
remove_filter( 'the_excerpt', 'wpautop' ); // Remove
tags from Excerpt altogether
// Shortcodes
add_shortcode( 'html5_shortcode_demo', 'html5_shortcode_demo' ); // You can place [html5_shortcode_demo] in Pages, Posts now.
add_shortcode( 'html5_shortcode_demo_2', 'html5_shortcode_demo_2' ); // Place [html5_shortcode_demo_2] in Pages, Posts now.
// Shortcodes above would be nested like this -
// [html5_shortcode_demo] [html5_shortcode_demo_2] Here's the page title! [/html5_shortcode_demo_2] [/html5_shortcode_demo]
/*------------------------------------*\
ShortCode Functions
\*------------------------------------*/
// Shortcode Demo with Nested Capability
function html5_shortcode_demo( $atts, $content = null ) {
return '
' . do_shortcode( $content ) . '
'; // do_shortcode allows for nested Shortcodes
}
// Demo Heading H2 shortcode, allows for nesting within above element. Fully expandable.
function html5_shortcode_demo_2( $atts, $content = null ) {
return '' . $content . ' ';
}