-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: compatibility with Sassy Social share plugin
- Loading branch information
1 parent
ce1c162
commit d4224cb
Showing
3 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
describe( 'Sassy Social Share', function () { | ||
it( 'successfully loads', function () { | ||
cy.visit( '/sassy-social-share/' ) | ||
} ); | ||
it( 'click on button', function () { | ||
cy.get( '.heateorSssSharing.heateorSssPinterestBackground' ).click( { multiple: true } ) | ||
} ); | ||
it( 'images should not have quality:eco', function () { | ||
cy.get( 'img' ).should( ( $imgs ) => { | ||
expect( $imgs ).to.have.length( 5 ) | ||
expect( $imgs.eq( 0 ) ).to.have.attr( 'src' ).and.to.not.contain( 'eco' ) | ||
expect( $imgs.eq( 1 ) ).to.have.attr( 'src' ).and.to.not.contain( 'eco' ) | ||
expect( $imgs.eq( 2 ) ).to.have.attr( 'src' ).and.to.not.contain( 'eco' ) | ||
expect( $imgs.eq( 3 ) ).to.have.attr( 'src' ).and.to.not.contain( 'eco' ) | ||
} ); | ||
} ); | ||
} ); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/** | ||
* Class Optml_sassy_social_share. | ||
* | ||
* @reason Sassy social share picks eco images to share | ||
*/ | ||
class Optml_sassy_social_share extends Optml_compatibility { | ||
/** | ||
* Should we load the integration logic. | ||
* | ||
* @return bool Should we load. | ||
*/ | ||
function should_load() { | ||
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | ||
|
||
if ( ! is_plugin_active( 'sassy-social-share/sassy-social-share.php' ) ) { | ||
return false; | ||
} | ||
$ss_options = get_option( 'heateor_sss' ); | ||
$ss_bars = ['vertical_re_providers', 'horizontal_re_providers']; | ||
if ( ! is_array( $ss_options ) ) { | ||
return false; | ||
} | ||
foreach ( $ss_bars as $key => $bar ) { | ||
if ( ! isset( $ss_options[ $bar ] ) ) { | ||
continue; | ||
} | ||
foreach ( $ss_options[ $bar ] as $index => $value ) { | ||
if ( isset( $value ) && is_string( $value ) ) { | ||
if ( strpos( $value, 'pinterest' ) !== false ) { | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Register integration details. | ||
*/ | ||
public function register() { | ||
add_action( | ||
'wp_enqueue_scripts', | ||
function () { | ||
wp_register_script( 'optml-typekit', false ); | ||
wp_enqueue_script( 'optml-typekit' ); | ||
$script = ' | ||
(function(w, d){ | ||
w.addEventListener("load", function(){ | ||
let p=d.querySelectorAll( ".heateorSssSharing.heateorSssPinterestBackground" ); | ||
p.forEach ( function (button,index) { | ||
button.addEventListener( "mouseover", () => { | ||
let images = d.getElementsByTagName( "img" ); | ||
for ( let i = 0; i < images.length; i++ ) { | ||
if ( "optSrc" in images[i].dataset ) { | ||
images[i].src = images[i].dataset.optSrc ; | ||
} | ||
} | ||
},{once:true} ); | ||
}); | ||
}); | ||
}(window, document)); | ||
'; | ||
wp_add_inline_script( 'optml-typekit', $script ); | ||
} | ||
); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ final class Optml_Manager { | |
'divi_builder', | ||
'thrive', | ||
'master_slider', | ||
'sassy_social_share', | ||
); | ||
|
||
/** | ||
|