Skip to content

Commit d4224cb

Browse files
GrigoreMihaiselul
authored andcommitted
fix: compatibility with Sassy Social share plugin
1 parent ce1c162 commit d4224cb

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
describe( 'Sassy Social Share', function () {
2+
it( 'successfully loads', function () {
3+
cy.visit( '/sassy-social-share/' )
4+
} );
5+
it( 'click on button', function () {
6+
cy.get( '.heateorSssSharing.heateorSssPinterestBackground' ).click( { multiple: true } )
7+
} );
8+
it( 'images should not have quality:eco', function () {
9+
cy.get( 'img' ).should( ( $imgs ) => {
10+
expect( $imgs ).to.have.length( 5 )
11+
expect( $imgs.eq( 0 ) ).to.have.attr( 'src' ).and.to.not.contain( 'eco' )
12+
expect( $imgs.eq( 1 ) ).to.have.attr( 'src' ).and.to.not.contain( 'eco' )
13+
expect( $imgs.eq( 2 ) ).to.have.attr( 'src' ).and.to.not.contain( 'eco' )
14+
expect( $imgs.eq( 3 ) ).to.have.attr( 'src' ).and.to.not.contain( 'eco' )
15+
} );
16+
} );
17+
} );
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
/**
4+
* Class Optml_sassy_social_share.
5+
*
6+
* @reason Sassy social share picks eco images to share
7+
*/
8+
class Optml_sassy_social_share extends Optml_compatibility {
9+
/**
10+
* Should we load the integration logic.
11+
*
12+
* @return bool Should we load.
13+
*/
14+
function should_load() {
15+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
16+
17+
if ( ! is_plugin_active( 'sassy-social-share/sassy-social-share.php' ) ) {
18+
return false;
19+
}
20+
$ss_options = get_option( 'heateor_sss' );
21+
$ss_bars = ['vertical_re_providers', 'horizontal_re_providers'];
22+
if ( ! is_array( $ss_options ) ) {
23+
return false;
24+
}
25+
foreach ( $ss_bars as $key => $bar ) {
26+
if ( ! isset( $ss_options[ $bar ] ) ) {
27+
continue;
28+
}
29+
foreach ( $ss_options[ $bar ] as $index => $value ) {
30+
if ( isset( $value ) && is_string( $value ) ) {
31+
if ( strpos( $value, 'pinterest' ) !== false ) {
32+
return true;
33+
}
34+
}
35+
}
36+
}
37+
38+
return false;
39+
}
40+
41+
/**
42+
* Register integration details.
43+
*/
44+
public function register() {
45+
add_action(
46+
'wp_enqueue_scripts',
47+
function () {
48+
wp_register_script( 'optml-typekit', false );
49+
wp_enqueue_script( 'optml-typekit' );
50+
$script = '
51+
(function(w, d){
52+
w.addEventListener("load", function(){
53+
let p=d.querySelectorAll( ".heateorSssSharing.heateorSssPinterestBackground" );
54+
p.forEach ( function (button,index) {
55+
button.addEventListener( "mouseover", () => {
56+
let images = d.getElementsByTagName( "img" );
57+
for ( let i = 0; i < images.length; i++ ) {
58+
if ( "optSrc" in images[i].dataset ) {
59+
images[i].src = images[i].dataset.optSrc ;
60+
}
61+
}
62+
},{once:true} );
63+
});
64+
65+
});
66+
}(window, document));
67+
';
68+
wp_add_inline_script( 'optml-typekit', $script );
69+
}
70+
);
71+
}
72+
}

inc/manager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ final class Optml_Manager {
6969
'divi_builder',
7070
'thrive',
7171
'master_slider',
72+
'sassy_social_share',
7273
);
7374

7475
/**

0 commit comments

Comments
 (0)