Skip to content

Add support for custom mobile URL. #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions includes/metaboxes/video-backgrounds/video-backgrounds.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ function mp_stacks_video_backgrounds_additional_items_array( $items_array ) {
'field_conditional_values' => array( 'custom' ),
'field_showhider' => 'brick_bg_video_showhider'
),
'mp_stacks_video_backgrounds_custom_mobile_option' => array(
'field_id' => 'brick_bg_video_custom_mobile_option',
'field_title' => __( 'Custom URL for Mobile?', 'mp_stacks'),
'field_description' => 'Do you want to set a separate custom URL for mobile?' ,
'field_type' => 'checkbox',
'field_value' => '',
'field_showhider' => 'brick_bg_video_showhider'
),
'mp_stacks_video_backgrounds_custom_mobile_url' => array(
'field_id' => 'brick_bg_video_custom_mobile_url',
'field_title' => __( 'Background Video URL for Mobile', 'mp_stacks'),
'field_description' => 'Upload/Enter the URL to the video',
'field_type' => 'mediaupload',
'field_value' => '',
'field_conditional_id' => 'brick_bg_video_custom_mobile_option',
'field_conditional_values' => array( 'true' ),
'field_showhider' => 'brick_bg_video_showhider'
),
'mp_stacks_video_backgrounds_color_overlay' => array(
'field_id' => 'brick_bg_video_color_overlay',
'field_title' => __( 'Color Overlay', 'mp_stacks'),
Expand Down
14 changes: 10 additions & 4 deletions includes/misc-functions/mp-stacks-hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
function mp_stacks_video_background( $html_output, $post_id ){

$brick_bg_video_source = mp_core_get_post_meta( $post_id, 'brick_bg_video_source' );
$brick_bg_video_custom_mobile_option = mp_core_get_post_meta( $post_id, 'brick_bg_video_custom_mobile_option' );

$foreign_video_url = mp_core_get_post_meta( $post_id, 'brick_bg_video' );
$custom_video_url = mp_core_get_post_meta( $post_id, 'brick_bg_video_custom_url' );
Expand All @@ -34,16 +35,22 @@ function mp_stacks_video_background( $html_output, $post_id ){
$color_overlay = mp_core_get_post_meta( $post_id, 'brick_bg_video_color_overlay', 'none' );
$color_opacity = mp_core_get_post_meta( $post_id, 'brick_bg_video_color_opacity', 50 );
$color_opacity = $color_opacity / 100;
$custom_mobile_video_url = mp_core_get_post_meta( $post_id, 'brick_bg_video_custom_mobile_url' );


//Convert to rgb from hex
$color_overlay_rgb_array = $color_overlay != 'none' ? mp_core_hex2rgb($color_overlay) : NULL;


//If this is an iphone or ipad, we don't want to show any video background cause it can't handle it
if ( $brick_bg_video_source != 'custom' && ( mp_core_is_iphone() || mp_core_is_ipad() ) ){
return false;
//If this is an iPhone or iPad and $brick_bg_video_custom_mobile_option is true and $custom_mobile_video_url is set
if ( $brick_bg_video_custom_mobile_option && !empty( $custom_mobile_video_url ) && ( mp_core_is_iphone() || mp_core_is_ipad() ) ){
//Use the same functions for the normal circumstance, just change the variables
$custom_video_url = $custom_mobile_video_url;
$foreign_video_url = '';
$brick_bg_video_source == 'custom';
}


//If a background video has been entered
if ( !empty( $foreign_video_url ) || !empty( $custom_video_url ) ){

Expand All @@ -52,7 +59,6 @@ function mp_stacks_video_background( $html_output, $post_id ){

//Video Container div
$html_output .= '<div class="mp-stacks-video-backgrounds-container" style="position:relative;">';

//If a color overlay has been set
if ( !empty( $color_overlay_rgb_array ) ){

Expand Down