* @copyright Copyright (c) 2018, Chris Baldelomar * @link https://webplantmedia.com/product/brimstone-wordpress-theme/ * @license http://www.gnu.org/licenses/gpl-2.0.html */ /** * Adds custom classes to the array of body classes. * * @since Brimstone 1.01 * * @param array $classes * @return array */ function brimstone_body_classes( $classes ) { global $brimstone; // Adds a class of hfeed to non-singular pages. if ( ! is_singular() ) { $classes[] = 'hfeed'; } // Sidebar. if ( brimstone_display_sidebar() ) { $classes[] = 'display-sidebar'; } elseif ( brimstone_display_fullwidth() ) { $classes[] = 'display-fullwidth'; $classes[] = 'no-sidebar'; } else { $classes[] = 'no-sidebar'; } // Footer. if ( brimstone_display_sidebar_footer() ) { $classes[] = 'display-sidebar-footer'; } // Widgetized Pages. if ( is_page_template( 'templates/widgetized-page.php' ) ) { $classes[] = 'widgetized-page'; } if ( $brimstone['show_menu_arrows'] ) { $classes[] = 'show-menu-arrows'; } if ( $brimstone['archive_title_light'] ) { $classes[] = 'archive-title-light'; } if ( $brimstone['footer_text_light'] ) { $classes[] = 'footer-text-light'; } if ( $brimstone['shop_truncate_titles'] ) { $classes[] = 'woocommerce-shop-truncate-titles'; } if ( $brimstone['jetpack_hide_share_count'] ) { $classes[] = 'jetpack-hide-share-count'; } if ( brimstone_is_woocommerce_activated() ) { if ( is_shop() ) { $classes[] = 'woocommerce-shop'; $classes[] = 'woocommerce-shop-columns-' . esc_attr( $brimstone['shop_columns'] ); } elseif ( is_product_taxonomy() ) { $classes[] = 'woocommerce-shop-columns-' . esc_attr( $brimstone['shop_archive_columns'] ); } elseif ( is_product() ) { $classes[] = 'woocommerce-shop-columns-' . esc_attr( $brimstone['shop_related_products_columns'] ); } if ( $brimstone['shop_image_backdrop'] ) { $classes[] = 'woocommerce-shop-image-backdrop'; } } if ( brimstone_display_header_image() ) { $classes[] = 'has-post-thumbnail'; } if ( is_404() ) { if ( 0 !== $brimstone['404_custom_page'] ) { $classes[] = 'has-custom-404-page'; } } return $classes; } add_filter( 'body_class', 'brimstone_body_classes' ); /** * Add a pingback url auto-discovery header for singularly identifiable articles. * * @since Brimstone 1.01 * * @return void */ function brimstone_pingback_header() { if ( is_singular() && pings_open() ) { echo ''; } } add_action( 'wp_head', 'brimstone_pingback_header' ); /** * Add retina src image to custom logo * * @since Brimstone 1.01 * * @param string $html * @param int $blog_id * @return string */ function brimstone_get_custom_logo( $html, $blog_id ) { global $brimstone; if ( is_customize_preview() || is_preview() ) { // fixes obscure bug when admin panel is ssl and front end is not ssl. $brimstone['custom_logo_2x'] = preg_replace( '/^https?:/', '', $brimstone['custom_logo_2x'] ); } if ( ! empty( $brimstone['custom_logo_2x'] ) ) { if ( preg_match( '/srcset=(\'|\").*?(\'|\")/', $html ) ) { $html = preg_replace( '/srcset=(\'|\").*?(\'|\")/', 'srcset="' . esc_url( $brimstone['custom_logo_2x'] ) . ' 2x"', $html ); } else { $html = preg_replace( '/(src=(\'|\").*?(\'|\"))/', '\\1 srcset="' . esc_url( $brimstone['custom_logo_2x'] ) . ' 2x"', $html ); } } return $html; } add_filter( 'get_custom_logo', 'brimstone_get_custom_logo', 10, 2 ); /** * Add "read more" link on all excerpts. * * @since Brimstone 1.01 * * @param string $output * @return string Appended "Read More" link */ function brimstone_read_more_link( $output ) { global $brimstone; if ( ! is_home() && ! is_archive() && ! is_search() ) { return $output; } $class = ''; if ( empty( $output ) ) { $class = ' no-excerpt'; } return $output . sprintf( ' %3$s', esc_attr( $class ), esc_url( get_permalink( get_the_ID() ) ), esc_html( $brimstone['read_more_label'] ) ); } add_filter( 'the_excerpt', 'brimstone_read_more_link' ); /** * Conditional display of read more text. * * @since Brimstone 1.01 * * @return string */ function brimstone_read_more_text() { global $brimstone; if ( 'post' !== get_post_type() ) { return ''; } $excerpt = get_the_excerpt(); if ( empty( $excerpt ) ) { return ''; } return esc_html( $brimstone['read_more_label'] ); } add_filter( 'brimstone_read_more_text', 'brimstone_read_more_text' ); /** * Convert single link line to button. * * @since Brimstone 1.01 * * @param string $output * @param string $button_style * @return string */ function brimstone_button_generation( $output, $button_style ) { $search = array(); $replace = array(); switch ( $button_style ) { case 'button-1': $button_class = ' fancy-button'; break; case 'button-2': $button_class = ' fancy2-button'; break; default: $button_class = ''; break; } if ( preg_match_all( '/\\\s*[^\<].*?\<\/a\><\/p\>/', $output, $matches ) ) { foreach ( $matches as $match ) { foreach ( $match as $html ) { if ( ! preg_match( '/class\=\"|\'/', $html ) ) { $search[] = $html; $replace[] = str_replace( '', $pieces ) . ''; } else { $title = '' . $title . ''; } return $title; } add_filter( 'get_the_archive_title', 'brimstone_get_the_archive_title', 11, 1 );