Simple Share Buttons Adder - Version 8.2.6

Version Description

  • Test with WordPress 6.0.
  • Fix Facebook error when App Id is missing.
  • Update Facebook SDK to v13.
Download this release

Release Info

Developer DavidoffNeal
Plugin Icon 128x128 Simple Share Buttons Adder
Version 8.2.6
Comparing to
See all releases

Code changes from version 8.2.5 to 8.2.6

instance.php CHANGED
@@ -9,7 +9,7 @@ namespace SimpleShareButtonsAdder;
9
 
10
  define( 'SSBA_FILE', __FILE__ );
11
  define( 'SSBA_ROOT', trailingslashit( dirname( __FILE__ ) ) );
12
- define( 'SSBA_VERSION', '8.2.5' );
13
 
14
  global $simple_share_buttons_adder_plugin;
15
 
9
 
10
  define( 'SSBA_FILE', __FILE__ );
11
  define( 'SSBA_ROOT', trailingslashit( dirname( __FILE__ ) ) );
12
+ define( 'SSBA_VERSION', '8.2.6' );
13
 
14
  global $simple_share_buttons_adder_plugin;
15
 
php/class-admin-bits.php CHANGED
@@ -24,7 +24,7 @@ class Admin_Bits {
24
  /**
25
  * Simple_Share_Buttons_Adder instance.
26
  *
27
- * @var object
28
  */
29
  public $class_ssba;
30
 
@@ -401,7 +401,8 @@ class Admin_Bits {
401
  );
402
  }
403
 
404
- $ssba_post = filter_input( INPUT_POST, 'ssbaData', FILTER_SANITIZE_STRING );
 
405
 
406
  // If a post has been made.
407
  if ( false === empty( $ssba_post ) ) {
24
  /**
25
  * Simple_Share_Buttons_Adder instance.
26
  *
27
+ * @var Simple_Share_Buttons_Adder
28
  */
29
  public $class_ssba;
30
 
401
  );
402
  }
403
 
404
+ // Sanitize with default filter.
405
+ $ssba_post = filter_input( INPUT_POST, 'ssbaData', FILTER_DEFAULT );
406
 
407
  // If a post has been made.
408
  if ( false === empty( $ssba_post ) ) {
php/class-admin-panel.php CHANGED
@@ -100,7 +100,7 @@ class Admin_Panel {
100
  * @param array[] $categories Array of categories for block types.
101
  * @param \WP_Post $post Post being loaded.
102
  *
103
- * @filter block_categories, 999
104
  */
105
  public function simpleshare_block_category( $categories, $post ) {
106
  return array_merge(
@@ -921,7 +921,7 @@ class Admin_Panel {
921
  'type' => 'checkbox',
922
  'name' => 'ignore_facebook_sdk',
923
  'label' => 'Ignore FB SDK',
924
- 'tooltip' => 'Using you\'re own Facebook SDK? Ignore ours.',
925
  'value' => 'Y',
926
  'checked' => isset( $arr_settings['ignore_facebook_sdk'] ) && 'Y' === $arr_settings['ignore_facebook_sdk'] ? esc_attr( 'checked' ) : '',
927
  );
@@ -944,7 +944,7 @@ class Admin_Panel {
944
  'type' => 'checkbox',
945
  'name' => 'plus_ignore_facebook_sdk',
946
  'label' => 'Ignore FB SDK',
947
- 'tooltip' => 'Using you\'re own Facebook SDK? Ignore ours.',
948
  'value' => 'Y',
949
  'checked' => isset( $arr_settings['plus_ignore_facebook_sdk'] ) && 'Y' === $arr_settings['plus_ignore_facebook_sdk'] ? esc_attr( 'checked' ) : '',
950
  );
100
  * @param array[] $categories Array of categories for block types.
101
  * @param \WP_Post $post Post being loaded.
102
  *
103
+ * @filter block_categories_all, 999
104
  */
105
  public function simpleshare_block_category( $categories, $post ) {
106
  return array_merge(
921
  'type' => 'checkbox',
922
  'name' => 'ignore_facebook_sdk',
923
  'label' => 'Ignore FB SDK',
924
+ 'tooltip' => 'Using your own Facebook SDK? Ignore ours.',
925
  'value' => 'Y',
926
  'checked' => isset( $arr_settings['ignore_facebook_sdk'] ) && 'Y' === $arr_settings['ignore_facebook_sdk'] ? esc_attr( 'checked' ) : '',
927
  );
944
  'type' => 'checkbox',
945
  'name' => 'plus_ignore_facebook_sdk',
946
  'label' => 'Ignore FB SDK',
947
+ 'tooltip' => 'Using your own Facebook SDK? Ignore ours.',
948
  'value' => 'Y',
949
  'checked' => isset( $arr_settings['plus_ignore_facebook_sdk'] ) && 'Y' === $arr_settings['plus_ignore_facebook_sdk'] ? esc_attr( 'checked' ) : '',
950
  );
php/class-buttons.php CHANGED
@@ -25,7 +25,7 @@ class Buttons {
25
  /**
26
  * Simple Share Buttons Adder instance.
27
  *
28
- * @var object
29
  */
30
  public $class_ssba;
31
 
@@ -97,15 +97,17 @@ class Buttons {
97
  /**
98
  * Adds a filter around the content.
99
  *
100
- * @action wp_head, 99
101
  */
102
  public function ssba_add_button_filter() {
103
- $arr_settings = $this->class_ssba->get_ssba_settings();
 
 
104
 
105
- add_filter( 'the_content', array( $this, 'show_share_buttons' ), (int) $arr_settings['ssba_content_priority'] );
106
 
107
  // If we wish to add to excerpts.
108
- if ( isset( $arr_settings['ssba_excerpts'] ) && 'Y' !== $arr_settings['ssba_excerpts'] ) {
109
  add_filter( 'the_excerpt', array( $this, 'show_share_buttons' ) );
110
  }
111
  }
@@ -128,14 +130,10 @@ class Buttons {
128
  $pattern = get_shortcode_regex();
129
 
130
  // Ssba_hide shortcode is in the post content and instance is not called by shortcode ssba.
131
- if ( isset( $post->post_content )
132
- &&
133
- preg_match_all( '/' . $pattern . '/s', $post->post_content, $matches )
134
- &&
135
- array_key_exists( 2, $matches )
136
- &&
137
- in_array( 'ssba_hide', $matches[2], true )
138
- &&
139
  ! $boo_shortcode
140
  ) {
141
  // Exit the function returning the content without the buttons.
25
  /**
26
  * Simple Share Buttons Adder instance.
27
  *
28
+ * @var Simple_Share_Buttons_Adder
29
  */
30
  public $class_ssba;
31
 
97
  /**
98
  * Adds a filter around the content.
99
  *
100
+ * @action init, 99
101
  */
102
  public function ssba_add_button_filter() {
103
+ if ( true === is_admin() ) {
104
+ return;
105
+ }
106
 
107
+ add_filter( 'the_content', array( $this, 'show_share_buttons' ), $this->class_ssba->get_content_priority() );
108
 
109
  // If we wish to add to excerpts.
110
+ if ( true === $this->class_ssba->is_enabled_on_excerpts() ) {
111
  add_filter( 'the_excerpt', array( $this, 'show_share_buttons' ) );
112
  }
113
  }
130
  $pattern = get_shortcode_regex();
131
 
132
  // Ssba_hide shortcode is in the post content and instance is not called by shortcode ssba.
133
+ if ( true === isset( $post->post_content ) &&
134
+ preg_match_all( '/' . $pattern . '/s', $post->post_content, $matches ) &&
135
+ array_key_exists( 2, $matches ) &&
136
+ in_array( 'ssba_hide', $matches[2], true ) &&
 
 
 
 
137
  ! $boo_shortcode
138
  ) {
139
  // Exit the function returning the content without the buttons.
php/class-forms-validation.php CHANGED
@@ -32,6 +32,7 @@ class Forms_Validation {
32
  'label' => array(),
33
  'input' => array(
34
  'class' => array(),
 
35
  'disabled' => array(),
36
  'id' => array(),
37
  'name' => array(),
32
  'label' => array(),
33
  'input' => array(
34
  'class' => array(),
35
+ 'checked' => array(),
36
  'disabled' => array(),
37
  'id' => array(),
38
  'name' => array(),
php/class-simple-share-buttons-adder.php CHANGED
@@ -8,7 +8,7 @@
8
  namespace SimpleShareButtonsAdder;
9
 
10
  /**
11
- * Simple Share Buttons Adder Class
12
  *
13
  * @package SimpleShareButtonsAdder
14
  */
@@ -17,7 +17,7 @@ class Simple_Share_Buttons_Adder {
17
  /**
18
  * Plugin instance.
19
  *
20
- * @var object
21
  */
22
  public $plugin;
23
 
@@ -53,6 +53,35 @@ class Simple_Share_Buttons_Adder {
53
  return $ssba_settings;
54
  }
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  /**
57
  * Convert settings to non JSON if they exist.
58
  */
@@ -122,4 +151,195 @@ class Simple_Share_Buttons_Adder {
122
 
123
  return array_merge( $links, $mylinks );
124
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  }
8
  namespace SimpleShareButtonsAdder;
9
 
10
  /**
11
+ * Simple Share Buttons Adder Class.
12
  *
13
  * @package SimpleShareButtonsAdder
14
  */
17
  /**
18
  * Plugin instance.
19
  *
20
+ * @var object Plugin object.
21
  */
22
  public $plugin;
23
 
53
  return $ssba_settings;
54
  }
55
 
56
+ /**
57
+ * Get a single SSBA setting by name.
58
+ *
59
+ * @param string $name Setting name string.
60
+ * @param mixed $default Default value in case setting is empty.
61
+ * @param bool $check_plus Whether to check for plus value or just look for $name as-is (default = true).
62
+ * @param string $prefix Which prefix to prepend onto setting check (default = ssba).
63
+ *
64
+ * @return mixed|null
65
+ */
66
+ public function get_ssba_setting( $name, $default = null, $check_plus = true, $prefix = 'ssba' ) {
67
+ $settings = $this->get_ssba_settings();
68
+
69
+ if ( true === $check_plus ) {
70
+ // Is 'Plus' enabled?
71
+ $is_plus_enabled = 'Y' === $settings['ssba_new_buttons'];
72
+
73
+ // Look up the plus equivalent value, if so.
74
+ $setting_check = sprintf( '%s_%s', $is_plus_enabled ? 'plus' : '', $name );
75
+ } else {
76
+ $setting_check = $name;
77
+ }
78
+
79
+ // Should we prefix the check with ssba?
80
+ $setting_check = sprintf( '%s%s', false === empty( $prefix ) ? $prefix . '_' : '', $setting_check );
81
+
82
+ return false === empty( $settings[ $setting_check ] ) ? $settings[ $setting_check ] : $default;
83
+ }
84
+
85
  /**
86
  * Convert settings to non JSON if they exist.
87
  */
151
 
152
  return array_merge( $links, $mylinks );
153
  }
154
+
155
+ /**
156
+ * Are new buttons active?
157
+ *
158
+ * @return bool
159
+ */
160
+ public function are_new_buttons_active() {
161
+ $settings = $this->get_ssba_settings();
162
+
163
+ return 'Y' === $settings['ssba_new_buttons'];
164
+ }
165
+
166
+ /**
167
+ * Has accepted ShareThis terms?
168
+ *
169
+ * @return bool
170
+ */
171
+ public function has_accepted_sharethis_terms() {
172
+ return 'Y' === $this->get_ssba_setting( 'accepted_sharethis_terms', 'N', false, '' );
173
+ }
174
+
175
+ /**
176
+ * Is enabled on Posts?
177
+ *
178
+ * @return bool
179
+ */
180
+ public function is_enabled_on_posts() {
181
+ return 'Y' === $this->get_ssba_setting( 'posts', 'N' );
182
+ }
183
+
184
+ /**
185
+ * Is enabled on Pages?
186
+ *
187
+ * @return bool
188
+ */
189
+ public function is_enabled_on_pages() {
190
+ return 'Y' === $this->get_ssba_setting( 'pages', 'N' );
191
+ }
192
+
193
+ /**
194
+ * Is enabled on Homepage?
195
+ *
196
+ * @return bool
197
+ */
198
+ public function is_enabled_on_homepage() {
199
+ return 'Y' === $this->get_ssba_setting( 'homepage', 'N' );
200
+ }
201
+
202
+ /**
203
+ * Is enabled on Categories or Archives?
204
+ *
205
+ * @return bool
206
+ */
207
+ public function is_enabled_on_categories() {
208
+ return 'Y' === $this->get_ssba_setting( 'cats_archs', 'N' );
209
+ }
210
+
211
+ /**
212
+ * Is enabled for Excerpts?
213
+ *
214
+ * @return bool
215
+ */
216
+ public function is_enabled_on_excerpts() {
217
+ return 'Y' === $this->get_ssba_setting( 'excerpts', 'N' );
218
+ }
219
+
220
+ /**
221
+ * Is enabled on this page?
222
+ *
223
+ * @return bool
224
+ */
225
+ public function is_enabled_on_this_page() {
226
+ if ( true === is_single() ) {
227
+ return $this->is_enabled_on_posts();
228
+ } elseif ( true === is_page() ) {
229
+ return $this->is_enabled_on_pages();
230
+ } elseif ( true === is_home() || true === is_front_page() ) {
231
+ return $this->is_enabled_on_homepage();
232
+ } elseif ( true === is_category() || true === is_archive() ) {
233
+ return $this->is_enabled_on_categories();
234
+ }
235
+
236
+ return false;
237
+ }
238
+
239
+ /**
240
+ * Are Facebook Insights enabled?
241
+ *
242
+ * @return bool
243
+ */
244
+ public function are_facebook_insights_enabled() {
245
+ return 'Y' === $this->get_ssba_setting( 'facebook_insights', 'N', true, '' );
246
+ }
247
+
248
+ /**
249
+ * Get Facebook App ID or empty string.
250
+ *
251
+ * @return string
252
+ */
253
+ public function get_facebook_app_id() {
254
+ return $this->get_ssba_setting( 'facebook_app_id', '', true, '' );
255
+ }
256
+
257
+ /**
258
+ * Ignore Facebook SDK?
259
+ *
260
+ * NOTE: This is enabled if the user wants to use their own SDK version.
261
+ *
262
+ * @return bool
263
+ */
264
+ public function ignore_facebook_sdk() {
265
+ return 'Y' === $this->get_ssba_setting( 'ignore_facebook_sdk', 'N', true, '' );
266
+ }
267
+
268
+ /**
269
+ * Get Font Family.
270
+ *
271
+ * @return string
272
+ */
273
+ public function get_font_family() {
274
+ return $this->get_ssba_setting( 'font_family', '' );
275
+ }
276
+
277
+ /**
278
+ * Are custom styles enabled?
279
+ *
280
+ * @return bool
281
+ */
282
+ public function are_custom_styles_enabled() {
283
+ return 'Y' === $this->get_ssba_setting( 'custom_styles_enabled', 'N' );
284
+ }
285
+
286
+ /**
287
+ * Get content priority.
288
+ *
289
+ * @return int
290
+ */
291
+ public function get_content_priority() {
292
+ return (int) $this->get_ssba_setting( 'content_priority', 10, false );
293
+ }
294
+
295
+ /* Share Bar */
296
+
297
+ /**
298
+ * Are Share Bar custom styles enabled?
299
+ *
300
+ * @return bool
301
+ */
302
+ public function are_bar_custom_styles_enabled() {
303
+ return 'Y' === $this->get_ssba_setting( 'custom_styles_enabled', 'N', false, 'ssba_bar' );
304
+ }
305
+
306
+ /**
307
+ * Get bar height string.
308
+ *
309
+ * @return string Bar height number string.
310
+ */
311
+ public function get_bar_height() {
312
+ return $this->get_ssba_setting( 'height', '48', false, 'ssba_bar' );
313
+ }
314
+
315
+ /**
316
+ * Get bar height style.
317
+ *
318
+ * @return string
319
+ */
320
+ public function get_bar_height_style() {
321
+ $bar_height = $this->get_bar_height();
322
+
323
+ return 'height: ' . $bar_height . 'px !important;';
324
+ }
325
+
326
+ /**
327
+ * Get bar width string.
328
+ *
329
+ * @return string Bar width number string.
330
+ */
331
+ public function get_bar_width() {
332
+ return $this->get_ssba_setting( 'width', '48', false, 'ssba_bar' );
333
+ }
334
+
335
+ /**
336
+ * Get bar width style.
337
+ *
338
+ * @return string
339
+ */
340
+ public function get_bar_width_style() {
341
+ $bar_width = $this->get_bar_width();
342
+
343
+ return 'width: ' . $bar_width . 'px !important;';
344
+ }
345
  }
php/class-styles.php CHANGED
@@ -24,7 +24,7 @@ class Styles {
24
  /**
25
  * Simple Share Buttons Adder instance.
26
  *
27
- * @var object
28
  */
29
  public $class_ssba;
30
 
@@ -45,10 +45,7 @@ class Styles {
45
  * @action wp_enqueue_scripts
46
  */
47
  public function ssba_page_scripts() {
48
- // Get settings.
49
- $arr_settings = $this->class_ssba->get_ssba_settings();
50
-
51
- if ( is_ssl() ) {
52
  $st_insights = 'https://ws.sharethis.com/button/st_insights.js';
53
  } else {
54
  $st_insights = 'http://w.sharethis.com/button/st_insights.js';
@@ -63,7 +60,7 @@ class Styles {
63
  $st_insights
64
  );
65
 
66
- if ( 'Y' === $arr_settings['accepted_sharethis_terms'] ) {
67
  wp_enqueue_script( 'ssba-sharethis', $url, null, SSBA_VERSION, false );
68
  add_filter( 'script_loader_tag', array( $this, 'ssba_script_tags' ), 10, 2 );
69
  }
@@ -84,13 +81,15 @@ class Styles {
84
  )
85
  );
86
 
 
 
87
  // If indie flower font is selected.
88
- if ( 'Indie Flower' === $arr_settings['ssba_font_family'] || 'Indie Flower' === $arr_settings['ssba_plus_font_family'] ) {
89
  // Font scripts.
90
  wp_enqueue_style( "{$this->plugin->assets_prefix}-indie" );
91
  }
92
 
93
- if ( 'Reenie Beanie' === $arr_settings['ssba_font_family'] || 'Reenie Beanie' === $arr_settings['ssba_plus_font_family'] ) {
94
  // Font scripts.
95
  wp_enqueue_style( "{$this->plugin->assets_prefix}-reenie" );
96
  }
@@ -118,53 +117,31 @@ class Styles {
118
  * @action wp_enqueue_scripts
119
  */
120
  public function get_ssba_style() {
121
- // Query the db for current ssba settings.
122
- $arr_settings = $this->class_ssba->get_ssba_settings();
123
-
124
- $facebook_app_id = true === empty( $arr_settings['plus_facebook_app_id'] ) ? $arr_settings['facebook_app_id'] : $arr_settings['plus_facebook_app_id'];
125
-
126
- // If the sharethis terms have been accepted.
127
- if ( 'Y' === $arr_settings['accepted_sharethis_terms'] && ( ( 'Y' !== $arr_settings['ssba_new_buttons'] && 'Y' !== $arr_settings['ignore_facebook_sdk'] ) || ( 'Y' === $arr_settings['ssba_new_buttons'] && 'Y' !== $arr_settings['plus_ignore_facebook_sdk'] ) ) ) {
128
- // If a facebook app id has been set.
129
- if ( false === empty( $facebook_app_id ) ) {
130
- $src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6&appID=' . $facebook_app_id;
131
- } else {
132
- $src = '//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6';
133
- }
134
-
135
- // If an app id has been entered.
136
- if ( false === empty( $facebook_app_id ) ) {
137
- // Init facebook.
138
- echo "<script>window.fbAsyncInit = function() {
139
- FB.init({
140
- appId : '" . esc_js( $facebook_app_id ) . "',
141
- xfbml : true,
142
- version : 'v2.6'
143
- });
144
- };</script>";
145
- }
146
-
147
- // Include facebook js sdk.
148
- echo '<script>(function(d, s, id){
149
- var js, fjs = d.getElementsByTagName(s)[0];
150
- if (d.getElementById(id)) {return;}
151
- js = d.createElement(s); js.id = id;
152
- js.src = "' . esc_js( $src ) . '";
153
- fjs.parentNode.insertBefore(js, fjs);
154
- }(document, \'script\', \'facebook-jssdk\'));</script>';
155
-
156
- // If an app id has been entered.
157
- if ( false === empty( $facebook_app_id ) ) {
158
- // If facebook insights have been enabled.
159
- if ( 'Y' === $arr_settings['facebook_insights'] ) {
160
- // Add facebook meta tag.
161
- echo '<meta property="fb:app_id" content="' . esc_attr( $facebook_app_id ) . '" />';
162
- }
163
- }
164
  }
165
 
 
 
166
  // Check if custom styles haven't been set.
167
- if ( 'Y' !== $arr_settings['ssba_custom_styles_enabled'] && 'Y' !== $arr_settings['ssba_new_buttons'] ) {
168
  $div_padding = '' !== $arr_settings['ssba_div_padding'] ? 'padding: ' . $arr_settings['ssba_div_padding'] . 'px;' : '';
169
  $border_width = '' !== $arr_settings['ssba_border_width'] ? 'border: ' . $arr_settings['ssba_border_width'] . 'px solid ' . $arr_settings['ssba_div_border'] . ';' : '';
170
  $div_background1 = '' !== $arr_settings['ssba_div_background'] ? 'background-color: ' . $arr_settings['ssba_div_background'] . ';' : '';
@@ -289,14 +266,14 @@ class Styles {
289
  }
290
 
291
  wp_add_inline_style( "{$this->plugin->assets_prefix}-ssba", $html_ssba_style ); // WPCS: XSS ok.
292
- } elseif ( 'Y' !== $arr_settings['ssba_new_buttons'] ) { // Else use set options.
293
  // Use custom styles.
294
  $html_ssba_style = $arr_settings['ssba_custom_styles'];
295
 
296
  wp_add_inline_style( "{$this->plugin->assets_prefix}-ssba", $html_ssba_style ); // WPCS: XSS ok.
297
  }
298
 
299
- if ( 'Y' === $arr_settings['ssba_new_buttons'] ) {
300
  // Plus styles.
301
  $plus_height = '' !== $arr_settings['ssba_plus_height'] ? 'height: ' . $arr_settings['ssba_plus_height'] . 'px!important;' : 'height: 48px!important;';
302
  $plus_width = '' !== $arr_settings['ssba_plus_width'] ? 'width: ' . $arr_settings['ssba_plus_width'] . 'px!important;' : 'width: 48px!important;';
@@ -357,12 +334,12 @@ class Styles {
357
  wp_add_inline_style( "{$this->plugin->assets_prefix}-ssba", $html_ssba_style ); // WPCS: XSS ok.
358
  }
359
 
360
- // If sharebar custom css is enabled use it.
361
  // Check if custom styles haven't been set.
362
- if ( 'Y' !== $arr_settings['ssba_bar_custom_styles_enabled'] ) {
363
  // Share bar styles.
364
- $bar_height = '' !== $arr_settings['ssba_bar_height'] ? 'height: ' . $arr_settings['ssba_bar_height'] . 'px!important;' : 'height: 48px!important;';
365
- $bar_width = '' !== $arr_settings['ssba_bar_width'] ? 'width: ' . $arr_settings['ssba_bar_width'] . 'px!important;' : 'width: 48px!important;';
366
  $bar_icon = '' !== $arr_settings['ssba_bar_icon_size'] ? 'line-' . $bar_height . '; font-size: ' . $arr_settings['ssba_bar_icon_size'] . 'px;' : 'line-' . $bar_height . '; font-size: 18px;';
367
  $bar_margin = '' !== $arr_settings['ssba_bar_margin'] ? 'margin: ' . $arr_settings['ssba_bar_margin'] . 'px 0!important;' : '';
368
  $bar_button_color = '' !== $arr_settings['ssba_bar_button_color'] ? 'background-color: ' . $arr_settings['ssba_bar_button_color'] . '!important;' : '';
24
  /**
25
  * Simple Share Buttons Adder instance.
26
  *
27
+ * @var Simple_Share_Buttons_Adder
28
  */
29
  public $class_ssba;
30
 
45
  * @action wp_enqueue_scripts
46
  */
47
  public function ssba_page_scripts() {
48
+ if ( true === is_ssl() ) {
 
 
 
49
  $st_insights = 'https://ws.sharethis.com/button/st_insights.js';
50
  } else {
51
  $st_insights = 'http://w.sharethis.com/button/st_insights.js';
60
  $st_insights
61
  );
62
 
63
+ if ( true === $this->class_ssba->has_accepted_sharethis_terms() ) {
64
  wp_enqueue_script( 'ssba-sharethis', $url, null, SSBA_VERSION, false );
65
  add_filter( 'script_loader_tag', array( $this, 'ssba_script_tags' ), 10, 2 );
66
  }
81
  )
82
  );
83
 
84
+ $font_family = $this->class_ssba->get_font_family();
85
+
86
  // If indie flower font is selected.
87
+ if ( 'Indie Flower' === $font_family ) {
88
  // Font scripts.
89
  wp_enqueue_style( "{$this->plugin->assets_prefix}-indie" );
90
  }
91
 
92
+ if ( 'Reenie Beanie' === $font_family ) {
93
  // Font scripts.
94
  wp_enqueue_style( "{$this->plugin->assets_prefix}-reenie" );
95
  }
117
  * @action wp_enqueue_scripts
118
  */
119
  public function get_ssba_style() {
120
+ // Get the Facebook ID.
121
+ $facebook_app_id = $this->class_ssba->get_facebook_app_id();
122
+
123
+ // Are Facebook Insights enabled?
124
+ $facebook_insights_enabled = $this->class_ssba->are_facebook_insights_enabled();
125
+
126
+ if (
127
+ true === $this->class_ssba->has_accepted_sharethis_terms() && // Terms are accepted.
128
+ true === $this->class_ssba->is_enabled_on_this_page() && // Enabled on this page.
129
+ false === empty( $facebook_app_id ) && // A Facebook ID has been entered.
130
+ false === $this->class_ssba->ignore_facebook_sdk() // Not using their own Facebook SDK.
131
+ ) {
132
+ _simple_share_load_template(
133
+ 'templates/facebook-sdk',
134
+ compact(
135
+ 'facebook_app_id',
136
+ 'facebook_insights_enabled'
137
+ )
138
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  }
140
 
141
+ $arr_settings = $this->class_ssba->get_ssba_settings();
142
+
143
  // Check if custom styles haven't been set.
144
+ if ( false === $this->class_ssba->are_custom_styles_enabled() && 'Y' !== $arr_settings['ssba_new_buttons'] ) {
145
  $div_padding = '' !== $arr_settings['ssba_div_padding'] ? 'padding: ' . $arr_settings['ssba_div_padding'] . 'px;' : '';
146
  $border_width = '' !== $arr_settings['ssba_border_width'] ? 'border: ' . $arr_settings['ssba_border_width'] . 'px solid ' . $arr_settings['ssba_div_border'] . ';' : '';
147
  $div_background1 = '' !== $arr_settings['ssba_div_background'] ? 'background-color: ' . $arr_settings['ssba_div_background'] . ';' : '';
266
  }
267
 
268
  wp_add_inline_style( "{$this->plugin->assets_prefix}-ssba", $html_ssba_style ); // WPCS: XSS ok.
269
+ } elseif ( false === $this->class_ssba->are_new_buttons_active() ) { // Else use set options.
270
  // Use custom styles.
271
  $html_ssba_style = $arr_settings['ssba_custom_styles'];
272
 
273
  wp_add_inline_style( "{$this->plugin->assets_prefix}-ssba", $html_ssba_style ); // WPCS: XSS ok.
274
  }
275
 
276
+ if ( true === $this->class_ssba->are_new_buttons_active() ) {
277
  // Plus styles.
278
  $plus_height = '' !== $arr_settings['ssba_plus_height'] ? 'height: ' . $arr_settings['ssba_plus_height'] . 'px!important;' : 'height: 48px!important;';
279
  $plus_width = '' !== $arr_settings['ssba_plus_width'] ? 'width: ' . $arr_settings['ssba_plus_width'] . 'px!important;' : 'width: 48px!important;';
334
  wp_add_inline_style( "{$this->plugin->assets_prefix}-ssba", $html_ssba_style ); // WPCS: XSS ok.
335
  }
336
 
337
+ // If ShareBar custom css is enabled, use it.
338
  // Check if custom styles haven't been set.
339
+ if ( false === $this->class_ssba->are_bar_custom_styles_enabled() ) {
340
  // Share bar styles.
341
+ $bar_height = $this->class_ssba->get_bar_height_style();
342
+ $bar_width = $this->class_ssba->get_bar_width_style();
343
  $bar_icon = '' !== $arr_settings['ssba_bar_icon_size'] ? 'line-' . $bar_height . '; font-size: ' . $arr_settings['ssba_bar_icon_size'] . 'px;' : 'line-' . $bar_height . '; font-size: 18px;';
344
  $bar_margin = '' !== $arr_settings['ssba_bar_margin'] ? 'margin: ' . $arr_settings['ssba_bar_margin'] . 'px 0!important;' : '';
345
  $bar_button_color = '' !== $arr_settings['ssba_bar_button_color'] ? 'background-color: ' . $arr_settings['ssba_bar_button_color'] . '!important;' : '';
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: sharethis, scottstorebloom, scottmweaver, surlyrightclick, DavidoffNeal
3
  Tags: share buttons, social buttons, facebook, twitter, google+, share, share links, stumble upon, linkedin, pinterest, yummly, vk, flattr
4
  Requires at least: 4.5
5
- Tested up to: 5.9.3
6
- Stable tag: 8.2.5
7
- Version: 8.2.5
8
  License: GPLv2 or later
9
 
10
  A simple plugin that enables you to add share buttons to all of your posts and/or pages.
@@ -67,6 +67,11 @@ Please visit the <a href="https://wordpress.org/support/plugin/simple-share-butt
67
 
68
  == Changelog ==
69
 
 
 
 
 
 
70
  = 8.2.5 =
71
  * Test with WordPress 5.9.3.
72
  * Fix critical error in PHP8.
2
  Contributors: sharethis, scottstorebloom, scottmweaver, surlyrightclick, DavidoffNeal
3
  Tags: share buttons, social buttons, facebook, twitter, google+, share, share links, stumble upon, linkedin, pinterest, yummly, vk, flattr
4
  Requires at least: 4.5
5
+ Tested up to: 6.0
6
+ Stable tag: 8.2.6
7
+ Version: 8.2.6
8
  License: GPLv2 or later
9
 
10
  A simple plugin that enables you to add share buttons to all of your posts and/or pages.
67
 
68
  == Changelog ==
69
 
70
+ = 8.2.6 =
71
+ * Test with WordPress 6.0.
72
+ * Fix Facebook error when App Id is missing.
73
+ * Update Facebook SDK to v13.
74
+
75
  = 8.2.5 =
76
  * Test with WordPress 5.9.3.
77
  * Fix critical error in PHP8.
simple-share-buttons-adder.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Simple Share Buttons Adder
4
  * Plugin URI: https://simplesharebuttons.com
5
  * Description: A simple plugin that enables you to add share buttons to all of your posts and/or pages.
6
- * Version: 8.2.5
7
  * Author: Simple Share Buttons
8
  * Author URI: https://simplesharebuttons.com
9
  * License: GPLv2
@@ -64,3 +64,23 @@ function _simple_share_buttons_adder_add_action_links( $links ) {
64
 
65
  return array_merge( $links, $mylinks );
66
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  * Plugin Name: Simple Share Buttons Adder
4
  * Plugin URI: https://simplesharebuttons.com
5
  * Description: A simple plugin that enables you to add share buttons to all of your posts and/or pages.
6
+ * Version: 8.2.6
7
  * Author: Simple Share Buttons
8
  * Author URI: https://simplesharebuttons.com
9
  * License: GPLv2
64
 
65
  return array_merge( $links, $mylinks );
66
  }
67
+
68
+ /**
69
+ * Load template.
70
+ *
71
+ * @param string $relative_path Relative path string (sans .php extension).
72
+ * @param array $data Data array.
73
+ *
74
+ * @since 8.2.6
75
+ */
76
+ function _simple_share_load_template( $relative_path, $data = array() ) {
77
+ load_template(
78
+ sprintf(
79
+ '%s/%s.php',
80
+ SSBA_ROOT,
81
+ $relative_path
82
+ ),
83
+ false,
84
+ $data
85
+ );
86
+ }
templates/facebook-sdk.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Facebook SDK header template.
4
+ *
5
+ * The template that gets injected into the header when Facebook App ID is entered.
6
+ *
7
+ * @package SimpleShareButtonsAdder
8
+ */
9
+
10
+ $args = false === empty( $args ) ? $args : array();
11
+
12
+ $data = wp_parse_args(
13
+ $args,
14
+ array(
15
+ 'facebook_app_id' => null,
16
+ 'facebook_insights_enabled' => false,
17
+ )
18
+ );
19
+ ?>
20
+ <script>
21
+ window.fbAsyncInit = function() {
22
+ FB.init({
23
+ appId: '<?php echo esc_js( $data['facebook_app_id'] ); ?>',
24
+ autoLogAppEvents: true,
25
+ xfbml: true,
26
+ version: 'v13.0',
27
+ })
28
+ }
29
+ </script>
30
+ <script>
31
+ (function(d, s, id) {
32
+ var js, fjs = d.getElementsByTagName(s)[0]
33
+ if (d.getElementById(id)) {
34
+ return
35
+ }
36
+ js = d.createElement(s)
37
+ js.id = id
38
+ js.src = "<?php echo esc_js( '//connect.facebook.net/en_US/sdk.js' ); ?>"
39
+ fjs.parentNode.insertBefore(js, fjs)
40
+ }(document, 'script', 'facebook-jssdk'))
41
+ </script>
42
+
43
+ <?php if ( true === $data['facebook_insights_enabled'] ) : ?>
44
+ <meta property="fb:app_id" content="<?php echo esc_attr( $data['facebook_app_id'] ); ?>" />
45
+ <?php endif; ?>