%3$s', is_front_page() && is_home() ? 'h1' : 'p', esc_url(home_url('/')), esc_html(get_bloginfo('name')) ); } } endif; /* SITE TAGLINE @since 2.0.0 ==================================================== */ if (!function_exists('amble_site_tagline')) : function amble_site_tagline() { $description = get_bloginfo('description', 'display'); // Check whether the site title is activated in the customizer. $amble_hide_tagline = get_theme_mod('amble_hide_tagline', false); if ($description) { if (false === $amble_hide_tagline) { echo '

' . esc_html($description) . '

'; } } } endif; /* HEADER BRANDING @since 2.0.0 ==================================================== */ if (!function_exists('amble_header_branding')) : function amble_header_branding() { $description = get_bloginfo('description', 'display'); echo '
'; amble_site_identity(); amble_site_tagline(); } endif; /* MAIN NAVIGATION ====================================================*/ if (!function_exists('amble_mainnav')) : function amble_mainnav() { $amble_header_layout = apply_filters('amble_header_layout', get_theme_mod('amble_header_layout', 'header1')); ?>
'; return $form; } endif; add_filter('get_search_form', 'amble_search_form'); /* ARCHIVE TITLE PREFIX Styles the archive title prefix with a span @since 2.0.0 ==================================================== */ function amble_prefix_archive_title($title) { $regex = apply_filters( 'amble_prefix_the_archive_title_regex', array( 'pattern' => '/(\A[^\:]+\:)/', 'replacement' => '$1', ) ); if (empty($regex)) { return $title; } return preg_replace($regex['pattern'], $regex['replacement'], $title); } add_filter('get_the_archive_title', 'amble_prefix_archive_title'); /* ARCHIVE TITLES Change how archive titles are displayed @since 2.0.0 ==================================================== */ if (!function_exists('amble_archive_title')) : function amble_archive_title($title) { // Check if this is set to show or hide the archive prefix $amble_hide_prefix_archive = get_theme_mod('amble_hide_prefix_archive', false); // If enabled - the prefix archive label is hidden if (true === $amble_hide_prefix_archive) { if (is_category()) { return single_cat_title('', false); } elseif (is_author()) { return get_the_author(); } } return $title; } endif; add_filter('get_the_archive_title', 'amble_archive_title', 10, 1); /* PAGE HEADERS Load the appropriate page headers @since 2.0.0 ==================================================== */ if (!function_exists('amble_page_headers')) : function amble_page_headers() { if (is_archive()) { echo '
'; the_archive_title('

', '

'); the_archive_description('
', '
'); // action hook for any content after the archive title and description if (!is_category() && !is_author()) { do_action('amble_after_archive_description'); } echo '
'; } elseif (is_page() && has_post_thumbnail()) { echo ''; } } endif; add_action('amble_page_header', 'amble_page_headers'); /* DISPLAY A SINGLE POST CATEGORY @since 2.0.0 ==================================================== */ if (!function_exists('amble_first_category')) : function amble_first_category() { $category = get_the_category(); $first_category = $category[0]; echo sprintf( '%s', get_category_link($first_category), $first_category->name ); // phpcs:ignore WordPress.Security.EscapeOutput } endif; /* DISPLAY FEATURED or CATEGORY LABEL @since 2.0.0 ==================================================== */ if (!function_exists('amble_featured_category_badge')) : function amble_featured_category_badge() { $amble_featured_label_text = get_theme_mod('amble_featured_label_text', esc_html__('Featured', 'amble')); if (is_sticky() && is_home() && !is_paged()) { echo '', wp_kses_post($amble_featured_label_text), ''; } else { echo '', esc_html(amble_first_category()), ''; } } endif; /* META DATE @since 2.0.0 ==================================================== */ if (!function_exists('amble_posted_on')) : function amble_posted_on() { $time_string = ''; if (get_the_time('U') !== get_the_modified_time('U')) { $time_string = ''; } $time_string = sprintf( $time_string, esc_attr(get_the_date(DATE_W3C)), esc_html(get_the_date()), esc_attr(get_the_modified_date(DATE_W3C)), esc_html(get_the_modified_date()) ); $posted_on = sprintf( /* translators: %s: post date. */ esc_html_x('%s', 'Short post date', 'amble'), '' . $time_string . '' ); echo '' . $posted_on . ''; // phpcs:ignore WordPress.Security.EscapeOutput } endif; /* UPDATED POST DATE @since 2.0.0 ==================================================== */ if (!function_exists('amble_updated')) : function amble_updated() { printf( /* translators: %s: For the updated date. */ '' . esc_html__('Updated on %s', 'amble') . '', get_the_modified_date() ); } endif; /* META AUTHOR @since 2.0.0 ==================================================== */ if (!function_exists('amble_posted_by')) : function amble_posted_by() { $byline = sprintf( /* translators: %s: post author. */ esc_html_x('by %s', 'post author', 'amble'), '' . esc_html(get_the_author()) . '' ); echo ' ' . $byline . ''; // phpcs:ignore WordPress.Security.EscapeOutput } endif; /* META COMMENT COUNT & LINK @since 2.0.0 ==================================================== */ if (!function_exists('amble_comment_link')) : function amble_comment_link() { if (!post_password_required() && (comments_open() || get_comments_number())) { echo ''; /* translators: %s: Name of current post. Only visible to screen readers. */ comments_popup_link(sprintf(__('Make a comment on %s', 'amble'), get_the_title())); echo ''; } } endif; /* ENTRY FOOTER @since 2.0.0 ==================================================== */ if (!function_exists('amble_entry_footer')) : // Prints HTML with meta information for the categories, tags and comments. function amble_entry_footer() { // Is the option to hide the edit link activated in the customizer. $amble_hide_edit = get_theme_mod('amble_hide_edit', false); $amble_hide_post_footer = get_theme_mod('amble_hide_post_footer', false); $amble_hide_post_categories = get_theme_mod('amble_hide_post_categories', false); $amble_hide_post_tags = get_theme_mod('amble_hide_post_tags', false); if (false === $amble_hide_post_footer) { echo ''; } } endif; add_action('amble_after_post_entry_content', 'amble_entry_footer'); /* POST THUMBNAILS @since 2.0.0 ==================================================== */ if (!function_exists('amble_post_thumbnail')) : function amble_post_thumbnail() { if (post_password_required() || is_attachment() || !has_post_thumbnail()) { return; } $caption = get_the_post_thumbnail_caption(); ?> '; printf( '
%s
', get_avatar(get_the_author_meta('user_email'), 100) ); echo '
'; printf( '', get_the_author() ); the_author_meta('description'); echo '
'; } endif; /* CHECK IF POST AUTHOR HAS COMMENT @since 2.0.0 ==================================================== */ if (!function_exists('amble_is_comment_by_post_author')) : function amble_is_comment_by_post_author($comment = null) { if (is_object($comment) && $comment->user_id > 0) { $user = get_userdata($comment->user_id); $post = get_post($comment->comment_post_ID); if (!empty($user) && !empty($post)) { return $comment->user_id === $post->post_author; } } return false; } endif; /* MODIFY the COMMENT FORM @since 2.0.0 ==================================================== */ if (!function_exists('amble_comment_form_default_fields')) : function amble_comment_form_default_fields($fields) { $commenter = wp_get_current_commenter(); $req = get_option('require_name_email'); $aria_req = ($req ? " aria-required='true'" : ''); $html_req = ($req ? " required='required'" : ''); $html5 = 'html5'; $fields['author'] = '

'; $fields['email'] = '
'; $fields['url'] = '

'; return $fields; } endif; add_filter('comment_form_default_fields', 'amble_comment_form_default_fields', 10, 1); /* ADD A TITLE TO POSTS MISSING TITLES When a post is missing a title, a default title will be used. @since 2.0.0 ==================================================== */ if (!function_exists('amble_post_title')) { function amble_post_title($title) { return '' === $title ? esc_html_x('Untitled', 'Added to posts and pages that are missing titles', 'amble') : $title; } } add_filter('the_title', 'amble_post_title'); /* FILTER THE EXCERPT LENGTH Customizable excerpt length @since 2.0.0 ==================================================== */ if (!function_exists('amble_excerpt_length')) { function amble_excerpt_length($length) { if (is_admin()) { return $length; } $excerpt_length = esc_attr(get_theme_mod('amble_excerpt_length', '25')); return $excerpt_length; // phpcs:ignore WordPress.Security.EscapeOutput } } add_filter('excerpt_length', 'amble_excerpt_length', 99); /* FILTER THE EXCERPT SUFFIX Replaces the default [...] with a … (three dots) @since 2.0.0 ==================================================== */ if (!function_exists('amble_excerpt_more')) : function amble_excerpt_more() { return '…'; } add_filter('excerpt_more', 'amble_excerpt_more'); endif; /* CREATE A CONTINUE READING LINK FOR EXCERPTS @since 2.0.0 ==================================================== */ if (!function_exists('amble_read_more_link')) : function amble_read_more_link() { $amble_readmore_text = esc_html(get_theme_mod('amble_readmore_text', esc_html__('Continue Reading...', 'amble'))); echo ''; } endif; /* MOVE READ MORE LINK OUTSIDE OF PARAGRAPHS Move the 'continue reading' link outside of paragraph. @since 2.0.0 ==================================================== */ if (!function_exists('amble_move_more_link')) : function amble_move_more_link() { $amble_readmore_text = esc_html(get_theme_mod('amble_readmore_text', esc_html__('Continue Reading...', 'amble'))); return '

' . wp_kses_post($amble_readmore_text) . '

'; } add_filter('the_content_more_link', 'amble_move_more_link'); endif; /* INSERT FORMATS TO DROP DOWN - CLASSIC EDITOR @since 2.0.0 ==================================================== */ if (!function_exists('insert_formats_to_editor')) : function insert_formats_to_editor($init_array) { // Define the style_formats array $style_formats = array( // Each array child is a format with it's own settings array( 'title' => esc_html__('Extra Small', 'amble'), 'inline' => 'span', 'classes' => 'has-extra-small-font-size', 'wrapper' => true ), array( 'title' => esc_html__('Small', 'amble'), 'inline' => 'span', 'classes' => 'has-small-font-size', 'wrapper' => true ), array( 'title' => esc_html__('Medium', 'amble'), 'inline' => 'span', 'classes' => 'has-medium-font-size', 'wrapper' => true ), array( 'title' => esc_html__('Large', 'amble'), 'inline' => 'span', 'classes' => 'has-large-font-size', 'wrapper' => true ), array( 'title' => esc_html__('Extra Large', 'amble'), 'inline' => 'span', 'classes' => 'has-extra-large-font-size', 'wrapper' => true ), array( 'title' => esc_html__('Huge', 'amble'), 'inline' => 'span', 'classes' => 'has-huge-font-size', 'wrapper' => true ), array( 'title' => esc_html__('Gigantic', 'amble'), 'block' => 'span', 'classes' => 'has-gigantic-font-size', 'wrapper' => true ) ); // Insert the array, JSON ENCODED, into 'style_formats' $init_array['style_formats'] = json_encode($style_formats); return $init_array; } endif; add_filter('tiny_mce_before_init', 'insert_formats_to_editor'); /* ADD STYLE DROP DOWN TO CLASSIC EDITOR @since 2.0.0 ==================================================== */ if (!function_exists('amble_mce_buttons_2')) : function amble_mce_buttons_2($buttons) { array_unshift($buttons, 'styleselect'); return $buttons; // phpcs:ignore WordPress.Security.EscapeOutput } endif; add_filter('mce_buttons_2', 'amble_mce_buttons_2'); /* DISPLAY SVG ICONS IN MENU @since 2.0.0 ==================================================== */ function amble_nav_menu_social_icons($item_output, $item, $depth, $args) { // Change SVG icon inside social links menu if there is supported URL. if ('social' === $args->theme_location) { $svg = Amble_SVG_Icons::get_social_link_svg($item->url); if (empty($svg)) { $svg = amble_get_theme_svg('link'); } $item_output = str_replace($args->link_after, '' . $svg, $item_output); } return $item_output; // phpcs:ignore WordPress.Security.EscapeOutput } add_filter('walker_nav_menu_start_el', 'amble_nav_menu_social_icons', 10, 4); /* CONVERT HEX to RGBA @since 2.0.0 ==================================================== */ if (!function_exists('hex2rgba')) : function hex2rgba($color, $opacity = 1, $css = false) { if (empty($color)) return; $color = str_replace('#', '', $color); if (strlen($color) == 6) { $r = hexdec($color[0] . $color[1]); $g = hexdec($color[2] . $color[3]); $b = hexdec($color[4] . $color[5]); } elseif (strlen($color) == 3) { $r = hexdec($color[0] . $color[0]); $g = hexdec($color[1] . $color[1]); $b = hexdec($color[2] . $color[2]); } else { return false; } $opacity = floatval($opacity); if ($css) return 'rgba( ' . esc_attr($r) . ', ' . esc_attr($g) . ', ' . esc_attr($b) . ', ' . esc_attr($opacity) . ' )'; else return compact(esc_attr($r), esc_attr($g), esc_attr($b), esc_attr($opacity)); } endif; /* INLINE COLOUR PRESETS ====================================================*/ if (!function_exists('amble_colour_presets')) : function amble_colour_presets() { $amble_presets = get_theme_mod('amble_presets', 'preset1'); switch (esc_attr($amble_presets)) { case "preset12": echo '--amble-primary: #b16060; --amble-secondary: #854c4c; --amble-tertiary: #c35249; --amble-body: #445062;'; break; case "preset11": echo '--amble-primary: #9ea7af; --amble-secondary: #87939f; --amble-tertiary: #d56a62; --amble-body: #e4e5e7;'; break; case "preset10": echo '--amble-primary: #ba8300; --amble-secondary: #ffba19; --amble-tertiary: #2c66e5; --amble-body: #dbd6d0;'; break; case "preset9": echo '--amble-primary: #b19d8d; --amble-secondary: #9d8775; --amble-tertiary: #53a0ad; --amble-body: #6f8387;'; break; case "preset8": echo '--amble-primary: #75a558; --amble-secondary: #abdf8b; --amble-tertiary: #c5613b; --amble-body: #97a390;'; break; case "preset7": echo '--amble-primary: #bd4b6e; --amble-secondary: #e57597; --amble-tertiary: #ab3169; --amble-body: #bfb8ba;'; break; case "preset6": echo '--amble-primary: #bda74b; --amble-secondary: #ffe680; --amble-tertiary: #6e80d7; --amble-body: #d7d5cf;'; break; case "preset5": echo '--amble-primary: #3f83bd; --amble-secondary: #6ebbff; --amble-tertiary: #bd8c3e; --amble-body: #3e5466;'; break; case "preset4": echo '--amble-primary: #bd561e; --amble-secondary: #ff8442; --amble-tertiary: #1ebdb7; --amble-body: #c9d3d2;'; break; case "preset3": echo '--amble-primary: #758870; --amble-secondary: #6b7c8b; --amble-tertiary: #365647; --amble-body: #c0c9c4;'; break; case "preset2": echo '--amble-primary: #58bdad; --amble-secondary: #bd7559; --amble-tertiary: #2a7064; --amble-body: #e1e6e7;'; break; default: echo '--amble-primary: #bba579; --amble-secondary: #c6975e; --amble-tertiary: #2b789b; --amble-body: #465156;'; } } endif; /* BLOG NAVIGATION Navigation for the blog @since 2.0.0 ==================================================== */ if (!function_exists('amble_blog_nav')) : function amble_blog_nav() { the_posts_pagination(array( 'prev_text' => is_rtl() ? amble_get_theme_svg('caret-right') : amble_get_theme_svg('caret-left'), 'next_text' => is_rtl() ? amble_get_theme_svg('caret-left') : amble_get_theme_svg('caret-right'), 'before_page_number' => '' )); } endif; /* POST NAVIGATION Navigation for full posts. @since 2.0.0 ==================================================== */ if (!function_exists('amble_post_pagination')) : function amble_post_pagination() { the_post_navigation(array( 'next_text' => '' . (is_singular('post') ? esc_html__('Next post', 'amble') : esc_html__('Next', 'amble')) . ' %title', 'prev_text' => '' . (is_singular('post') ? esc_html__('Previous post', 'amble') : esc_html__('Previous', 'amble')) . ' %title', )); } endif; /* MULTIPAGE NAVIGATION Navigation for splitting posts or pages into more than one page. @since 2.0.0 ==================================================== */ if (!function_exists('amble_multipage_pagination')) : function amble_multipage_pagination() { wp_link_pages(array( 'before' => '', 'link_before' => '', 'link_after' => '', 'pagelink' => '%', 'separator' => false, )); } endif;