Skip to content

Commit

Permalink
Merge branch 'release/2.13.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Misplon committed Aug 14, 2021
2 parents fe33337 + f22379c commit 156fd84
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 35 deletions.
30 changes: 30 additions & 0 deletions compat/jetpack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* Prevent Photon from filtering srcset.
* This is done using a method to prevent conflicting with other usage of this filter.
*
* @param $valid
* @param $url
* @param $parsed_url
*
* @return false
*/
function siteorigin_panels_photon_exclude_parallax_srcset( $valid, $url, $parsed_url ) {
return false;
}

/**
* Prevent Photon from overriding parallax images when it calculates srcset and filters the_content.
*
* @param $skip Whether to exclude the iamge from Photon.
* @param $src The URL of the current image
* @param $tag This parameter is unrelaible as it can contain the image tag, or an array containing image values.
*
* @return bool
*/
function siteorigin_panels_photon_exclude_parallax( $skip, $src, $tag ) {
if ( ! is_array( $tag ) && strpos( $tag, 'data-siteorigin-parallax' ) !== false ) {
$skip = true;
}
return $skip;
}
4 changes: 3 additions & 1 deletion compat/layout-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function enqueue_layout_block_editor_assets() {
$panels_admin = SiteOrigin_Panels_Admin::single();
$panels_admin->enqueue_admin_scripts();
$panels_admin->enqueue_admin_styles();
$panels_admin->js_templates();
if ( ! is_customize_preview() ) {
$panels_admin->js_templates();
}

$current_screen = get_current_screen();
wp_enqueue_script(
Expand Down
2 changes: 1 addition & 1 deletion inc/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function __construct() {
add_action( 'load-post-new.php', array( $this, 'add_help_tab' ), 12 );
add_action( 'load-appearance_page_so_panels_home_page', array( $this, 'add_help_tab' ), 12 );

add_action( 'customize_controls_print_footer_scripts', array( $this, 'js_templates' ) );
add_action( 'customize_controls_print_scripts', array( $this, 'js_templates' ) );

// Register all the admin actions
add_action( 'wp_ajax_so_panels_builder_content', array( $this, 'action_builder_content' ) );
Expand Down
35 changes: 3 additions & 32 deletions inc/styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,35 +467,6 @@ static function vantage_row_style_attributes( $attributes, $style ) {
return $attributes;
}

/**
* Prevent Photon from overriding image URL.
* This is done using a method to prevent conflicting with other usage of this filter.
*
* @param $skip
* @param $args
*
* @return true
*/
function jetpack_photon_exclude_modern_parallax_downsize( $skip, $args ) {
return true;
}

/**
* Prevent Photon from overriding parallax images when it calculates srcset and filters the_content.
*
* @param $skip
* @param $src
* @param $tag
*
* @return bool
*/
function jetpack_photon_exclude_modern_parallax_content( $skip, $src, $tag ) {
if ( strpos( $tag, 'data-siteorigin-parallax' ) !== false ) {
$skip = true;
}
return $skip;
}

function add_parallax( $output, $context ) {
if (
! empty( $context['style']['background_display'] ) &&
Expand All @@ -506,9 +477,9 @@ function add_parallax( $output, $context ) {
// Jetpack Image Accelerator (Photon) can result in the parallax being incorrectly sized so we need to exclude it.
$photon_exclude = class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' );
if ( $photon_exclude ) {
add_filter( 'jetpack_photon_override_image_downsize', array( $this, 'jetpack_photon_exclude_modern_parallax_downsize' ), 10, 2 );
add_filter( 'photon_validate_image_url', 'siteorigin_panels_photon_exclude_parallax_srcset', 10, 3 );
// Prevent Photon from overriding the image URL later.
add_filter( 'jetpack_photon_skip_image', array( $this, 'jetpack_photon_exclude_modern_parallax_content' ), 10, 3 );
add_filter( 'jetpack_photon_skip_image', 'siteorigin_panels_photon_exclude_parallax', 10, 3 );
}

$image_html = wp_get_attachment_image(
Expand All @@ -523,7 +494,7 @@ function add_parallax( $output, $context ) {

if ( $photon_exclude ) {
// Restore photon.
remove_filter( 'jetpack_photon_override_image_downsize', array( $this, 'jetpack_photon_exclude_modern_parallax_downsize' ), 10 );
remove_filter( 'photon_validate_image_url', 'siteorigin_panels_photon_exclude_parallax_downsize', 10 );
}

if ( ! empty( $image_html ) ) {
Expand Down
1 change: 0 additions & 1 deletion js/siteorigin-panels/model/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ module.exports = Backbone.Model.extend( {
title = title.replace( /<\/?[^>]+(>|$)/g, "" );
var parts = title.split( " " );
parts = parts.slice( 0, 20 );
console.log(parts);
return parts.join( ' ' );
},

Expand Down
4 changes: 4 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ SiteOrigin Premium includes access to our professional email support service, pe

== Changelog ==

= 2.13.2 - 14 August 2021 =
* Modern Parallax: Resolved potential Jetpack Image Accelerator notice.
* Customizer: Resolved new widget area notice.

= 2.13.1 - 03 August 2021 =
* Modern Parallax: Exclude images from Jetpack Image Accelerator.
* Modern Parallax: Resolved sizing issue when the browser back button was used.
Expand Down
4 changes: 4 additions & 0 deletions siteorigin-panels.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ public function init_compat() {
if ( apply_filters( 'siteorigin_lazyload_compat', $load_lazy_load_compat ) ) {
require_once plugin_dir_path( __FILE__ ) . 'compat/lazy-load-backgrounds.php';
}

if ( siteorigin_panels_setting( 'parallax-type' ) == 'modern' && class_exists( 'Jetpack_Photon' ) && Jetpack::is_module_active( 'photon' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'compat/jetpack.php';
}
}

/**
Expand Down

0 comments on commit 156fd84

Please sign in to comment.