Shariff Wrapper - Version 4.1.0

Version Description

  • new design option to set a custom button color for all buttons
  • new design option to set a border radius for the round theme (up to a square)
  • new design option to hide all buttons until the page is fully loaded
  • new mailform option to use a html anchor (again)
  • new statistic option to fill the cache automatically
  • new statistic option to set the amount of posts for the ranking tab
  • new statistic option to use share counts with PHP < 5.4
  • fix preventing buttons from beeing added to excerpts under certain conditions
  • fix urlencoding of share count requests
  • improved handling of wrong or mistyped service entries
  • minor bug fixes
Download this release

Release Info

Developer starguide
Plugin Icon 128x128 Shariff Wrapper
Version 4.1.0
Comparing to
See all releases

Code changes from version 4.0.8 to 4.1.0

admin/admin_menu.php CHANGED
@@ -85,6 +85,18 @@ function shariff3UU_options_init(){
85
  add_settings_field( 'shariff3UU_checkbox_buttonsstretch', __( 'Stretch buttons horizontally to full width.', 'shariff' ),
86
  'shariff3UU_checkbox_buttonstretch_render', 'design', 'shariff3UU_design_section' );
87
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  // vertical
89
  add_settings_field( 'shariff3UU_checkbox_vertical', __( 'Shariff button orientation <b>vertical</b>.', 'shariff' ),
90
  'shariff3UU_checkbox_vertical_render', 'design', 'shariff3UU_design_section' );
@@ -105,6 +117,10 @@ function shariff3UU_options_init(){
105
  add_settings_field( 'shariff3UU_text_style', __( 'CSS attributes for the container <span style="text-decoration: underline;">around</span> Shariff:', 'shariff' ),
106
  'shariff3UU_text_style_render', 'design', 'shariff3UU_design_section' );
107
 
 
 
 
 
108
  // third tab - advanced
109
 
110
  // register third tab (advanced) settings and call sanitize function
@@ -201,6 +217,11 @@ function shariff3UU_options_init(){
201
  'shariff3UU_text_mail_sender_from', '<div class="shariff_status-col">' . __( 'Default sender e-mail address:', 'shariff' ) .'</div>',
202
  'shariff3UU_text_mail_sender_from_render', 'mailform', 'shariff3UU_mailform_section' );
203
 
 
 
 
 
 
204
  // fifth tab - statistic
205
 
206
  // register fifth tab (statistic) settings and call sanitize function
@@ -226,6 +247,14 @@ function shariff3UU_options_init(){
226
  add_settings_field( 'shariff3UU_text_fb_secret', '<div class="shariff_status-col">' . __( 'Facebook App Secret:', 'shariff' ) .'</div>',
227
  'shariff3UU_text_fb_secret_render', 'statistic', 'shariff3UU_statistic_section' );
228
 
 
 
 
 
 
 
 
 
229
  // ttl
230
  add_settings_field( 'shariff3UU_number_ttl', '<div class="shariff_status-col">' . __( 'Cache TTL in seconds (60 - 7200):', 'shariff' ) .'</div>',
231
  'shariff3UU_number_ttl_render', 'statistic', 'shariff3UU_statistic_section' );
@@ -271,7 +300,7 @@ function shariff3UU_basic_sanitize( $input ) {
271
  $valid = array();
272
 
273
  if ( isset( $input["version"] ) ) $valid["version"] = sanitize_text_field( $input["version"] );
274
- if ( isset( $input["services"] ) ) $valid["services"] = str_replace( ' ', '', sanitize_text_field( $input["services"] ) );
275
  if ( isset( $input["add_after"] ) ) $valid["add_after"] = sani_arrays( $input["add_after"] );
276
  if ( isset( $input["add_before"] ) ) $valid["add_before"] = sani_arrays( $input["add_before"] );
277
  if ( isset( $input["disable_on_protected"] ) ) $valid["disable_on_protected"] = absint( $input["disable_on_protected"] );
@@ -291,11 +320,15 @@ function shariff3UU_design_sanitize( $input ) {
291
  if ( isset( $input["theme"] ) ) $valid["theme"] = sanitize_text_field( $input["theme"] );
292
  if ( isset( $input["buttonsize"] ) ) $valid["buttonsize"] = absint( $input["buttonsize"] );
293
  if ( isset( $input["buttonstretch"] ) ) $valid["buttonstretch"] = absint( $input["buttonstretch"] );
 
 
 
294
  if ( isset( $input["vertical"] ) ) $valid["vertical"] = absint( $input["vertical"] );
295
  if ( isset( $input["align"] ) ) $valid["align"] = sanitize_text_field( $input["align"] );
296
  if ( isset( $input["align_widget"] ) ) $valid["align_widget"] = sanitize_text_field( $input["align_widget"] );
297
  if ( isset( $input["style"] ) ) $valid["style"] = sanitize_text_field( $input["style"] );
298
  if ( isset( $input["headline"] ) ) $valid["headline"] = wp_kses( $input["headline"], $GLOBALS["allowed_tags"] );
 
299
 
300
  // remove empty elements
301
  $valid = array_filter($valid);
@@ -336,6 +369,7 @@ function shariff3UU_mailform_sanitize( $input ) {
336
  if ( isset( $input["mail_add_post_content"] ) ) $valid["mail_add_post_content"] = absint( $input["mail_add_post_content"] );
337
  if ( isset( $input["mail_sender_name"] ) ) $valid["mail_sender_name"] = sanitize_text_field( $input["mail_sender_name"] );
338
  if ( isset( $input["mail_sender_from"] ) && is_email( $input["mail_sender_from"] ) != false ) $valid["mail_sender_from"] = sanitize_email( $input["mail_sender_from"] );
 
339
 
340
  // remove empty elements
341
  $valid = array_filter( $valid );
@@ -350,6 +384,8 @@ function shariff3UU_statistic_sanitize( $input ) {
350
 
351
  if ( isset( $input["backend"] ) ) $valid["backend"] = absint( $input["backend"] );
352
  if ( isset( $input["sharecounts"] ) ) $valid["sharecounts"] = absint( $input["sharecounts"] );
 
 
353
  if ( isset( $input["fb_id"] ) ) $valid["fb_id"] = sanitize_text_field( $input["fb_id"] );
354
  if ( isset( $input["fb_secret"] ) ) $valid["fb_secret"] = sanitize_text_field( $input["fb_secret"] );
355
  if ( isset( $input["ttl"] ) ) $valid["ttl"] = absint( $input["ttl"] );
@@ -553,6 +589,41 @@ function shariff3UU_checkbox_buttonstretch_render() {
553
  echo ' value="1">';
554
  }
555
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
556
  // vertical
557
  function shariff3UU_checkbox_vertical_render() {
558
  $plugins_url = plugins_url();
@@ -612,6 +683,13 @@ function shariff3UU_text_style_render() {
612
  echo '<input type="text" name="shariff3UU_design[style]" value="' . esc_html($style) . '" size="50" placeholder="' . __( "More information in the FAQ.", "shariff" ) . '">';
613
  }
614
 
 
 
 
 
 
 
 
615
  // advanced options
616
 
617
  // description advanced options
@@ -828,6 +906,13 @@ function shariff3UU_text_mail_sender_from_render() {
828
  echo '<input type="email" name="shariff3UU_mailform[mail_sender_from]" value="' . esc_html($mail_sender_from) . '" size="50" placeholder="wordpress@' . $domain .'">';
829
  }
830
 
 
 
 
 
 
 
 
831
  // statistic section
832
 
833
  // description statistic options
@@ -837,15 +922,14 @@ function shariff3UU_statistic_section_callback(){
837
  echo '<br>';
838
  echo __( '<span style="color: red; font-weight: bold;">Warning:</span> You entered an external API and chose to call it directly! Therefore, all options and features (e.g. the ranking tab) regarding the statistic have no effect. You need to configure them on the external server. Remember: This feature is still experimental!', 'shariff' );
839
  }
 
 
840
  }
841
 
842
  // statistic
843
  function shariff3UU_checkbox_backend_render() {
844
- // check PHP version
845
- if ( version_compare( PHP_VERSION, '5.4.0' ) < 1 ) {
846
- echo __( 'PHP-Version 5.4 or better is required to enable the statistic / share count functionality.', 'shariff');
847
- }
848
- elseif ( version_compare( get_bloginfo('version'), '4.4.0' ) < 1 ) {
849
  echo __( 'WordPress-Version 4.4 or better is required to enable the statistic / share count functionality.', 'shariff');
850
  }
851
  else {
@@ -859,21 +943,35 @@ function shariff3UU_checkbox_backend_render() {
859
 
860
  // share counts on buttons
861
  function shariff3UU_checkbox_sharecounts_render() {
862
- // check PHP version
863
- if ( version_compare( PHP_VERSION, '5.4.0' ) < 1 ) {
864
- echo __( 'PHP-Version 5.4 or better is needed to enable the statistic / share count functionality.', 'shariff');
 
 
 
 
 
 
 
 
 
 
 
 
865
  }
866
  else {
867
- echo '<input type="checkbox" name="shariff3UU_statistic[sharecounts]" ';
868
- if ( isset( $GLOBALS['shariff3UU_statistic']['sharecounts'] ) ) {
869
- echo checked( $GLOBALS['shariff3UU_statistic']['sharecounts'], 1, 0 );
870
- }
871
- echo ' value="1">';
872
- if ( ! isset( $GLOBALS['shariff3UU_statistic']['backend'] ) && isset( $GLOBALS['shariff3UU_statistic']['sharecounts'] ) ) {
873
- echo ' ';
874
- echo __( 'Warning: The statistic functionality must be enabled in order for the share counts to be shown.', 'shariff' );
875
- }
876
  }
 
 
 
 
 
 
 
 
 
 
877
  }
878
 
879
  // Facebook App ID
@@ -1075,6 +1173,30 @@ function shariff3UU_help_section_callback() {
1075
  echo '<div class="shariff_shortcode_cell">[shariff buttonstretch="1"]</div>';
1076
  echo '<div class="shariff_shortcode_cell">' . __( 'Stretch buttons horizontally to full width.', 'shariff' ) . '</div>';
1077
  echo '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1078
  // orientation
1079
  echo '<div class="shariff_shortcode_row">';
1080
  echo '<div class="shariff_shortcode_cell">orientation</div>';
@@ -1336,22 +1458,31 @@ function shariff3UU_ranking_section_callback() {
1336
 
1337
  // services
1338
  $services = array();
 
 
 
 
 
 
 
 
1339
 
1340
- // catch last 100 posts
1341
- $args = array( 'numberposts' => '100', 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish' );
1342
  $recent_posts = wp_get_recent_posts( $args );
1343
  if ( $recent_posts ) {
1344
  foreach( $recent_posts as $recent ) {
1345
  // get url
1346
  $url = get_permalink( $recent["ID"] );
1347
- $post_url = urlencode( get_permalink( $recent["ID"] ) );
1348
  // set transient name
1349
  $post_hash = 'shariff' . hash( "md5", $post_url );
1350
  // get share counts from cache
1351
  if ( get_transient( $post_hash ) !== false ) {
1352
  $share_counts = get_transient( $post_hash );
1353
  $services = array_merge( $services, $share_counts );
1354
- $total = $share_counts['total'];
 
1355
  }
1356
  else {
1357
  $share_counts = array();
85
  add_settings_field( 'shariff3UU_checkbox_buttonsstretch', __( 'Stretch buttons horizontally to full width.', 'shariff' ),
86
  'shariff3UU_checkbox_buttonstretch_render', 'design', 'shariff3UU_design_section' );
87
 
88
+ // border radius
89
+ add_settings_field( 'shariff3UU_number_borderradius', __( 'Border radius for the round theme (1-50):', 'shariff' ),
90
+ 'shariff3UU_number_borderradius_render', 'design', 'shariff3UU_design_section' );
91
+
92
+ // custom main color
93
+ add_settings_field( 'shariff3UU_text_maincolor', __( 'Custom main color for <b>all</b> buttons (hexadecimal):', 'shariff' ),
94
+ 'shariff3UU_text_maincolor_render', 'design', 'shariff3UU_design_section' );
95
+
96
+ // custom secondary color
97
+ add_settings_field( 'shariff3UU_text_secondarycolor', __( 'Custom secondary color for <b>all</b> buttons (hexadecimal):', 'shariff' ),
98
+ 'shariff3UU_text_secondarycolor_render', 'design', 'shariff3UU_design_section' );
99
+
100
  // vertical
101
  add_settings_field( 'shariff3UU_checkbox_vertical', __( 'Shariff button orientation <b>vertical</b>.', 'shariff' ),
102
  'shariff3UU_checkbox_vertical_render', 'design', 'shariff3UU_design_section' );
117
  add_settings_field( 'shariff3UU_text_style', __( 'CSS attributes for the container <span style="text-decoration: underline;">around</span> Shariff:', 'shariff' ),
118
  'shariff3UU_text_style_render', 'design', 'shariff3UU_design_section' );
119
 
120
+ // hide until css loaded
121
+ add_settings_field( 'shariff3UU_checkbox_hideuntilcss', __( 'Hide buttons until page is fully loaded.', 'shariff' ),
122
+ 'shariff3UU_checkbox_hideuntilcss_render', 'design', 'shariff3UU_design_section' );
123
+
124
  // third tab - advanced
125
 
126
  // register third tab (advanced) settings and call sanitize function
217
  'shariff3UU_text_mail_sender_from', '<div class="shariff_status-col">' . __( 'Default sender e-mail address:', 'shariff' ) .'</div>',
218
  'shariff3UU_text_mail_sender_from_render', 'mailform', 'shariff3UU_mailform_section' );
219
 
220
+ // use anchor
221
+ add_settings_field(
222
+ 'shariff3UU_checkbox_mailform_anchor', '<div class="shariff_status-col">' . __( 'Use an anchor to jump to the mail form.', 'shariff' ) .'</div>',
223
+ 'shariff3UU_checkbox_mailform_anchor_render', 'mailform', 'shariff3UU_mailform_section' );
224
+
225
  // fifth tab - statistic
226
 
227
  // register fifth tab (statistic) settings and call sanitize function
247
  add_settings_field( 'shariff3UU_text_fb_secret', '<div class="shariff_status-col">' . __( 'Facebook App Secret:', 'shariff' ) .'</div>',
248
  'shariff3UU_text_fb_secret_render', 'statistic', 'shariff3UU_statistic_section' );
249
 
250
+ // autoamtic cache
251
+ add_settings_field( 'shariff3UU_checkbox_automaticcache', '<div class="shariff_status-col">' . __( 'Fill cache automatically.', 'shariff' ) .'</div>',
252
+ 'shariff3UU_checkbox_automaticcache_render', 'statistic', 'shariff3UU_statistic_section' );
253
+
254
+ // ranking
255
+ add_settings_field( 'shariff3UU_number_ranking', '<div class="shariff_status-col">' . __( 'Number of posts on ranking tab:', 'shariff' ) .'</div>',
256
+ 'shariff3UU_number_ranking_render', 'statistic', 'shariff3UU_statistic_section' );
257
+
258
  // ttl
259
  add_settings_field( 'shariff3UU_number_ttl', '<div class="shariff_status-col">' . __( 'Cache TTL in seconds (60 - 7200):', 'shariff' ) .'</div>',
260
  'shariff3UU_number_ttl_render', 'statistic', 'shariff3UU_statistic_section' );
300
  $valid = array();
301
 
302
  if ( isset( $input["version"] ) ) $valid["version"] = sanitize_text_field( $input["version"] );
303
+ if ( isset( $input["services"] ) ) $valid["services"] = trim( preg_replace( "/[^A-Za-z|]/", '', sanitize_text_field( $input["services"] ) ), '|' );
304
  if ( isset( $input["add_after"] ) ) $valid["add_after"] = sani_arrays( $input["add_after"] );
305
  if ( isset( $input["add_before"] ) ) $valid["add_before"] = sani_arrays( $input["add_before"] );
306
  if ( isset( $input["disable_on_protected"] ) ) $valid["disable_on_protected"] = absint( $input["disable_on_protected"] );
320
  if ( isset( $input["theme"] ) ) $valid["theme"] = sanitize_text_field( $input["theme"] );
321
  if ( isset( $input["buttonsize"] ) ) $valid["buttonsize"] = absint( $input["buttonsize"] );
322
  if ( isset( $input["buttonstretch"] ) ) $valid["buttonstretch"] = absint( $input["buttonstretch"] );
323
+ if ( isset( $input["borderradius"] ) ) $valid["borderradius"] = absint( $input["borderradius"] );
324
+ if ( isset( $input["maincolor"] ) ) $valid["maincolor"] = sanitize_text_field( $input["maincolor"] );
325
+ if ( isset( $input["secondarycolor"] ) ) $valid["secondarycolor"] = sanitize_text_field( $input["secondarycolor"] );
326
  if ( isset( $input["vertical"] ) ) $valid["vertical"] = absint( $input["vertical"] );
327
  if ( isset( $input["align"] ) ) $valid["align"] = sanitize_text_field( $input["align"] );
328
  if ( isset( $input["align_widget"] ) ) $valid["align_widget"] = sanitize_text_field( $input["align_widget"] );
329
  if ( isset( $input["style"] ) ) $valid["style"] = sanitize_text_field( $input["style"] );
330
  if ( isset( $input["headline"] ) ) $valid["headline"] = wp_kses( $input["headline"], $GLOBALS["allowed_tags"] );
331
+ if ( isset( $input["hideuntilcss"] ) ) $valid["hideuntilcss"] = absint( $input["hideuntilcss"] );
332
 
333
  // remove empty elements
334
  $valid = array_filter($valid);
369
  if ( isset( $input["mail_add_post_content"] ) ) $valid["mail_add_post_content"] = absint( $input["mail_add_post_content"] );
370
  if ( isset( $input["mail_sender_name"] ) ) $valid["mail_sender_name"] = sanitize_text_field( $input["mail_sender_name"] );
371
  if ( isset( $input["mail_sender_from"] ) && is_email( $input["mail_sender_from"] ) != false ) $valid["mail_sender_from"] = sanitize_email( $input["mail_sender_from"] );
372
+ if ( isset( $input["mailform_anchor"] ) ) $valid["mailform_anchor"] = absint( $input["mailform_anchor"] );
373
 
374
  // remove empty elements
375
  $valid = array_filter( $valid );
384
 
385
  if ( isset( $input["backend"] ) ) $valid["backend"] = absint( $input["backend"] );
386
  if ( isset( $input["sharecounts"] ) ) $valid["sharecounts"] = absint( $input["sharecounts"] );
387
+ if ( isset( $input["ranking"] ) ) $valid["ranking"] = absint( $input["ranking"] );
388
+ if ( isset( $input["automaticcache"] ) ) $valid["automaticcache"] = absint( $input["automaticcache"] );
389
  if ( isset( $input["fb_id"] ) ) $valid["fb_id"] = sanitize_text_field( $input["fb_id"] );
390
  if ( isset( $input["fb_secret"] ) ) $valid["fb_secret"] = sanitize_text_field( $input["fb_secret"] );
391
  if ( isset( $input["ttl"] ) ) $valid["ttl"] = absint( $input["ttl"] );
589
  echo ' value="1">';
590
  }
591
 
592
+ // border radius
593
+ function shariff3UU_number_borderradius_render() {
594
+ $plugins_url = plugins_url();
595
+ if ( isset( $GLOBALS["shariff3UU_design"]["borderradius"] ) ) {
596
+ $borderradius = $GLOBALS["shariff3UU_design"]["borderradius"];
597
+ }
598
+ else {
599
+ $borderradius = '';
600
+ }
601
+ echo '<input type="number" name="shariff3UU_design[borderradius]" value="'. $borderradius .'" maxlength="2" min="1" max="50" placeholder="50" style="width: 75px">';
602
+ echo '<img src="'. $plugins_url .'/shariff/pictos/borderradius.png" align="top">';
603
+ }
604
+
605
+ // custom main color
606
+ function shariff3UU_text_maincolor_render() {
607
+ if ( isset( $GLOBALS["shariff3UU_design"]["maincolor"] ) ) {
608
+ $maincolor = $GLOBALS["shariff3UU_design"]["maincolor"];
609
+ }
610
+ else {
611
+ $maincolor = '';
612
+ }
613
+ echo '<input type="text" name="shariff3UU_design[maincolor]" value="' . esc_html( $maincolor ) . '" size="7" placeholder="#000000">';
614
+ }
615
+
616
+ // custom secondary color
617
+ function shariff3UU_text_secondarycolor_render() {
618
+ if ( isset( $GLOBALS["shariff3UU_design"]["secondarycolor"] ) ) {
619
+ $secondarycolor = $GLOBALS["shariff3UU_design"]["secondarycolor"];
620
+ }
621
+ else {
622
+ $secondarycolor = '';
623
+ }
624
+ echo '<input type="text" name="shariff3UU_design[secondarycolor]" value="' . esc_html( $secondarycolor ) . '" size="7" placeholder="#afafaf">';
625
+ }
626
+
627
  // vertical
628
  function shariff3UU_checkbox_vertical_render() {
629
  $plugins_url = plugins_url();
683
  echo '<input type="text" name="shariff3UU_design[style]" value="' . esc_html($style) . '" size="50" placeholder="' . __( "More information in the FAQ.", "shariff" ) . '">';
684
  }
685
 
686
+ // hide until page is fully loaded
687
+ function shariff3UU_checkbox_hideuntilcss_render() {
688
+ echo '<input type="checkbox" name="shariff3UU_design[hideuntilcss]" ';
689
+ if ( isset( $GLOBALS["shariff3UU_design"]["hideuntilcss"] ) ) echo checked( $GLOBALS["shariff3UU_design"]["hideuntilcss"], 1, 0 );
690
+ echo ' value="1">';
691
+ }
692
+
693
  // advanced options
694
 
695
  // description advanced options
906
  echo '<input type="email" name="shariff3UU_mailform[mail_sender_from]" value="' . esc_html($mail_sender_from) . '" size="50" placeholder="wordpress@' . $domain .'">';
907
  }
908
 
909
+ // mailform anchor
910
+ function shariff3UU_checkbox_mailform_anchor_render() {
911
+ echo '<input type="checkbox" name="shariff3UU_mailform[mailform_anchor]" ';
912
+ if ( isset( $GLOBALS["shariff3UU_mailform"]["mailform_anchor"] ) ) echo checked( $GLOBALS["shariff3UU_mailform"]["mailform_anchor"], 1, 0 );
913
+ echo ' value="1">';
914
+ }
915
+
916
  // statistic section
917
 
918
  // description statistic options
922
  echo '<br>';
923
  echo __( '<span style="color: red; font-weight: bold;">Warning:</span> You entered an external API and chose to call it directly! Therefore, all options and features (e.g. the ranking tab) regarding the statistic have no effect. You need to configure them on the external server. Remember: This feature is still experimental!', 'shariff' );
924
  }
925
+ // hook to add or remove cron job
926
+ do_action( 'shariff3UU_save_statistic_options' );
927
  }
928
 
929
  // statistic
930
  function shariff3UU_checkbox_backend_render() {
931
+ // check WP version
932
+ if ( version_compare( get_bloginfo('version'), '4.4.0' ) < 1 ) {
 
 
 
933
  echo __( 'WordPress-Version 4.4 or better is required to enable the statistic / share count functionality.', 'shariff');
934
  }
935
  else {
943
 
944
  // share counts on buttons
945
  function shariff3UU_checkbox_sharecounts_render() {
946
+ echo '<input type="checkbox" name="shariff3UU_statistic[sharecounts]" ';
947
+ if ( isset( $GLOBALS['shariff3UU_statistic']['sharecounts'] ) ) {
948
+ echo checked( $GLOBALS['shariff3UU_statistic']['sharecounts'], 1, 0 );
949
+ }
950
+ echo ' value="1">';
951
+ if ( ! isset( $GLOBALS['shariff3UU_statistic']['backend'] ) && isset( $GLOBALS['shariff3UU_statistic']['sharecounts'] ) ) {
952
+ echo ' ';
953
+ echo __( 'Warning: The statistic functionality must be enabled in order for the share counts to be shown.', 'shariff' );
954
+ }
955
+ }
956
+
957
+ // ranking
958
+ function shariff3UU_number_ranking_render() {
959
+ if ( isset($GLOBALS["shariff3UU_statistic"]["ranking"]) ) {
960
+ $numberposts = $GLOBALS["shariff3UU_statistic"]["ranking"];
961
  }
962
  else {
963
+ $numberposts = '';
 
 
 
 
 
 
 
 
964
  }
965
+ echo '<input type="number" name="shariff3UU_statistic[ranking]" value="'. $numberposts .'" maxlength="4" min="0" max="10000" placeholder="100" style="width: 75px">';
966
+ }
967
+
968
+ // automatic cache
969
+ function shariff3UU_checkbox_automaticcache_render() {
970
+ echo '<input type="checkbox" name="shariff3UU_statistic[automaticcache]" ';
971
+ if ( isset( $GLOBALS['shariff3UU_statistic']['automaticcache'] ) ) {
972
+ echo checked( $GLOBALS['shariff3UU_statistic']['automaticcache'], 1, 0 );
973
+ }
974
+ echo ' value="1">';
975
  }
976
 
977
  // Facebook App ID
1173
  echo '<div class="shariff_shortcode_cell">[shariff buttonstretch="1"]</div>';
1174
  echo '<div class="shariff_shortcode_cell">' . __( 'Stretch buttons horizontally to full width.', 'shariff' ) . '</div>';
1175
  echo '</div>';
1176
+ // borderradius
1177
+ echo '<div class="shariff_shortcode_row">';
1178
+ echo '<div class="shariff_shortcode_cell">borderradius</div>';
1179
+ echo '<div class="shariff_shortcode_cell">1-50</div>';
1180
+ echo '<div class="shariff_shortcode_cell">50</div>';
1181
+ echo '<div class="shariff_shortcode_cell">[shariff borderradius="1"]</div>';
1182
+ echo '<div class="shariff_shortcode_cell">' . __( 'Sets the border radius for the round theme. 1 essentially equals a square.', 'shariff' ) . '</div>';
1183
+ echo '</div>';
1184
+ // maincolor
1185
+ echo '<div class="shariff_shortcode_row">';
1186
+ echo '<div class="shariff_shortcode_cell">maincolor</div>';
1187
+ echo '<div class="shariff_shortcode_cell"></div>';
1188
+ echo '<div class="shariff_shortcode_cell"></div>';
1189
+ echo '<div class="shariff_shortcode_cell">[shariff maincolor="#000"]</div>';
1190
+ echo '<div class="shariff_shortcode_cell">' . __( 'Sets a custom main color for all buttons (hexadecimal).', 'shariff' ) . '</div>';
1191
+ echo '</div>';
1192
+ // secondarycolor
1193
+ echo '<div class="shariff_shortcode_row">';
1194
+ echo '<div class="shariff_shortcode_cell">secondarycolor</div>';
1195
+ echo '<div class="shariff_shortcode_cell"></div>';
1196
+ echo '<div class="shariff_shortcode_cell"></div>';
1197
+ echo '<div class="shariff_shortcode_cell">[shariff secondarycolor="#afafaf"]</div>';
1198
+ echo '<div class="shariff_shortcode_cell">' . __( 'Sets a custom secondary color for all buttons (hexadecimal). The secondary color is, depending on theme, used for hover effects.', 'shariff' ) . '</div>';
1199
+ echo '</div>';
1200
  // orientation
1201
  echo '<div class="shariff_shortcode_row">';
1202
  echo '<div class="shariff_shortcode_cell">orientation</div>';
1458
 
1459
  // services
1460
  $services = array();
1461
+
1462
+ // amount of posts - set to 100 if not set
1463
+ if ( isset( $GLOBALS["shariff3UU"]["ranking"] ) && absint( $GLOBALS["shariff3UU"]["ranking"] ) > '0' ) {
1464
+ $numberposts = absint( $GLOBALS["shariff3UU"]["ranking"] );
1465
+ }
1466
+ else {
1467
+ $numberposts = '100';
1468
+ }
1469
 
1470
+ // catch last 100 posts or whatever number is set for it
1471
+ $args = array( 'numberposts' => $numberposts, 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish' );
1472
  $recent_posts = wp_get_recent_posts( $args );
1473
  if ( $recent_posts ) {
1474
  foreach( $recent_posts as $recent ) {
1475
  // get url
1476
  $url = get_permalink( $recent["ID"] );
1477
+ $post_url = urlencode( $url );
1478
  // set transient name
1479
  $post_hash = 'shariff' . hash( "md5", $post_url );
1480
  // get share counts from cache
1481
  if ( get_transient( $post_hash ) !== false ) {
1482
  $share_counts = get_transient( $post_hash );
1483
  $services = array_merge( $services, $share_counts );
1484
+ if ( isset( $share_counts['total'] ) ) $total = $share_counts['total'];
1485
+ else $total = '0';
1486
  }
1487
  else {
1488
  $share_counts = array();
css/shariff.css CHANGED
@@ -1,4 +1,5 @@
1
  /* Shariff Wrapper */
 
2
  .shariff ul {
3
  display: flex;
4
  flex-direction: row;
@@ -19,12 +20,12 @@
19
  }
20
  .shariff a {
21
  position: relative;
22
- display: block;
23
  height: 35px;
24
  padding: 0;
25
  box-sizing: border-box;
26
  border: 0;
27
- color: #fff !important;
28
  text-decoration: none;
29
  background-image: none !important;
30
  }
@@ -279,19 +280,14 @@
279
  }
280
  .shariff .shariff-button.info {
281
  width: 35px;
282
- background-color: transparent !important;
283
  }
284
  .shariff .buttonsize-small .shariff-button.info { width: 25px; }
285
  .shariff .buttonsize-small .info a { width: 25px; }
286
- .shariff .info a:hover { background-color: #efefef !important; }
287
- .shariff .theme-grey .info a:hover { background-color: #666 !important; }
288
  .shariff .info .shariff-icon svg {
289
  display: block;
290
- fill: #666;
291
  margin: auto;
292
  }
293
- .shariff .theme-grey .info .shariff-icon svg { fill: #fff; }
294
- .shariff .theme-white .info .shariff-icon svg { fill: #666; }
295
  /* media queries */
296
  @media only screen and (max-width: 360px) {
297
  .shariff .orientation-horizontal li { width: 35px; }
1
  /* Shariff Wrapper */
2
+ .shariff-main { display: block !important; }
3
  .shariff ul {
4
  display: flex;
5
  flex-direction: row;
20
  }
21
  .shariff a {
22
  position: relative;
23
+ display: block !important;
24
  height: 35px;
25
  padding: 0;
26
  box-sizing: border-box;
27
  border: 0;
28
+ color: #fff;
29
  text-decoration: none;
30
  background-image: none !important;
31
  }
280
  }
281
  .shariff .shariff-button.info {
282
  width: 35px;
283
+ flex: 0 0 auto !important;
284
  }
285
  .shariff .buttonsize-small .shariff-button.info { width: 25px; }
286
  .shariff .buttonsize-small .info a { width: 25px; }
 
 
287
  .shariff .info .shariff-icon svg {
288
  display: block;
 
289
  margin: auto;
290
  }
 
 
291
  /* media queries */
292
  @media only screen and (max-width: 360px) {
293
  .shariff .orientation-horizontal li { width: 35px; }
css/shariff.min.css CHANGED
@@ -1 +1 @@
1
- .shariff ul{display:flex;flex-direction:row;flex-flow:row wrap;padding:0!important;margin:0!important}.shariff li{height:35px;box-sizing:border-box;list-style-type:none!important;list-style-image:none!important;overflow:hidden!important;margin:5px!important;padding:0!important;text-indent:0!important;border-left:0 none!important}.shariff a{position:relative;display:block;height:35px;padding:0;box-sizing:border-box;border:0;color:#fff!important;text-decoration:none;background-image:none!important}.shariff a:hover{color:#fff;background-color:inherit!important;text-decoration:none!important}.shariff span{color:inherit}.shariff .shariff-count{position:absolute;height:33px;top:0;right:0;margin:1px;padding:0 8px;background-color:rgba(255,255,255,0.5)}.shariff .shariff-count,.shariff .shariff-text{font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:36px;vertical-align:top}.shariff .shariff-text{padding-left:3px}.shariff .shariff-icon svg{width:32px;height:20px;padding:7px 1px;box-sizing:content-box;fill:#fff}.shariff-button::before{content:none!important}.shariff .theme-color .shariff-count{background-color:transparent!important;color:#fff!important}.shariff .theme-grey a{background-color:#b0b0b0!important}.shariff .theme-grey a:hover{background-color:inherit!important}.shariff .theme-grey .shariff-count{background-color:transparent;color:#fff!important}.shariff .theme-white a{background-color:#fff!important;border:1px solid #ddd}.shariff .theme-white a:hover{background-color:#eee!important}.shariff .theme-white svg{fill:inherit}.shariff .theme-white .shariff-count{background-color:transparent;margin:0}.shariff .theme-round li{background:none;width:35px!important;height:35px;border-radius:50%;margin:5px}.shariff .theme-round a{position:relative;height:35px;border-radius:50%}.shariff .theme-round .shariff-icon svg{display:block;margin:auto;padding:8px 1px}.shariff .theme-round .shariff-text{display:block}.shariff .theme-round .shariff-count{display:inline;padding:0;right:0;left:0;top:0;background-color:transparent;color:transparent!important;text-align:center}.shariff .theme-round .shariff-count:hover{background-color:inherit!important;color:#fff!important}.shariff .buttonsize-small li{height:25px!important}.shariff .buttonsize-small a{height:25px!important}.shariff .buttonsize-small.orientation-vertical li{width:115px}.shariff .buttonsize-small .shariff-icon svg{width:22px;height:15px;padding:5px 1px}.shariff .buttonsize-small .shariff-text,.shariff .buttonsize-small .shariff-count{font-size:11px;line-height:25px;padding:0 5px;height:23px}.shariff .buttonsize-small .shariff-text{padding-left:1px!important}.shariff .buttonsize-small.theme-round li{width:25px!important}.shariff .buttonsize-small.theme-round a{width:25px!important}.shariff .buttonsize-small.theme-round .shariff-count{padding:0!important;height:25px!important}.shariff .orientation-vertical{flex-direction:column}.shariff .orientation-vertical li{width:135px}.shariff.shariff-align-flex-start ul{justify-content:flex-start;align-items:flex-start}.shariff.shariff-align-center ul{justify-content:center;align-items:center}.shariff.shariff-align-flex-end ul{justify-content:flex-end;align-items:flex-end}.widget .shariff.shariff-widget-align-flex-start ul{justify-content:flex-start;align-items:flex-start}.widget .shariff.shariff-widget-align-center ul{justify-content:center;align-items:center}.widget .shariff.shariff-widget-align-flex-end ul{justify-content:flex-end;align-items:flex-end}.shariff.shariff-buttonstretch li{flex:1 0 auto!important}.shariff.shariff-buttonstretch .orientation-vertical li{width:100%!important}.widget .shariff .theme-default li,.widget .shariff .theme-color li,.widget .shariff .theme-grey li,.widget .shariff .theme-round li{border:medium none;font-weight:400}.widget .shariff .theme-default a,.widget .shariff .theme-color a,.widget .shariff .theme-grey a,.widget .shariff .theme-round a{color:#fff;display:block;font-weight:400}.widget .shariff .theme-default a:hover,.widget .shariff .theme-color a:hover,.widget .shariff .theme-grey a:hover,.widget .shariff .theme-round a:hover{color:#fff;font-weight:400}.shariff_mailform{background:#eee none repeat scroll 0 0;border:1px solid;margin:10px;max-width:750px;padding:10px 15px}.shariff_mailform form{margin:0!important}.shariff_mailform fieldset{border:none;margin:0!important;padding:0}.shariff_mailform label{margin-left:3px;display:inline-block}.shariff_mailform p{margin:10px 0!important}.shariff_mailform textarea{height:auto!important;margin:0!important;padding:0;width:100%}.shariff_mailform input,.shariff_mailform select{vertical-align:baseline;height:2.2rem;padding:0 10px;width:100%;margin:0!important}.shariff_mailform_error{color:red;font-weight:700;padding:0 0 5px}.shariff_mailform_disabled{color:red;font-weight:700;padding:2px 0 0}.shariff_mailform_headline{position:relative;padding:0}.shariff_mailform_headline legend{font-weight:700!important}.shariff_mailform_submit{cursor:pointer}.shariff_closeX{position:absolute;right:0;top:0;padding:2px;text-decoration:none;box-shadow:none!important;border:none!important;cursor:pointer}.shariff_closeX svg:hover{fill:#c00}.shariff-warning{background-color:red;color:#fff;font-size:20px;font-weight:700;padding:10px;text-align:center;margin:0 auto;line-height:1.5}.shariff .info a{border:1px solid #ddd;width:35px}.shariff .shariff-button.info{width:35px;background-color:transparent!important}.shariff .buttonsize-small .shariff-button.info{width:25px}.shariff .buttonsize-small .info a{width:25px}.shariff .info a:hover{background-color:#efefef!important}.shariff .theme-grey .info a:hover{background-color:#666!important}.shariff .info .shariff-icon svg{display:block;fill:#666;margin:auto}.shariff .theme-grey .info .shariff-icon svg{fill:#fff}.shariff .theme-white .info .shariff-icon svg{fill:#666}@media only screen and (max-width: 360px){.shariff .orientation-horizontal li{width:35px}.shariff .orientation-horizontal.buttonsize-small li{width:25px}.shariff .orientation-horizontal .shariff-icon svg{display:block;margin:auto}.shariff .orientation-horizontal .shariff-count{display:none}}@media only screen and (min-width: 361px){.shariff .orientation-horizontal li{width:80px}.shariff .orientation-horizontal li .shariff-text{display:block}.shariff .orientation-horizontal li .shariff-count{display:block}}@media only screen and (min-width: 768px){.shariff .orientation-horizontal li{width:130px}.shariff .orientation-horizontal.buttonsize-small li{width:105px}.shariff .orientation-horizontal li .shariff-text{display:inline}}@media only screen and (min-device-width: 1025px){.shariff .shariff-mobile{display:none!important}}
1
+ .shariff-main{display:block!important}.shariff ul{display:flex;flex-direction:row;flex-flow:row wrap;padding:0!important;margin:0!important}.shariff li{height:35px;box-sizing:border-box;list-style-type:none!important;list-style-image:none!important;overflow:hidden!important;margin:5px!important;padding:0!important;text-indent:0!important;border-left:0 none!important}.shariff a{position:relative;display:block!important;height:35px;padding:0;box-sizing:border-box;border:0;color:#fff;text-decoration:none;background-image:none!important}.shariff a:hover{color:#fff;background-color:inherit!important;text-decoration:none!important}.shariff span{color:inherit}.shariff .shariff-count{position:absolute;height:33px;top:0;right:0;margin:1px;padding:0 8px;background-color:rgba(255,255,255,0.5)}.shariff .shariff-count,.shariff .shariff-text{font-family:Arial,Helvetica,sans-serif;font-size:12px;line-height:36px;vertical-align:top}.shariff .shariff-text{padding-left:3px}.shariff .shariff-icon svg{width:32px;height:20px;padding:7px 1px;box-sizing:content-box;fill:#fff}.shariff-button::before{content:none!important}.shariff .theme-color .shariff-count{background-color:transparent!important;color:#fff!important}.shariff .theme-grey a{background-color:#b0b0b0!important}.shariff .theme-grey a:hover{background-color:inherit!important}.shariff .theme-grey .shariff-count{background-color:transparent;color:#fff!important}.shariff .theme-white a{background-color:#fff!important;border:1px solid #ddd}.shariff .theme-white a:hover{background-color:#eee!important}.shariff .theme-white svg{fill:inherit}.shariff .theme-white .shariff-count{background-color:transparent;margin:0}.shariff .theme-round li{background:none;width:35px!important;height:35px;border-radius:50%;margin:5px}.shariff .theme-round a{position:relative;height:35px;border-radius:50%}.shariff .theme-round .shariff-icon svg{display:block;margin:auto;padding:8px 1px}.shariff .theme-round .shariff-text{display:block}.shariff .theme-round .shariff-count{display:inline;padding:0;right:0;left:0;top:0;background-color:transparent;color:transparent!important;text-align:center}.shariff .theme-round .shariff-count:hover{background-color:inherit!important;color:#fff!important}.shariff .buttonsize-small li{height:25px!important}.shariff .buttonsize-small a{height:25px!important}.shariff .buttonsize-small.orientation-vertical li{width:115px}.shariff .buttonsize-small .shariff-icon svg{width:22px;height:15px;padding:5px 1px}.shariff .buttonsize-small .shariff-text,.shariff .buttonsize-small .shariff-count{font-size:11px;line-height:25px;padding:0 5px;height:23px}.shariff .buttonsize-small .shariff-text{padding-left:1px!important}.shariff .buttonsize-small.theme-round li{width:25px!important}.shariff .buttonsize-small.theme-round a{width:25px!important}.shariff .buttonsize-small.theme-round .shariff-count{padding:0!important;height:25px!important}.shariff .orientation-vertical{flex-direction:column}.shariff .orientation-vertical li{width:135px}.shariff.shariff-align-flex-start ul{justify-content:flex-start;align-items:flex-start}.shariff.shariff-align-center ul{justify-content:center;align-items:center}.shariff.shariff-align-flex-end ul{justify-content:flex-end;align-items:flex-end}.widget .shariff.shariff-widget-align-flex-start ul{justify-content:flex-start;align-items:flex-start}.widget .shariff.shariff-widget-align-center ul{justify-content:center;align-items:center}.widget .shariff.shariff-widget-align-flex-end ul{justify-content:flex-end;align-items:flex-end}.shariff.shariff-buttonstretch li{flex:1 0 auto!important}.shariff.shariff-buttonstretch .orientation-vertical li{width:100%!important}.widget .shariff .theme-default li,.widget .shariff .theme-color li,.widget .shariff .theme-grey li,.widget .shariff .theme-round li{border:medium none;font-weight:400}.widget .shariff .theme-default a,.widget .shariff .theme-color a,.widget .shariff .theme-grey a,.widget .shariff .theme-round a{color:#fff;display:block;font-weight:400}.widget .shariff .theme-default a:hover,.widget .shariff .theme-color a:hover,.widget .shariff .theme-grey a:hover,.widget .shariff .theme-round a:hover{color:#fff;font-weight:400}.shariff_mailform{background:#eee none repeat scroll 0 0;border:1px solid;margin:10px;max-width:750px;padding:10px 15px}.shariff_mailform form{margin:0!important}.shariff_mailform fieldset{border:none;margin:0!important;padding:0}.shariff_mailform label{margin-left:3px;display:inline-block}.shariff_mailform p{margin:10px 0!important}.shariff_mailform textarea{height:auto!important;margin:0!important;padding:0;width:100%}.shariff_mailform input,.shariff_mailform select{vertical-align:baseline;height:2.2rem;padding:0 10px;width:100%;margin:0!important}.shariff_mailform_error{color:red;font-weight:700;padding:0 0 5px}.shariff_mailform_disabled{color:red;font-weight:700;padding:2px 0 0}.shariff_mailform_headline{position:relative;padding:0}.shariff_mailform_headline legend{font-weight:700!important}.shariff_mailform_submit{cursor:pointer}.shariff_closeX{position:absolute;right:0;top:0;padding:2px;text-decoration:none;box-shadow:none!important;border:none!important;cursor:pointer}.shariff_closeX svg:hover{fill:#c00}.shariff-warning{background-color:red;color:#fff;font-size:20px;font-weight:700;padding:10px;text-align:center;margin:0 auto;line-height:1.5}.shariff .info a{border:1px solid #ddd;width:35px}.shariff .shariff-button.info{width:35px;flex:0 0 auto!important}.shariff .buttonsize-small .shariff-button.info{width:25px}.shariff .buttonsize-small .info a{width:25px}.shariff .info .shariff-icon svg{display:block;margin:auto}@media only screen and (max-width: 360px){.shariff .orientation-horizontal li{width:35px}.shariff .orientation-horizontal.buttonsize-small li{width:25px}.shariff .orientation-horizontal .shariff-icon svg{display:block;margin:auto}.shariff .orientation-horizontal .shariff-count{display:none}}@media only screen and (min-width: 361px){.shariff .orientation-horizontal li{width:80px}.shariff .orientation-horizontal li .shariff-text{display:block}.shariff .orientation-horizontal li .shariff-count{display:block}}@media only screen and (min-width: 768px){.shariff .orientation-horizontal li{width:130px}.shariff .orientation-horizontal.buttonsize-small li{width:105px}.shariff .orientation-horizontal li .shariff-text{display:inline}}@media only screen and (min-device-width: 1025px){.shariff .shariff-mobile{display:none!important}}
pictos/borderradius.png ADDED
Binary file
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: 3UU, starguide
3
  Tags: Shariff, Facebook, Twitter, VKontakte, VK, GooglePlus, WhatsApp, share buttons, sharing, privacy, social
4
  Requires at least: 4.4
5
  Tested up to: 4.5
6
- Stable tag: 4.0.8
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
  Donate link: http://folge.link/?bitcoin=1Ritz1iUaLaxuYcXhUCoFhkVRH6GWiMTP
@@ -172,6 +172,19 @@ fixed in the future - if we have time to spend or you provide us with a lot of "
172
 
173
  == Changelog ==
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  = 4.0.8 =
176
  - new workaround for sites running PHP 5.2 and older
177
 
3
  Tags: Shariff, Facebook, Twitter, VKontakte, VK, GooglePlus, WhatsApp, share buttons, sharing, privacy, social
4
  Requires at least: 4.4
5
  Tested up to: 4.5
6
+ Stable tag: 4.1.0
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
  Donate link: http://folge.link/?bitcoin=1Ritz1iUaLaxuYcXhUCoFhkVRH6GWiMTP
172
 
173
  == Changelog ==
174
 
175
+ = 4.1.0 =
176
+ - new design option to set a custom button color for all buttons
177
+ - new design option to set a border radius for the round theme (up to a square)
178
+ - new design option to hide all buttons until the page is fully loaded
179
+ - new mailform option to use a html anchor (again)
180
+ - new statistic option to fill the cache automatically
181
+ - new statistic option to set the amount of posts for the ranking tab
182
+ - new statistic option to use share counts with PHP < 5.4
183
+ - fix preventing buttons from beeing added to excerpts under certain conditions
184
+ - fix urlencoding of share count requests
185
+ - improved handling of wrong or mistyped service entries
186
+ - minor bug fixes
187
+
188
  = 4.0.8 =
189
  - new workaround for sites running PHP 5.2 and older
190
 
services/shariff-info.php CHANGED
@@ -16,11 +16,22 @@ if ( isset( $frontend ) && $frontend == '1' ) {
16
  $button_url = $service_url;
17
 
18
  // svg icon
19
- $svg_icon = '<svg width="32px" height="20px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 32"><path d="M11.4 24v2.3q0 0.5-0.3 0.8t-0.8 0.4h-9.1q-0.5 0-0.8-0.4t-0.4-0.8v-2.3q0-0.5 0.4-0.8t0.8-0.4h1.1v-6.8h-1.1q-0.5 0-0.8-0.4t-0.4-0.8v-2.3q0-0.5 0.4-0.8t0.8-0.4h6.8q0.5 0 0.8 0.4t0.4 0.8v10.3h1.1q0.5 0 0.8 0.4t0.3 0.8zM9.2 3.4v3.4q0 0.5-0.4 0.8t-0.8 0.4h-4.6q-0.4 0-0.8-0.4t-0.4-0.8v-3.4q0-0.4 0.4-0.8t0.8-0.4h4.6q0.5 0 0.8 0.4t0.4 0.8z"/></svg>';
 
 
 
 
 
20
 
21
  // colors
22
- $main_color = '#fff';
23
- $secondary_color = '#fff';
 
 
 
 
 
 
24
 
25
  // button title / label
26
  $button_title_array = array(
16
  $button_url = $service_url;
17
 
18
  // svg icon
19
+ $svg_icon = '<svg width="32px" height="20px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11 32"';
20
+ // default theme?
21
+ if ( ! array_key_exists( 'maincolor', $atts ) && ( ( array_key_exists( 'theme', $atts ) && $atts['theme'] == "default" || ( array_key_exists( 'theme', $atts ) && $atts['theme'] == "round" ) ) || ! array_key_exists( 'theme', $atts ) ) ) {
22
+ $svg_icon .= ' style="fill:#999"';
23
+ }
24
+ $svg_icon .= '><path d="M11.4 24v2.3q0 0.5-0.3 0.8t-0.8 0.4h-9.1q-0.5 0-0.8-0.4t-0.4-0.8v-2.3q0-0.5 0.4-0.8t0.8-0.4h1.1v-6.8h-1.1q-0.5 0-0.8-0.4t-0.4-0.8v-2.3q0-0.5 0.4-0.8t0.8-0.4h6.8q0.5 0 0.8 0.4t0.4 0.8v10.3h1.1q0.5 0 0.8 0.4t0.3 0.8zM9.2 3.4v3.4q0 0.5-0.4 0.8t-0.8 0.4h-4.6q-0.4 0-0.8-0.4t-0.4-0.8v-3.4q0-0.4 0.4-0.8t0.8-0.4h4.6q0.5 0 0.8 0.4t0.4 0.8z"/></svg>';
25
 
26
  // colors
27
+ $main_color = '#999';
28
+ $secondary_color = '#a8a8a8';
29
+
30
+ // button share text
31
+ $button_text_array = array(
32
+ 'de' => 'info',
33
+ 'en' => 'info'
34
+ );
35
 
36
  // button title / label
37
  $button_title_array = array(
services/shariff-mailform.php CHANGED
@@ -10,6 +10,11 @@ if ( isset( $frontend ) && $frontend == '1' ) {
10
  // build button url
11
  $button_url = urldecode( $share_url ) . '?view=mail';
12
 
 
 
 
 
 
13
  // svg icon
14
  $svg_icon = '<svg width="32px" height="20px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M32 12.7v14.2q0 1.2-0.8 2t-2 0.9h-26.3q-1.2 0-2-0.9t-0.8-2v-14.2q0.8 0.9 1.8 1.6 6.5 4.4 8.9 6.1 1 0.8 1.6 1.2t1.7 0.9 2 0.4h0.1q0.9 0 2-0.4t1.7-0.9 1.6-1.2q3-2.2 8.9-6.1 1-0.7 1.8-1.6zM32 7.4q0 1.4-0.9 2.7t-2.2 2.2q-6.7 4.7-8.4 5.8-0.2 0.1-0.7 0.5t-1 0.7-0.9 0.6-1.1 0.5-0.9 0.2h-0.1q-0.4 0-0.9-0.2t-1.1-0.5-0.9-0.6-1-0.7-0.7-0.5q-1.6-1.1-4.7-3.2t-3.6-2.6q-1.1-0.7-2.1-2t-1-2.5q0-1.4 0.7-2.3t2.1-0.9h26.3q1.2 0 2 0.8t0.9 2z"/></svg>';
15
 
10
  // build button url
11
  $button_url = urldecode( $share_url ) . '?view=mail';
12
 
13
+ // add anchor if option is set
14
+ if ( isset( $shariff3UU["mailform_anchor"] ) && $shariff3UU["mailform_anchor"] == '1' ) {
15
+ $button_url .= '#shariff_mailform';
16
+ }
17
+
18
  // svg icon
19
  $svg_icon = '<svg width="32px" height="20px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path d="M32 12.7v14.2q0 1.2-0.8 2t-2 0.9h-26.3q-1.2 0-2-0.9t-0.8-2v-14.2q0.8 0.9 1.8 1.6 6.5 4.4 8.9 6.1 1 0.8 1.6 1.2t1.7 0.9 2 0.4h0.1q0.9 0 2-0.4t1.7-0.9 1.6-1.2q3-2.2 8.9-6.1 1-0.7 1.8-1.6zM32 7.4q0 1.4-0.9 2.7t-2.2 2.2q-6.7 4.7-8.4 5.8-0.2 0.1-0.7 0.5t-1 0.7-0.9 0.6-1.1 0.5-0.9 0.2h-0.1q-0.4 0-0.9-0.2t-1.1-0.5-0.9-0.6-1-0.7-0.7-0.5q-1.6-1.1-4.7-3.2t-3.6-2.6q-1.1-0.7-2.1-2t-1-2.5q0-1.4 0.7-2.3t2.1-0.9h26.3q1.2 0 2 0.8t0.9 2z"/></svg>';
20
 
shariff.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Shariff Wrapper
4
  * Plugin URI: https://de.wordpress.org/plugins/shariff/
5
  * Description: The Shariff Wrapper provides share buttons that respect the privacy of your visitors and are compliant to the German data protection laws.
6
- * Version: 4.0.8
7
  * Author: Jan-Peter Lambeck & 3UU
8
  * Author URI: https://de.wordpress.org/plugins/shariff/
9
  * License: MIT
@@ -26,7 +26,7 @@ $shariff3UU = array_merge( $shariff3UU_basic, $shariff3UU_design, $shariff3UU_ad
26
  // update function to perform tasks _once_ after an update, based on version number to work for automatic as well as manual updates
27
  function shariff3UU_update() {
28
  /******************** ADJUST VERSION ********************/
29
- $code_version = "4.0.8"; // set code version - needs to be adjusted for every new version!
30
  /******************** ADJUST VERSION ********************/
31
 
32
  // get options
@@ -90,6 +90,20 @@ function shariff_init_locale() {
90
  }
91
  }
92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  // provide share counts via the wp rest api
94
  function shariff3UU_share_counts( WP_REST_Request $request ) {
95
  // get options
@@ -116,13 +130,13 @@ function shariff3UU_share_counts( WP_REST_Request $request ) {
116
  // on an external backend check allowed hosts
117
  if ( defined( 'SHARIFF_FRONTENDS' ) ) {
118
  $shariff_frontends = array_flip( explode( '|', SHARIFF_FRONTENDS ) );
119
- if ( ! array_key_exists( $get_url['host'], $shariff_frontends ) ) {
120
  return new WP_Error( 'externaldomainnotallowed', 'External domain not allowed by this server!', array( 'status' => 400 ) );
121
  }
122
  }
123
  // else compare that domain is equal
124
- elseif ( $get_url['host'] != $wp_url['host'] ) {
125
- return new WP_Error( 'domainnotallowed', 'Domain not allowed by this server!' . $get_url['host'], array( 'status' => 400 ) );
126
  }
127
 
128
  // encode shareurl
@@ -225,73 +239,152 @@ function shariff3UU_share_counts( WP_REST_Request $request ) {
225
  }
226
  // else we fetch new counts ourselfs
227
  else {
228
- // we only need the backend part from the service phps
229
- $backend = '1';
230
-
231
- // prevent php notices
232
- $total_count = '0';
233
-
234
- // loop through all desired services
235
- foreach ( $service_array as $service ) {
236
- // only include services that are not disabled
237
- if ( ! empty( $service ) && ( ! isset( $shariff3UU["disable"][ $service ] ) || ( isset( $shariff3UU["disable"][ $service ] ) && $shariff3UU["disable"][ $service ] == 0 ) ) ) {
238
- // determine path
239
- $path_service_file = plugin_dir_path( __FILE__ ) . 'services/shariff-' . $service . '.php';
240
- // include service files
241
- if ( file_exists( $path_service_file ) ) include( $path_service_file );
242
- // if we have an error (e.g. a timeout) and we have an old share count for this service, keep it!
243
- if ( array_key_exists( $service, $old_share_counts ) && ( ! array_key_exists( $service, $share_counts ) || empty( $share_counts[ $service ] ) ) ) {
244
- $share_counts[ $service ] = $old_share_counts[ $service ];
245
- }
 
 
 
 
 
 
 
 
 
 
 
246
  }
247
- // calculate total share count
248
- if ( isset( $share_counts[ $service ] ) ) $total_count = $total_count + $share_counts[ $service ];
249
  }
 
 
 
250
 
251
- // add total count
252
- if ( $total_count != '0' ) $share_counts[ 'total' ] = $total_count;
253
-
254
- // save transient, if we have counts
255
- if ( isset( $share_counts ) && $share_counts != null ) {
256
- // add current timestamp and url
257
- $share_counts['timestamp'] = current_time( 'timestamp', true );
258
- $share_counts['url'] = $post_url2;
259
- // combine different set of services
260
- if ( get_transient( $post_hash ) !== false ) {
261
- $other_request = get_transient( $post_hash );
262
- $share_counts = array_merge( $other_request, $share_counts );
263
- }
264
- // save transient
265
- set_transient( $post_hash, $share_counts, '604800' );
266
- // offer a hook to work with the share counts
267
- do_action( 'shariff_share_counts', $share_counts );
268
- // update info
269
- $share_counts['updated'] = '1';
270
  }
 
 
 
 
 
 
 
 
 
 
 
271
  }
272
 
273
- // return results, if we have some or an error message if not
274
- if ( isset( $share_counts ) && $share_counts != null ) {
275
- return $share_counts;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  }
277
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
- // register route and sanitize input
280
- function shariff3UU_sanitize_api () {
281
- register_rest_route( 'shariff/v1', '/share_counts', array(
282
- 'methods' => 'GET',
283
- 'callback' => 'shariff3UU_share_counts',
284
- 'args' => array(
285
- 'url' => array( 'sanitize_callback' => 'esc_url' ),
286
- 'services' => array( 'sanitize_callback' => 'sanitize_text_field' ),
287
- 'timestamp' => array( 'sanitize_callback' => 'absint' ),
288
- ),
289
- ) );
290
  }
291
- add_action( 'rest_api_init', 'shariff3UU_sanitize_api' );
 
 
 
 
 
 
 
 
 
292
 
293
  // add shorttag to posts
294
  function shariff3UU_posts( $content ) {
 
 
 
 
295
  // get options
296
  $shariff3UU = $GLOBALS["shariff3UU"];
297
 
@@ -371,7 +464,7 @@ function shariff3UU_excerpt( $content ) {
371
  }
372
  return $content;
373
  }
374
- add_filter( 'get_the_excerpt', 'shariff3UU_excerpt' );
375
 
376
  // add mailform to bbpress_replies
377
  function bbp_add_mailform_to_bbpress_replies() {
@@ -417,6 +510,9 @@ function shariff3UU_render( $atts, $content = null ) {
417
  // remove empty elements
418
  $atts = array_filter( $atts );
419
 
 
 
 
420
  // clean up headline in case it was used in a shorttag
421
  if ( array_key_exists( 'headline', $atts ) ) {
422
  $atts['headline'] = wp_kses( $atts['headline'], $GLOBALS["allowed_tags"] );
@@ -461,7 +557,7 @@ function shariff3UU_render( $atts, $content = null ) {
461
  $share_counts = get_transient( $post_hash );
462
  }
463
 
464
- // prevent an error notice while debug mode is on, because of "undefined variable" when using .=
465
  $output = '';
466
 
467
  // if we have a style attribute add ShariffSC container including these styles
@@ -508,7 +604,7 @@ function shariff3UU_render( $atts, $content = null ) {
508
  if ( array_key_exists( 'timestamp', $atts ) ) $output .= ' data-timestamp="' . absint( get_the_modified_date( 'U', true ) ) . '"';
509
 
510
  // start output of actual Shariff buttons
511
- $output .= '<div class="shariff';
512
  // alignment
513
  if ( array_key_exists( 'align', $atts ) && $atts['align'] != 'none' ) {
514
  $output .= ' shariff-align-' . $atts["align"];
@@ -522,10 +618,12 @@ function shariff3UU_render( $atts, $content = null ) {
522
  $output .= ' shariff-buttonstretch';
523
  }
524
  $output .= '"';
 
 
525
  // add information for share count request
526
  if ( array_key_exists( 'backend', $atts ) && $atts['backend'] == "on" ) {
527
  // share url
528
- $output .= ' data-url="' . urlencode( $share_url ) . '"';
529
  // timestamp for cache
530
  $output .= ' data-timestamp="' . absint( get_the_modified_date( 'U', true ) ) . '"';
531
  // add external api if entered
@@ -585,74 +683,102 @@ function shariff3UU_render( $atts, $content = null ) {
585
  elseif ( $service == 'patreon' && ! array_key_exists( 'patreonid', $atts ) ) $patreon_error = '1';
586
  // start render button
587
  elseif ( $service != 'total' && $service != 'totalnumber' ) {
 
588
  // include service parameters
589
  $frontend = '1';
590
 
591
  // determine path to service phps
592
  $path_service_file = plugin_dir_path( __FILE__ ) . 'services/shariff-' . $service . '.php';
593
 
594
- // include service files
595
- if ( file_exists( $path_service_file ) ) include( $path_service_file );
 
 
 
 
 
 
 
 
 
 
 
596
 
597
- // start li
598
- $output .= '<li class="shariff-button ' . $service;
599
- // mobile only
600
- if ( $mobile_only == '1') $output .= ' shariff-mobile';
601
- $output .= '" style="background-color:' . $secondary_color . '">';
602
-
603
- // use default button share text, if $button_text_array is empty
604
- if ( empty( $button_text_array ) ) $button_text_array = $default_button_text_array;
605
-
606
- // set button text in desired language, fallback is English
607
- if ( array_key_exists( 'lang', $atts ) && array_key_exists( $atts['lang'], $button_text_array ) ) $button_text = $button_text_array[ $atts['lang'] ];
608
- else $button_text = $button_text_array['en'];
609
-
610
- // set button title / label in desired language, fallback is English
611
- if ( array_key_exists( 'lang', $atts ) && array_key_exists( $atts['lang'], $button_title_array ) ) $button_title = $button_title_array[ $atts['lang'] ];
612
- else $button_title = $button_title_array['en'];
613
-
614
- // reset $button_text_array
615
- $button_text_array = '';
616
-
617
- // build the actual button
618
- $output .= '<a href="' . $button_url . '" title="' . $button_title . '" aria-label="' . $button_title . '" role="button" rel="nofollow" class="shariff-link" ';
619
- // same window?
620
- if ( ! isset( $same_window ) || isset( $same_window ) && $same_window != '1' ) $output .= 'target="_blank" ';
621
- $output .= 'style="background-color:' . $main_color;
622
- // theme white?
623
- if ( isset( $atts['theme'] ) && $atts['theme'] == "white" ) $output .= '; color:' . $main_color . ' !important';
624
- $output .= '">';
625
- $output .= '<span class="shariff-icon"';
 
 
 
 
 
 
 
 
 
 
626
  // theme white?
627
- if ( isset( $atts['theme'] ) && $atts['theme'] == "white" ) $output .= ' style="fill:' . $main_color . '"';
628
- $output .= '>' . $svg_icon . '</span>';
629
- $output .= '<span class="shariff-text">' . $button_text . '</span>&nbsp;';
630
- // share counts?
631
- if ( array_key_exists( 'sharecounts', $atts ) && $atts['sharecounts'] == "1" && $backend_available == '1' && ! isset ( $shariff3UU["disable"][ $service ] ) ) {
632
- $output .= '<span class="shariff-count" data-service="' . $service . '" style="color:' . $main_color;
633
- if ( array_key_exists( $service, $share_counts ) === true && $share_counts[ $service ] !== null && $share_counts[ $service ] !== '-1' ) {
634
- $output .= '">' . $share_counts[ $service ];
 
 
 
 
 
 
 
 
635
  }
636
- else $output .= ';opacity:0">';
637
- $output .= '</span>&nbsp;';
638
- }
639
- $output .= '</a>';
640
- $output .= '</li>';
641
-
642
- // add service to backend service, if available
643
- if ( $backend_available == '1' && ! isset ( $shariff3UU["disable"][ $service ] ) ) $backend_service_array[] = $service;
644
-
645
- // reset $backend_available, $mobile_only, $same_window
646
- $backend_available = '';
647
- $mobile_only = '';
648
- $same_window = '';
649
  }
650
  }
651
 
652
  // add the list of backend services
653
  if ( ! empty( $backend_service_array ) ) {
654
  $backend_services = implode( '|', $backend_service_array );
655
- $output = str_replace( 'data-url=', 'data-services="' . $backend_services . '" data-url=', $output );
656
  }
657
 
658
  // close ul and the main shariff div
@@ -781,6 +907,11 @@ function shariff3UU_addMailForm( $content, $error ) {
781
  // use wp_nonce_url / wp_verify_nonce to prevent automated spam by url
782
  $submit_link = wp_nonce_url( get_permalink(), 'shariff3UU_send_mail', 'shariff_mf_nonce' );
783
 
 
 
 
 
 
784
  // sender address optional?
785
  $mf_optional_text = '';
786
  $mf_sender_required = '';
@@ -1219,6 +1350,8 @@ function shariff3UU_deactivate() {
1219
  switch_to_blog( $blog['blog_id'] );
1220
  // purge transients
1221
  shariff3UU_purge_transients_deactivation();
 
 
1222
  // switch back to main
1223
  restore_current_blog();
1224
  }
@@ -1227,10 +1360,15 @@ function shariff3UU_deactivate() {
1227
  else {
1228
  // purge transients
1229
  shariff3UU_purge_transients_deactivation();
 
 
1230
  }
1231
  }
1232
  register_deactivation_hook( __FILE__, 'shariff3UU_deactivate' );
1233
 
 
 
 
1234
  // purge all the transients associated with our plugin
1235
  function shariff3UU_purge_transients_deactivation() {
1236
  // make sure we have the $wpdb class ready
3
  * Plugin Name: Shariff Wrapper
4
  * Plugin URI: https://de.wordpress.org/plugins/shariff/
5
  * Description: The Shariff Wrapper provides share buttons that respect the privacy of your visitors and are compliant to the German data protection laws.
6
+ * Version: 4.1.0
7
  * Author: Jan-Peter Lambeck & 3UU
8
  * Author URI: https://de.wordpress.org/plugins/shariff/
9
  * License: MIT
26
  // update function to perform tasks _once_ after an update, based on version number to work for automatic as well as manual updates
27
  function shariff3UU_update() {
28
  /******************** ADJUST VERSION ********************/
29
+ $code_version = "4.1.0"; // set code version - needs to be adjusted for every new version!
30
  /******************** ADJUST VERSION ********************/
31
 
32
  // get options
90
  }
91
  }
92
 
93
+ // register wp rest api route and sanitize input
94
+ function shariff3UU_sanitize_api() {
95
+ register_rest_route( 'shariff/v1', '/share_counts', array(
96
+ 'methods' => 'GET',
97
+ 'callback' => 'shariff3UU_share_counts',
98
+ 'args' => array(
99
+ 'url' => array( 'sanitize_callback' => 'esc_url' ),
100
+ 'services' => array( 'sanitize_callback' => 'sanitize_text_field' ),
101
+ 'timestamp' => array( 'sanitize_callback' => 'absint' ),
102
+ ),
103
+ ) );
104
+ }
105
+ add_action( 'rest_api_init', 'shariff3UU_sanitize_api' );
106
+
107
  // provide share counts via the wp rest api
108
  function shariff3UU_share_counts( WP_REST_Request $request ) {
109
  // get options
130
  // on an external backend check allowed hosts
131
  if ( defined( 'SHARIFF_FRONTENDS' ) ) {
132
  $shariff_frontends = array_flip( explode( '|', SHARIFF_FRONTENDS ) );
133
+ if ( ! isset( $get_url['host'] ) || ! array_key_exists( $get_url['host'], $shariff_frontends ) ) {
134
  return new WP_Error( 'externaldomainnotallowed', 'External domain not allowed by this server!', array( 'status' => 400 ) );
135
  }
136
  }
137
  // else compare that domain is equal
138
+ elseif ( ! isset( $get_url['host'] ) || $get_url['host'] != $wp_url['host'] ) {
139
+ return new WP_Error( 'domainnotallowed', 'Domain not allowed by this server!', array( 'status' => 400 ) );
140
  }
141
 
142
  // encode shareurl
239
  }
240
  // else we fetch new counts ourselfs
241
  else {
242
+ $share_counts = shariff3UU_fetch_sharecounts( $service_array, $old_share_counts, $post_hash, $post_url, $post_url2 );
243
+ }
244
+
245
+ // return results, if we have some or an error message if not
246
+ if ( isset( $share_counts ) && $share_counts != null ) {
247
+ return $share_counts;
248
+ }
249
+ }
250
+
251
+ // fetch share counts
252
+ function shariff3UU_fetch_sharecounts( $service_array, $old_share_counts, $post_hash, $post_url, $post_url2 ) {
253
+ // we only need the backend part from the service phps
254
+ $backend = '1';
255
+
256
+ // prevent php notices
257
+ $total_count = '0';
258
+ $share_counts = array();
259
+
260
+ // loop through all desired services
261
+ foreach ( $service_array as $service ) {
262
+ // only include services that are not disabled
263
+ if ( ! empty( $service ) && ( ! isset( $shariff3UU["disable"][ $service ] ) || ( isset( $shariff3UU["disable"][ $service ] ) && $shariff3UU["disable"][ $service ] == 0 ) ) ) {
264
+ // determine path
265
+ $path_service_file = plugin_dir_path( __FILE__ ) . 'services/shariff-' . $service . '.php';
266
+ // include service files
267
+ if ( file_exists( $path_service_file ) ) include( $path_service_file );
268
+ // if we have an error (e.g. a timeout) and we have an old share count for this service, keep it!
269
+ if ( array_key_exists( $service, $old_share_counts ) && ( ! array_key_exists( $service, $share_counts ) || empty( $share_counts[ $service ] ) ) ) {
270
+ $share_counts[ $service ] = $old_share_counts[ $service ];
271
  }
 
 
272
  }
273
+ // calculate total share count
274
+ if ( isset( $share_counts[ $service ] ) ) $total_count = $total_count + $share_counts[ $service ];
275
+ }
276
 
277
+ // add total count
278
+ if ( $total_count != '0' ) $share_counts[ 'total' ] = $total_count;
279
+
280
+ // save transient, if we have counts
281
+ if ( isset( $share_counts ) ) {
282
+ // add current timestamp and url
283
+ $share_counts['timestamp'] = current_time( 'timestamp', true );
284
+ $share_counts['url'] = $post_url2;
285
+ // combine different set of services
286
+ if ( get_transient( $post_hash ) !== false ) {
287
+ $other_request = get_transient( $post_hash );
288
+ $share_counts = array_merge( $other_request, $share_counts );
 
 
 
 
 
 
 
289
  }
290
+ // save transient
291
+ set_transient( $post_hash, $share_counts, '604800' );
292
+ // offer a hook to work with the share counts
293
+ do_action( 'shariff_share_counts', $share_counts );
294
+ // update info
295
+ $share_counts['updated'] = '1';
296
+ }
297
+ elseif ( isset( $old_share_counts ) ) {
298
+ $share_counts = $old_share_counts;
299
+ // update info
300
+ $share_counts['updated'] = '0';
301
  }
302
 
303
+ // return share counts
304
+ return $share_counts;
305
+ }
306
+
307
+ // fill cache automatically
308
+ function shariff3UU_fill_cache() {
309
+ // amount of posts - set to 100 if not set
310
+ if ( isset( $GLOBALS["shariff3UU"]["ranking"] ) && absint( $GLOBALS["shariff3UU"]["ranking"] ) > '0' ) {
311
+ $numberposts = absint( $GLOBALS["shariff3UU"]["ranking"] );
312
+ }
313
+ else {
314
+ $numberposts = '100';
315
+ }
316
+
317
+ // avoid errors if no services are given - instead use the default set of services
318
+ if ( empty( $GLOBALS["shariff3UU"]["services"] ) ) $services = "twitter|facebook|googleplus";
319
+ else $services = $GLOBALS["shariff3UU"]["services"];
320
+
321
+ // explode services
322
+ $service_array = explode( '|', $services );
323
+
324
+ // catch last 100 posts or whatever number is set for it
325
+ $args = array( 'numberposts' => $numberposts, 'orderby' => 'post_date', 'order' => 'DESC', 'post_status' => 'publish' );
326
+ $recent_posts = wp_get_recent_posts( $args );
327
+ if ( $recent_posts ) {
328
+ foreach( $recent_posts as $recent ) {
329
+ // get url
330
+ $url = get_permalink( $recent["ID"] );
331
+ $post_url = urlencode( $url );
332
+ // set transient name
333
+ $post_hash = 'shariff' . hash( "md5", $post_url );
334
+ // get old share counts
335
+ if ( get_transient( $post_hash ) !== false ) $old_share_counts = get_transient( $post_hash );
336
+ else $old_share_counts = array();
337
+ // fetch share counts and save same
338
+ shariff3UU_fetch_sharecounts( $service_array, $old_share_counts, $post_hash, $post_url, $url );
339
+ }
340
  }
341
  }
342
+ add_action( 'shariff3UU_fill_cache', 'shariff3UU_fill_cache' );
343
+
344
+ // add schedule event in order to fill cache automatically
345
+ function shariff3UU_fill_cache_schedule() {
346
+ // get options manually bc of start on activation
347
+ $shariff3UU_statistic = (array) get_option( 'shariff3UU_statistic' );
348
+ // check if option is set
349
+ if ( isset( $shariff3UU_statistic["automaticcache"] ) && $shariff3UU_statistic["automaticcache"] == '1' ) {
350
+ // check if job is already scheduled
351
+ if ( ! wp_next_scheduled( 'shariff3UU_fill_cache' ) ) {
352
+ // add cron job
353
+ wp_schedule_event( time(), 'weekly', 'shariff3UU_fill_cache' );
354
+ }
355
+ }
356
+ // else option is not set therefore remove cron job if scheduled
357
+ else {
358
+ if ( wp_next_scheduled( 'shariff3UU_fill_cache' ) ) {
359
+ // remove cron job
360
+ wp_clear_scheduled_hook( 'shariff3UU_fill_cache' );
361
+ }
362
+ }
363
+ }
364
+ add_action( 'shariff3UU_save_statistic_options', 'shariff3UU_fill_cache_schedule' );
365
 
366
+ add_filter( 'http_request_timeout', 'wp_smushit_filter_timeout_time');
367
+ function wp_smushit_filter_timeout_time($time) {
368
+ $time = 25; //new number of seconds
369
+ return $time;
 
 
 
 
 
 
 
370
  }
371
+
372
+ // custom weekly cron recurrences
373
+ function shariff3UU_fill_cache_schedule_custom_recurrence( $schedules ) {
374
+ $schedules['weekly'] = array(
375
+ 'display' => __( 'Once weekly', 'shariff' ),
376
+ 'interval' => '804600',
377
+ );
378
+ return $schedules;
379
+ }
380
+ add_filter( 'cron_schedules', 'shariff3UU_fill_cache_schedule_custom_recurrence' );
381
 
382
  // add shorttag to posts
383
  function shariff3UU_posts( $content ) {
384
+
385
+ // do not add Shariff to excerpts
386
+ if ( in_array( 'get_the_excerpt', $GLOBALS['wp_current_filter'] ) ) return $content;
387
+
388
  // get options
389
  $shariff3UU = $GLOBALS["shariff3UU"];
390
 
464
  }
465
  return $content;
466
  }
467
+ add_filter( 'the_excerpt', 'shariff3UU_excerpt' );
468
 
469
  // add mailform to bbpress_replies
470
  function bbp_add_mailform_to_bbpress_replies() {
510
  // remove empty elements
511
  $atts = array_filter( $atts );
512
 
513
+ // clean up services (remove leading or trailing |, spaces, etc.)
514
+ $atts['services'] = trim( preg_replace( "/[^A-Za-z|]/", '', $atts['services'] ), '|' );
515
+
516
  // clean up headline in case it was used in a shorttag
517
  if ( array_key_exists( 'headline', $atts ) ) {
518
  $atts['headline'] = wp_kses( $atts['headline'], $GLOBALS["allowed_tags"] );
557
  $share_counts = get_transient( $post_hash );
558
  }
559
 
560
+ // prevent info notices in case debug mode is on
561
  $output = '';
562
 
563
  // if we have a style attribute add ShariffSC container including these styles
604
  if ( array_key_exists( 'timestamp', $atts ) ) $output .= ' data-timestamp="' . absint( get_the_modified_date( 'U', true ) ) . '"';
605
 
606
  // start output of actual Shariff buttons
607
+ $output .= '<div class="shariff shariff-main';
608
  // alignment
609
  if ( array_key_exists( 'align', $atts ) && $atts['align'] != 'none' ) {
610
  $output .= ' shariff-align-' . $atts["align"];
618
  $output .= ' shariff-buttonstretch';
619
  }
620
  $output .= '"';
621
+ // hide buttons until css is loaded
622
+ if ( array_key_exists( 'hideuntilcss', $atts ) && $atts['hideuntilcss'] == '1' ) $output .= ' style="display:none"';
623
  // add information for share count request
624
  if ( array_key_exists( 'backend', $atts ) && $atts['backend'] == "on" ) {
625
  // share url
626
+ $output .= ' data-url="' . esc_url( urlencode( $share_url ) ) . '"';
627
  // timestamp for cache
628
  $output .= ' data-timestamp="' . absint( get_the_modified_date( 'U', true ) ) . '"';
629
  // add external api if entered
683
  elseif ( $service == 'patreon' && ! array_key_exists( 'patreonid', $atts ) ) $patreon_error = '1';
684
  // start render button
685
  elseif ( $service != 'total' && $service != 'totalnumber' ) {
686
+
687
  // include service parameters
688
  $frontend = '1';
689
 
690
  // determine path to service phps
691
  $path_service_file = plugin_dir_path( __FILE__ ) . 'services/shariff-' . $service . '.php';
692
 
693
+ // check if service file exists
694
+ if ( file_exists( $path_service_file ) ) {
695
+
696
+ // include service file
697
+ include( $path_service_file );
698
+
699
+ // overwrite service specific colors, if custom colors are set
700
+ if ( array_key_exists( 'maincolor', $atts ) ) {
701
+ $main_color = $atts['maincolor'];
702
+ }
703
+ if ( array_key_exists( 'secondarycolor', $atts ) ) {
704
+ $secondary_color = $atts['secondarycolor'];
705
+ }
706
 
707
+ // set border radius for round theme
708
+ if ( array_key_exists( 'borderradius', $atts ) && array_key_exists( 'theme', $atts ) && $atts['theme'] == "round" ) {
709
+ $border_radius = '; border-radius:' . $atts['borderradius'] . '%';
710
+ }
711
+ else {
712
+ $border_radius = '';
713
+ }
714
+
715
+ // info button for default theme
716
+ if ( ! array_key_exists( 'maincolor', $atts ) && $service == 'info' && ( ( array_key_exists( 'theme', $atts ) && $atts['theme'] == "default" || ( array_key_exists( 'theme', $atts ) && $atts['theme'] == "round" ) ) || ! array_key_exists( 'theme', $atts ) ) ) {
717
+ $main_color = '#fff';
718
+ $secondary_color = "#eee";
719
+ }
720
+
721
+ // start li
722
+ $output .= '<li class="shariff-button ' . $service;
723
+ // mobile only
724
+ if ( $mobile_only == '1') $output .= ' shariff-mobile';
725
+ $output .= '" style="background-color:' . $secondary_color . $border_radius . '">';
726
+
727
+ // use default button share text, if $button_text_array is empty
728
+ if ( empty( $button_text_array ) ) $button_text_array = $default_button_text_array;
729
+
730
+ // set button text in desired language, fallback is English
731
+ if ( array_key_exists( 'lang', $atts ) && array_key_exists( $atts['lang'], $button_text_array ) ) $button_text = $button_text_array[ $atts['lang'] ];
732
+ else $button_text = $button_text_array['en'];
733
+
734
+ // set button title / label in desired language, fallback is English
735
+ if ( array_key_exists( 'lang', $atts ) && array_key_exists( $atts['lang'], $button_title_array ) ) $button_title = $button_title_array[ $atts['lang'] ];
736
+ else $button_title = $button_title_array['en'];
737
+
738
+ // reset $button_text_array
739
+ $button_text_array = '';
740
+
741
+ // build the actual button
742
+ $output .= '<a href="' . $button_url . '" title="' . $button_title . '" aria-label="' . $button_title . '" role="button" rel="nofollow" class="shariff-link" ';
743
+ // same window?
744
+ if ( ! isset( $same_window ) || isset( $same_window ) && $same_window != '1' ) $output .= 'target="_blank" ';
745
+ $output .= 'style="background-color:' . $main_color . $border_radius;
746
  // theme white?
747
+ if ( isset( $atts['theme'] ) && $atts['theme'] == "white" ) $output .= '; color:' . $main_color;
748
+ else $output .= '; color:#fff';
749
+ $output .= '">';
750
+ $output .= '<span class="shariff-icon"';
751
+ // theme white?
752
+ if ( isset( $atts['theme'] ) && $atts['theme'] == "white" ) $output .= ' style="fill:' . $main_color . '"';
753
+ $output .= '>' . $svg_icon . '</span>';
754
+ $output .= '<span class="shariff-text">' . $button_text . '</span>&nbsp;';
755
+ // share counts?
756
+ if ( array_key_exists( 'sharecounts', $atts ) && $atts['sharecounts'] == "1" && $backend_available == '1' && ! isset ( $shariff3UU["disable"][ $service ] ) ) {
757
+ $output .= '<span class="shariff-count" data-service="' . $service . '" style="color:' . $main_color;
758
+ if ( array_key_exists( $service, $share_counts ) === true && $share_counts[ $service ] !== null && $share_counts[ $service ] !== '-1' ) {
759
+ $output .= '">' . $share_counts[ $service ];
760
+ }
761
+ else $output .= ';opacity:0">';
762
+ $output .= '</span>&nbsp;';
763
  }
764
+ $output .= '</a>';
765
+ $output .= '</li>';
766
+
767
+ // add service to backend service, if available
768
+ if ( $backend_available == '1' && ! isset ( $shariff3UU["disable"][ $service ] ) ) $backend_service_array[] = $service;
769
+
770
+ // reset $backend_available, $mobile_only, $same_window
771
+ $backend_available = '';
772
+ $mobile_only = '';
773
+ $same_window = '';
774
+ }
 
 
775
  }
776
  }
777
 
778
  // add the list of backend services
779
  if ( ! empty( $backend_service_array ) ) {
780
  $backend_services = implode( '|', $backend_service_array );
781
+ $output = str_replace( 'data-url=', 'data-services="' . esc_html( urlencode( $backend_services ) ) . '" data-url=', $output );
782
  }
783
 
784
  // close ul and the main shariff div
907
  // use wp_nonce_url / wp_verify_nonce to prevent automated spam by url
908
  $submit_link = wp_nonce_url( get_permalink(), 'shariff3UU_send_mail', 'shariff_mf_nonce' );
909
 
910
+ // add anchor if option is set
911
+ if ( isset( $shariff3UU["mailform_anchor"] ) && $shariff3UU["mailform_anchor"] == '1' ) {
912
+ $submit_link .= '#shariff_mailform';
913
+ }
914
+
915
  // sender address optional?
916
  $mf_optional_text = '';
917
  $mf_sender_required = '';
1350
  switch_to_blog( $blog['blog_id'] );
1351
  // purge transients
1352
  shariff3UU_purge_transients_deactivation();
1353
+ // remove cron job
1354
+ wp_clear_scheduled_hook( 'shariff3UU_fill_cache' );
1355
  // switch back to main
1356
  restore_current_blog();
1357
  }
1360
  else {
1361
  // purge transients
1362
  shariff3UU_purge_transients_deactivation();
1363
+ // remove cron job
1364
+ wp_clear_scheduled_hook( 'shariff3UU_fill_cache' );
1365
  }
1366
  }
1367
  register_deactivation_hook( __FILE__, 'shariff3UU_deactivate' );
1368
 
1369
+ // activation hook to start cron job after update
1370
+ register_activation_hook( __FILE__, 'shariff3UU_fill_cache_schedule' );
1371
+
1372
  // purge all the transients associated with our plugin
1373
  function shariff3UU_purge_transients_deactivation() {
1374
  // make sure we have the $wpdb class ready
uninstall.php CHANGED
@@ -14,65 +14,69 @@ $widget_name = 'widget_shariff';
14
 
15
  // check for multisite
16
  if ( is_multisite() ) {
17
- global $wpdb;
18
- $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A);
19
- if ( $blogs ) {
20
- foreach( $blogs as $blog ) {
21
- // switch to each blog
22
- switch_to_blog( $blog['blog_id'] );
23
- // delete options from options table
24
- delete_option( $option_name );
25
- delete_option( $shariff3UU_basic );
26
- delete_option( $shariff3UU_design );
27
- delete_option( $shariff3UU_advanced );
28
- delete_option( $shariff3UU_mailform );
29
- delete_option( $shariff3UU_statistic );
30
- delete_option( $widget_name );
31
- // delete user meta entry shariff3UU_ignore_notice
32
- $users = get_users('role=administrator');
33
- foreach ( $users as $user ) {
34
- if ( ! get_user_meta( $user, 'shariff3UU_ignore_notice' ) ) {
35
- delete_user_meta( $user->ID, 'shariff3UU_ignore_notice' );
36
- }
37
- };
38
- // purge transients
39
- purge_transients();
40
- // switch back to main
41
- restore_current_blog();
42
- }
43
- }
 
 
44
  } else {
45
- // delete options from options table
46
- delete_option( $option_name );
47
- delete_option( $shariff3UU_basic );
48
- delete_option( $shariff3UU_design );
49
- delete_option( $shariff3UU_advanced );
50
- delete_option( $shariff3UU_mailform );
51
  delete_option( $shariff3UU_statistic );
52
- delete_option( $widget_name );
53
- // delete user meta entry shariff3UU_ignore_notice
54
- $users = get_users('role=administrator');
55
- foreach ( $users as $user ) {
56
- if ( ! get_user_meta( $user, 'shariff3UU_ignore_notice' ) ) {
57
- delete_user_meta( $user->ID, 'shariff3UU_ignore_notice' );
58
- }
59
- };
60
- // purge transients
61
- purge_transients();
 
 
62
  }
63
 
64
  // purge all the transients associated with our plugin
65
  function purge_transients() {
66
- global $wpdb;
67
 
68
- // delete transients
69
- $sql = 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE "_transient_timeout_shariff%"';
70
- $wpdb->query($sql);
71
- $sql = 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE "_transient_shariff%"';
72
- $wpdb->query($sql);
73
 
74
- // clear object cache
75
- wp_cache_flush();
76
  }
77
 
78
  ?>
14
 
15
  // check for multisite
16
  if ( is_multisite() ) {
17
+ global $wpdb;
18
+ $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A);
19
+ if ( $blogs ) {
20
+ foreach( $blogs as $blog ) {
21
+ // switch to each blog
22
+ switch_to_blog( $blog['blog_id'] );
23
+ // delete options from options table
24
+ delete_option( $option_name );
25
+ delete_option( $shariff3UU_basic );
26
+ delete_option( $shariff3UU_design );
27
+ delete_option( $shariff3UU_advanced );
28
+ delete_option( $shariff3UU_mailform );
29
+ delete_option( $shariff3UU_statistic );
30
+ delete_option( $widget_name );
31
+ // delete user meta entry shariff3UU_ignore_notice
32
+ $users = get_users('role=administrator');
33
+ foreach ( $users as $user ) {
34
+ if ( ! get_user_meta( $user, 'shariff3UU_ignore_notice' ) ) {
35
+ delete_user_meta( $user->ID, 'shariff3UU_ignore_notice' );
36
+ }
37
+ };
38
+ // purge transients
39
+ purge_transients();
40
+ // remove cron job
41
+ wp_clear_scheduled_hook( 'shariff3UU_fill_cache' );
42
+ // switch back to main
43
+ restore_current_blog();
44
+ }
45
+ }
46
  } else {
47
+ // delete options from options table
48
+ delete_option( $option_name );
49
+ delete_option( $shariff3UU_basic );
50
+ delete_option( $shariff3UU_design );
51
+ delete_option( $shariff3UU_advanced );
52
+ delete_option( $shariff3UU_mailform );
53
  delete_option( $shariff3UU_statistic );
54
+ delete_option( $widget_name );
55
+ // delete user meta entry shariff3UU_ignore_notice
56
+ $users = get_users('role=administrator');
57
+ foreach ( $users as $user ) {
58
+ if ( ! get_user_meta( $user, 'shariff3UU_ignore_notice' ) ) {
59
+ delete_user_meta( $user->ID, 'shariff3UU_ignore_notice' );
60
+ }
61
+ };
62
+ // purge transients
63
+ purge_transients();
64
+ // remove cron job
65
+ wp_clear_scheduled_hook( 'shariff3UU_fill_cache' );
66
  }
67
 
68
  // purge all the transients associated with our plugin
69
  function purge_transients() {
70
+ global $wpdb;
71
 
72
+ // delete transients
73
+ $sql = 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE "_transient_timeout_shariff%"';
74
+ $wpdb->query($sql);
75
+ $sql = 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE "_transient_shariff%"';
76
+ $wpdb->query($sql);
77
 
78
+ // clear object cache
79
+ wp_cache_flush();
80
  }
81
 
82
  ?>
updates.php CHANGED
@@ -310,6 +310,10 @@ function shariff3UU_purge_transients() {
310
  wp_cache_flush();
311
  }
312
 
 
 
 
 
313
  // set new version
314
  $GLOBALS["shariff3UU"]["version"] = $code_version;
315
  $GLOBALS["shariff3UU_basic"]["version"] = $code_version;
310
  wp_cache_flush();
311
  }
312
 
313
+ // remove Shriff cron job and add it again if wanted
314
+ wp_clear_scheduled_hook( 'shariff3UU_fill_cache' );
315
+ do_action( 'shariff3UU_save_statistic_options' );
316
+
317
  // set new version
318
  $GLOBALS["shariff3UU"]["version"] = $code_version;
319
  $GLOBALS["shariff3UU_basic"]["version"] = $code_version;