Created
June 16, 2018 05:24
-
-
Save congthien/1ef90ba867bd9bc80d1111118318462e 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 onepress_before_section( $section_id, $args = array() ){ | |
if ( ! isset( $args['_bg_type'] ) ) { | |
$args['_bg_type'] = ''; | |
} | |
if ( ! class_exists( 'OnePress_Plus' ) ) { | |
if ( $section_id == 'videolightbox' ) { | |
$image = onepress_get_video_lightbox_image(); | |
if ( $image || onepress_is_selective_refresh() ) { | |
echo '<div class="section-parallax">'; | |
echo ' <div class="parallax-bg"><img src="' . esc_url($image) . '" alt=""></div>'; | |
} | |
return ; | |
} | |
} | |
switch( $args['_bg_type'] ) { | |
case 'video': | |
$args = wp_parse_args( $args, array( | |
'video_url' => '', | |
'video_webm_url' => '', | |
'video_ogv_url' => '', | |
'image' => '' | |
) ); | |
extract( $args ); | |
if ( $video_url || $video_webm_url || $video_ogv_url ) { | |
?> | |
<div class="video-section" | |
data-mp4="<?php echo esc_url( $video_url ); ?>" | |
data-webm="<?php echo esc_url( $video_webm_url ); ?>" | |
data-ogv="<?php echo esc_url( $video_ogv_url ); ?>" | |
data-bg="<?php echo esc_attr( $image ); ?>"> | |
<?php | |
} | |
break; | |
case 'image': | |
$args = wp_parse_args( $args, array( | |
'image' => '', | |
'alpha' => '', | |
'enable_parallax' => '' | |
) ); | |
extract( $args ); | |
if ( $enable_parallax == 1 ) { | |
$class = 'section-parallax'; | |
if( $section_id == 'hero' ){ | |
$class =' parallax-hero'; | |
} | |
echo '<div id="parallax-'.esc_attr( $section_id ).'" class="'.esc_attr( $class ).'">'; | |
echo ' <div class="parallax-bg"><img src="'.esc_url( $image ).'" alt=""></div>'; | |
} else if ( $image || $alpha ) { // image bg | |
echo '<div id="bgimage-'.esc_attr( $section_id ).'" class="bgimage-alpha bgimage-'.esc_attr( $section_id ).'">'; | |
} | |
break; | |
}// end switch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment