*/ /** * Get Logo and show * * This function is called by canuck_header(). * It checks to see if there is a header image from Appearance => Header if there it loads it. * If blank then a nothing is loaded. * * WordPress Functions used - see WordPress Codex * * @uses get_header_image() @uses home_url( '/' ) @uses header_image() * @uses get_custom_header() @uses get_template_directory_uri() */ function canuck_show_logo() { $custom_logo_id = get_theme_mod( 'custom_logo' ); $logo = wp_get_attachment_image_src( $custom_logo_id, 'full' ); if ( has_custom_logo() ) { ?> <?php esc_attr_e( 'logo', 'canuck' ); ?> 'canuck_primary', 'container_class' => 'main-nav', 'container_id' => 'main-menu-right', 'menu_class' => 'main-menu', 'menu_id' => 'main-menu-ul', 'depth' => 4, 'fallback_cb' => 'false', ) ); } /** * Side Menu 1 function * * This function sets up social menu 1. * WordPress Functions - See the Codex. * * @param string $position is the position of the menu. * @uses has_nav_menu() @uses wp_nav_menu() */ function canuck_social_menu( $position ) { $containerid = 'social-nav-id-' . $position; $menuid = 'social-menu-id-' . $position; wp_nav_menu( array( 'theme_location' => 'canuck_social', 'container_class' => 'social-nav-class', 'container_id' => $containerid, 'menu_class' => 'social-menu-class', 'menu_id' => $menuid, 'depth' => 1, 'link_before' => '', 'link_after' => '', 'item_spacing' => 'discard', 'fallback_cb' => 'false', ) ); } /** * The wpautop filter fix. * * Description: Fix issues when shortcodes are embedded in a block of content that is filtered by wpautop. * Author URI: http://www.johannheyne.de. * * @param string $content is the content of the post. */ function canuck_shortcode_paragraph_insertion_fix( $content ) { $array = array( '

[' => '[', ']

' => ']', ']
' => ']', ']
' => ']', '

' => '', ); $content = strtr( $content, $array ); return $content; } add_filter( 'the_content', 'canuck_shortcode_paragraph_insertion_fix' ); /** * Home Page Area Selection Helper * * This function is called by template-home.php and is used to set up * the area variables on the the home page. * * @param string $area_select - section selected wor the home page area. * @return $area_select - simplified form of template part */ function canuck_home_area_selection( $area_select ) { if ( 'Section 1' === $area_select ) { $area_select = 'one'; } elseif ( 'Section 2' === $area_select ) { $area_select = 'two'; } elseif ( 'Section 3' === $area_select ) { $area_select = 'three'; } elseif ( 'Section 4' === $area_select ) { $area_select = 'four'; } elseif ( 'Section 5' === $area_select ) { $area_select = 'five'; } elseif ( 'Section 6' === $area_select ) { $area_select = 'six'; } elseif ( 'Section 7' === $area_select ) { $area_select = 'seven'; } elseif ( 'Section 8' === $area_select ) { $area_select = 'eight'; } elseif ( 'Section 9' === $area_select ) { $area_select = 'nine'; } elseif ( 'Section 10' === $area_select ) { $area_select = 'ten'; } elseif ( 'Section 11' === $area_select ) { $area_select = 'eleven'; } elseif ( 'Section 12' === $area_select ) { $area_select = 'twelve'; } elseif ( 'Section 13' === $area_select ) { $area_select = 'thirteen'; } else { $area_select = 'none'; } return $area_select; } /** * Home Page Section Options * * This function is called by template-home.php and is used to set up * the optional sections for the static home page * * @uses canuck_home_area_selection() in this file * @uses get_template_part() see WordPress Codex */ function canuck_home_page_sections() { $area_1 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_1', 'none' ) ) ); $area_2 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_2', 'none' ) ) ); $area_3 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_3', 'none' ) ) ); $area_4 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_4', 'none' ) ) ); $area_5 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_5', 'none' ) ) ); $area_6 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_6', 'none' ) ) ); $area_7 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_7', 'none' ) ) ); $area_8 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_8', 'none' ) ) ); $area_9 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_9', 'none' ) ) ); $area_10 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_10', 'none' ) ) ); $area_11 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_11', 'none' ) ) ); $area_12 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_12', 'none' ) ) ); $area_13 = esc_html( canuck_home_area_selection( get_theme_mod( 'canuck_home_area_13', 'none' ) ) ); if ( 'none' !== $area_1 ) { get_template_part( '/template-parts/static_home-parts/home', $area_1 ); } if ( 'none' !== $area_2 ) { get_template_part( '/template-parts/static_home-parts/home', $area_2 ); } if ( 'none' !== $area_3 ) { get_template_part( '/template-parts/static_home-parts/home', $area_3 ); } if ( 'none' !== $area_4 ) { get_template_part( '/template-parts/static_home-parts/home', $area_4 ); } if ( 'none' !== $area_5 ) { get_template_part( '/template-parts/static_home-parts/home', $area_5 ); } if ( 'none' !== $area_6 ) { get_template_part( '/template-parts/static_home-parts/home', $area_6 ); } if ( 'none' !== $area_7 ) { get_template_part( '/template-parts/static_home-parts/home', $area_7 ); } if ( 'none' !== $area_8 ) { get_template_part( '/template-parts/static_home-parts/home', $area_8 ); } if ( 'none' !== $area_9 ) { get_template_part( '/template-parts/static_home-parts/home', $area_9 ); } if ( 'none' !== $area_10 ) { get_template_part( '/template-parts/static_home-parts/home', $area_10 ); } if ( 'none' !== $area_11 ) { get_template_part( '/template-parts/static_home-parts/home', $area_11 ); } if ( 'none' !== $area_12 ) { get_template_part( '/template-parts/static_home-parts/home', $area_12 ); } if ( 'none' !== $area_13 ) { get_template_part( '/template-parts/static_home-parts/home', $area_13 ); } } /** * Simple array for how custom home sections are set up. * This is used to figure out the section overlay margins. * It sets up an array of the stacked section numbers used. */ function canuck_home_area_setup() { $home_area_setup = array(); $home_area_setup[1] = get_theme_mod( 'canuck_home_area_1', 'none' ); $home_area_setup[2] = get_theme_mod( 'canuck_home_area_2', 'none' ); $home_area_setup[3] = get_theme_mod( 'canuck_home_area_3', 'none' ); $home_area_setup[4] = get_theme_mod( 'canuck_home_area_4', 'none' ); $home_area_setup[5] = get_theme_mod( 'canuck_home_area_5', 'none' ); $home_area_setup[6] = get_theme_mod( 'canuck_home_area_6', 'none' ); $home_area_setup[7] = get_theme_mod( 'canuck_home_area_7', 'none' ); $home_area_setup[8] = get_theme_mod( 'canuck_home_area_8', 'none' ); $home_area_setup[9] = get_theme_mod( 'canuck_home_area_9', 'none' ); $home_area_setup[10] = get_theme_mod( 'canuck_home_area_10', 'none' ); $home_area_setup[11] = get_theme_mod( 'canuck_home_area_11', 'none' ); $home_area_setup[12] = get_theme_mod( 'canuck_home_area_12', 'none' ); $home_area_setup[13] = get_theme_mod( 'canuck_home_area_13', 'none' ); $home_final_setup = array(); $count = 1; //var_dump($home_area_setup); foreach ( $home_area_setup as $area => $section ) { if ( 'none' !== $section ) { $home_final_setup[ $count ] = str_ireplace( 'Section ', '', $section ); $count++; } } return $home_final_setup; } /** * Function to use Justin Tadlocks Breadcrumb Trail */ function canuck_custom_breadcrumbs() { // Breadcrumb args. $breadcrumb_args = array( 'container' => 'nav', 'before' => '', 'after' => '', 'show_on_front' => false, 'network' => false, 'show_title' => true, 'show_browse' => false, 'echo' => true, 'labels' => array( 'browse' => esc_html__( 'Browse:', 'canuck' ), 'aria_label' => esc_attr_x( 'Breadcrumbs', 'breadcrumbs aria label', 'canuck' ), 'home' => '', 'error_404' => esc_html__( '404 Not Found', 'canuck' ), 'archives' => esc_html__( 'Archives', 'canuck' ), // Translators: %s is the search query. The HTML entities are opening and closing curly quotes. 'search' => esc_html__( 'Search results for “%s”', 'canuck' ), // Translators: %s is the page number. 'paged' => esc_html__( 'Page %s', 'canuck' ), // Translators: Minute archive title. %s is the minute time format. 'archive_minute' => esc_html__( 'Minute %s', 'canuck' ), // Translators: Weekly archive title. %s is the week date format. 'archive_week' => esc_html__( 'Week %s', 'canuck' ), // "%s" is replaced with the translated date/time format. 'archive_minute_hour' => '%s', 'archive_hour' => '%s', 'archive_day' => '%s', 'archive_month' => '%s', 'archive_year' => '%s', ), ); if ( function_exists( 'breadcrumb_trail' ) ) { breadcrumb_trail( $breadcrumb_args ); } } /** * Extract embed from selected content * * Modified from wp_extract_urls() in /wp-includes/functions.php * * Add content between . The function extracts * the content between these tags and then and returns it as a string. * format quote|author|author link. * example Only one thing is impossible for God: To find any sense in any copyright law on the planet.|Mark Twain|http://www.brainyquote.com/quotes/quotes/m/marktwain163473.html. * * @param string $content is the post content. */ function canuck_extract_embed( $content ) { $pattern = "/\(.*?)\<\/q\>/s";// phpcs:ignore preg_match( $pattern, $content, $embed_string ); if ( $embed_string ) { if ( $embed_string[0] ) { $embed_string[0] = str_replace( '', '', $embed_string[0] ); } if ( $embed_string[0] ) { $embed_string[0] = str_replace( '', '', $embed_string[0] ); } return $embed_string[0]; } else { return false; } } /** * Remove content from first tags and return it for display * * @param string $content is the post content. */ function canuck_strip_extracted_quote( $content ) { $pattern = "/\(.*?)\<\/q\>/s";// phpcs:ignore preg_match( $pattern, $content, $text_to_search ); if ( isset( $text_to_search[0] ) ) { $content = str_replace( $text_to_search[0], '', $content ); } $content = str_replace( '

', '', $content ); return $content; } /** * Add Image Title to link on images. * * @param string $link link to post. * @param int $id post id. */ function canuck_add_title_attachment_link( $link, $id = null ) { $id = intval( $id ); $_post = get_post( $id ); $post_title = esc_attr( $_post->post_title ); return str_replace( ' array( 'type' => 'google', 'enqueue' => 'Open+Sans:300,400', 'family' => "'Open Sans', 'Lucida Sans', sans-serif", ), 'default' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => 'none', ), 'Arial' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => 'Arial, sans-serif', ), 'Artifika' => array( 'type' => 'google', 'enqueue' => 'Artifika:400,400i', 'family' => 'Artifika, Cambria, serif', ), 'Arvo' => array( 'type' => 'google', 'enqueue' => 'Arvo:400,400i', 'family' => "Arvo, 'Courier New', serif", ), 'Book Antiqua' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => "'Book Antiqua', serif", ), 'Bubbler One' => array( 'type' => 'google', 'enqueue' => 'Bubbler+One', 'family' => "'Bubbler One', 'Courier New', sans-serif", ), 'Cabin' => array( 'type' => 'google', 'enqueue' => 'Cabin:400,400i', 'family' => 'Cabin, Tahoma, sans-serif', ), 'Cambria' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => 'Cambria, serif', ), 'Comic Sans MS' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => "'Comic Sans MS', sans-serif", ), 'Corben' => array( 'type' => 'google', 'enqueue' => 'Corben', 'family' => "Corben, 'Book Antiqua', cursive", ), 'Droid Sans' => array( 'type' => 'google', 'enqueue' => 'Droid+Sans:400,400i', 'family' => "'Droid Sans', Tahoma, sans-serif", ), 'Droid Serif' => array( 'type' => 'google', 'enqueue' => 'Droid+Serif:400,400i', 'family' => "'Droid Serif', Cambria, serif", ), 'Great Vibes' => array( 'type' => 'google', 'enqueue' => 'Great+Vibes', 'family' => "'Great Vibes', cursive", ), 'Georgia' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => 'Georgia, serif', ), 'Josefin Sans' => array( 'type' => 'google', 'enqueue' => 'Josefin+Sans:400,400i', 'family' => "'Josefin Sans', Tahoma, serif", ), 'Josefin Slab' => array( 'type' => 'google', 'enqueue' => 'Josefin+Slab:400,400i', 'family' => "'Josefin Slab', 'Courier New', serif", ), 'Karla' => array( 'type' => 'google', 'enqueue' => 'Karla:400,400i', 'family' => 'Karla, Arial, sans-serif', ), 'Lato' => array( 'type' => 'google', 'enqueue' => 'Lato:400,400i', 'family' => 'Lato, Arial,sans-serif', ), 'Lobster' => array( 'type' => 'google', 'enqueue' => 'Lobster', 'family' => 'Lobster, cursive', ), 'Old Standard TT' => array( 'type' => 'google', 'enqueue' => 'Old+Standard+TT:400,400i', 'family' => "'Old Standard TT', 'Times New Roman', serif", ), 'Playfair Display SC' => array( 'type' => 'google', 'enqueue' => 'Playfair+Display+SC', 'family' => "'Playfair Display SC', 'Book Antiqua', serif", ), 'PT Sans' => array( 'type' => 'google', 'enqueue' => 'PT+Sans:400,400i', 'family' => "'PT Sans', 'Trebuchet MS', sans-serif", ), 'PT Serif' => array( 'type' => 'google', 'enqueue' => 'PT+Serif:400,400i', 'family' => "'PT Serif', Cambria, serif", ), 'Puritan' => array( 'type' => 'google', 'enqueue' => 'Puritan:400,400i', 'family' => 'Puritan, Arial, sans-serif', ), 'Raleway' => array( 'type' => 'google', 'enqueue' => 'Raleway:300,300i', 'family' => 'Raleway, Tahoma, sans-serif', ), 'Rock Salt' => array( 'type' => 'google', 'enqueue' => 'Rock+Salt', 'family' => "'Rock Salt', cursive", ), 'Tahoma' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => 'Tahoma, sans-serif', ), 'Times New Roman' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => "'Times New Roman', serif", ), 'Titillium Web' => array( 'type' => 'google', 'enqueue' => 'Titillium+Web:400,400i', 'family' => "'Titillium Web', Tahoma, sans-serif", ), 'Trebuchet MS' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => "'Trebuchet MS', sans-serif", ), 'Ubuntu' => array( 'type' => 'google', 'enqueue' => 'Ubuntu:400,400i', 'family' => 'Ubuntu, Tahoma, sans-serif', ), 'Verdana' => array( 'type' => 'standard', 'enqueue' => 'none', 'family' => 'Verdana, sans-serif', ), 'Vollkorn' => array( 'type' => 'google', 'enqueue' => 'Vollkorn:400,400i', 'family' => "Vollkorn, 'Times New Roman', serif", ), ); $theme_fonts = array( 'header' => array( 'type' => $fonts[ $header_font ]['type'], 'enqueue' => $fonts[ $header_font ]['enqueue'], 'family' => $fonts[ $header_font ]['family'], ), 'body' => array( 'type' => $fonts[ $body_font ]['type'], 'enqueue' => $fonts[ $body_font ]['enqueue'], 'family' => $fonts[ $body_font ]['family'], ), 'page' => array( 'type' => $fonts[ $page_title_font ]['type'], 'enqueue' => $fonts[ $page_title_font ]['enqueue'], 'family' => $fonts[ $page_title_font ]['family'], ), ); return $theme_fonts; } /** * filter to remove selected categories from archive * * Source: https://stackoverflow.com/questions/2789228/exclude-category-from-wp-get-archives/5945750#5945750 * Before Use: add_filter( 'getarchives_where', 'canuck_customarchives_where' ); to set up use * After Use: remove_filter( 'getarchives_where', 'canuck_customarchives_where' ); */ function canuck_customarchives_where( $x ) { // Get exclude ids. $exclude_ids = canuck_exclude_category_validation(); global $wpdb; $exclude = $exclude_ids; // category id to exclude return $x . " AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->term_taxonomy.term_id NOT IN ($exclude)"; } /** * filter to exclude selected categories from archive * * Before Use: add_filter( 'getarchives_join', 'canuck_customarchives_join' ); to execute * After Use: remove_filter( 'getarchives_join', 'canuck_customarchives_join' ); */ function canuck_customarchives_join( $x ) { global $wpdb; return $x . " INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id) INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)"; } /** * Remove content from first tags and return it for display */ if ( ! function_exists( 'canuck_strip_first_block_gallery' ) ) { function canuck_strip_first_block_gallery( $content ) { $pattern = "/\