Version Description
- new option to add Shariff to custom WordPress hooks
- new option to support multilingual sites using WPML and other plugins
- new support for WooCommerce products on the ranking table
- new option to show different headlines based on share counts
- updated button languages, now supporting 25 languages
- fixed a bug causing share counts to not being displayed properly
Download this release
Release Info
Developer | starguide |
Plugin | Shariff Wrapper |
Version | 4.5.0 |
Comparing to | |
See all releases |
Code changes from version 4.4.4 to 4.5.0
- admin/admin-menu.php +240 -47
- changelog.txt +8 -0
- readme.txt +11 -3
- shariff.php +70 -14
- updates.php +13 -0
admin/admin-menu.php
CHANGED
@@ -62,8 +62,7 @@ function shariff3uu_options_init() {
|
|
62 |
'shariff3uu_basic_section_callback', 'basic' );
|
63 |
|
64 |
// Services.
|
65 |
-
add_settings_field( 'shariff3uu_text_services', '<div style="width:450px">' .
|
66 |
-
'shariff3uu_text_services_render', 'basic', 'shariff3uu_basic_section' );
|
67 |
|
68 |
// Add after.
|
69 |
add_settings_field( 'shariff3uu_multiplecheckbox_add_after', __( 'Add the Shariff buttons <u>after</u> all:', 'shariff' ),
|
@@ -81,19 +80,28 @@ function shariff3uu_options_init() {
|
|
81 |
add_settings_field( 'shariff3uu_checkbox_disable_outside_loop', __( 'Disable the Shariff buttons outside of the main loop.', 'shariff' ),
|
82 |
'shariff3uu_checkbox_disable_outside_loop_render', 'basic', 'shariff3uu_basic_section' );
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
/** Second tab - design */
|
85 |
|
86 |
// Registers second tab (design) settings and calls sanitize function.
|
87 |
register_setting( 'design', 'shariff3uu_design', 'shariff3uu_design_sanitize' );
|
88 |
|
89 |
// Second tab - design options.
|
90 |
-
add_settings_section( 'shariff3uu_design_section', __( 'Design options', 'shariff' ),
|
91 |
-
'shariff3uu_design_section_callback', 'design' );
|
92 |
|
93 |
// Button language.
|
94 |
-
add_settings_field( 'shariff3uu_select_language', '<div style="width:450px">' . esc_html__( '
|
95 |
'shariff3uu_select_language_render', 'design', 'shariff3uu_design_section' );
|
96 |
|
|
|
|
|
|
|
|
|
97 |
// Theme.
|
98 |
add_settings_field( 'shariff3uu_radio_theme', __( 'Shariff button design:', 'shariff' ),
|
99 |
'shariff3uu_radio_theme_render', 'design', 'shariff3uu_design_section' );
|
@@ -134,6 +142,10 @@ function shariff3uu_options_init() {
|
|
134 |
add_settings_field( 'shariff3uu_text_headline', __( 'Headline above all Shariff buttons:', 'shariff' ),
|
135 |
'shariff3uu_text_headline_render', 'design', 'shariff3uu_design_section' );
|
136 |
|
|
|
|
|
|
|
|
|
137 |
// Custom css.
|
138 |
add_settings_field( 'shariff3uu_text_style', __( 'Custom CSS <u>attributes</u> for the container <u>around</u> Shariff:', 'shariff' ),
|
139 |
'shariff3uu_text_style_render', 'design', 'shariff3uu_design_section' );
|
@@ -161,12 +173,12 @@ function shariff3uu_options_init() {
|
|
161 |
|
162 |
// Info url.
|
163 |
add_settings_field(
|
164 |
-
'shariff3uu_text_info_url', '<div style="width:450px">' .
|
165 |
'shariff3uu_text_info_url_render', 'advanced', 'shariff3uu_advanced_section' );
|
166 |
|
167 |
// Info text.
|
168 |
add_settings_field(
|
169 |
-
'shariff3uu_text_info_text',
|
170 |
'shariff3uu_text_info_text_render', 'advanced', 'shariff3uu_advanced_section' );
|
171 |
|
172 |
// Twitter via.
|
@@ -226,7 +238,7 @@ function shariff3uu_options_init() {
|
|
226 |
'shariff3uu_statistic_section_callback', 'statistic' );
|
227 |
|
228 |
// Statistic.
|
229 |
-
add_settings_field( 'shariff3uu_checkbox_backend', '<div style="width:450px">' .
|
230 |
'shariff3uu_checkbox_backend_render', 'statistic', 'shariff3uu_statistic_section' );
|
231 |
|
232 |
// Share counts.
|
@@ -329,6 +341,12 @@ function shariff3uu_basic_sanitize( $input ) {
|
|
329 |
if ( isset( $input['disable_outside_loop'] ) ) {
|
330 |
$valid['disable_outside_loop'] = absint( $input['disable_outside_loop'] );
|
331 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
|
333 |
// Remove empty elements.
|
334 |
$valid = array_filter( $valid );
|
@@ -350,6 +368,9 @@ function shariff3uu_design_sanitize( $input ) {
|
|
350 |
if ( isset( $input['lang'] ) ) {
|
351 |
$valid['lang'] = sanitize_text_field( $input['lang'] );
|
352 |
}
|
|
|
|
|
|
|
353 |
if ( isset( $input['theme'] ) ) {
|
354 |
$valid['theme'] = sanitize_text_field( $input['theme'] );
|
355 |
}
|
@@ -385,6 +406,9 @@ function shariff3uu_design_sanitize( $input ) {
|
|
385 |
if ( isset( $input['headline'] ) ) {
|
386 |
$valid['headline'] = wp_kses( $input['headline'], $GLOBALS['allowed_tags'] );
|
387 |
}
|
|
|
|
|
|
|
388 |
if ( isset( $input['hideuntilcss'] ) ) {
|
389 |
$valid['hideuntilcss'] = absint( $input['hideuntilcss'] );
|
390 |
}
|
@@ -561,9 +585,11 @@ function shariff3uu_text_services_render() {
|
|
561 |
} else {
|
562 |
$services = '';
|
563 |
}
|
564 |
-
echo '<input type="text" name="shariff3uu_basic[services]" value="' . esc_html( $services ) . '" size="
|
565 |
-
echo '<p><code>addthis|bitcoin|diaspora|facebook|flattr|flipboard|googleplus|info|linkedin|mailto
|
566 |
-
echo '<p><code>pinterest|pocket|printer|qzone|reddit
|
|
|
|
|
567 |
echo '<p>' . esc_html__( 'Use the pipe sign | (Alt Gr + < or ⌥ + 7) between two or more services.', 'shariff' ) . '</p>';
|
568 |
}
|
569 |
|
@@ -689,6 +715,31 @@ function shariff3uu_checkbox_disable_outside_loop_render() {
|
|
689 |
echo ' value="1">';
|
690 |
}
|
691 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
692 |
/** Design options */
|
693 |
|
694 |
/**
|
@@ -716,35 +767,48 @@ function shariff3uu_design_section_callback() {
|
|
716 |
function shariff3uu_select_language_render() {
|
717 |
$options = $GLOBALS['shariff3uu_design'];
|
718 |
if ( ! isset( $options['lang'] ) ) {
|
719 |
-
$options['lang'] =
|
720 |
}
|
721 |
echo '<select name="shariff3uu_design[lang]">
|
722 |
-
<option value="" ' . selected( $options['lang'], '', 0 ) . '
|
723 |
-
<option value="
|
|
|
724 |
<option value="de" ' . selected( $options['lang'], 'de', 0 ) . '>Deutsch</option>
|
725 |
-
<option value="
|
726 |
<option value="es" ' . selected( $options['lang'], 'es', 0 ) . '>Español</option>
|
727 |
-
<option value="zh" ' . selected( $options['lang'], 'zh', 0 ) . '>Chinese</option>
|
728 |
-
<option value="hr" ' . selected( $options['lang'], 'hr', 0 ) . '>Croatian</option>
|
729 |
-
<option value="da" ' . selected( $options['lang'], 'da', 0 ) . '>Danish</option>
|
730 |
-
<option value="nl" ' . selected( $options['lang'], 'nl', 0 ) . '>Dutch</option>
|
731 |
<option value="fi" ' . selected( $options['lang'], 'fi', 0 ) . '>Finnish</option>
|
|
|
|
|
|
|
732 |
<option value="it" ' . selected( $options['lang'], 'it', 0 ) . '>Italiano</option>
|
733 |
-
<option value="ja" ' . selected( $options['lang'], 'ja', 0 ) . '
|
734 |
-
<option value="ko" ' . selected( $options['lang'], 'ko', 0 ) . '
|
735 |
-
<option value="
|
736 |
-
<option value="
|
737 |
-
<option value="
|
738 |
-
<option value="
|
739 |
-
<option value="
|
740 |
-
<option value="
|
741 |
-
<option value="
|
742 |
-
<option value="
|
743 |
-
<option value="
|
744 |
-
<option value="
|
|
|
|
|
745 |
</select>';
|
746 |
}
|
747 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
748 |
/**
|
749 |
* Theme.
|
750 |
*/
|
@@ -815,7 +879,6 @@ function shariff3uu_checkbox_buttonsize_render() {
|
|
815 |
* Button stretch.
|
816 |
*/
|
817 |
function shariff3uu_checkbox_buttonstretch_render() {
|
818 |
-
$plugins_url = plugins_url();
|
819 |
echo '<input type="checkbox" name="shariff3uu_design[buttonstretch]" ';
|
820 |
if ( isset( $GLOBALS['shariff3uu_design']['buttonstretch'] ) ) {
|
821 |
echo checked( $GLOBALS['shariff3uu_design']['buttonstretch'], 1, 0 );
|
@@ -913,11 +976,26 @@ function shariff3uu_text_headline_render() {
|
|
913 |
echo esc_html__( 'Basic HTML as well as style and class attributes are allowed. You can use %total to show the total amount of shares.', 'shariff' );
|
914 |
echo '<br>';
|
915 |
echo esc_html__( 'Example:', 'shariff' );
|
916 |
-
echo '<code><h3 class="shariff_headline">';
|
917 |
echo esc_html__( 'Already shared %total times!', 'shariff' );
|
918 |
echo '</h3></code></p>';
|
919 |
}
|
920 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
921 |
/**
|
922 |
* Custom CSS.
|
923 |
*/
|
@@ -1814,27 +1892,27 @@ function shariff3uu_ranking_section_callback() {
|
|
1814 |
|
1815 |
// Intro text.
|
1816 |
echo '<p>';
|
1817 |
-
|
1818 |
echo '</p>';
|
1819 |
|
1820 |
// Warning if statistic has been disabled.
|
1821 |
if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
|
1822 |
echo '<p>';
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
echo '</p>';
|
1828 |
}
|
1829 |
|
1830 |
// Begin ranking table.
|
1831 |
echo '<div style="display:table;background-color:#fff">';
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
foreach ( $services as $service => $nothing ) {
|
1839 |
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center;">' . esc_html( ucfirst( $service ) ) . '</div>';
|
1840 |
}
|
@@ -1843,7 +1921,7 @@ function shariff3uu_ranking_section_callback() {
|
|
1843 |
// Posts.
|
1844 |
$rank = '0';
|
1845 |
foreach ( $posts as $post => $value ) {
|
1846 |
-
$rank++;
|
1847 |
echo '<div style="display:table-row">';
|
1848 |
echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">' . absint( $rank ) . '</div>';
|
1849 |
echo '<div style="display:table-cell;border:1px solid;padding:10px"><a href="' . esc_url( $value['url'] ) . '" target="_blank">' . esc_html( wp_strip_all_tags( $value['title'] ) ) . '</a></div>';
|
@@ -1929,7 +2007,6 @@ function shariff3uu_ranking_section_callback() {
|
|
1929 |
}
|
1930 |
array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
|
1931 |
|
1932 |
-
// Intro text.
|
1933 |
echo '<p></p>';
|
1934 |
|
1935 |
// Warning if statistic has been disabled.
|
@@ -1958,7 +2035,7 @@ function shariff3uu_ranking_section_callback() {
|
|
1958 |
// Pages.
|
1959 |
$rank = '0';
|
1960 |
foreach ( $posts as $post => $value ) {
|
1961 |
-
$rank++;
|
1962 |
echo '<div style="display:table-row">';
|
1963 |
echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">' . absint( $rank ) . '</div>';
|
1964 |
echo '<div style="display:table-cell;border:1px solid;padding:10px"><a href="' . esc_url( $value['url'] ) . '" target="_blank">' . esc_html( $value['title'] ) . '</a></div>';
|
@@ -1980,6 +2057,122 @@ function shariff3uu_ranking_section_callback() {
|
|
1980 |
echo '</div>';
|
1981 |
}
|
1982 |
echo '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1983 |
}
|
1984 |
|
1985 |
/**
|
62 |
'shariff3uu_basic_section_callback', 'basic' );
|
63 |
|
64 |
// Services.
|
65 |
+
add_settings_field( 'shariff3uu_text_services', '<div style="width:450px">' . __( 'Enable the following services in the provided order:', 'shariff' ) . '</div>', 'shariff3uu_text_services_render', 'basic', 'shariff3uu_basic_section' );
|
|
|
66 |
|
67 |
// Add after.
|
68 |
add_settings_field( 'shariff3uu_multiplecheckbox_add_after', __( 'Add the Shariff buttons <u>after</u> all:', 'shariff' ),
|
80 |
add_settings_field( 'shariff3uu_checkbox_disable_outside_loop', __( 'Disable the Shariff buttons outside of the main loop.', 'shariff' ),
|
81 |
'shariff3uu_checkbox_disable_outside_loop_render', 'basic', 'shariff3uu_basic_section' );
|
82 |
|
83 |
+
// Add to custom WordPress hooks.
|
84 |
+
add_settings_field( 'shariff3uu_text_custom_hooks', __( 'Add Shariff to the following custom WordPress hooks:', 'shariff' ), 'shariff3uu_text_custom_hooks_render', 'basic', 'shariff3uu_basic_section' );
|
85 |
+
|
86 |
+
// Shortcode to use for custom hook.
|
87 |
+
add_settings_field( 'shariff3uu_text_custom_hooks_shortcode', __( 'Use the following shortcode for the custom hooks:', 'shariff' ), 'shariff3uu_text_custom_hooks_shortcode_render', 'basic', 'shariff3uu_basic_section' );
|
88 |
+
|
89 |
/** Second tab - design */
|
90 |
|
91 |
// Registers second tab (design) settings and calls sanitize function.
|
92 |
register_setting( 'design', 'shariff3uu_design', 'shariff3uu_design_sanitize' );
|
93 |
|
94 |
// Second tab - design options.
|
95 |
+
add_settings_section( 'shariff3uu_design_section', __( 'Design options', 'shariff' ), 'shariff3uu_design_section_callback', 'design' );
|
|
|
96 |
|
97 |
// Button language.
|
98 |
+
add_settings_field( 'shariff3uu_select_language', '<div style="width:450px">' . esc_html__( 'Default button language:', 'shariff' ) . '</div>',
|
99 |
'shariff3uu_select_language_render', 'design', 'shariff3uu_design_section' );
|
100 |
|
101 |
+
// Automatic button language for multilingual sites.
|
102 |
+
add_settings_field( 'shariff3uu_checkbox_autolang', __( 'Automatically set button language based on locale (e.g. set by WPML).', 'shariff' ),
|
103 |
+
'shariff3uu_checkbox_autolang_render', 'design', 'shariff3uu_design_section' );
|
104 |
+
|
105 |
// Theme.
|
106 |
add_settings_field( 'shariff3uu_radio_theme', __( 'Shariff button design:', 'shariff' ),
|
107 |
'shariff3uu_radio_theme_render', 'design', 'shariff3uu_design_section' );
|
142 |
add_settings_field( 'shariff3uu_text_headline', __( 'Headline above all Shariff buttons:', 'shariff' ),
|
143 |
'shariff3uu_text_headline_render', 'design', 'shariff3uu_design_section' );
|
144 |
|
145 |
+
// Alternative headline if share counts are zero.
|
146 |
+
add_settings_field( 'shariff3uu_text_headline_zero', __( 'Alternative headline, if share counts are zero:', 'shariff' ),
|
147 |
+
'shariff3uu_text_headline_zero_render', 'design', 'shariff3uu_design_section' );
|
148 |
+
|
149 |
// Custom css.
|
150 |
add_settings_field( 'shariff3uu_text_style', __( 'Custom CSS <u>attributes</u> for the container <u>around</u> Shariff:', 'shariff' ),
|
151 |
'shariff3uu_text_style_render', 'design', 'shariff3uu_design_section' );
|
173 |
|
174 |
// Info url.
|
175 |
add_settings_field(
|
176 |
+
'shariff3uu_text_info_url', '<div style="width:450px">' . __( 'Custom link for the info button:', 'shariff' ) . '</div>',
|
177 |
'shariff3uu_text_info_url_render', 'advanced', 'shariff3uu_advanced_section' );
|
178 |
|
179 |
// Info text.
|
180 |
add_settings_field(
|
181 |
+
'shariff3uu_text_info_text', __( 'Custom text for the info button:', 'shariff' ),
|
182 |
'shariff3uu_text_info_text_render', 'advanced', 'shariff3uu_advanced_section' );
|
183 |
|
184 |
// Twitter via.
|
238 |
'shariff3uu_statistic_section_callback', 'statistic' );
|
239 |
|
240 |
// Statistic.
|
241 |
+
add_settings_field( 'shariff3uu_checkbox_backend', '<div style="width:450px">' . __( 'Enable statistic.', 'shariff' ) . '</div>',
|
242 |
'shariff3uu_checkbox_backend_render', 'statistic', 'shariff3uu_statistic_section' );
|
243 |
|
244 |
// Share counts.
|
341 |
if ( isset( $input['disable_outside_loop'] ) ) {
|
342 |
$valid['disable_outside_loop'] = absint( $input['disable_outside_loop'] );
|
343 |
}
|
344 |
+
if ( isset( $input['custom_hooks'] ) ) {
|
345 |
+
$valid['custom_hooks'] = sanitize_text_field( $input['custom_hooks'] );
|
346 |
+
}
|
347 |
+
if ( isset( $input['custom_hooks_shortcode'] ) ) {
|
348 |
+
$valid['custom_hooks_shortcode'] = sanitize_text_field( $input['custom_hooks_shortcode'] );
|
349 |
+
}
|
350 |
|
351 |
// Remove empty elements.
|
352 |
$valid = array_filter( $valid );
|
368 |
if ( isset( $input['lang'] ) ) {
|
369 |
$valid['lang'] = sanitize_text_field( $input['lang'] );
|
370 |
}
|
371 |
+
if ( isset( $input['autolang'] ) ) {
|
372 |
+
$valid['autolang'] = absint( $input['autolang'] );
|
373 |
+
}
|
374 |
if ( isset( $input['theme'] ) ) {
|
375 |
$valid['theme'] = sanitize_text_field( $input['theme'] );
|
376 |
}
|
406 |
if ( isset( $input['headline'] ) ) {
|
407 |
$valid['headline'] = wp_kses( $input['headline'], $GLOBALS['allowed_tags'] );
|
408 |
}
|
409 |
+
if ( isset( $input['headline_zero'] ) ) {
|
410 |
+
$valid['headline_zero'] = wp_kses( $input['headline_zero'], $GLOBALS['allowed_tags'] );
|
411 |
+
}
|
412 |
if ( isset( $input['hideuntilcss'] ) ) {
|
413 |
$valid['hideuntilcss'] = absint( $input['hideuntilcss'] );
|
414 |
}
|
585 |
} else {
|
586 |
$services = '';
|
587 |
}
|
588 |
+
echo '<input type="text" name="shariff3uu_basic[services]" value="' . esc_html( $services ) . '" size="90" placeholder="twitter|facebook|googleplus|info">';
|
589 |
+
echo '<p><code>addthis|bitcoin|diaspora|facebook|flattr|flipboard|googleplus|info|linkedin|mailto</code></p>';
|
590 |
+
echo '<p><code>mastodon|odnoklassniki|patreon|paypal|paypalme|pinterest|pocket|printer|qzone|reddit</code></p>';
|
591 |
+
echo '<p><code>rss|sms|stumbleupon|telegram|tencentweibo|threema|tumblr|twitter|vk|wallabag|weibo</code></p>';
|
592 |
+
echo '<p><code>whatsapp|xing</code></p>';
|
593 |
echo '<p>' . esc_html__( 'Use the pipe sign | (Alt Gr + < or ⌥ + 7) between two or more services.', 'shariff' ) . '</p>';
|
594 |
}
|
595 |
|
715 |
echo ' value="1">';
|
716 |
}
|
717 |
|
718 |
+
/**
|
719 |
+
* Custom hooks.
|
720 |
+
*/
|
721 |
+
function shariff3uu_text_custom_hooks_render() {
|
722 |
+
if ( isset( $GLOBALS['shariff3uu_basic']['custom_hooks'] ) ) {
|
723 |
+
$custom_hooks = $GLOBALS['shariff3uu_basic']['custom_hooks'];
|
724 |
+
} else {
|
725 |
+
$custom_hooks = '';
|
726 |
+
}
|
727 |
+
echo '<input type="text" name="shariff3uu_basic[custom_hooks]" value="' . esc_html( $custom_hooks ) . '" size="90" placeholder="' . esc_html__( 'some_custom_wordpress_hook|some_other_custom_wordpress_hook', 'shariff' ) . '">';
|
728 |
+
echo '<p>' . esc_html__( 'Use the pipe sign | (Alt Gr + < or ⌥ + 7) between two or more hooks.', 'shariff' ) . '</p>';
|
729 |
+
}
|
730 |
+
|
731 |
+
/**
|
732 |
+
* Custom hooks shortcode.
|
733 |
+
*/
|
734 |
+
function shariff3uu_text_custom_hooks_shortcode_render() {
|
735 |
+
if ( isset( $GLOBALS['shariff3uu_basic']['custom_hooks_shortcode'] ) ) {
|
736 |
+
$custom_hooks_shortcode = $GLOBALS['shariff3uu_basic']['custom_hooks_shortcode'];
|
737 |
+
} else {
|
738 |
+
$custom_hooks_shortcode = '';
|
739 |
+
}
|
740 |
+
echo '<input type="text" name="shariff3uu_basic[custom_hooks_shortcode]" value="' . esc_html( $custom_hooks_shortcode ) . '" size="90" placeholder="[shariff]">';
|
741 |
+
}
|
742 |
+
|
743 |
/** Design options */
|
744 |
|
745 |
/**
|
767 |
function shariff3uu_select_language_render() {
|
768 |
$options = $GLOBALS['shariff3uu_design'];
|
769 |
if ( ! isset( $options['lang'] ) ) {
|
770 |
+
$options['lang'] = substr( get_locale(), 0, 2 );
|
771 |
}
|
772 |
echo '<select name="shariff3uu_design[lang]">
|
773 |
+
<option value="bg" ' . selected( $options['lang'], 'bg', 0 ) . '>български</option>
|
774 |
+
<option value="cs" ' . selected( $options['lang'], 'cs', 0 ) . '>český</option>
|
775 |
+
<option value="da" ' . selected( $options['lang'], 'da', 0 ) . '>Dansk</option>
|
776 |
<option value="de" ' . selected( $options['lang'], 'de', 0 ) . '>Deutsch</option>
|
777 |
+
<option value="en" ' . selected( $options['lang'], 'en', 0 ) . '>English</option>
|
778 |
<option value="es" ' . selected( $options['lang'], 'es', 0 ) . '>Español</option>
|
|
|
|
|
|
|
|
|
779 |
<option value="fi" ' . selected( $options['lang'], 'fi', 0 ) . '>Finnish</option>
|
780 |
+
<option value="fr" ' . selected( $options['lang'], 'fr', 0 ) . '>Français</option>
|
781 |
+
<option value="hr" ' . selected( $options['lang'], 'hr', 0 ) . '>Croatian</option>
|
782 |
+
<option value="hu" ' . selected( $options['lang'], 'hu', 0 ) . '>Magyar</option>
|
783 |
<option value="it" ' . selected( $options['lang'], 'it', 0 ) . '>Italiano</option>
|
784 |
+
<option value="ja" ' . selected( $options['lang'], 'ja', 0 ) . '>日本語</option>
|
785 |
+
<option value="ko" ' . selected( $options['lang'], 'ko', 0 ) . '>한국어</option>
|
786 |
+
<option value="nl" ' . selected( $options['lang'], 'nl', 0 ) . '>Nederlands</option>
|
787 |
+
<option value="no" ' . selected( $options['lang'], 'no', 0 ) . '>Norsk</option>
|
788 |
+
<option value="pl" ' . selected( $options['lang'], 'pl', 0 ) . '>Polskie</option>
|
789 |
+
<option value="pt" ' . selected( $options['lang'], 'pt', 0 ) . '>Português</option>
|
790 |
+
<option value="ro" ' . selected( $options['lang'], 'ro', 0 ) . '>Română</option>
|
791 |
+
<option value="ru" ' . selected( $options['lang'], 'ru', 0 ) . '>Pусский</option>
|
792 |
+
<option value="sk" ' . selected( $options['lang'], 'sk', 0 ) . '>Slovenský</option>
|
793 |
+
<option value="sl" ' . selected( $options['lang'], 'sl', 0 ) . '>Slovenščina</option>
|
794 |
+
<option value="sr" ' . selected( $options['lang'], 'sr', 0 ) . '>Српски</option>
|
795 |
+
<option value="sv" ' . selected( $options['lang'], 'sv', 0 ) . '>Svenska</option>
|
796 |
+
<option value="tr" ' . selected( $options['lang'], 'tr', 0 ) . '>Türk</option>
|
797 |
+
<option value="zh" ' . selected( $options['lang'], 'zh', 0 ) . '>中文</option>
|
798 |
</select>';
|
799 |
}
|
800 |
|
801 |
+
/**
|
802 |
+
* Automatic button language.
|
803 |
+
*/
|
804 |
+
function shariff3uu_checkbox_autolang_render() {
|
805 |
+
echo '<input type="checkbox" name="shariff3uu_design[autolang]" ';
|
806 |
+
if ( isset( $GLOBALS['shariff3uu_design']['autolang'] ) ) {
|
807 |
+
echo checked( $GLOBALS['shariff3uu_design']['autolang'], 1, 0 );
|
808 |
+
}
|
809 |
+
echo ' value="1">';
|
810 |
+
}
|
811 |
+
|
812 |
/**
|
813 |
* Theme.
|
814 |
*/
|
879 |
* Button stretch.
|
880 |
*/
|
881 |
function shariff3uu_checkbox_buttonstretch_render() {
|
|
|
882 |
echo '<input type="checkbox" name="shariff3uu_design[buttonstretch]" ';
|
883 |
if ( isset( $GLOBALS['shariff3uu_design']['buttonstretch'] ) ) {
|
884 |
echo checked( $GLOBALS['shariff3uu_design']['buttonstretch'], 1, 0 );
|
976 |
echo esc_html__( 'Basic HTML as well as style and class attributes are allowed. You can use %total to show the total amount of shares.', 'shariff' );
|
977 |
echo '<br>';
|
978 |
echo esc_html__( 'Example:', 'shariff' );
|
979 |
+
echo ' <code><h3 class="shariff_headline">';
|
980 |
echo esc_html__( 'Already shared %total times!', 'shariff' );
|
981 |
echo '</h3></code></p>';
|
982 |
}
|
983 |
|
984 |
+
/**
|
985 |
+
* Alternative headline.
|
986 |
+
*/
|
987 |
+
function shariff3uu_text_headline_zero_render() {
|
988 |
+
if ( isset( $GLOBALS['shariff3uu_design']['headline_zero'] ) ) {
|
989 |
+
$headline_zero = $GLOBALS['shariff3uu_design']['headline_zero'];
|
990 |
+
} else {
|
991 |
+
$headline_zero = '';
|
992 |
+
}
|
993 |
+
echo '<input type="text" name="shariff3uu_design[headline_zero]" value="' . esc_html( $headline_zero ) . '" size="50" placeholder="' . esc_html__( 'Be the first one to share this post!', 'shariff' ) . '">';
|
994 |
+
echo '<p>';
|
995 |
+
echo esc_html__( 'Same rules as for the default headline. Leave empty to keep the same headline in all cases.', 'shariff' );
|
996 |
+
echo '</p>';
|
997 |
+
}
|
998 |
+
|
999 |
/**
|
1000 |
* Custom CSS.
|
1001 |
*/
|
1892 |
|
1893 |
// Intro text.
|
1894 |
echo '<p>';
|
1895 |
+
echo esc_html__( 'The following tables shows the ranking of your last 100 posts, pages and, if applicable, products in descending order by total share counts. To prevent slow loading times only cached data is being used. Therefore, you may see blank entries for posts that have not been visited by anyone since the last update or activation of Shariff Wrapper. You can simply visit the respective post yourself in order to have the share counts fetched.', 'shariff' );
|
1896 |
echo '</p>';
|
1897 |
|
1898 |
// Warning if statistic has been disabled.
|
1899 |
if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
|
1900 |
echo '<p>';
|
1901 |
+
echo '<span style="color: red; font-weight: bold;">';
|
1902 |
+
echo esc_html__( 'Warning:', 'shariff' );
|
1903 |
+
echo '</span> ';
|
1904 |
+
echo esc_html__( 'The statistic option has been disabled on the statistic tab. Share counts will not get updated!', 'shariff' );
|
1905 |
echo '</p>';
|
1906 |
}
|
1907 |
|
1908 |
// Begin ranking table.
|
1909 |
echo '<div style="display:table;background-color:#fff">';
|
1910 |
+
// Head.
|
1911 |
+
echo '<div style="display:table-row">';
|
1912 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Rank', 'shariff' ) . '</div>';
|
1913 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Post', 'shariff' ) . '</div>';
|
1914 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Date', 'shariff' ) . '</div>';
|
1915 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Time', 'shariff' ) . '</div>';
|
1916 |
foreach ( $services as $service => $nothing ) {
|
1917 |
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center;">' . esc_html( ucfirst( $service ) ) . '</div>';
|
1918 |
}
|
1921 |
// Posts.
|
1922 |
$rank = '0';
|
1923 |
foreach ( $posts as $post => $value ) {
|
1924 |
+
$rank ++;
|
1925 |
echo '<div style="display:table-row">';
|
1926 |
echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">' . absint( $rank ) . '</div>';
|
1927 |
echo '<div style="display:table-cell;border:1px solid;padding:10px"><a href="' . esc_url( $value['url'] ) . '" target="_blank">' . esc_html( wp_strip_all_tags( $value['title'] ) ) . '</a></div>';
|
2007 |
}
|
2008 |
array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
|
2009 |
|
|
|
2010 |
echo '<p></p>';
|
2011 |
|
2012 |
// Warning if statistic has been disabled.
|
2035 |
// Pages.
|
2036 |
$rank = '0';
|
2037 |
foreach ( $posts as $post => $value ) {
|
2038 |
+
$rank ++;
|
2039 |
echo '<div style="display:table-row">';
|
2040 |
echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">' . absint( $rank ) . '</div>';
|
2041 |
echo '<div style="display:table-cell;border:1px solid;padding:10px"><a href="' . esc_url( $value['url'] ) . '" target="_blank">' . esc_html( $value['title'] ) . '</a></div>';
|
2057 |
echo '</div>';
|
2058 |
}
|
2059 |
echo '</div>';
|
2060 |
+
|
2061 |
+
// Clear arrays.
|
2062 |
+
$posts = array();
|
2063 |
+
$services = array();
|
2064 |
+
|
2065 |
+
// Set arguments for wp_get_recent_posts().
|
2066 |
+
$args = array(
|
2067 |
+
'numberposts' => $numberposts,
|
2068 |
+
'orderby' => 'post_date',
|
2069 |
+
'order' => 'DESC',
|
2070 |
+
'post_status' => 'publish',
|
2071 |
+
'post_type' => 'product',
|
2072 |
+
);
|
2073 |
+
|
2074 |
+
// Catch last 100 pages or whatever number is set for it.
|
2075 |
+
$recent_posts = wp_get_recent_posts( $args );
|
2076 |
+
if ( $recent_posts ) {
|
2077 |
+
foreach ( $recent_posts as $recent ) {
|
2078 |
+
// Get URL.
|
2079 |
+
$url = get_permalink( $recent['ID'] );
|
2080 |
+
$post_url = rawurlencode( $url );
|
2081 |
+
// Set transient name.
|
2082 |
+
$post_hash = 'shariff' . hash( 'md5', $post_url );
|
2083 |
+
// Get share counts from cache.
|
2084 |
+
if ( get_transient( $post_hash ) !== false ) {
|
2085 |
+
$share_counts = get_transient( $post_hash );
|
2086 |
+
$services = array_merge( $services, $share_counts );
|
2087 |
+
if ( isset( $share_counts['total'] ) ) {
|
2088 |
+
$total = $share_counts['total'];
|
2089 |
+
} else {
|
2090 |
+
$total = '0';
|
2091 |
+
}
|
2092 |
+
} else {
|
2093 |
+
$share_counts = array();
|
2094 |
+
$total = '';
|
2095 |
+
}
|
2096 |
+
// Add to array.
|
2097 |
+
$posts[ $post_hash ] = array(
|
2098 |
+
'url' => $url,
|
2099 |
+
'title' => $recent['post_title'],
|
2100 |
+
'post_date' => $recent['post_date'],
|
2101 |
+
'share_counts' => $share_counts,
|
2102 |
+
'total_share_counts' => $total,
|
2103 |
+
);
|
2104 |
+
}
|
2105 |
+
}
|
2106 |
+
|
2107 |
+
// Clean up services.
|
2108 |
+
unset( $services['total'] );
|
2109 |
+
unset( $services['timestamp'] );
|
2110 |
+
unset( $services['url'] );
|
2111 |
+
ksort( $services );
|
2112 |
+
|
2113 |
+
// Sort array: first descending using total share counts then descending using post date.
|
2114 |
+
$tmp = array();
|
2115 |
+
$tmp2 = array();
|
2116 |
+
foreach ( $posts as &$ma ) {
|
2117 |
+
$tmp[] = &$ma['total_share_counts'];
|
2118 |
+
}
|
2119 |
+
foreach ( $posts as &$ma2 ) {
|
2120 |
+
$tmp2[] = &$ma2['post_date'];
|
2121 |
+
}
|
2122 |
+
array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
|
2123 |
+
|
2124 |
+
echo '<p></p>';
|
2125 |
+
|
2126 |
+
// Warning if statistic has been disabled.
|
2127 |
+
if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
|
2128 |
+
echo '<p>';
|
2129 |
+
echo '<span style="color: red; font-weight: bold;">';
|
2130 |
+
echo esc_html__( 'Warning:', 'shariff' );
|
2131 |
+
echo '</span> ';
|
2132 |
+
echo esc_html__( 'The statistic option has been disabled on the statistic tab. Share counts will not get updated!', 'shariff' );
|
2133 |
+
echo '</p>';
|
2134 |
+
}
|
2135 |
+
|
2136 |
+
if ( ! empty( $services ) ) {
|
2137 |
+
// Begin ranking table.
|
2138 |
+
echo '<div style="display:table;background-color:#fff">';
|
2139 |
+
// Head.
|
2140 |
+
echo '<div style="display:table-row">';
|
2141 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Rank', 'shariff' ) . '</div>';
|
2142 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Product', 'shariff' ) . '</div>';
|
2143 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Date', 'shariff' ) . '</div>';
|
2144 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Time', 'shariff' ) . '</div>';
|
2145 |
+
foreach ( $services as $service => $nothing ) {
|
2146 |
+
echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center;">' . esc_html( ucfirst( $service ) ) . '</div>';
|
2147 |
+
}
|
2148 |
+
echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Total', 'shariff' ) . '</div>';
|
2149 |
+
echo '</div>';
|
2150 |
+
// Pages.
|
2151 |
+
$rank = '0';
|
2152 |
+
foreach ( $posts as $post => $value ) {
|
2153 |
+
$rank ++;
|
2154 |
+
echo '<div style="display:table-row">';
|
2155 |
+
echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">' . absint( $rank ) . '</div>';
|
2156 |
+
echo '<div style="display:table-cell;border:1px solid;padding:10px"><a href="' . esc_url( $value['url'] ) . '" target="_blank">' . esc_html( $value['title'] ) . '</a></div>';
|
2157 |
+
echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html( mysql2date( 'd.m.Y', $value['post_date'] ) ) . '</div>';
|
2158 |
+
echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html( mysql2date( 'H:i', $value['post_date'] ) ) . '</div>';
|
2159 |
+
// Share counts.
|
2160 |
+
foreach ( $services as $service => $nothing ) {
|
2161 |
+
echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">';
|
2162 |
+
if ( isset( $value['share_counts'][ $service ] ) ) {
|
2163 |
+
echo absint( $value['share_counts'][ $service ] );
|
2164 |
+
}
|
2165 |
+
echo '</div>';
|
2166 |
+
}
|
2167 |
+
echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">';
|
2168 |
+
if ( isset( $value['share_counts']['total'] ) ) {
|
2169 |
+
echo absint( $value['share_counts']['total'] );
|
2170 |
+
}
|
2171 |
+
echo '</div>';
|
2172 |
+
echo '</div>';
|
2173 |
+
}
|
2174 |
+
echo '</div>';
|
2175 |
+
}
|
2176 |
}
|
2177 |
|
2178 |
/**
|
changelog.txt
CHANGED
@@ -2,6 +2,14 @@
|
|
2 |
|
3 |
== Changelog ==
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
= 4.4.4 =
|
6 |
- add support for automatic addition to bbpress forums, topics and replies
|
7 |
- fix a bug that caused "hideshariff" to not function properly
|
2 |
|
3 |
== Changelog ==
|
4 |
|
5 |
+
= 4.5.0 =
|
6 |
+
- new option to add Shariff to custom WordPress hooks
|
7 |
+
- new option to support multilingual sites using WPML and other plugins
|
8 |
+
- new support for WooCommerce products on the ranking table
|
9 |
+
- new option to show different headlines based on share counts
|
10 |
+
- updated button languages, now supporting 25 languages
|
11 |
+
- fixed a bug causing share counts to not being displayed properly
|
12 |
+
|
13 |
= 4.4.4 =
|
14 |
- add support for automatic addition to bbpress forums, topics and replies
|
15 |
- fix a bug that caused "hideshariff" to not function properly
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: Shariff, GDPR, DSGVO, share buttons, sharing
|
|
4 |
Requires at least: 4.9
|
5 |
Requires PHP: 5.6
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 4.
|
8 |
License: MIT
|
9 |
License URI: http://opensource.org/licenses/mit
|
10 |
|
@@ -168,9 +168,17 @@ These are bugs or unexpected glitches that we know of, but that do not have an i
|
|
168 |
|
169 |
== Changelog ==
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
= 4.4.4 =
|
172 |
-
-
|
173 |
-
-
|
174 |
|
175 |
= 4.4.3 =
|
176 |
- new support for additional manual AMP integrations
|
4 |
Requires at least: 4.9
|
5 |
Requires PHP: 5.6
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 4.5.0
|
8 |
License: MIT
|
9 |
License URI: http://opensource.org/licenses/mit
|
10 |
|
168 |
|
169 |
== Changelog ==
|
170 |
|
171 |
+
= 4.5.0 =
|
172 |
+
- new option to add Shariff to custom WordPress hooks
|
173 |
+
- new option to support multilingual sites using WPML and other plugins
|
174 |
+
- new support for WooCommerce products on the ranking table
|
175 |
+
- new option to show different headlines based on share counts
|
176 |
+
- updated button languages, now supporting 25 languages
|
177 |
+
- fixed a bug causing share counts to not being displayed properly
|
178 |
+
|
179 |
= 4.4.4 =
|
180 |
+
- added support for automatic addition to bbpress forums, topics and replies
|
181 |
+
- fixed a bug that caused "hideshariff" to not function properly
|
182 |
|
183 |
= 4.4.3 =
|
184 |
- new support for additional manual AMP integrations
|
shariff.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Shariff Wrapper
|
4 |
* Plugin URI: https://wordpress.org/plugins-wp/shariff/
|
5 |
* Description: Shariff provides share buttons that respect the privacy of your visitors and follow the General Data Protection Regulation (GDPR).
|
6 |
-
* Version: 4.
|
7 |
* Author: Jan-Peter Lambeck & 3UU
|
8 |
* Author URI: https://wordpress.org/plugins/shariff/
|
9 |
* License: MIT
|
@@ -33,7 +33,7 @@ $shariff3uu = array_merge( $shariff3uu_basic, $shariff3uu_design, $shariff3uu_ad
|
|
33 |
*/
|
34 |
function shariff3uu_update() {
|
35 |
// Adjust code version.
|
36 |
-
$code_version = '4.
|
37 |
|
38 |
// Get options.
|
39 |
$shariff3uu = $GLOBALS['shariff3uu'];
|
@@ -510,7 +510,7 @@ register_activation_hook( __FILE__, 'shariff3uu_fill_cache_schedule' );
|
|
510 |
function shariff3uu_fill_cache_schedule_custom_recurrence( $schedules ) {
|
511 |
$schedules['weekly'] = array(
|
512 |
'display' => __( 'Once weekly', 'shariff' ),
|
513 |
-
'interval' =>
|
514 |
);
|
515 |
return $schedules;
|
516 |
}
|
@@ -760,6 +760,51 @@ function shariff3uu_bbp_add_shariff_before_reply() {
|
|
760 |
}
|
761 |
add_action( 'bbp_theme_before_reply_content', 'shariff3uu_bbp_add_shariff_before_reply' );
|
762 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
763 |
/**
|
764 |
* Function is called to include the shariff.css in the header of AMP pages.
|
765 |
* Currently only called by the amp_post_template_css hook.
|
@@ -850,7 +895,7 @@ function shariff3uu_render( $atts ) {
|
|
850 |
$shariff3uu_metabox = str_replace( '[shariff ', '[shariffmeta ', $shariff3uu_metabox );
|
851 |
|
852 |
// Gets the meta box attributes.
|
853 |
-
if ( '[
|
854 |
do_shortcode( $shariff3uu_metabox );
|
855 |
}
|
856 |
|
@@ -889,6 +934,11 @@ function shariff3uu_render( $atts ) {
|
|
889 |
$atts['headline'] = wp_kses( $atts['headline'], $GLOBALS['allowed_tags'] );
|
890 |
}
|
891 |
|
|
|
|
|
|
|
|
|
|
|
892 |
// Remove previous added inline styles to prevent duplications.
|
893 |
if ( wp_style_is( 'shariffcss', 'enqueued' ) ) {
|
894 |
wp_deregister_style( 'shariffcss' );
|
@@ -962,11 +1012,9 @@ function shariff3uu_render( $atts ) {
|
|
962 |
$output .= '>';
|
963 |
}
|
964 |
|
965 |
-
//
|
966 |
-
if ( ! array_key_exists( 'lang', $atts )
|
967 |
-
$
|
968 |
-
$lang = http_negotiate_language( $available_lang );
|
969 |
-
$atts['lang'] = substr( $lang, 0, 2 );
|
970 |
}
|
971 |
|
972 |
// Sets the default button share text.
|
@@ -1016,7 +1064,8 @@ function shariff3uu_render( $atts ) {
|
|
1016 |
$output .= ' shariff-widget-align-' . $atts['align_widget'];
|
1017 |
}
|
1018 |
// Button Stretch.
|
1019 |
-
|
|
|
1020 |
$output .= ' shariff-buttonstretch';
|
1021 |
}
|
1022 |
$output .= '"';
|
@@ -1054,10 +1103,15 @@ function shariff3uu_render( $atts ) {
|
|
1054 |
// Adds the headline.
|
1055 |
if ( array_key_exists( 'headline', $atts ) ) {
|
1056 |
if ( ! array_key_exists( 'total', $share_counts ) ) {
|
1057 |
-
$share_counts['total'] =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1058 |
}
|
1059 |
-
$atts['headline'] = str_replace( '%total', '<span class="shariff-total">' . absint( $share_counts['total'] ) . '</span>', $atts['headline'] );
|
1060 |
-
$output .= '<div class="ShariffHeadline">' . $atts['headline'] . '</div>';
|
1061 |
}
|
1062 |
|
1063 |
// Start the ul list with design classes.
|
@@ -1196,9 +1250,11 @@ function shariff3uu_render( $atts ) {
|
|
1196 |
$button_text_array = $default_button_text_array;
|
1197 |
}
|
1198 |
|
1199 |
-
// Sets button text in desired language
|
1200 |
if ( array_key_exists( 'lang', $atts ) && array_key_exists( $atts['lang'], $button_text_array ) ) {
|
1201 |
$button_text = $button_text_array[ $atts['lang'] ];
|
|
|
|
|
1202 |
} else {
|
1203 |
$button_text = $button_text_array['en'];
|
1204 |
}
|
3 |
* Plugin Name: Shariff Wrapper
|
4 |
* Plugin URI: https://wordpress.org/plugins-wp/shariff/
|
5 |
* Description: Shariff provides share buttons that respect the privacy of your visitors and follow the General Data Protection Regulation (GDPR).
|
6 |
+
* Version: 4.5.0
|
7 |
* Author: Jan-Peter Lambeck & 3UU
|
8 |
* Author URI: https://wordpress.org/plugins/shariff/
|
9 |
* License: MIT
|
33 |
*/
|
34 |
function shariff3uu_update() {
|
35 |
// Adjust code version.
|
36 |
+
$code_version = '4.5.0';
|
37 |
|
38 |
// Get options.
|
39 |
$shariff3uu = $GLOBALS['shariff3uu'];
|
510 |
function shariff3uu_fill_cache_schedule_custom_recurrence( $schedules ) {
|
511 |
$schedules['weekly'] = array(
|
512 |
'display' => __( 'Once weekly', 'shariff' ),
|
513 |
+
'interval' => 604800,
|
514 |
);
|
515 |
return $schedules;
|
516 |
}
|
760 |
}
|
761 |
add_action( 'bbp_theme_before_reply_content', 'shariff3uu_bbp_add_shariff_before_reply' );
|
762 |
|
763 |
+
/**
|
764 |
+
* Adds shariff to custom hooks.
|
765 |
+
*/
|
766 |
+
function shariff3uu_add_shariff_custom_hooks() {
|
767 |
+
// Get options.
|
768 |
+
$shariff3uu = $GLOBALS['shariff3uu'];
|
769 |
+
|
770 |
+
if ( isset( $shariff3uu['custom_hooks_shortcode'] ) && ! empty( $shariff3uu['custom_hooks_shortcode'] ) ) {
|
771 |
+
// Replaces shariff with shariffmeta.
|
772 |
+
$shariff3uu_custom_hooks_shortcode = str_replace( '[shariff ', '[shariffmeta ', $shariff3uu['custom_hooks_shortcode'] );
|
773 |
+
|
774 |
+
// Extracts attributes.
|
775 |
+
if ( '[shariffmeta]' !== $shariff3uu_custom_hooks_shortcode ) {
|
776 |
+
do_shortcode( $shariff3uu_custom_hooks_shortcode );
|
777 |
+
}
|
778 |
+
|
779 |
+
if ( isset( $GLOBALS['shariff3uu']['metabox'] ) && ! empty( $GLOBALS['shariff3uu']['metabox'] ) ) {
|
780 |
+
$shariff3uu_custom_hooks_shortcode = $GLOBALS['shariff3uu']['metabox'];
|
781 |
+
} else {
|
782 |
+
$shariff3uu_custom_hooks_shortcode = array();
|
783 |
+
}
|
784 |
+
|
785 |
+
// Clears the metabox global.
|
786 |
+
$GLOBALS['shariff3uu']['metabox'] = '';
|
787 |
+
|
788 |
+
// phpcs:ignore
|
789 |
+
echo shariff3uu_render( $shariff3uu_custom_hooks_shortcode );
|
790 |
+
} else {
|
791 |
+
// phpcs:ignore
|
792 |
+
echo shariff3uu_render( array() );
|
793 |
+
}
|
794 |
+
}
|
795 |
+
if ( isset( $shariff3uu['custom_hooks'] ) && ! empty( $shariff3uu['custom_hooks'] ) ) {
|
796 |
+
// Explodes hooks.
|
797 |
+
$hook_array = explode( '|', $shariff3uu['custom_hooks'] );
|
798 |
+
|
799 |
+
// Remove duplicated hooks.
|
800 |
+
$hook_array = array_unique( $hook_array );
|
801 |
+
|
802 |
+
// Loops through all desired hooks.
|
803 |
+
foreach ( $hook_array as $hook ) {
|
804 |
+
add_action( esc_html( $hook ), 'shariff3uu_add_shariff_custom_hooks' );
|
805 |
+
}
|
806 |
+
}
|
807 |
+
|
808 |
/**
|
809 |
* Function is called to include the shariff.css in the header of AMP pages.
|
810 |
* Currently only called by the amp_post_template_css hook.
|
895 |
$shariff3uu_metabox = str_replace( '[shariff ', '[shariffmeta ', $shariff3uu_metabox );
|
896 |
|
897 |
// Gets the meta box attributes.
|
898 |
+
if ( '[shariffmeta]' !== $shariff3uu_metabox ) {
|
899 |
do_shortcode( $shariff3uu_metabox );
|
900 |
}
|
901 |
|
934 |
$atts['headline'] = wp_kses( $atts['headline'], $GLOBALS['allowed_tags'] );
|
935 |
}
|
936 |
|
937 |
+
// Cleans up the alternative headline in case it was used in a shorttag.
|
938 |
+
if ( array_key_exists( 'headline_zero', $atts ) ) {
|
939 |
+
$atts['headline_zero'] = wp_kses( $atts['headline_zero'], $GLOBALS['allowed_tags'] );
|
940 |
+
}
|
941 |
+
|
942 |
// Remove previous added inline styles to prevent duplications.
|
943 |
if ( wp_style_is( 'shariffcss', 'enqueued' ) ) {
|
944 |
wp_deregister_style( 'shariffcss' );
|
1012 |
$output .= '>';
|
1013 |
}
|
1014 |
|
1015 |
+
// Sets the language using get_locale(), if no language is set or if automatic language selection is set as an option.
|
1016 |
+
if ( ! array_key_exists( 'lang', $atts ) || ( array_key_exists( 'autolang', $atts ) && 1 === $atts['autolang'] ) ) {
|
1017 |
+
$atts['lang'] = substr( get_locale(), 0, 2 );
|
|
|
|
|
1018 |
}
|
1019 |
|
1020 |
// Sets the default button share text.
|
1064 |
$output .= ' shariff-widget-align-' . $atts['align_widget'];
|
1065 |
}
|
1066 |
// Button Stretch.
|
1067 |
+
// phpcs:ignore
|
1068 |
+
if ( array_key_exists( 'buttonstretch', $atts ) && 1 == $atts['buttonstretch'] ) {
|
1069 |
$output .= ' shariff-buttonstretch';
|
1070 |
}
|
1071 |
$output .= '"';
|
1103 |
// Adds the headline.
|
1104 |
if ( array_key_exists( 'headline', $atts ) ) {
|
1105 |
if ( ! array_key_exists( 'total', $share_counts ) ) {
|
1106 |
+
$share_counts['total'] = 0;
|
1107 |
+
}
|
1108 |
+
if ( 0 === $share_counts['total'] && array_key_exists( 'headline_zero', $atts ) && ! empty( $atts['headline_zero'] ) ) {
|
1109 |
+
$atts['headline_zero'] = str_replace( '%total', '<span class="shariff-total">' . absint( $share_counts['total'] ) . '</span>', $atts['headline_zero'] );
|
1110 |
+
$output .= '<div class="ShariffHeadline">' . $atts['headline_zero'] . '</div>';
|
1111 |
+
} else {
|
1112 |
+
$atts['headline'] = str_replace( '%total', '<span class="shariff-total">' . absint( $share_counts['total'] ) . '</span>', $atts['headline'] );
|
1113 |
+
$output .= '<div class="ShariffHeadline">' . $atts['headline'] . '</div>';
|
1114 |
}
|
|
|
|
|
1115 |
}
|
1116 |
|
1117 |
// Start the ul list with design classes.
|
1250 |
$button_text_array = $default_button_text_array;
|
1251 |
}
|
1252 |
|
1253 |
+
// Sets button text in desired language, first fallback is default language set in options, second one is English.
|
1254 |
if ( array_key_exists( 'lang', $atts ) && array_key_exists( $atts['lang'], $button_text_array ) ) {
|
1255 |
$button_text = $button_text_array[ $atts['lang'] ];
|
1256 |
+
} elseif ( isset( $shariff3uu['lang'] ) && ! empty( $shariff3uu['lang'] ) && array_key_exists( $shariff3uu['lang'], $button_text_array ) ) {
|
1257 |
+
$button_text = $button_text_array[ $shariff3uu['lang'] ];
|
1258 |
} else {
|
1259 |
$button_text = $button_text_array['en'];
|
1260 |
}
|
updates.php
CHANGED
@@ -291,6 +291,19 @@ if ( isset( $GLOBALS['shariff3UU']['version'] ) && -1 === version_compare( $GLOB
|
|
291 |
$GLOBALS['shariff3UU']['version'] = '4.4.0';
|
292 |
}
|
293 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
/**
|
295 |
* General tasks we do on every update, like clean up transients and so on.
|
296 |
*/
|
291 |
$GLOBALS['shariff3UU']['version'] = '4.4.0';
|
292 |
}
|
293 |
|
294 |
+
/**
|
295 |
+
* Migration < 4.5
|
296 |
+
*/
|
297 |
+
if ( isset( $GLOBALS['shariff3UU']['version'] ) && -1 === version_compare( $GLOBALS['shariff3UU']['version'], '4.5.0' ) ) {
|
298 |
+
// Update language settings.
|
299 |
+
if ( ! isset( $GLOBALS['shariff3UU_design']['lang'] ) ) {
|
300 |
+
$GLOBALS['shariff3UU_design']['autolang'] = 1;
|
301 |
+
$GLOBALS['shariff3UU_design']['lang'] = substr( get_locale(), 0, 2 );
|
302 |
+
}
|
303 |
+
// Update version.
|
304 |
+
$GLOBALS['shariff3UU']['version'] = '4.5.0';
|
305 |
+
}
|
306 |
+
|
307 |
/**
|
308 |
* General tasks we do on every update, like clean up transients and so on.
|
309 |
*/
|