| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /inetpub/wwwroot/cdc/wp-content/plugins/siteorigin-panels/compat/ |
Upload File : |
<?php
/**
* Apply background and Lazy Load attributes/classes to rows, cells and widgets.
*
* @return array $attributes
*/
function siteorigin_apply_lazy_load_attributes( $attributes, $style ) {
if (
! empty( $style['background_display'] ) &&
! empty( $style['background_image_attachment'] ) &&
$style['background_display'] != 'parallax' &&
$style['background_display'] != 'parallax-original' &&
// When there's an overlay, the image is painted (and lazy loaded) on the
// overlay div only. Tagging the style div here would let the lazy loader
// re-add the image the plugin deliberately strips, defeating the opacity.
! SiteOrigin_Panels_Styles::has_overlay( array( 'style' => $style ) )
) {
$url = SiteOrigin_Panels_Styles::get_attachment_image_src( $style['background_image_attachment'], 'full' );
if ( ! empty( $url ) ) {
$attributes['class'][] = 'lazy';
$attributes['data-bg'] = $url[0];
// WP Rocket uses a different lazy load class.
if ( defined( 'ROCKET_LL_VERSION' ) || function_exists( 'get_rocket_option' ) ) {
$attributes['class'][] = 'rocket-lazyload';
}
// Other lazy loads can sometimes use an inline background image.
if ( apply_filters( 'siteorigin_lazy_load_inline_background', false ) ) {
$attributes['style'] = 'background-image: url(' . $url[0] . ')';
}
}
}
return $attributes;
}
add_filter( 'siteorigin_panels_row_style_attributes', 'siteorigin_apply_lazy_load_attributes', 10, 2 );
add_filter( 'siteorigin_panels_cell_style_attributes', 'siteorigin_apply_lazy_load_attributes', 10, 2 );
add_filter( 'siteorigin_panels_widget_style_attributes', 'siteorigin_apply_lazy_load_attributes', 10, 2 );
/**
* Prevent background image from being added using CSS.
*
* @return mixed
*/
function siteorigin_prevent_background_css( $css, $style ) {
if (
! empty( $css['background-image'] ) &&
$style['background_display'] != 'parallax' &&
$style['background_display'] != 'parallax-original'
) {
unset( $css['background-image'] );
}
return $css;
}
add_filter( 'siteorigin_panels_row_style_css', 'siteorigin_prevent_background_css', 10, 2 );
add_filter( 'siteorigin_panels_cell_style_css', 'siteorigin_prevent_background_css', 10, 2 );
add_filter( 'siteorigin_panels_widget_style_css', 'siteorigin_prevent_background_css', 10, 2 );