Created
November 28, 2019 01:38
-
-
Save Longkt/f004367808c2597a5a1bad2b5fafd2ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function custom_screenr_page_header_cover() { | |
if ( is_page_template( 'template-frontpage.php' ) ) { | |
return false; | |
} | |
$image = $title = $desc = ''; | |
if ( is_singular() && ! is_attachment() ) { | |
if ( is_single() ) { | |
$title = esc_html( get_theme_mod( 'page_blog_title', esc_html__( 'The Blog', 'screenr' ) ) ); | |
} else { | |
$title = get_the_title(); | |
} | |
} elseif ( is_search() ) { | |
$title = sprintf( esc_html__( 'Search Results for: %s', 'screenr' ), '<span>' . esc_html( get_search_query() ) . '</span>' ); | |
} elseif ( ( is_home() || is_front_page() ) && ! is_attachment() ) { | |
$title = esc_html( get_theme_mod( 'page_blog_title', esc_html__( 'The Blog', 'screenr' ) ) ); | |
} elseif ( is_404() ) { | |
$title = sprintf( esc_html__( '%s 404 Not Found!', 'screenr' ), '<i class="fa fa-frown-o"></i><br>' ); | |
} else { | |
$title = get_the_archive_title(); | |
$desc = get_the_archive_description(); | |
} | |
if ( function_exists( 'is_woocommerce' ) ) { | |
if ( is_shop() || is_singular( 'product' ) ) { | |
$title = get_the_title( wc_get_page_id( 'shop' ) ); | |
} | |
if ( is_product_category() || is_product_tag() ) { | |
$title = single_term_title( '', false ); | |
} | |
} | |
if ( ! $image ) { | |
$image = get_header_image(); | |
} | |
$is_parallax = true; | |
$item = array( | |
'position' => 'center', | |
'pd_top' => get_theme_mod( 'page_header_pdtop' ) == '' ? 13 : get_theme_mod( 'page_header_pdtop' ), | |
'pd_bottom' => get_theme_mod( 'page_header_pdbottom' ) == '' ? 13 : get_theme_mod( 'page_header_pdbottom' ), | |
'title' => $title, | |
'desc' => $desc, | |
'image' => $image, | |
); | |
$classes = array( | |
'section-slider', | |
'swiper-slider', | |
); | |
if ( $is_parallax ) { | |
$classes[] = 'fixed'; | |
} | |
$item = apply_filters( 'screenr_page_header_item', $item ); | |
if ( $item['image'] ) { | |
$classes[] = 'has-image'; | |
} else { | |
$classes[] = 'no-image'; | |
} | |
$classes = apply_filters( 'screenr_page_header_cover_class', $classes ); | |
/** | |
* Apply filters hook screenr_page_header_cover_swiper_slider_class. | |
* | |
* @since 1.2.0 | |
*/ | |
$swiper_slide_classes = apply_filters( 'screenr_page_header_cover_swiper_slider_class', array() ); | |
/** | |
* Apply filters hook screenr_page_header_cover_swiper_wrapper_class. | |
* | |
* @since 1.2.0 | |
*/ | |
$swiper_wrapper_classes = apply_filters( 'screenr_page_header_cover_swiper_wrapper_class', array() ); | |
?> | |
<section id="page-header-cover" class="<?php echo esc_attr( join( ' ', $classes ) ); ?>" > | |
<div class="swiper-container" data-autoplay="0"> | |
<div class="swiper-wrapper <?php echo esc_attr( implode( ' ', $swiper_wrapper_classes ) ); ?>"> | |
<?php | |
$style = ''; | |
if ( $item['image'] ) { | |
$style = ' style="background-image: url(\'' . esc_url( $item['image'] ) . '\');" '; | |
} | |
$html = '<div class="swiper-slide slide-align-' . esc_attr( $item['position'] ) . ' ' . esc_attr( implode( ' ', $swiper_slide_classes ) ) . '"' . $style . '>'; | |
$style = ''; | |
if ( $item['pd_top'] != '' ) { | |
$style .= 'padding-top: ' . floatval( $item['pd_top'] ) . '%; '; | |
} | |
if ( $item['pd_bottom'] != '' ) { | |
$style .= 'padding-bottom: ' . floatval( $item['pd_bottom'] ) . '%; '; | |
} | |
if ( $style != '' ) { | |
$style = ' style="' . $style . '" '; | |
} | |
$html .= '<div class="swiper-slide-intro">'; | |
$html .= '<div class="swiper-intro-inner"' . $style . '>'; | |
if ( $item['title'] ) { | |
$html .= '<h1 class="swiper-slide-heading">' . wp_kses_post( $item['title'] ) . '</h1>'; | |
} | |
if ( $item['desc'] ) { | |
$html .= '<div class="swiper-slide-desc">' . apply_filters( 'screenr_content_text', $item['desc'] ) . '</div>'; | |
} | |
$html .= '</div>'; | |
$html .= '</div>'; | |
$html .= '<div class="overlay"></div>'; | |
$html .= '</div>'; | |
echo $html; | |
?> | |
</div> | |
</div> | |
</section> | |
<?php | |
} | |
add_action( 'init', function() { | |
remove_action( 'screenr_after_site_header', 'screenr_page_header_cover' ); | |
add_action( 'screenr_after_site_header', 'custom_screenr_page_header_cover' ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment