PluginProbe
Shariff Wrapper / trunk
Shariff Wrapper vtrunk
4.6.22 4.6.21 4.6.20 4.6.19 trunk 1.0.0 1.9.0 1.9.9 2.4.3 3.4.2 4.0.8 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.3.0 4.4.2 4.4.3 4.4.4 4.5.0 4.5.1 4.5.2 4.5.3 4.6.0 All 42 releases
shariff / admin / admin-menu.php

admin-menu.php in Shariff Wrapper trunk, at admin/admin-menu.php

2,300 lines 94.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Will be included in the shariff.php only, when an admin is logged in.
4 *
5 * @package Shariff Wrapper
6 * @subpackage admin
7 */
8
9 // Prevent direct calls.
10 if ( ! class_exists( 'WP' ) ) { die(); }
11 // and again the same because the WP Plugin Check does not understand what the line above does ;-)
12 if ( ! defined( 'ABSPATH' ) ) exit;
13
14 // Set services that have a share count API / backend.
15 #$shariff3uu_services_backend = array( 'facebook', 'pinterest', 'reddit', 'tumblr', 'vk', 'odnoklassniki', 'buffer' );
16 $shariff3uu_services_backend = array( 'facebook', 'pinterest', 'tumblr', 'vk', 'odnoklassniki', 'buffer' );
17
18 // Adds the actions for the admin page.
19 add_action( 'admin_menu', 'shariff3uu_add_admin_menu' );
20 add_action( 'admin_init', 'shariff3uu_options_init' );
21
22 # findet jetzt via https://translate.wordpress.org/projects/wp-plugins/shariff statt
23 # add_action( 'init', 'shariff_init_locale' );
24 #
25 #/** Initialize translations. */
26 #function shariff_init_locale() {
27 # if ( function_exists( 'load_plugin_textdomain' ) ) {
28 # load_plugin_textdomain( 'shariff' );
29 # }
30 #}
31
32 /**
33 * Scripts and styles for admin pages e.g. info notice.
34 *
35 * @param string $hook The calling hook.
36 */
37 function shariff3uu_admin_style( $hook ) {
38 // Scripts only needed on our plugin options page - no need to load them on _ALL_ admin pages.
39 if ( 'settings_page_shariff3uu' === $hook ) {
40 // Scripts for pinterest default image media uploader.
41 wp_enqueue_media();
42 $shariff_js_media_url = trailingslashit( plugins_url() ) . 'shariff/js/shariff-media.js';
43 wp_register_script( 'shariff_mediaupload', $shariff_js_media_url, array( 'jquery' ), '1.0', true );
44 $translation_array = array(
45 'choose_image' => __( 'Choose image', 'shariff' ),
46 );
47 wp_localize_script( 'shariff_mediaupload', 'shariff_media', $translation_array );
48 wp_enqueue_script( 'shariff_mediaupload' );
49 }
50 }
51 add_action( 'admin_enqueue_scripts', 'shariff3uu_admin_style' );
52
53 /**
54 * Adds the admin menu.
55 */
56 function shariff3uu_add_admin_menu() {
57 add_options_page( 'Shariff', 'Shariff', 'manage_options', 'shariff3uu', 'shariff3uu_options_page' );
58 }
59
60 /**
61 * Creates the plugin options page.
62 */
63 function shariff3uu_options_init() {
64
65 /** First tab - basic */
66
67 // Registers first tab (basic) settings and calls sanitize function.
68 register_setting( 'shariff3uu_basic', 'shariff3uu_basic', 'shariff3uu_basic_sanitize' );
69
70 // First tab - basic options.
71 add_settings_section(
72 'shariff3uu_basic_section',
73 __( 'Basic options', 'shariff' ),
74 'shariff3uu_basic_section_callback',
75 'shariff3uu_basic'
76 );
77
78 // Services.
79 add_settings_field( 'shariff3uu_text_services', '<div style="width:450px">' . __( 'Enable the following services in the provided order:', 'shariff' ) . '</div>', 'shariff3uu_text_services_render', 'shariff3uu_basic', 'shariff3uu_basic_section' );
80
81 // Add after.
82 add_settings_field(
83 'shariff3uu_multiplecheckbox_add_after',
84 __( 'Add the Shariff buttons <u>after</u> all:', 'shariff' ),
85 'shariff3uu_multiplecheckbox_add_after_render',
86 'shariff3uu_basic',
87 'shariff3uu_basic_section'
88 );
89
90 // Add before.
91 add_settings_field(
92 'shariff3uu_checkbox_add_before',
93 __( 'Add the Shariff buttons <u>before</u> all:', 'shariff' ),
94 'shariff3uu_multiplecheckbox_add_before_render',
95 'shariff3uu_basic',
96 'shariff3uu_basic_section'
97 );
98
99 // Disable on protected posts.
100 add_settings_field(
101 'shariff3uu_checkbox_disable_on_protected',
102 __( 'Disable the Shariff buttons on password protected posts.', 'shariff' ),
103 'shariff3uu_checkbox_disable_on_protected_render',
104 'shariff3uu_basic',
105 'shariff3uu_basic_section'
106 );
107
108 // Disable outside of loop.
109 add_settings_field(
110 'shariff3uu_checkbox_disable_outside_loop',
111 __( 'Disable the Shariff buttons outside of the main loop.', 'shariff' ),
112 'shariff3uu_checkbox_disable_outside_loop_render',
113 'shariff3uu_basic',
114 'shariff3uu_basic_section'
115 );
116
117 // Add to custom WordPress hooks.
118 add_settings_field( 'shariff3uu_text_custom_hooks', __( 'Add Shariff to the following custom WordPress hooks:', 'shariff' ), 'shariff3uu_text_custom_hooks_render', 'shariff3uu_basic', 'shariff3uu_basic_section' );
119
120 // Shortcode to use for custom hook.
121 add_settings_field( 'shariff3uu_text_custom_hooks_shortcode', __( 'Use the following shortcode for the custom hooks:', 'shariff' ), 'shariff3uu_text_custom_hooks_shortcode_render', 'shariff3uu_basic', 'shariff3uu_basic_section' );
122
123 /** Second tab - design */
124
125 // Registers second tab (design) settings and calls sanitize function.
126 register_setting( 'shariff3uu_design', 'shariff3uu_design', 'shariff3uu_design_sanitize' );
127
128 // Second tab - design options.
129 add_settings_section( 'shariff3uu_design_section', __( 'Design options', 'shariff' ), 'shariff3uu_design_section_callback', 'shariff3uu_design' );
130
131 // Button language.
132 add_settings_field(
133 'shariff3uu_select_language',
134 '<div style="width:450px">' . esc_html__( 'Default button language:', 'shariff' ) . '</div>',
135 'shariff3uu_select_language_render',
136 'shariff3uu_design',
137 'shariff3uu_design_section'
138 );
139
140 // Automatic button language for multilingual sites.
141 add_settings_field(
142 'shariff3uu_checkbox_autolang',
143 __( 'Automatically set button language based on locale (e.g. set by WPML).', 'shariff' ),
144 'shariff3uu_checkbox_autolang_render',
145 'shariff3uu_design',
146 'shariff3uu_design_section'
147 );
148
149 // Theme.
150 add_settings_field(
151 'shariff3uu_radio_theme',
152 __( 'Shariff button design:', 'shariff' ),
153 'shariff3uu_radio_theme_render',
154 'shariff3uu_design',
155 'shariff3uu_design_section'
156 );
157
158 // Button size.
159 add_settings_field(
160 'shariff3uu_checkbox_buttonsize',
161 __( 'Button size:', 'shariff' ),
162 'shariff3uu_checkbox_buttonsize_render',
163 'shariff3uu_design',
164 'shariff3uu_design_section'
165 );
166
167 // Button stretch.
168 add_settings_field(
169 'shariff3uu_checkbox_buttonsstretch',
170 __( 'Stretch buttons horizontally to full width.', 'shariff' ),
171 'shariff3uu_checkbox_buttonstretch_render',
172 'shariff3uu_design',
173 'shariff3uu_design_section'
174 );
175
176 // Border radius.
177 add_settings_field(
178 'shariff3uu_number_borderradius',
179 __( 'Border radius for the round theme (1-50):', 'shariff' ),
180 'shariff3uu_number_borderradius_render',
181 'shariff3uu_design',
182 'shariff3uu_design_section'
183 );
184
185 // Custom main color.
186 add_settings_field(
187 'shariff3uu_text_maincolor',
188 __( 'Custom main color for <b>all</b> buttons (hexadecimal):', 'shariff' ),
189 'shariff3uu_text_maincolor_render',
190 'shariff3uu_design',
191 'shariff3uu_design_section'
192 );
193
194 // Custom secondary color.
195 add_settings_field(
196 'shariff3uu_text_secondarycolor',
197 __( 'Custom secondary color for <b>all</b> buttons (hexadecimal):', 'shariff' ),
198 'shariff3uu_text_secondarycolor_render',
199 'shariff3uu_design',
200 'shariff3uu_design_section'
201 );
202
203 // Vertical.
204 add_settings_field(
205 'shariff3uu_checkbox_vertical',
206 __( 'Shariff button orientation <b>vertical</b>.', 'shariff' ),
207 'shariff3uu_checkbox_vertical_render',
208 'shariff3uu_design',
209 'shariff3uu_design_section'
210 );
211
212 // Alignment option.
213 add_settings_field(
214 'shariff3uu_radio_align',
215 __( 'Alignment of the Shariff buttons:', 'shariff' ),
216 'shariff3uu_radio_align_render',
217 'shariff3uu_design',
218 'shariff3uu_design_section'
219 );
220
221 // Alignment option for the widget.
222 add_settings_field(
223 'shariff3uu_radio_align_widget',
224 __( 'Alignment of the Shariff buttons in the widget:', 'shariff' ),
225 'shariff3uu_radio_align_widget_render',
226 'shariff3uu_design',
227 'shariff3uu_design_section'
228 );
229
230 // Headline.
231 add_settings_field(
232 'shariff3uu_text_headline',
233 __( 'Headline above all Shariff buttons:', 'shariff' ),
234 'shariff3uu_text_headline_render',
235 'shariff3uu_design',
236 'shariff3uu_design_section'
237 );
238
239 // Alternative headline if share counts are zero.
240 add_settings_field(
241 'shariff3uu_text_headline_zero',
242 __( 'Alternative headline, if share counts are zero:', 'shariff' ),
243 'shariff3uu_text_headline_zero_render',
244 'shariff3uu_design',
245 'shariff3uu_design_section'
246 );
247
248 // Custom css.
249 add_settings_field(
250 'shariff3uu_text_style',
251 __( 'Custom CSS <u>attributes</u> for the container <u>around</u> Shariff:', 'shariff' ),
252 'shariff3uu_text_style_render',
253 'shariff3uu_design',
254 'shariff3uu_design_section'
255 );
256
257 // Custom css class.
258 add_settings_field(
259 'shariff3uu_text_cssclass',
260 __( 'Custom CSS <u>class</u> for the container <u>around</u> Shariff:', 'shariff' ),
261 'shariff3uu_text_cssclass_render',
262 'shariff3uu_design',
263 'shariff3uu_design_section'
264 );
265
266 // Hide until css loaded.
267 add_settings_field(
268 'shariff3uu_checkbox_hideuntilcss',
269 __( 'Hide buttons until page is fully loaded.', 'shariff' ),
270 'shariff3uu_checkbox_hideuntilcss_render',
271 'shariff3uu_design',
272 'shariff3uu_design_section'
273 );
274
275 // Open in popup.
276 add_settings_field(
277 'shariff3uu_checkbox_popup',
278 __( 'Open links in a popup (requires JavaScript).', 'shariff' ),
279 'shariff3uu_checkbox_popup_render',
280 'shariff3uu_design',
281 'shariff3uu_design_section'
282 );
283
284 /** Third tab - advanced */
285
286 // Registers third tab (advanced) settings and calls sanitize function.
287 register_setting( 'shariff3uu_advanced', 'shariff3uu_advanced', 'shariff3uu_advanced_sanitize' );
288
289 // Third tab - advanced options.
290 add_settings_section(
291 'shariff3uu_advanced_section',
292 __( 'Advanced options', 'shariff' ),
293 'shariff3uu_advanced_section_callback',
294 'shariff3uu_advanced'
295 );
296
297 // Info url.
298 add_settings_field(
299 'shariff3uu_text_info_url',
300 '<div style="width:450px">' . __( 'Custom link for the info button:', 'shariff' ) . '</div>',
301 'shariff3uu_text_info_url_render',
302 'shariff3uu_advanced',
303 'shariff3uu_advanced_section'
304 );
305
306 // Info text.
307 add_settings_field(
308 'shariff3uu_text_info_text',
309 __( 'Custom text for the info button:', 'shariff' ),
310 'shariff3uu_text_info_text_render',
311 'shariff3uu_advanced',
312 'shariff3uu_advanced_section'
313 );
314
315 // Twitter via.
316 add_settings_field(
317 'shariff3uu_text_twittervia',
318 __( 'Twitter username for the via tag:', 'shariff' ),
319 'shariff3uu_text_twittervia_render',
320 'shariff3uu_advanced',
321 'shariff3uu_advanced_section'
322 );
323
324 // Bluesky via.
325 add_settings_field(
326 'shariff3uu_text_blueskyvia',
327 __( 'Bluesky username for the via tag:', 'shariff' ),
328 'shariff3uu_text_blueskyvia_render',
329 'shariff3uu_advanced',
330 'shariff3uu_advanced_section'
331 );
332
333 // Mastodon via.
334 add_settings_field(
335 'shariff3uu_text_mastodonvia',
336 __( 'Mastodon username for the via tag:', 'shariff' ),
337 'shariff3uu_text_mastodonvia_render',
338 'shariff3uu_advanced',
339 'shariff3uu_advanced_section'
340 );
341
342 // Patreon username.
343 add_settings_field(
344 'shariff3uu_text_patreonid',
345 __( 'Patreon username:', 'shariff' ),
346 'shariff3uu_text_patreonid_render',
347 'shariff3uu_advanced',
348 'shariff3uu_advanced_section'
349 );
350
351 // Paypal button id.
352 add_settings_field(
353 'shariff3uu_text_paypalbuttonid',
354 __( 'PayPal hosted button ID:', 'shariff' ),
355 'shariff3uu_text_paypalbuttonid_render',
356 'shariff3uu_advanced',
357 'shariff3uu_advanced_section'
358 );
359
360 // Paypalme id.
361 add_settings_field(
362 'shariff3uu_text_paypalmeid',
363 __( 'PayPal.Me ID:', 'shariff' ),
364 'shariff3uu_text_paypalmeid_render',
365 'shariff3uu_advanced',
366 'shariff3uu_advanced_section'
367 );
368
369 // Bitcoin address.
370 add_settings_field(
371 'shariff3uu_text_bitcoinaddress',
372 __( 'Bitcoin address:', 'shariff' ),
373 'shariff3uu_text_bitcoinaddress_render',
374 'shariff3uu_advanced',
375 'shariff3uu_advanced_section'
376 );
377
378 // RSS feed.
379 add_settings_field(
380 'shariff3uu_text_rssfeed',
381 __( 'RSS feed:', 'shariff' ),
382 'shariff3uu_text_rssfeed_render',
383 'shariff3uu_advanced',
384 'shariff3uu_advanced_section'
385 );
386
387 // Default image for pinterest.
388 add_settings_field(
389 'shariff3uu_text_default_pinterest',
390 __( 'Default image for Pinterest:', 'shariff' ),
391 'shariff3uu_text_default_pinterest_render',
392 'shariff3uu_advanced',
393 'shariff3uu_advanced_section'
394 );
395
396 // Hide WhatsApp.
397 add_settings_field(
398 'shariff3uu_checkbox_hide_whatsapp',
399 __( 'Hide WhatsApp on desktop devices.', 'shariff' ),
400 'shariff3uu_checkbox_hide_whatsapp_render',
401 'shariff3uu_advanced',
402 'shariff3uu_advanced_section'
403 );
404
405 // Shortcode priority.
406 add_settings_field(
407 'shariff3uu_number_shortcodeprio',
408 __( 'Shortcode priority:', 'shariff' ),
409 'shariff3uu_number_shortcodeprio_render',
410 'shariff3uu_advanced',
411 'shariff3uu_advanced_section'
412 );
413
414 // Disable metabox.
415 add_settings_field(
416 'shariff3uu_checkbox_disable_metabox',
417 __( 'Disable the metabox.', 'shariff' ),
418 'shariff3uu_checkbox_disable_metabox_render',
419 'shariff3uu_advanced',
420 'shariff3uu_advanced_section'
421 );
422
423 /** Fifth tab - statistic */
424
425 // Registers fifth tab (statistic) settings and calls sanitize function.
426 register_setting( 'shariff3uu_statistic', 'shariff3uu_statistic', 'shariff3uu_statistic_sanitize' );
427
428 // Fifth tab (statistic).
429 add_settings_section(
430 'shariff3uu_statistic_section',
431 __( 'Statistic', 'shariff' ),
432 'shariff3uu_statistic_section_callback',
433 'shariff3uu_statistic'
434 );
435
436 // Statistic.
437 add_settings_field(
438 'shariff3uu_checkbox_backend',
439 '<div style="width:450px">' . __( 'Enable statistic.', 'shariff' ) . '</div>',
440 'shariff3uu_checkbox_backend_render',
441 'shariff3uu_statistic',
442 'shariff3uu_statistic_section'
443 );
444
445 // Share counts.
446 add_settings_field(
447 'shariff3uu_checkbox_sharecounts',
448 __( 'Show share counts on buttons.', 'shariff' ),
449 'shariff3uu_checkbox_sharecounts_render',
450 'shariff3uu_statistic',
451 'shariff3uu_statistic_section'
452 );
453
454 // Hide when zero.
455 add_settings_field(
456 'shariff3uu_checkbox_hidezero',
457 __( 'Hide share counts when they are zero.', 'shariff' ),
458 'shariff3uu_checkbox_hidezero_render',
459 'shariff3uu_statistic',
460 'shariff3uu_statistic_section'
461 );
462
463 // Facebook App ID.
464 add_settings_field(
465 'shariff3uu_text_fb_id',
466 __( 'Facebook App ID:', 'shariff' ),
467 'shariff3uu_text_fb_id_render',
468 'shariff3uu_statistic',
469 'shariff3uu_statistic_section'
470 );
471
472 // Facebook App Secret.
473 add_settings_field(
474 'shariff3uu_text_fb_secret',
475 __( 'Facebook App Secret:', 'shariff' ),
476 'shariff3uu_text_fb_secret_render',
477 'shariff3uu_statistic',
478 'shariff3uu_statistic_section'
479 );
480
481 // Automatic cache.
482 add_settings_field(
483 'shariff3uu_checkbox_automaticcache',
484 __( 'Fill cache automatically.', 'shariff' ),
485 'shariff3uu_checkbox_automaticcache_render',
486 'shariff3uu_statistic',
487 'shariff3uu_statistic_section'
488 );
489
490 // Ranking.
491 add_settings_field(
492 'shariff3uu_number_ranking',
493 __( 'Number of posts on ranking tab:', 'shariff' ),
494 'shariff3uu_number_ranking_render',
495 'shariff3uu_statistic',
496 'shariff3uu_statistic_section'
497 );
498
499 // TTL.
500 add_settings_field(
501 'shariff3uu_number_ttl',
502 __( 'Cache TTL in seconds (60 - 7200):', 'shariff' ),
503 'shariff3uu_number_ttl_render',
504 'shariff3uu_statistic',
505 'shariff3uu_statistic_section'
506 );
507
508 // Disable dynamic cache lifespan.
509 add_settings_field(
510 'shariff3uu_checkbox_disable_dynamic_cache',
511 __( 'Disable the dynamic cache lifespan (not recommended).', 'shariff' ),
512 'shariff3uu_checkbox_disable_dynamic_cache_render',
513 'shariff3uu_statistic',
514 'shariff3uu_statistic_section'
515 );
516
517 // Disable services.
518 add_settings_field(
519 'shariff3uu_multiplecheckbox_disable_services',
520 __( 'Disable the following services (share counts only):', 'shariff' ),
521 'shariff3uu_multiplecheckbox_disable_services_render',
522 'shariff3uu_statistic',
523 'shariff3uu_statistic_section'
524 );
525
526 // External hosts.
527 add_settings_field(
528 'shariff3uu_text_external_host',
529 __( 'External API for share counts:', 'shariff' ),
530 'shariff3uu_text_external_host_render',
531 'shariff3uu_statistic',
532 'shariff3uu_statistic_section'
533 );
534
535 // Request external api directly from js.
536 add_settings_field(
537 'shariff3uu_checkbox_external_direct',
538 __( 'Request external API directly.', 'shariff' ),
539 'shariff3uu_checkbox_external_direct_render',
540 'shariff3uu_statistic',
541 'shariff3uu_statistic_section'
542 );
543
544 // WP in sub folder and api only reachable there?
545 add_settings_field(
546 'shariff3uu_checkbox_subapi',
547 __( 'Local API not reachable in root.', 'shariff' ),
548 'shariff3uu_checkbox_subapi_render',
549 'shariff3uu_statistic',
550 'shariff3uu_statistic_section'
551 );
552
553 /** Sixth tab - help */
554
555 // Register sixth tab (help).
556 add_settings_section(
557 'shariff3uu_help_section',
558 __( 'Shariff Help', 'shariff' ),
559 'shariff3uu_help_section_callback',
560 'shariff3uu_help'
561 );
562
563 /** Seventh tab - status */
564
565 // Register seventh tab (status).
566 add_settings_section(
567 'shariff3uu_status_section',
568 __( 'Status', 'shariff' ),
569 'shariff3uu_status_section_callback',
570 'shariff3uu_status'
571 );
572
573 /** Eight tab - ranking */
574
575 // Register eight tab (ranking).
576 add_settings_section(
577 'shariff3uu_ranking_section',
578 __( 'Ranking', 'shariff' ),
579 'shariff3uu_ranking_section_callback',
580 'shariff3uu_ranking'
581 );
582 }
583
584 /** Render admin options: use isset() to prevent errors while debug mode is on. */
585
586 /** Basic options */
587
588 /**
589 * Description of basic options.
590 */
591 function shariff3uu_basic_section_callback() {
592 esc_html_e( 'Select the desired services in the order you want them to be displayed and where the Shariff buttons should be included automatically.', 'shariff' );
593 }
594
595 /**
596 * Services.
597 */
598 function shariff3uu_text_services_render() {
599 if ( isset( $GLOBALS['shariff3uu_basic']['services'] ) ) {
600 $services = $GLOBALS['shariff3uu_basic']['services'];
601 } else {
602 $services = '';
603 }
604 echo '<input type="text" name="shariff3uu_basic[services]" value="' . esc_html( $services ) . '" size="90" placeholder="mastodon|facebook|linkedin|info">';
605 echo '<p><code>bitcoin|bluesky|buffer|diaspora|facebook|flipboard|info|linkedin|mailto|mastodon</code></p>';
606 echo '<p><code>|mewe|mix|odnoklassniki|patreon|paypal|paypalme|pinterest|pocket|printer|reddit</code></p>';
607 echo '<p><code>|rss|sms|telegram|threema|tumblr|twitter|vk|wallabag|weibo|whatsapp|xing</code></p>';
608 echo '<p>' . esc_html__( 'Use the pipe sign | (Alt Gr + &lt; or &#8997; + 7) between two or more services.', 'shariff' ) . '</p>';
609 }
610
611 /**
612 * Add after.
613 */
614 function shariff3uu_multiplecheckbox_add_after_render() {
615 // Add after all posts.
616 echo '<p><input type="checkbox" name="shariff3uu_basic[add_after][post]" ';
617 if ( isset( $GLOBALS['shariff3uu_basic']['add_after']['post'] ) ) {
618 echo checked( $GLOBALS['shariff3uu_basic']['add_after']['post'], 1, 0 );
619 }
620 echo ' value="1">' . esc_html__( 'Posts', 'shariff' ) . '</p>';
621
622 // Add after all posts (blog page).
623 echo '<p><input type="checkbox" name="shariff3uu_basic[add_after][blogpage]" ';
624 if ( isset( $GLOBALS['shariff3uu_basic']['add_after']['blogpage'] ) ) {
625 echo checked( $GLOBALS['shariff3uu_basic']['add_after']['blogpage'], 1, 0 );
626 }
627 echo ' value="1">' . esc_html__( 'Posts (blog page)', 'shariff' ) . '</p>';
628
629 // Add after all pages.
630 echo '<p><input type="checkbox" name="shariff3uu_basic[add_after][page]" ';
631 if ( isset( $GLOBALS['shariff3uu_basic']['add_after']['page'] ) ) {
632 echo checked( $GLOBALS['shariff3uu_basic']['add_after']['page'], 1, 0 );
633 }
634 echo ' value="1">' . esc_html__( 'Pages', 'shariff' ) . '</p>';
635
636 // Add after all excerpts.
637 echo '<p><input type="checkbox" name="shariff3uu_basic[add_after][excerpt]" ';
638 if ( isset( $GLOBALS['shariff3uu_basic']['add_after']['excerpt'] ) ) {
639 echo checked( $GLOBALS['shariff3uu_basic']['add_after']['excerpt'], 1, 0 );
640 }
641 echo ' value="1">' . esc_html__( 'Excerpts', 'shariff' ) . '</p>';
642
643 // Add after custom post types - choose after which to add.
644 $post_types = get_post_types( array( '_builtin' => false ) );
645 if ( isset( $post_types ) && is_array( $post_types ) && ! empty( $post_types ) ) {
646 echo '<p>Custom Post Types:</p>';
647 };
648
649 foreach ( $post_types as $post_type ) {
650 $object = get_post_type_object( $post_type );
651 printf(
652 '<p><input type="checkbox" name="shariff3uu_basic[add_after][%s]" %s value="1">%s</p>',
653 $post_type,
654 isset( $GLOBALS['shariff3uu_basic']['add_after'][ $post_type ] ) ? checked( $GLOBALS['shariff3uu_basic']['add_after'][ $post_type ], 1, 0 ) : '',
655 // The following should already be localized <- not always, but there is no way to know, so we have to accept the language mix up.
656 esc_html( $object->labels->singular_name )
657 );
658 }
659 }
660
661 /**
662 * Add before.
663 */
664 function shariff3uu_multiplecheckbox_add_before_render() {
665 // Add before all posts.
666 echo '<p><input type="checkbox" name="shariff3uu_basic[add_before][post]" ';
667 if ( isset( $GLOBALS['shariff3uu_basic']['add_before']['post'] ) ) {
668 echo checked( $GLOBALS['shariff3uu_basic']['add_before']['post'], 1, 0 );
669 }
670 echo ' value="1">' . esc_html__( 'Posts', 'shariff' ) . '</p>';
671
672 // Add before all posts (blog page).
673 echo '<p><input type="checkbox" name="shariff3uu_basic[add_before][blogpage]" ';
674 if ( isset( $GLOBALS['shariff3uu_basic']['add_before']['blogpage'] ) ) {
675 echo checked( $GLOBALS['shariff3uu_basic']['add_before']['blogpage'], 1, 0 );
676 }
677 echo ' value="1">' . esc_html__( 'Posts (blog page)', 'shariff' ) . '</p>';
678
679 // Add before all pages.
680 echo '<p><input type="checkbox" name="shariff3uu_basic[add_before][page]" ';
681 if ( isset( $GLOBALS['shariff3uu_basic']['add_before']['page'] ) ) {
682 echo checked( $GLOBALS['shariff3uu_basic']['add_before']['page'], 1, 0 );
683 }
684 echo ' value="1">' . esc_html__( 'Pages', 'shariff' ) . '</p>';
685
686 // Add before all excerpts.
687 echo '<p><input type="checkbox" name="shariff3uu_basic[add_before][excerpt]" ';
688 if ( isset( $GLOBALS['shariff3uu_basic']['add_before']['excerpt'] ) ) {
689 echo checked( $GLOBALS['shariff3uu_basic']['add_before']['excerpt'], 1, 0 );
690 }
691 echo ' value="1">' . esc_html__( 'Excerpts', 'shariff' ) . '</p>';
692
693 // Add before custom post types - choose before which to add.
694 $post_types = get_post_types( array( '_builtin' => false ) );
695 if ( isset( $post_types ) && is_array( $post_types ) && ! empty( $post_types ) ) {
696 echo '<p>Custom Post Types:</p>';
697 };
698
699 foreach ( $post_types as $post_type ) {
700 $object = get_post_type_object( $post_type );
701 printf(
702 '<p><input type="checkbox" name="shariff3uu_basic[add_before][%s]" %s value="1">%s</p>',
703 $post_type,
704 isset( $GLOBALS['shariff3uu_basic']['add_before'][ $post_type ] ) ? checked( $GLOBALS['shariff3uu_basic']['add_before'][ $post_type ], 1, 0 ) : '',
705 // The following should already be localized <- not always, but there is no way to know, so we have to accept the language mix up.
706 esc_html( $object->labels->singular_name )
707 );
708 }
709 }
710
711 /**
712 * Disable on password protected posts.
713 */
714 function shariff3uu_checkbox_disable_on_protected_render() {
715 echo '<input type="checkbox" name="shariff3uu_basic[disable_on_protected]" ';
716 if ( isset( $GLOBALS['shariff3uu_basic']['disable_on_protected'] ) ) {
717 echo checked( $GLOBALS['shariff3uu_basic']['disable_on_protected'], 1, 0 );
718 }
719 echo ' value="1">';
720 }
721
722 /**
723 * Disable outside loop.
724 */
725 function shariff3uu_checkbox_disable_outside_loop_render() {
726 echo '<input type="checkbox" name="shariff3uu_basic[disable_outside_loop]" ';
727 if ( isset( $GLOBALS['shariff3uu_basic']['disable_outside_loop'] ) ) {
728 echo checked( $GLOBALS['shariff3uu_basic']['disable_outside_loop'], 1, 0 );
729 }
730 echo ' value="1">';
731 }
732
733 /**
734 * Custom hooks.
735 */
736 function shariff3uu_text_custom_hooks_render() {
737 if ( isset( $GLOBALS['shariff3uu_basic']['custom_hooks'] ) ) {
738 $custom_hooks = $GLOBALS['shariff3uu_basic']['custom_hooks'];
739 } else {
740 $custom_hooks = '';
741 }
742 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' ) . '">';
743 echo '<p>' . esc_html__( 'Use the pipe sign | (Alt Gr + &lt; or &#8997; + 7) between two or more hooks.', 'shariff' ) . '</p>';
744 }
745
746 /**
747 * Custom hooks shortcode.
748 */
749 function shariff3uu_text_custom_hooks_shortcode_render() {
750 if ( isset( $GLOBALS['shariff3uu_basic']['custom_hooks_shortcode'] ) ) {
751 $custom_hooks_shortcode = $GLOBALS['shariff3uu_basic']['custom_hooks_shortcode'];
752 } else {
753 $custom_hooks_shortcode = '';
754 }
755 echo '<input type="text" name="shariff3uu_basic[custom_hooks_shortcode]" value="' . esc_html( $custom_hooks_shortcode ) . '" size="90" placeholder="[shariff]">';
756 }
757
758 /** Design options */
759
760 /**
761 * Description of the design options.
762 */
763 function shariff3uu_design_section_callback() {
764 esc_html_e( 'This configures the default design of the Shariff buttons. Most options can be overwritten for single posts or pages with the options within the [shariff] shorttag. ', 'shariff' );
765 $help_link = get_bloginfo( 'wpurl' ) . '/wp-admin/options-general.php?page=shariff3uu&tab=help';
766 // Translators: %s will be replaced with the correct URL to the help section.
767 printf( wp_kses( __( 'For more information please take a look at the <a href="%s">Help Section</a>. ', 'shariff' ), array( 'a' => array( 'href' => true ) ) ), esc_url( $help_link ) );
768 printf(
769 wp_kses(
770 // Translators: %s will be replaced with the correct URL to the wordpress.org support forum.
771 __( 'You should also check out the <a href="%s" target="_blank">Support Forum</a>. ', 'shariff' ),
772 array(
773 'a' => array(
774 'href' => true,
775 'target' => true,
776 ),
777 )
778 ),
779 'https://wordpress.org/support/plugin/shariff/'
780 );
781 }
782
783 /**
784 * Language.
785 */
786 function shariff3uu_select_language_render() {
787 $options = $GLOBALS['shariff3uu_design'];
788 if ( ! isset( $options['lang'] ) ) {
789 $options['lang'] = substr( get_locale(), 0, 2 );
790 }
791 echo '<select name="shariff3uu_design[lang]">
792 <option value="bg" ' . selected( $options['lang'], 'bg', 0 ) . '>български</option>
793 <option value="cs" ' . selected( $options['lang'], 'cs', 0 ) . '>český</option>
794 <option value="da" ' . selected( $options['lang'], 'da', 0 ) . '>Dansk</option>
795 <option value="de" ' . selected( $options['lang'], 'de', 0 ) . '>Deutsch</option>
796 <option value="en" ' . selected( $options['lang'], 'en', 0 ) . '>English</option>
797 <option value="es" ' . selected( $options['lang'], 'es', 0 ) . '>Español</option>
798 <option value="fi" ' . selected( $options['lang'], 'fi', 0 ) . '>Finnish</option>
799 <option value="fr" ' . selected( $options['lang'], 'fr', 0 ) . '>Français</option>
800 <option value="hr" ' . selected( $options['lang'], 'hr', 0 ) . '>Croatian</option>
801 <option value="hu" ' . selected( $options['lang'], 'hu', 0 ) . '>Magyar</option>
802 <option value="it" ' . selected( $options['lang'], 'it', 0 ) . '>Italiano</option>
803 <option value="ja" ' . selected( $options['lang'], 'ja', 0 ) . '>日本語</option>
804 <option value="ko" ' . selected( $options['lang'], 'ko', 0 ) . '>한국어</option>
805 <option value="nl" ' . selected( $options['lang'], 'nl', 0 ) . '>Nederlands</option>
806 <option value="no" ' . selected( $options['lang'], 'no', 0 ) . '>Norsk</option>
807 <option value="pl" ' . selected( $options['lang'], 'pl', 0 ) . '>Polskie</option>
808 <option value="pt" ' . selected( $options['lang'], 'pt', 0 ) . '>Português</option>
809 <option value="ro" ' . selected( $options['lang'], 'ro', 0 ) . '>Română</option>
810 <option value="ru" ' . selected( $options['lang'], 'ru', 0 ) . '>Pусский</option>
811 <option value="sk" ' . selected( $options['lang'], 'sk', 0 ) . '>Slovenský</option>
812 <option value="sl" ' . selected( $options['lang'], 'sl', 0 ) . '>Slovenščina</option>
813 <option value="sr" ' . selected( $options['lang'], 'sr', 0 ) . '>Српски</option>
814 <option value="sv" ' . selected( $options['lang'], 'sv', 0 ) . '>Svenska</option>
815 <option value="tr" ' . selected( $options['lang'], 'tr', 0 ) . '>Türk</option>
816 <option value="zh" ' . selected( $options['lang'], 'zh', 0 ) . '>中文</option>
817 </select>';
818 }
819
820 /**
821 * Automatic button language.
822 */
823 function shariff3uu_checkbox_autolang_render() {
824 echo '<input type="checkbox" name="shariff3uu_design[autolang]" ';
825 if ( isset( $GLOBALS['shariff3uu_design']['autolang'] ) ) {
826 echo checked( $GLOBALS['shariff3uu_design']['autolang'], 1, 0 );
827 }
828 echo ' value="1">';
829 }
830
831 /**
832 * Theme.
833 */
834 function shariff3uu_radio_theme_render() {
835 $options = $GLOBALS['shariff3uu_design'];
836 if ( ! isset( $options['theme'] ) ) {
837 $options['theme'] = '';
838 }
839 $plugins_url = plugins_url();
840 echo '<div style="display:grid;grid-template-columns:75px auto;grid-template-rows:44px 45px 45px 45px 45px 45px;grid-auto-flow: column;align-items:center">
841 <div><input type="radio" name="shariff3uu_design[theme]" value="" ' . checked( $options['theme'], '', 0 ) . '>default</div>
842 <div><input type="radio" name="shariff3uu_design[theme]" value="color" ' . checked( $options['theme'], 'color', 0 ) . '>color</div>
843 <div><input type="radio" name="shariff3uu_design[theme]" value="grey" ' . checked( $options['theme'], 'grey', 0 ) . '>grey</div>
844 <div><input type="radio" name="shariff3uu_design[theme]" value="white" ' . checked( $options['theme'], 'white', 0 ) . '>white</div>
845 <div><input type="radio" name="shariff3uu_design[theme]" value="round" ' . checked( $options['theme'], 'round', 0 ) . '>round</div>
846 <div><input type="radio" name="shariff3uu_design[theme]" value="wcag" ' . checked( $options['theme'], 'wcag', 0 ) . '>wcag</div>
847 <img alt="Shariff Designs" src="' . esc_url( $plugins_url ) . '/shariff/images/shariff_designs.png" style="grid-row: 1 / span 6;align-self:baseline">
848 </div>';
849 }
850
851 /**
852 * Button size.
853 */
854 function shariff3uu_checkbox_buttonsize_render() {
855 $options = $GLOBALS['shariff3uu_design'];
856 if ( ! isset( $options['buttonsize'] ) ) {
857 $options['buttonsize'] = 'medium';
858 }
859 echo '<p><input type="radio" name="shariff3uu_design[buttonsize]" value="small" ' . checked( $options['buttonsize'], 'small', 0 ) . '>' . esc_html__( 'small', 'shariff' ) . '</p>';
860 echo '<p><input type="radio" name="shariff3uu_design[buttonsize]" value="medium" ' . checked( $options['buttonsize'], 'medium', 0 ) . '>' . esc_html__( 'medium', 'shariff' ) . '</p>';
861 echo '<p><input type="radio" name="shariff3uu_design[buttonsize]" value="large" ' . checked( $options['buttonsize'], 'large', 0 ) . '>' . esc_html__( 'large', 'shariff' ) . '</p>';
862 }
863
864 /**
865 * Button stretch.
866 */
867 function shariff3uu_checkbox_buttonstretch_render() {
868 echo '<input type="checkbox" name="shariff3uu_design[buttonstretch]" ';
869 if ( isset( $GLOBALS['shariff3uu_design']['buttonstretch'] ) ) {
870 echo checked( $GLOBALS['shariff3uu_design']['buttonstretch'], 1, 0 );
871 }
872 echo ' value="1">';
873 }
874
875 /**
876 * Border radius.
877 */
878 function shariff3uu_number_borderradius_render() {
879 if ( isset( $GLOBALS['shariff3uu_design']['borderradius'] ) ) {
880 $borderradius = $GLOBALS['shariff3uu_design']['borderradius'];
881 } else {
882 $borderradius = '';
883 }
884 echo '<input type="number" name="shariff3uu_design[borderradius]" value="' . esc_attr( $borderradius ) . '" maxlength="2" min="1" max="50" placeholder="50" style="width: 75px">';
885 echo '<img src="' . plugins_url() . '/shariff/images/borderradius.png" align="top">';
886 }
887
888 /**
889 * Custom main color.
890 */
891 function shariff3uu_text_maincolor_render() {
892 if ( isset( $GLOBALS['shariff3uu_design']['maincolor'] ) ) {
893 $maincolor = $GLOBALS['shariff3uu_design']['maincolor'];
894 } else {
895 $maincolor = '';
896 }
897 echo '<input type="text" name="shariff3uu_design[maincolor]" value="' . esc_html( $maincolor ) . '" size="7" placeholder="#000000">';
898 }
899
900 /**
901 * Custom secondary color.
902 */
903 function shariff3uu_text_secondarycolor_render() {
904 if ( isset( $GLOBALS['shariff3uu_design']['secondarycolor'] ) ) {
905 $secondarycolor = $GLOBALS['shariff3uu_design']['secondarycolor'];
906 } else {
907 $secondarycolor = '';
908 }
909 echo '<input type="text" name="shariff3uu_design[secondarycolor]" value="' . esc_html( $secondarycolor ) . '" size="7" placeholder="#afafaf">';
910 }
911
912 /**
913 * Vertical.
914 */
915 function shariff3uu_checkbox_vertical_render() {
916 $plugins_url = plugins_url();
917 echo '<input type="checkbox" name="shariff3uu_design[vertical]" ';
918 if ( isset( $GLOBALS['shariff3uu_design']['vertical'] ) ) {
919 echo checked( $GLOBALS['shariff3uu_design']['vertical'], 1, 0 );
920 }
921 echo ' value="1">';
922 }
923
924 /**
925 * Alignment.
926 */
927 function shariff3uu_radio_align_render() {
928 $options = $GLOBALS['shariff3uu_design'];
929 if ( ! isset( $options['align'] ) ) {
930 $options['align'] = 'flex-start';
931 }
932 echo '<p><input type="radio" name="shariff3uu_design[align]" value="flex-start" ' . checked( $options['align'], 'flex-start', 0 ) . '>' . esc_html__( 'left', 'shariff' ) . '</p>';
933 echo '<p><input type="radio" name="shariff3uu_design[align]" value="center" ' . checked( $options['align'], 'center', 0 ) . '>' . esc_html__( 'center', 'shariff' ) . '</p>';
934 echo '<p><input type="radio" name="shariff3uu_design[align]" value="flex-end" ' . checked( $options['align'], 'flex-end', 0 ) . '>' . esc_html__( 'right', 'shariff' ) . '</p>';
935 }
936
937 /**
938 * Alignment widget.
939 */
940 function shariff3uu_radio_align_widget_render() {
941 $options = $GLOBALS['shariff3uu_design'];
942 if ( ! isset( $options['align_widget'] ) ) {
943 $options['align_widget'] = 'flex-start';
944 }
945 echo '<p><input type="radio" name="shariff3uu_design[align_widget]" value="flex-start" ' . checked( $options['align_widget'], 'flex-start', 0 ) . '>' . esc_html__( 'left', 'shariff' ) . '</p>';
946 echo '<p><input type="radio" name="shariff3uu_design[align_widget]" value="center" ' . checked( $options['align_widget'], 'center', 0 ) . '>' . esc_html__( 'center', 'shariff' ) . '</p>';
947 echo '<p><input type="radio" name="shariff3uu_design[align_widget]" value="flex-end" ' . checked( $options['align_widget'], 'flex-end', 0 ) . '>' . esc_html__( 'right', 'shariff' ) . '</p>';
948 }
949
950 /**
951 * Headline.
952 */
953 function shariff3uu_text_headline_render() {
954 if ( isset( $GLOBALS['shariff3uu_design']['headline'] ) ) {
955 $headline = $GLOBALS['shariff3uu_design']['headline'];
956 } else {
957 $headline = '';
958 }
959 echo '<input type="text" name="shariff3uu_design[headline]" value="' . esc_html( $headline ) . '" size="50" placeholder="' . esc_html__( 'Share this post', 'shariff' ) . '">';
960 echo '<p>';
961 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' );
962 echo '<br>';
963 echo esc_html__( 'Example:', 'shariff' );
964 echo ' <code>&lt;h3 class="shariff_headline"&gt;';
965 echo esc_html__( 'Already shared %total times!', 'shariff' );
966 echo '&lt;/h3&gt;</code></p>';
967 }
968
969 /**
970 * Alternative headline.
971 */
972 function shariff3uu_text_headline_zero_render() {
973 if ( isset( $GLOBALS['shariff3uu_design']['headline_zero'] ) ) {
974 $headline_zero = $GLOBALS['shariff3uu_design']['headline_zero'];
975 } else {
976 $headline_zero = '';
977 }
978 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' ) . '">';
979 echo '<p>';
980 echo esc_html__( 'Same rules as for the default headline. Leave empty to keep the same headline in all cases.', 'shariff' );
981 echo '</p>';
982 }
983
984 /**
985 * Custom CSS.
986 */
987 function shariff3uu_text_style_render() {
988 if ( isset( $GLOBALS['shariff3uu_design']['style'] ) ) {
989 $style = $GLOBALS['shariff3uu_design']['style'];
990 } else {
991 $style = '';
992 }
993 echo '<input type="text" name="shariff3uu_design[style]" value="' . esc_html( $style ) . '" size="50" placeholder="' . esc_attr__( 'More information in the FAQ.', 'shariff' ) . '">';
994 }
995
996 /**
997 * Custom CSS class.
998 */
999 function shariff3uu_text_cssclass_render() {
1000 if ( isset( $GLOBALS['shariff3uu_design']['cssclass'] ) ) {
1001 $cssclass = $GLOBALS['shariff3uu_design']['cssclass'];
1002 } else {
1003 $cssclass = '';
1004 }
1005 echo '<input type="text" name="shariff3uu_design[cssclass]" value="' . esc_html( $cssclass ) . '" size="50" placeholder="' . esc_attr__( 'More information in the FAQ.', 'shariff' ) . '">';
1006 }
1007
1008 /**
1009 * Hide buttons until page is fully loaded.
1010 */
1011 function shariff3uu_checkbox_hideuntilcss_render() {
1012 echo '<input type="checkbox" name="shariff3uu_design[hideuntilcss]" ';
1013 if ( isset( $GLOBALS['shariff3uu_design']['hideuntilcss'] ) ) {
1014 echo checked( $GLOBALS['shariff3uu_design']['hideuntilcss'], 1, 0 );
1015 }
1016 echo ' value="1">';
1017 }
1018
1019 /**
1020 * Open links in a popup.
1021 */
1022 function shariff3uu_checkbox_popup_render() {
1023 echo '<input type="checkbox" name="shariff3uu_design[popup]" ';
1024 if ( isset( $GLOBALS['shariff3uu_design']['popup'] ) ) {
1025 echo checked( $GLOBALS['shariff3uu_design']['popup'], 1, 0 );
1026 }
1027 echo ' value="1">';
1028 }
1029
1030 /** Advanced options */
1031
1032 /**
1033 * Description of the advanced options.
1034 */
1035 function shariff3uu_advanced_section_callback() {
1036 esc_html_e( 'This configures the advanced options of Shariff regarding specific services. ', 'shariff' );
1037 $help_link = get_bloginfo( 'wpurl' ) . '/wp-admin/options-general.php?page=shariff3uu&tab=help';
1038 // Translators: %s will be replaced with the correct URL to the help section.
1039 printf( wp_kses( __( 'For more information please take a look at the <a href="%s">Help Section</a>. ', 'shariff' ), array( 'a' => array( 'href' => true ) ) ), esc_url( $help_link ) );
1040 printf(
1041 wp_kses(
1042 // Translators: %s will be replaced with the correct URL to the wordpress.org support forum.
1043 __( 'You should also check out the <a href="%s" target="_blank">Support Forum</a>. ', 'shariff' ),
1044 array(
1045 'a' => array(
1046 'href' => true,
1047 'target' => true,
1048 ),
1049 )
1050 ),
1051 'https://wordpress.org/support/plugin/shariff/'
1052 );
1053 }
1054
1055 /**
1056 * Info URL.
1057 */
1058 function shariff3uu_text_info_url_render() {
1059 if ( isset( $GLOBALS['shariff3uu_advanced']['info_url'] ) ) {
1060 $info_url = $GLOBALS['shariff3uu_advanced']['info_url'];
1061 } else {
1062 $info_url = '';
1063 }
1064 echo '<input type="text" name="shariff3uu_advanced[info_url]" value="' . esc_html( $info_url ) . '" size="50" placeholder="https://ct.de/-2467514">';
1065 }
1066
1067 /**
1068 * Info Text.
1069 */
1070 function shariff3uu_text_info_text_render() {
1071 if ( isset( $GLOBALS['shariff3uu_advanced']['info_text'] ) ) {
1072 $info_text = $GLOBALS['shariff3uu_advanced']['info_text'];
1073 } else {
1074 $info_text = '';
1075 }
1076 echo '<input type="text" name="shariff3uu_advanced[info_text]" value="' . esc_html( $info_text ) . '" size="50" placeholder="' . esc_html__( 'More information about these buttons.', 'shariff' ) . '">';
1077 }
1078
1079 /**
1080 * Twitter via attribute.
1081 */
1082 function shariff3uu_text_twittervia_render() {
1083 if ( isset( $GLOBALS['shariff3uu_advanced']['twitter_via'] ) ) {
1084 $twitter_via = $GLOBALS['shariff3uu_advanced']['twitter_via'];
1085 } else {
1086 $twitter_via = '';
1087 }
1088 echo '<input type="text" name="shariff3uu_advanced[twitter_via]" value="' . esc_html( $twitter_via ) . '" size="50" placeholder="' . esc_html__( 'username', 'shariff' ) . '">';
1089 }
1090
1091 /**
1092 * Bluesky via attribute.
1093 */
1094 function shariff3uu_text_blueskyvia_render() {
1095 if ( isset( $GLOBALS['shariff3uu_advanced']['bluesky_via'] ) ) {
1096 $bluesky_via = $GLOBALS['shariff3uu_advanced']['bluesky_via'];
1097 } else {
1098 $bluesky_via = '';
1099 }
1100 echo '<input type="text" name="shariff3uu_advanced[bluesky_via]" value="' . esc_html( $bluesky_via ) . '" size="50" placeholder="' . esc_html__( 'username', 'shariff' ) . '">';
1101 }
1102
1103 /**
1104 * Mastodon via attribute.
1105 */
1106 function shariff3uu_text_mastodonvia_render() {
1107 if ( isset( $GLOBALS['shariff3uu_advanced']['mastodon_via'] ) ) {
1108 $mastodon_via = $GLOBALS['shariff3uu_advanced']['mastodon_via'];
1109 } else {
1110 $mastodon_via = '';
1111 }
1112 echo '<input type="text" name="shariff3uu_advanced[mastodon_via]" value="' . esc_html( $mastodon_via ) . '" size="50" placeholder="' . esc_html__( 'username', 'shariff' ) . '">';
1113 }
1114
1115 /**
1116 * Patreon username.
1117 */
1118 function shariff3uu_text_patreonid_render() {
1119 if ( isset( $GLOBALS['shariff3uu_advanced']['patreonid'] ) ) {
1120 $patreonid = $GLOBALS['shariff3uu_advanced']['patreonid'];
1121 } else {
1122 $patreonid = '';
1123 }
1124 echo '<input type="text" name="shariff3uu_advanced[patreonid]" value="' . esc_html( $patreonid ) . '" size="50" placeholder="' . esc_html__( 'username', 'shariff' ) . '">';
1125 }
1126
1127 /**
1128 * PayPal Button ID.
1129 */
1130 function shariff3uu_text_paypalbuttonid_render() {
1131 if ( isset( $GLOBALS['shariff3uu_advanced']['paypalbuttonid'] ) ) {
1132 $paypalbuttonid = $GLOBALS['shariff3uu_advanced']['paypalbuttonid'];
1133 } else {
1134 $paypalbuttonid = '';
1135 }
1136 echo '<input type="text" name="shariff3uu_advanced[paypalbuttonid]" value="' . esc_html( $paypalbuttonid ) . '" size="50" placeholder="1ABCDEF23GH4I">';
1137 }
1138
1139 /**
1140 * PayPal.Me ID.
1141 */
1142 function shariff3uu_text_paypalmeid_render() {
1143 if ( isset( $GLOBALS['shariff3uu_advanced']['paypalmeid'] ) ) {
1144 $paypalmeid = $GLOBALS['shariff3uu_advanced']['paypalmeid'];
1145 } else {
1146 $paypalmeid = '';
1147 }
1148 echo '<input type="text" name="shariff3uu_advanced[paypalmeid]" value="' . esc_html( $paypalmeid ) . '" size="50" placeholder="' . esc_html__( 'name', 'shariff' ) . '">';
1149 }
1150
1151 /**
1152 * Bitcoin address.
1153 */
1154 function shariff3uu_text_bitcoinaddress_render() {
1155 if ( isset( $GLOBALS['shariff3uu_advanced']['bitcoinaddress'] ) ) {
1156 $bitcoinaddress = $GLOBALS['shariff3uu_advanced']['bitcoinaddress'];
1157 } else {
1158 $bitcoinaddress = '';
1159 }
1160 echo '<input type="text" name="shariff3uu_advanced[bitcoinaddress]" value="' . esc_html( $bitcoinaddress ) . '" size="50" placeholder="1Ab2CdEfGhijKL34mnoPQRSTu5VwXYzaBcD">';
1161 }
1162
1163 /**
1164 * RSS feed.
1165 */
1166 function shariff3uu_text_rssfeed_render() {
1167 if ( isset( $GLOBALS['shariff3uu_advanced']['rssfeed'] ) ) {
1168 $rssfeed = $GLOBALS['shariff3uu_advanced']['rssfeed'];
1169 } else {
1170 $rssfeed = '';
1171 }
1172 $rssdefault = get_bloginfo( 'rss_url' );
1173 echo '<input type="text" name="shariff3uu_advanced[rssfeed]" value="' . esc_url( $rssfeed ) . '" size="50" placeholder="' . esc_url( $rssdefault ) . '">';
1174 }
1175
1176 /**
1177 * Pinterest Default Image.
1178 */
1179 function shariff3uu_text_default_pinterest_render() {
1180 $options = $GLOBALS['shariff3uu_advanced'];
1181 if ( ! isset( $options['default_pinterest'] ) ) {
1182 $options['default_pinterest'] = '';
1183 }
1184 echo '<div><input type="text" name="shariff3uu_advanced[default_pinterest]" value="' . esc_url( $options['default_pinterest'] ) . '" id="shariff-image-url" class="regular-text"><input type="button" name="upload-btn" id="shariff-upload-btn" class="button-secondary" value="' . esc_html__( 'Choose image', 'shariff' ) . '"></div>';
1185 }
1186
1187 /**
1188 * Hide WhatsApp on Desktop.
1189 */
1190 function shariff3uu_checkbox_hide_whatsapp_render() {
1191 echo '<input type="checkbox" name="shariff3uu_advanced[hide_whatsapp]" ';
1192 if ( isset( $GLOBALS['shariff3uu_advanced']['hide_whatsapp'] ) ) {
1193 echo checked( $GLOBALS['shariff3uu_advanced']['hide_whatsapp'], 1, 0 );
1194 }
1195 echo ' value="1">';
1196 }
1197
1198 /**
1199 * Shortcode Priority.
1200 */
1201 function shariff3uu_number_shortcodeprio_render() {
1202 if ( isset( $GLOBALS['shariff3uu_advanced']['shortcodeprio'] ) ) {
1203 $prio = $GLOBALS['shariff3uu_advanced']['shortcodeprio'];
1204 } else {
1205 $prio = '';
1206 }
1207 echo '<input type="number" name="shariff3uu_advanced[shortcodeprio]" value="' . esc_html( $prio ) . '" maxlength="2" min="0" max="20" placeholder="10" style="width: 75px">';
1208 echo '<p>' . esc_html__( 'Warning: DO NOT change this unless you know what you are doing or have been told so by the plugin author!', 'shariff' ) . '</p>';
1209 }
1210
1211 /**
1212 * Disable metabox.
1213 */
1214 function shariff3uu_checkbox_disable_metabox_render() {
1215 echo '<input type="checkbox" name="shariff3uu_advanced[disable_metabox]" ';
1216 if ( isset( $GLOBALS['shariff3uu_advanced']['disable_metabox'] ) ) {
1217 echo checked( $GLOBALS['shariff3uu_advanced']['disable_metabox'], 1, 0 );
1218 }
1219 echo ' value="1">';
1220 }
1221
1222 /** Statistic section */
1223
1224 /**
1225 * Description statistic options.
1226 */
1227 function shariff3uu_statistic_section_callback() {
1228 echo esc_html__( 'This determines how share counts are handled by Shariff.', 'shariff' );
1229 echo '<br>';
1230 if ( isset( $GLOBALS['shariff3uu_statistic']['external_direct'] ) ) {
1231 echo '<br><span style="color:red;font-weight:bold;">';
1232 echo esc_html__( 'Warning: ', 'shariff' );
1233 echo '</span>';
1234 echo esc_html__( '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' );
1235 }
1236 // Hook to add or remove cron job.
1237 do_action( 'shariff3uu_save_statistic_options' );
1238 }
1239
1240 /**
1241 * Enable Statistic.
1242 */
1243 function shariff3uu_checkbox_backend_render() {
1244 // Check WP version.
1245 if ( version_compare( get_bloginfo( 'version' ), '4.4.0' ) < 1 ) {
1246 echo esc_html__( 'WordPress-Version 4.4 or better is required to enable the statistic / share count functionality.', 'shariff' );
1247 } else {
1248 echo '<input type="checkbox" name="shariff3uu_statistic[backend]" ';
1249 if ( isset( $GLOBALS['shariff3uu_statistic']['backend'] ) ) {
1250 echo checked( $GLOBALS['shariff3uu_statistic']['backend'], 1, 0 );
1251 }
1252 echo ' value="1">';
1253 }
1254 }
1255
1256 /**
1257 * Share Counts On Buttons.
1258 */
1259 function shariff3uu_checkbox_sharecounts_render() {
1260 echo '<input type="checkbox" name="shariff3uu_statistic[sharecounts]" ';
1261 if ( isset( $GLOBALS['shariff3uu_statistic']['sharecounts'] ) ) {
1262 echo checked( $GLOBALS['shariff3uu_statistic']['sharecounts'], 1, 0 );
1263 }
1264 echo ' value="1">';
1265 if ( ! isset( $GLOBALS['shariff3uu_statistic']['backend'] ) && isset( $GLOBALS['shariff3uu_statistic']['sharecounts'] ) ) {
1266 echo ' ';
1267 echo esc_html__( 'Warning: The statistic functionality must be enabled in order for the share counts to be shown.', 'shariff' );
1268 }
1269 }
1270
1271 /**
1272 * Hide when zero.
1273 */
1274 function shariff3uu_checkbox_hidezero_render() {
1275 echo '<input type="checkbox" name="shariff3uu_statistic[hidezero]" ';
1276 if ( isset( $GLOBALS['shariff3uu_statistic']['hidezero'] ) ) {
1277 echo checked( $GLOBALS['shariff3uu_statistic']['hidezero'], 1, 0 );
1278 }
1279 echo ' value="1">';
1280 }
1281
1282 /**
1283 * Ranking.
1284 */
1285 function shariff3uu_number_ranking_render() {
1286 if ( isset( $GLOBALS['shariff3uu_statistic']['ranking'] ) ) {
1287 $numberposts = $GLOBALS['shariff3uu_statistic']['ranking'];
1288 } else {
1289 $numberposts = '';
1290 }
1291 echo '<input type="number" name="shariff3uu_statistic[ranking]" value="' . esc_html( $numberposts ) . '" maxlength="4" min="0" max="10000" placeholder="100" style="width: 75px">';
1292 }
1293
1294 /**
1295 * Automatic cache.
1296 */
1297 function shariff3uu_checkbox_automaticcache_render() {
1298 echo '<input type="checkbox" name="shariff3uu_statistic[automaticcache]" ';
1299 if ( isset( $GLOBALS['shariff3uu_statistic']['automaticcache'] ) ) {
1300 echo checked( $GLOBALS['shariff3uu_statistic']['automaticcache'], 1, 0 );
1301 }
1302 echo ' value="1">';
1303 }
1304
1305 /**
1306 * Facebook App ID.
1307 */
1308 function shariff3uu_text_fb_id_render() {
1309 if ( isset( $GLOBALS['shariff3uu_statistic']['fb_id'] ) ) {
1310 $fb_id = $GLOBALS['shariff3uu_statistic']['fb_id'];
1311 } else {
1312 $fb_id = '';
1313 }
1314 echo '<input type="text" name="shariff3uu_statistic[fb_id]" value="' . esc_html( $fb_id ) . '" size="50" placeholder="1234567891234567">';
1315 }
1316
1317 /**
1318 * Facebook App Secret.
1319 */
1320 function shariff3uu_text_fb_secret_render() {
1321 if ( isset( $GLOBALS['shariff3uu_statistic']['fb_secret'] ) ) {
1322 $fb_secret = $GLOBALS['shariff3uu_statistic']['fb_secret'];
1323 } else {
1324 $fb_secret = '';
1325 }
1326 echo '<input type="text" name="shariff3uu_statistic[fb_secret]" value="' . esc_html( $fb_secret ) . '" size="50" placeholder="123abc456def789123456789ghi12345">';
1327 }
1328
1329 /**
1330 * TTL.
1331 */
1332 function shariff3uu_number_ttl_render() {
1333 if ( isset( $GLOBALS['shariff3uu_statistic']['ttl'] ) ) {
1334 $ttl = $GLOBALS['shariff3uu_statistic']['ttl'];
1335 } else {
1336 $ttl = '';
1337 }
1338 echo '<input type="number" name="shariff3uu_statistic[ttl]" value="' . esc_html( $ttl ) . '" maxlength="4" min="60" max="7200" placeholder="60" style="width: 75px">';
1339 }
1340
1341 /**
1342 * Disable dynamic cache lifespan.
1343 */
1344 function shariff3uu_checkbox_disable_dynamic_cache_render() {
1345 echo '<input type="checkbox" name="shariff3uu_statistic[disable_dynamic_cache]" ';
1346 if ( isset( $GLOBALS['shariff3uu_statistic']['disable_dynamic_cache'] ) ) {
1347 echo checked( $GLOBALS['shariff3uu_statistic']['disable_dynamic_cache'], 1, 0 );
1348 }
1349 echo ' value="1">';
1350 }
1351
1352 /**
1353 * Disable services.
1354 */
1355 function shariff3uu_multiplecheckbox_disable_services_render() {
1356 // Loop through all services with a backend.
1357 foreach ( $GLOBALS['shariff3uu_services_backend'] as $service ) {
1358 // Capitalize service name.
1359 $service_name = ucfirst( $service );
1360 // Add option.
1361 echo '<p><input type="checkbox" name="shariff3uu_statistic[disable][' . esc_html( $service ) . ']" ';
1362 if ( isset( $GLOBALS['shariff3uu_statistic']['disable'][ $service ] ) ) {
1363 echo checked( $GLOBALS['shariff3uu_statistic']['disable'][ $service ], 1, 0 );
1364 }
1365 echo ' value="1">' . esc_html( $service_name ) . '</p>';
1366 }
1367 }
1368
1369 /**
1370 * External host.
1371 */
1372 function shariff3uu_text_external_host_render() {
1373 if ( isset( $GLOBALS['shariff3uu_statistic']['external_host'] ) ) {
1374 $external_host = $GLOBALS['shariff3uu_statistic']['external_host'];
1375 } else {
1376 $external_host = '';
1377 }
1378 echo '<input type="text" name="shariff3uu_statistic[external_host]" value="' . esc_html( $external_host ) . '" size="50" placeholder="' . esc_url( get_bloginfo( 'url' ) ) . '/wp-json/shariff/v1/share_counts">';
1379 echo '<p>' . wp_kses(
1380 __( 'Warning: This is an experimental feature. Please read the <a href="https://wordpress.org/plugins/shariff/faq/" target="_blank">Frequently Asked Questions (FAQ)</a>.', 'shariff' ),
1381 array(
1382 'a' => array(
1383 'href' => true,
1384 'target' => true,
1385 ),
1386 )
1387 ) . '</p>';
1388 echo '<p>' . esc_html__( 'Please check, if you have to add this domain to the array $SHARIFF_FRONTENDS on the external server.', 'shariff' ) . '</p>';
1389 }
1390
1391 /**
1392 * Direct external api call from JS.
1393 */
1394 function shariff3uu_checkbox_external_direct_render() {
1395 echo '<input type="checkbox" name="shariff3uu_statistic[external_direct]" ';
1396 if ( isset( $GLOBALS['shariff3uu_statistic']['external_direct'] ) ) {
1397 echo checked( $GLOBALS['shariff3uu_statistic']['external_direct'], 1, 0 );
1398 }
1399 echo ' value="1">';
1400 echo '<p>' . esc_html__( 'Please check, if you have correctly set the Access-Control-Allow-Origin header!', 'shariff' ) . '</p>';
1401 }
1402
1403 /**
1404 * Local API only reachable in subfolder.
1405 */
1406 function shariff3uu_checkbox_subapi_render() {
1407 echo '<input type="checkbox" name="shariff3uu_statistic[subapi]" ';
1408 if ( isset( $GLOBALS['shariff3uu_statistic']['subapi'] ) ) {
1409 echo checked( $GLOBALS['shariff3uu_statistic']['subapi'], 1, 0 );
1410 }
1411 echo ' value="1">';
1412 }
1413
1414 /**
1415 * Help section.
1416 */
1417 function shariff3uu_help_section_callback() {
1418 echo '<p>';
1419 printf(
1420 wp_kses(
1421 __( 'The WordPress plugin "Shariff Wrapper" has been developed by Jan-Peter Lambeck and <a href="%2$s" target="_blank">3UU</a> in order to help protect the privacy of your visitors. ', 'shariff' ),
1422 array(
1423 'a' => array(
1424 'href' => true,
1425 'target' => true,
1426 ),
1427 )
1428 ),
1429 'https://www.jplambeck.de',
1430 'https://datenverwurstungszentrale.com'
1431 );
1432 echo ' ';
1433 printf(
1434 wp_kses(
1435 // Translators: %s will be replaced with the correct URL to the German computer magazine.
1436 __( 'It is based on the original Shariff buttons developed by the German computer magazine <a href="%s" target="_blank">c\'t</a> that are compliant to the General Data Protection Regulation (GDPR) (Regulation (EU) 2016/679).', 'shariff' ),
1437 array(
1438 'a' => array(
1439 'href' => true,
1440 'target' => true,
1441 ),
1442 )
1443 ),
1444 'https://ct.de/-2467514'
1445 );
1446 echo ' ';
1447 printf(
1448 wp_kses(
1449 // Translators: %1$s and %2$s will be replaced with the correct URLs to FAQ and the forum on wordpress.org.
1450 __( 'If you need any help with the plugin, take a look at the <a href="%1$s" target="_blank">Frequently Asked Questions (FAQ)</a> and the <a href="%2$s" target="_blank">Support Forum</a> on wordpress.org. ', 'shariff' ),
1451 array(
1452 'a' => array(
1453 'href' => true,
1454 'target' => true,
1455 ),
1456 )
1457 ),
1458 'https://wordpress.org/plugins/shariff/#faq',
1459 'https://wordpress.org/support/plugin/shariff'
1460 );
1461 echo '</p>';
1462 echo '<p>';
1463 // Translators: %s will be replaced with the correct URL to the wordpress.org review page.
1464 printf(
1465 wp_kses(
1466 // Translators: %s will be replaced with the correct URL to the wordpress.org review page.
1467 __( 'If you enjoy our plugin, please consider writing a review about it on <a href="%s" target="_blank">wordpress.org</a>.', 'shariff' ),
1468 array(
1469 'a' => array(
1470 'href' => true,
1471 'target' => true,
1472 ),
1473 )
1474 ),
1475 'https://wordpress.org/support/view/plugin-reviews/shariff'
1476 );
1477 echo '</p>';
1478 echo '<p>';
1479 echo wp_kses( __( 'This is a list of all available options for the <code>[shariff]</code> shortcode:', 'shariff' ), array( 'code' => array() ) );
1480 echo '</p>';
1481 // Shortcode table.
1482 echo '<div style="display:table;background-color:#fff">';
1483 // Head.
1484 echo '<div style="display:table-row">';
1485 echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Name', 'shariff' ) . '</div>';
1486 echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Options', 'shariff' ) . '</div>';
1487 echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Default', 'shariff' ) . '</div>';
1488 echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Example', 'shariff' ) . '</div>';
1489 echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Description', 'shariff' ) . '</div>';
1490 echo '</div>';
1491 // Services.
1492 echo '<div style="display:table-row">';
1493 echo '<div style="display:table-cell;border:1px solid;padding:10px">services</div>';
1494 echo '<div style="display:table-cell;border:1px solid;padding:10px">bitcoin<br>blueksy<br>buffer<br>diaspora<br>facebook<br>flipboard<br>info<br>linkedin<br>mailto<br>mastodon<br>mewe<br>mix<br>odnoklassniki<br>patreon<br>paypal<br>paypalme<br>pinterest<br>pocket<br>printer<br>reddit<br>rss<br>sms<br>telegram<br>threema<br>tumblr<br>twitter<br>vk<br>wallabag<br>weibo<br>whatsapp<br>xing</div>';
1495 echo '<div style="display:table-cell;border:1px solid;padding:10px">mastodon|facebook|linkedin|info</div>';
1496 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff services="facebook|mastodon|mailto"]</div>';
1497 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Determines which buttons to show and in which order.', 'shariff' ) . '</div>';
1498 echo '</div>';
1499 // Backend.
1500 echo '<div style="display:table-row">';
1501 echo '<div style="display:table-cell;border:1px solid;padding:10px">backend</div>';
1502 echo '<div style="display:table-cell;border:1px solid;padding:10px">on<br>off</div>';
1503 echo '<div style="display:table-cell;border:1px solid;padding:10px">off</div>';
1504 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff backend="on"]</div>';
1505 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Enables share counts on the buttons.', 'shariff' ) . '</div>';
1506 echo '</div>';
1507 // Theme.
1508 echo '<div style="display:table-row">';
1509 echo '<div style="display:table-cell;border:1px solid;padding:10px">theme</div>';
1510 echo '<div style="display:table-cell;border:1px solid;padding:10px">default<br>color<br>grey<br>white<br>round<br>wcag</div>';
1511 echo '<div style="display:table-cell;border:1px solid;padding:10px">default</div>';
1512 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff theme="round"]</div>';
1513 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Determines the main design of the buttons.', 'shariff' ) . '</div>';
1514 echo '</div>';
1515 // Buttonsize.
1516 echo '<div style="display:table-row">';
1517 echo '<div style="display:table-cell;border:1px solid;padding:10px">buttonsize</div>';
1518 echo '<div style="display:table-cell;border:1px solid;padding:10px">small<br>medium<br>large</div>';
1519 echo '<div style="display:table-cell;border:1px solid;padding:10px">medium</div>';
1520 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff buttonsize="small"]</div>';
1521 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Determines the button size regardless of theme choice.', 'shariff' ) . '</div>';
1522 echo '</div>';
1523 // Buttonstretch.
1524 echo '<div style="display:table-row">';
1525 echo '<div style="display:table-cell;border:1px solid;padding:10px">buttonstretch</div>';
1526 echo '<div style="display:table-cell;border:1px solid;padding:10px">0<br>1</div>';
1527 echo '<div style="display:table-cell;border:1px solid;padding:10px">0</div>';
1528 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff buttonstretch="1"]</div>';
1529 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Stretch buttons horizontally to full width.', 'shariff' ) . '</div>';
1530 echo '</div>';
1531 // Borderradius.
1532 echo '<div style="display:table-row">';
1533 echo '<div style="display:table-cell;border:1px solid;padding:10px">borderradius</div>';
1534 echo '<div style="display:table-cell;border:1px solid;padding:10px">1-50</div>';
1535 echo '<div style="display:table-cell;border:1px solid;padding:10px">50</div>';
1536 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff borderradius="1"]</div>';
1537 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets the border radius for the round theme. 1 essentially equals a square.', 'shariff' ) . '</div>';
1538 echo '</div>';
1539 // Maincolor.
1540 echo '<div style="display:table-row">';
1541 echo '<div style="display:table-cell;border:1px solid;padding:10px">maincolor</div>';
1542 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1543 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1544 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff maincolor="#000"]</div>';
1545 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets a custom main color for all buttons (hexadecimal).', 'shariff' ) . '</div>';
1546 echo '</div>';
1547 // Secondarycolor.
1548 echo '<div style="display:table-row">';
1549 echo '<div style="display:table-cell;border:1px solid;padding:10px">secondarycolor</div>';
1550 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1551 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1552 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff secondarycolor="#afafaf"]</div>';
1553 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets a custom secondary color for all buttons (hexadecimal). The secondary color is, depending on theme, used for hover effects.', 'shariff' ) . '</div>';
1554 echo '</div>';
1555 // Orientation.
1556 echo '<div style="display:table-row">';
1557 echo '<div style="display:table-cell;border:1px solid;padding:10px">orientation</div>';
1558 echo '<div style="display:table-cell;border:1px solid;padding:10px">horizontal<br>vertical</div>';
1559 echo '<div style="display:table-cell;border:1px solid;padding:10px">horizontal</div>';
1560 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff orientation="vertical"]</div>';
1561 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Changes the orientation of the buttons.', 'shariff' ) . '</div>';
1562 echo '</div>';
1563 // Alignment.
1564 echo '<div style="display:table-row">';
1565 echo '<div style="display:table-cell;border:1px solid;padding:10px">align</div>';
1566 echo '<div style="display:table-cell;border:1px solid;padding:10px">flex-start<br>center<br>flex-end</div>';
1567 echo '<div style="display:table-cell;border:1px solid;padding:10px">flex-start</div>';
1568 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff align="center"]</div>';
1569 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Changes the horizontal alignment of the buttons. flex-start means left, center is obvious and flex-end means right.', 'shariff' ) . '</div>';
1570 echo '</div>';
1571 // Language.
1572 echo '<div style="display:table-row">';
1573 echo '<div style="display:table-cell;border:1px solid;padding:10px">language</div>';
1574 echo '<div style="display:table-cell;border:1px solid;padding:10px">bg, cs, da, de, en, es, fi, fr, hr, hu, it, ja, ko, nl, no, pl, pt, ro, ru, sk, sl, sr, sv, tr, zh</div>';
1575 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Automatically selected by browser.', 'shariff' ) . '</div>';
1576 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff lang="de"]</div>';
1577 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Changes the language of the share buttons.', 'shariff' ) . '</div>';
1578 echo '</div>';
1579 // Headline.
1580 echo '<div style="display:table-row">';
1581 echo '<div style="display:table-cell;border:1px solid;padding:10px">headline</div>';
1582 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1583 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1584 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff headline="&lt;hr style=\'margin:20px 0\'&gt;&lt;p&gt;' . esc_html__( 'Please share this post', 'shariff' ) . '&lt;/p&gt;"]</div>';
1585 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Adds a headline above the Shariff buttons. Basic HTML as well as style and class attributes can be used. To remove a headline set on the plugins options page use headline="".', 'shariff' ) . '</div>';
1586 echo '</div>';
1587 // Style.
1588 echo '<div style="display:table-row">';
1589 echo '<div style="display:table-cell;border:1px solid;padding:10px">style</div>';
1590 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1591 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1592 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff style="margin:20px;"]</div>';
1593 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Adds custom style attributes to the container around Shariff.', 'shariff' ) . '</div>';
1594 echo '</div>';
1595 // CSS class.
1596 echo '<div style="display:table-row">';
1597 echo '<div style="display:table-cell;border:1px solid;padding:10px">cssclass</div>';
1598 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1599 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1600 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff class="classname"]</div>';
1601 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Adds a custom class to the container around Shariff.', 'shariff' ) . '</div>';
1602 echo '</div>';
1603 // Twitter_via.
1604 echo '<div style="display:table-row">';
1605 echo '<div style="display:table-cell;border:1px solid;padding:10px">twitter_via</div>';
1606 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1607 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1608 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff twitter_via="your_twittername"]</div>';
1609 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets the Twitter via tag.', 'shariff' ) . '</div>';
1610 echo '</div>';
1611 echo '<div style="display:table-row">';
1612 echo '<div style="display:table-cell;border:1px solid;padding:10px">bluesky_via</div>';
1613 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1614 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1615 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff bluesky_via="your_blueskyhandle"]</div>';
1616 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets the Bluesky via tag.', 'shariff' ) . '</div>';
1617 echo '</div>';
1618 // Mastodon_via.
1619 echo '<div style="display:table-row">';
1620 echo '<div style="display:table-cell;border:1px solid;padding:10px">mastodon_via</div>';
1621 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1622 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1623 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff mastodon_via="your_mastodonname"]</div>';
1624 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets the Mastodon via tag.', 'shariff' ) . '</div>';
1625 echo '</div>';
1626 // Patreonid.
1627 echo '<div style="display:table-row">';
1628 echo '<div style="display:table-cell;border:1px solid;padding:10px">patreonid</div>';
1629 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1630 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1631 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff patreonid="your_username"]</div>';
1632 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets the Patreon username.', 'shariff' ) . '</div>';
1633 echo '</div>';
1634 // Paypalbuttonid.
1635 echo '<div style="display:table-row">';
1636 echo '<div style="display:table-cell;border:1px solid;padding:10px">paypalbuttonid</div>';
1637 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1638 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1639 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff paypalbuttonid="hosted_button_id"]</div>';
1640 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets the PayPal hosted button ID.', 'shariff' ) . '</div>';
1641 echo '</div>';
1642 // Paypalmeid.
1643 echo '<div style="display:table-row">';
1644 echo '<div style="display:table-cell;border:1px solid;padding:10px">paypalmeid</div>';
1645 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1646 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1647 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff paypalmeid="name"]</div>';
1648 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets the PayPal.Me ID. Default amount can be added with a / e.g. name/25.', 'shariff' ) . '</div>';
1649 echo '</div>';
1650 // Bitcoinaddress.
1651 echo '<div style="display:table-row">';
1652 echo '<div style="display:table-cell;border:1px solid;padding:10px">bitcoinaddress</div>';
1653 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1654 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1655 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff bitcoinaddress="bitcoin_address"]</div>';
1656 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets the bitcoin address.', 'shariff' ) . '</div>';
1657 echo '</div>';
1658 // Media.
1659 echo '<div style="display:table-row">';
1660 echo '<div style="display:table-cell;border:1px solid;padding:10px">media</div>';
1661 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1662 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'The post featured image or the first image of the post.', 'shariff' ) . '</div>';
1663 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff media="http://www.mydomain.com/image.jpg"]</div>';
1664 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Determines the default image to share for Pinterest, if no other usable image is found.', 'shariff' ) . '</div>';
1665 echo '</div>';
1666 // Info_URL.
1667 echo '<div style="display:table-row">';
1668 echo '<div style="display:table-cell;border:1px solid;padding:10px">info_url</div>';
1669 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1670 echo '<div style="display:table-cell;border:1px solid;padding:10px">http://ct.de/-2467514</div>';
1671 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff info_url="http://www.mydomain.com/shariff-buttons"]</div>';
1672 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets a custom link for the info button.', 'shariff' ) . '</div>';
1673 echo '</div>';
1674 // Info_Text.
1675 echo '<div style="display:table-row">';
1676 echo '<div style="display:table-cell;border:1px solid;padding:10px">info_text</div>';
1677 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1678 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'More information about these buttons.', 'shariff' ) . '</div>';
1679 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff info_text="' . esc_html__( 'My custom text.', 'shariff' ) . '"]</div>';
1680 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Sets a custom text for the info button.', 'shariff' ) . '</div>';
1681 echo '</div>';
1682 // URL.
1683 echo '<div style="display:table-row">';
1684 echo '<div style="display:table-cell;border:1px solid;padding:10px">url</div>';
1685 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1686 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'The url of the current post or page.', 'shariff' ) . '</div>';
1687 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff url="http://www.mydomain.com/somepost"]</div>';
1688 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Changes the url to share. Only for special use cases.', 'shariff' ) . '</div>';
1689 echo '</div>';
1690 // Title.
1691 echo '<div style="display:table-row">';
1692 echo '<div style="display:table-cell;border:1px solid;padding:10px">title</div>';
1693 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1694 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'The title of the current post or page.', 'shariff' ) . '</div>';
1695 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff title="' . esc_html__( 'My Post Title', 'shariff' ) . '"]</div>';
1696 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Changes the title to share. Only for special use cases.', 'shariff' ) . '</div>';
1697 echo '</div>';
1698 // Timestamp.
1699 echo '<div style="display:table-row">';
1700 echo '<div style="display:table-cell;border:1px solid;padding:10px">timestamp</div>';
1701 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1702 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'The timestamp of the last modification of the current post or page.', 'shariff' ) . '</div>';
1703 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff timestamp="1473240010"]</div>';
1704 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Provides the time the current post or page was last modified as a timestamp. Used for determining the dynamic cache lifespan. Only for special use cases.', 'shariff' ) . '</div>';
1705 echo '</div>';
1706 // RSS feed.
1707 echo '<div style="display:table-row">';
1708 echo '<div style="display:table-cell;border:1px solid;padding:10px">rssfeed</div>';
1709 echo '<div style="display:table-cell;border:1px solid;padding:10px"></div>';
1710 echo '<div style="display:table-cell;border:1px solid;padding:10px">http://www.mydomain.com/feed/rss/</div>';
1711 echo '<div style="display:table-cell;border:1px solid;padding:10px">[shariff rssfeed="http://www.mydomain.com/feed/rss2/"]</div>';
1712 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html__( 'Changes the RSS feed url to another feed.', 'shariff' ) . '</div>';
1713 echo '</div>';
1714
1715 echo '</div>';
1716 }
1717
1718 /**
1719 * Status section.
1720 */
1721 function shariff3uu_status_section_callback() {
1722 // Get options.
1723 $shariff3uu = $GLOBALS['shariff3uu'];
1724
1725 // Begin status table.
1726 echo '<div style="display:table;border-spacing:10px;margin:-10px 0 0 -10px">';
1727
1728 // Begin statistic row.
1729 echo '<div style="display:table-row">';
1730 echo '<div style="display:table-cell;width:125px">' . esc_html__( 'Statistic:', 'shariff' ) . '</div>';
1731
1732 // Check if statistic is enabled.
1733 if ( ! isset( $shariff3uu['backend'] ) ) {
1734 // Statistic disabled message.
1735 echo '<div style="display:table">';
1736 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold">' . esc_html__( 'Disabled', 'shariff' ) . '</div></div>';
1737 echo '</div>';
1738 // End statistic row, if statistic is disabled.
1739 echo '</div>';
1740 } else {
1741 // Encode shareurl.
1742 $post_url = rawurlencode( esc_url( get_bloginfo( 'url' ) ) );
1743 $post_url_raw = esc_url( get_bloginfo( 'url' ) );
1744
1745 // We only need the backend part.
1746 $backend = 1;
1747
1748 // But we also want error messages.
1749 $record_errors = 1;
1750
1751 // Avoid debug messages.
1752 $service_errors = array();
1753
1754 // Loop through all desired services.
1755 foreach ( $GLOBALS['shariff3uu_services_backend'] as $service ) {
1756 // Include service parameters.
1757 if ( ! isset( $shariff3uu['disable'][ $service ] ) || ( isset( $shariff3uu['disable'][ $service ] ) && 0 === $shariff3uu['disable'][ $service ] ) ) {
1758 include plugin_dir_path( __FILE__ ) . '../services/shariff-' . $service . '.php';
1759 }
1760 }
1761
1762 // General statistic status.
1763 echo '<div style="display:table-cell">';
1764 echo '<div style="display:table">';
1765 if ( empty( $service_errors ) ) {
1766 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:green">' . esc_html__( 'OK', 'shariff' ) . '</div></div>';
1767 echo '<div style="display:table-row"><div style="display:table-cell">' . esc_html__( 'No error messages.', 'shariff' ) . '</div></div>';
1768 } elseif ( array_filter( $service_errors ) ) {
1769 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:red">' . esc_html__( 'Error', 'shariff' ) . '</div></div>';
1770 echo '<div style="display:table-row"><div style="display:table-cell">' . esc_html__( 'One or more services reported an error.', 'shariff' ) . '</div></div>';
1771 } else {
1772 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:orange">' . esc_html__( 'Timeout', 'shariff' ) . '</div></div>';
1773 echo '<div style="display:table-row"><div style="display:table-cell">' . esc_html__( 'One or more services didn\'t respond in less than five seconds.', 'shariff' ) . '</div></div>';
1774 }
1775 echo '<div style="display:table-row"><div style="display:table-cell"></div></div>';
1776 echo '</div>';
1777 echo '</div>';
1778
1779 // End statistic row.
1780 echo '</div>';
1781
1782 // Output all services.
1783 foreach ( $GLOBALS['shariff3uu_services_backend'] as $service ) {
1784 // Begin service row.
1785 echo '<div style="display:table-row">';
1786 echo '<div class="shariff_status-first-cell">' . esc_html( ucfirst( $service ) ) . ':</div>';
1787 echo '<div style="display:table-cell">';
1788 echo '<div class="shariff_status-table">';
1789 if ( isset( $shariff3uu['disable'][ $service ] ) && 1 === $shariff3uu['disable'][ $service ] ) {
1790 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold">' . esc_html__( 'Disabled', 'shariff' ) . '</div></div>';
1791 } elseif ( 'facebook' === $service && ( ! isset( $shariff3uu['fb_id'] ) || ! isset( $shariff3uu['fb_secret'] ) ) ) {
1792 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:#ff0000">' . esc_html__( 'Facebook shut down the possibility to request share counts without an APP ID and Secret. Therefore, you need to create a Facebook APP ID and Secret and enter it in the settings on the Statistic tab. Google will provide you with many tutorials. Simple search for “facebook app id secret” and you will find one in your language.', 'shariff' ) . '</div></div>';
1793 } elseif ( ! array_key_exists( $service, $service_errors ) ) {
1794 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:green">' . esc_html__( 'OK', 'shariff' ) . '</div></div>';
1795 echo '<div style="display:table-row"><div style="display:table-cell">' . esc_html__( 'Share Count:', 'shariff' ) . ' ' . absint( $share_counts[ $service ] ) . '</div></div>';
1796 } elseif ( empty( $service_errors[ $service ] ) ) {
1797 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:orange">' . esc_html__( 'Timeout', 'shariff' ) . '</div></div>';
1798 echo '<div style="display:table-row"><div style="display:table-cell">';
1799 echo esc_html__( 'Service didn\'t respond in less than five seconds.', 'shariff' );
1800 echo '</div></div>';
1801 } else {
1802 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:#ff0000">' . esc_html__( 'Error', 'shariff' ) . '</span></div></div>';
1803 echo '<div style="display:table-row"><div style="display:table-cell">';
1804 echo esc_html( $service_errors[ $service ] );
1805 echo '</div></div>';
1806 }
1807 echo '<div style="display:table-row"><div style="display:table-cell"></div></div>';
1808 echo '</div>';
1809 echo '</div>';
1810 echo '</div>';
1811 }
1812 }// End if.
1813
1814 // GD needed for QR codes of the Bitcoin links.
1815 echo '<div style="display:table-row">';
1816 echo '<div style="display:table-cell">' . esc_html__( 'GD Library:', 'shariff' ) . '</div>';
1817 // Working message.
1818 if ( function_exists( 'gd_info' ) ) {
1819 $gd_info = gd_info();
1820 echo '<div style="display:table-cell">';
1821 echo '<div style="display: table">';
1822 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:green">' . esc_html__( 'OK', 'shariff' ) . '</div></div>';
1823 echo '<div style="display:table-row"><div style="display:table-cell">Version: ' . esc_html( $gd_info['GD Version'] ) . '</div></div>';
1824 echo '</div>';
1825 echo '</div>';
1826 } else {
1827 echo '<div style="display:table-cell">';
1828 echo '<div style="display: table">';
1829 echo '<div style="display:table-row"><div style="display:table-cell;font-weight:bold;color:red">' . esc_html__( 'Error', 'shariff' ) . '</div></div>';
1830 echo '<div style="display:table-row"><div style="display:table-cell">' . esc_html__( 'The GD Library is not installed on this server. This is only needed for the QR codes, if your are using the bitcoin button.', 'shariff' ) . '</div></div>';
1831 echo '</div>';
1832 echo '</div>';
1833 }
1834 echo '</div>';
1835
1836 // End status table.
1837 echo '</div>';
1838 }
1839
1840 /**
1841 * Ranking section.
1842 */
1843 function shariff3uu_ranking_section_callback() {
1844 // Post and service array.
1845 $posts = array();
1846 $services = array();
1847
1848 // Amount of posts - set to 100 if not set.
1849 if ( isset( $GLOBALS['shariff3uu']['ranking'] ) && absint( $GLOBALS['shariff3uu']['ranking'] ) > 0 ) {
1850 $numberposts = absint( $GLOBALS['shariff3uu']['ranking'] );
1851 } else {
1852 $numberposts = 100 ;
1853 }
1854
1855 // Set arguments for wp_get_recent_posts().
1856 $args = array(
1857 'numberposts' => $numberposts,
1858 'orderby' => 'post_date',
1859 'order' => 'DESC',
1860 'post_status' => 'publish',
1861 );
1862
1863 // Catch last 100 posts or whatever number is set for it.
1864 $recent_posts = wp_get_recent_posts( $args );
1865 if ( $recent_posts ) {
1866 foreach ( $recent_posts as $recent ) {
1867 // Get URL.
1868 $url = get_permalink( $recent['ID'] );
1869 $post_url = rawurlencode( $url );
1870 // Set transient name.
1871 $post_hash = 'shariff' . hash( 'md5', $post_url );
1872 // Get share counts from cache.
1873 if ( get_transient( $post_hash ) !== false ) {
1874 $share_counts = get_transient( $post_hash );
1875 $services = array_merge( $services, $share_counts );
1876 if ( isset( $share_counts['total'] ) ) {
1877 $total = $share_counts['total'];
1878 } else {
1879 $total = 0 ;
1880 }
1881 } else {
1882 $share_counts = array();
1883 $total = '';
1884 }
1885 // Add to array.
1886 $posts[ $post_hash ] = array(
1887 'url' => $url,
1888 'title' => $recent['post_title'],
1889 'post_date' => $recent['post_date'],
1890 'share_counts' => $share_counts,
1891 'total_share_counts' => $total,
1892 );
1893 }
1894 }
1895
1896 // Clean up services.
1897 unset( $services['total'] );
1898 unset( $services['timestamp'] );
1899 unset( $services['url'] );
1900 ksort( $services );
1901
1902 // Sort array: first descending using total share counts then descending using post date.
1903 $tmp = array();
1904 $tmp2 = array();
1905 foreach ( $posts as &$ma ) {
1906 $tmp[] = &$ma['total_share_counts'];
1907 }
1908 foreach ( $posts as &$ma2 ) {
1909 $tmp2[] = &$ma2['post_date'];
1910 }
1911 array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
1912
1913 // Intro text.
1914 echo '<p>';
1915 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' );
1916 echo '</p>';
1917
1918 // Warning if statistic has been disabled.
1919 if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
1920 echo '<p>';
1921 echo '<span style="color: red; font-weight: bold;">';
1922 echo esc_html__( 'Warning:', 'shariff' );
1923 echo '</span> ';
1924 echo esc_html__( 'The statistic option has been disabled on the statistic tab. Share counts will not get updated!', 'shariff' );
1925 echo '</p>';
1926 }
1927
1928 // Begin ranking table.
1929 echo '<div style="display:table;background-color:#fff">';
1930 // Head.
1931 echo '<div style="display:table-row">';
1932 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Rank', 'shariff' ) . '</div>';
1933 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Post', 'shariff' ) . '</div>';
1934 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Date', 'shariff' ) . '</div>';
1935 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Time', 'shariff' ) . '</div>';
1936 foreach ( $services as $service => $nothing ) {
1937 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center;">' . esc_html( ucfirst( $service ) ) . '</div>';
1938 }
1939 echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Total', 'shariff' ) . '</div>';
1940 echo '</div>';
1941 // Posts.
1942 $rank = 0 ;
1943 foreach ( $posts as $post => $value ) {
1944 $rank++;
1945 echo '<div style="display:table-row">';
1946 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">' . absint( $rank ) . '</div>';
1947 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>';
1948 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html( mysql2date( 'd.m.Y', $value['post_date'] ) ) . '</div>';
1949 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html( mysql2date( 'H:i', $value['post_date'] ) ) . '</div>';
1950 // Share counts.
1951 foreach ( $services as $service => $nothing ) {
1952 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">';
1953 if ( isset( $value['share_counts'][ $service ] ) ) {
1954 echo absint( $value['share_counts'][ $service ] );
1955 }
1956 echo '</div>';
1957 }
1958 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">';
1959 if ( isset( $value['share_counts']['total'] ) ) {
1960 echo absint( $value['share_counts']['total'] );
1961 }
1962 echo '</div>';
1963 echo '</div>';
1964 }
1965 echo '</div>';
1966
1967 // Clear arrays.
1968 $posts = array();
1969 $services = array();
1970
1971 // Set arguments for wp_get_recent_posts().
1972 $args = array(
1973 'numberposts' => $numberposts,
1974 'orderby' => 'post_date',
1975 'order' => 'DESC',
1976 'post_status' => 'publish',
1977 'post_type' => 'page',
1978 );
1979
1980 // Catch last 100 pages or whatever number is set for it.
1981 $recent_posts = wp_get_recent_posts( $args );
1982 if ( $recent_posts ) {
1983 foreach ( $recent_posts as $recent ) {
1984 // Get URL.
1985 $url = get_permalink( $recent['ID'] );
1986 $post_url = rawurlencode( $url );
1987 // Set transient name.
1988 $post_hash = 'shariff' . hash( 'md5', $post_url );
1989 // Get share counts from cache.
1990 if ( get_transient( $post_hash ) !== false ) {
1991 $share_counts = get_transient( $post_hash );
1992 $services = array_merge( $services, $share_counts );
1993 if ( isset( $share_counts['total'] ) ) {
1994 $total = $share_counts['total'];
1995 } else {
1996 $total = 0 ;
1997 }
1998 } else {
1999 $share_counts = array();
2000 $total = '';
2001 }
2002 // Add to array.
2003 $posts[ $post_hash ] = array(
2004 'url' => $url,
2005 'title' => $recent['post_title'],
2006 'post_date' => $recent['post_date'],
2007 'share_counts' => $share_counts,
2008 'total_share_counts' => $total,
2009 );
2010 }
2011 }
2012
2013 // Clean up services.
2014 unset( $services['total'] );
2015 unset( $services['timestamp'] );
2016 unset( $services['url'] );
2017 ksort( $services );
2018
2019 // Sort array: first descending using total share counts then descending using post date.
2020 $tmp = array();
2021 $tmp2 = array();
2022 foreach ( $posts as &$ma ) {
2023 $tmp[] = &$ma['total_share_counts'];
2024 }
2025 foreach ( $posts as &$ma2 ) {
2026 $tmp2[] = &$ma2['post_date'];
2027 }
2028 array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
2029
2030 echo '<p></p>';
2031
2032 // Warning if statistic has been disabled.
2033 if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
2034 echo '<p>';
2035 echo '<span style="color: red; font-weight: bold;">';
2036 echo esc_html__( 'Warning:', 'shariff' );
2037 echo '</span> ';
2038 echo esc_html__( 'The statistic option has been disabled on the statistic tab. Share counts will not get updated!', 'shariff' );
2039 echo '</p>';
2040 }
2041
2042 // Begin ranking table.
2043 echo '<div style="display:table;background-color:#fff">';
2044 // Head.
2045 echo '<div style="display:table-row">';
2046 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Rank', 'shariff' ) . '</div>';
2047 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Page', 'shariff' ) . '</div>';
2048 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Date', 'shariff' ) . '</div>';
2049 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Time', 'shariff' ) . '</div>';
2050 foreach ( $services as $service => $nothing ) {
2051 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center;">' . esc_html( ucfirst( $service ) ) . '</div>';
2052 }
2053 echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Total', 'shariff' ) . '</div>';
2054 echo '</div>';
2055 // Pages.
2056 $rank = 0 ;
2057 foreach ( $posts as $post => $value ) {
2058 $rank++;
2059 echo '<div style="display:table-row">';
2060 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">' . absint( $rank ) . '</div>';
2061 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>';
2062 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html( mysql2date( 'd.m.Y', $value['post_date'] ) ) . '</div>';
2063 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html( mysql2date( 'H:i', $value['post_date'] ) ) . '</div>';
2064 // Share counts.
2065 foreach ( $services as $service => $nothing ) {
2066 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">';
2067 if ( isset( $value['share_counts'][ $service ] ) ) {
2068 echo absint( $value['share_counts'][ $service ] );
2069 }
2070 echo '</div>';
2071 }
2072 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">';
2073 if ( isset( $value['share_counts']['total'] ) ) {
2074 echo absint( $value['share_counts']['total'] );
2075 }
2076 echo '</div>';
2077 echo '</div>';
2078 }
2079 echo '</div>';
2080
2081 // Clear arrays.
2082 $posts = array();
2083 $services = array();
2084
2085 // Set arguments for wp_get_recent_posts().
2086 $args = array(
2087 'numberposts' => $numberposts,
2088 'orderby' => 'post_date',
2089 'order' => 'DESC',
2090 'post_status' => 'publish',
2091 'post_type' => 'product',
2092 );
2093
2094 // Catch last 100 pages or whatever number is set for it.
2095 $recent_posts = wp_get_recent_posts( $args );
2096 if ( $recent_posts ) {
2097 foreach ( $recent_posts as $recent ) {
2098 // Get URL.
2099 $url = get_permalink( $recent['ID'] );
2100 $post_url = rawurlencode( $url );
2101 // Set transient name.
2102 $post_hash = 'shariff' . hash( 'md5', $post_url );
2103 // Get share counts from cache.
2104 if ( get_transient( $post_hash ) !== false ) {
2105 $share_counts = get_transient( $post_hash );
2106 $services = array_merge( $services, $share_counts );
2107 if ( isset( $share_counts['total'] ) ) {
2108 $total = $share_counts['total'];
2109 } else {
2110 $total = 0 ;
2111 }
2112 } else {
2113 $share_counts = array();
2114 $total = '';
2115 }
2116 // Add to array.
2117 $posts[ $post_hash ] = array(
2118 'url' => $url,
2119 'title' => $recent['post_title'],
2120 'post_date' => $recent['post_date'],
2121 'share_counts' => $share_counts,
2122 'total_share_counts' => $total,
2123 );
2124 }
2125 }
2126
2127 // Clean up services.
2128 unset( $services['total'] );
2129 unset( $services['timestamp'] );
2130 unset( $services['url'] );
2131 ksort( $services );
2132
2133 // Sort array: first descending using total share counts then descending using post date.
2134 $tmp = array();
2135 $tmp2 = array();
2136 foreach ( $posts as &$ma ) {
2137 $tmp[] = &$ma['total_share_counts'];
2138 }
2139 foreach ( $posts as &$ma2 ) {
2140 $tmp2[] = &$ma2['post_date'];
2141 }
2142 array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
2143
2144 echo '<p></p>';
2145
2146 // Warning if statistic has been disabled.
2147 if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
2148 echo '<p>';
2149 echo '<span style="color: red; font-weight: bold;">';
2150 echo esc_html__( 'Warning:', 'shariff' );
2151 echo '</span> ';
2152 echo esc_html__( 'The statistic option has been disabled on the statistic tab. Share counts will not get updated!', 'shariff' );
2153 echo '</p>';
2154 }
2155
2156 if ( ! empty( $services ) ) {
2157 // Begin ranking table.
2158 echo '<div style="display:table;background-color:#fff">';
2159 // Head.
2160 echo '<div style="display:table-row">';
2161 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Rank', 'shariff' ) . '</div>';
2162 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px">' . esc_html__( 'Product', 'shariff' ) . '</div>';
2163 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Date', 'shariff' ) . '</div>';
2164 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center">' . esc_html__( 'Time', 'shariff' ) . '</div>';
2165 foreach ( $services as $service => $nothing ) {
2166 echo '<div style="display:table-cell;font-weight:bold;border:1px solid;padding:10px;text-align:center;">' . esc_html( ucfirst( $service ) ) . '</div>';
2167 }
2168 echo '<div style="display:table-cell;border:1px solid;padding:10px;font-weight:bold">' . esc_html__( 'Total', 'shariff' ) . '</div>';
2169 echo '</div>';
2170 // Pages.
2171 $rank = 0 ;
2172 foreach ( $posts as $post => $value ) {
2173 $rank++;
2174 echo '<div style="display:table-row">';
2175 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">' . absint( $rank ) . '</div>';
2176 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>';
2177 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html( mysql2date( 'd.m.Y', $value['post_date'] ) ) . '</div>';
2178 echo '<div style="display:table-cell;border:1px solid;padding:10px">' . esc_html( mysql2date( 'H:i', $value['post_date'] ) ) . '</div>';
2179 // Share counts.
2180 foreach ( $services as $service => $nothing ) {
2181 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">';
2182 if ( isset( $value['share_counts'][ $service ] ) ) {
2183 echo absint( $value['share_counts'][ $service ] );
2184 }
2185 echo '</div>';
2186 }
2187 echo '<div style="display:table-cell;border:1px solid;padding:10px;text-align:center">';
2188 if ( isset( $value['share_counts']['total'] ) ) {
2189 echo absint( $value['share_counts']['total'] );
2190 }
2191 echo '</div>';
2192 echo '</div>';
2193 }
2194 echo '</div>';
2195 }
2196 }
2197
2198 /**
2199 * Renders the plugin option page.
2200 */
2201 function shariff3uu_options_page() {
2202 // The <div> with the class "wrap" makes sure that admin messages are displayed below the title and not above.
2203 echo '<div class="wrap">';
2204
2205 // Title.
2206 echo '<h2>Shariff ' . esc_html( $GLOBALS['shariff3uu_basic']['version'] ) . '</h2>';
2207
2208 // Start the form.
2209 echo '<form class="shariff" action="options.php" method="post">';
2210
2211 // Hidden version entry, so it will get saved upon updating the options.
2212 echo '<input type="hidden" name="shariff3uu_basic[version]" value="' . esc_html( $GLOBALS['shariff3uu_basic']['version'] ) . '">';
2213
2214 // Determine active tab.
2215 // phpcs:ignore
2216 if ( isset( $_GET['tab'] ) ) {
2217 // phpcs:ignore
2218 $allowed_tabs = [ 'shariff3uu_basic', 'shariff3uu_design', 'shariff3uu_advanced', 'shariff3uu_statistic', 'shariff3uu_help', 'shariff3uu_status', 'shariff3uu_ranking' ];
2219 $active_tab = in_array( $_GET['tab'], $allowed_tabs, true ) ? $_GET['tab'] : 'shariff3uu_basic';
2220 }
2221 else{ $active_tab = 'shariff3uu_basic'; }
2222
2223 // Tabs.
2224 echo '<h2 class="nav-tab-wrapper">';
2225 // Basic.
2226 echo '<a href="?page=shariff3uu&tab=shariff3uu_basic" class="nav-tab ';
2227 if ( 'shariff3uu_basic' === $active_tab ) {
2228 echo 'nav-tab-active';
2229 }
2230 echo '">' . esc_html__( 'Basic', 'shariff' ) . '</a>';
2231 // Design.
2232 echo '<a href="?page=shariff3uu&tab=shariff3uu_design" class="nav-tab ';
2233 if ( 'shariff3uu_design' === $active_tab ) {
2234 echo 'nav-tab-active';
2235 }
2236 echo '">' . esc_html__( 'Design', 'shariff' ) . '</a>';
2237 // Advanced.
2238 echo '<a href="?page=shariff3uu&tab=shariff3uu_advanced" class="nav-tab ';
2239 if ( 'shariff3uu_advanced' === $active_tab ) {
2240 echo 'nav-tab-active';
2241 }
2242 echo '">' . esc_html__( 'Advanced', 'shariff' ) . '</a>';
2243 // Statistic.
2244 echo '<a href="?page=shariff3uu&tab=shariff3uu_statistic" class="nav-tab ';
2245 if ( 'shariff3uu_statistic' === $active_tab ) {
2246 echo 'nav-tab-active';
2247 }
2248 echo '">' . esc_html__( 'Statistic', 'shariff' ) . '</a>';
2249 // Help.
2250 echo '<a href="?page=shariff3uu&tab=shariff3uu_help" class="nav-tab ';
2251 if ( 'shariff3uu_help' === $active_tab ) {
2252 echo 'nav-tab-active';
2253 }
2254 echo '">' . esc_html__( 'Help', 'shariff' ) . '</a>';
2255 // Status.
2256 echo '<a href="?page=shariff3uu&tab=shariff3uu_status" class="nav-tab ';
2257 if ( 'shariff3uu_status' === $active_tab ) {
2258 echo 'nav-tab-active';
2259 }
2260 echo '">' . esc_html__( 'Status', 'shariff' ) . '</a>';
2261 // Ranking.
2262 echo '<a href="?page=shariff3uu&tab=shariff3uu_ranking" class="nav-tab ';
2263 if ( 'shariff3uu_ranking' === $active_tab ) {
2264 echo 'nav-tab-active';
2265 }
2266 echo '">' . esc_html__( 'Ranking', 'shariff' ) . '</a>';
2267 echo '</h2>';
2268
2269 // Content of tabs.
2270 if ( 'shariff3uu_basic' === $active_tab ) {
2271 settings_fields( 'shariff3uu_basic' );
2272 do_settings_sections( 'shariff3uu_basic' );
2273 submit_button();
2274 } elseif ( 'shariff3uu_design' === $active_tab ) {
2275 settings_fields( 'shariff3uu_design' );
2276 do_settings_sections( 'shariff3uu_design' );
2277 submit_button();
2278 } elseif ( 'shariff3uu_advanced' === $active_tab ) {
2279 settings_fields( 'shariff3uu_advanced' );
2280 do_settings_sections( 'shariff3uu_advanced' );
2281 submit_button();
2282 } elseif ( 'shariff3uu_statistic' === $active_tab ) {
2283 settings_fields( 'shariff3uu_statistic' );
2284 do_settings_sections( 'shariff3uu_statistic' );
2285 submit_button();
2286 } elseif ( 'shariff3uu_help' === $active_tab ) {
2287 settings_fields( 'shariff3uu_help' );
2288 do_settings_sections( 'shariff3uu_help' );
2289 } elseif ( 'shariff3uu_status' === $active_tab ) {
2290 settings_fields( 'shariff3uu_status' );
2291 do_settings_sections( 'shariff3uu_status' );
2292 } elseif ( 'shariff3uu_ranking' === $active_tab ) {
2293 settings_fields( 'shariff3uu_ranking' );
2294 do_settings_sections( 'shariff3uu_ranking' );
2295 }
2296
2297 // End of form.
2298 echo '</form>';
2299 }
2300