PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | modules/sharedaddy/sharing-service.php +32 -22 13.0.2 → 16.3-a.5 View file →
@@ -12,12 +12,14 @@
12 12
13 13 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
14 14
15 15 use Automattic\Jetpack\Assets;
16 -use Automattic\Jetpack\Redirect;
17 -use Automattic\Jetpack\Status;
18 16 use Automattic\Jetpack\Sync\Settings;
19 17
18 +if ( ! defined( 'ABSPATH' ) ) {
19 + exit( 0 );
20 +}
21 +
20 22 require_once __DIR__ . '/sharing-sources.php';
21 23
22 24 define( 'WP_SHARING_PLUGIN_VERSION', JETPACK__VERSION );
23 25
@@ -102,16 +104,15 @@
102 104 'reddit' => 'Share_Reddit',
103 105 'twitter' => 'Share_Twitter',
104 106 'tumblr' => 'Share_Tumblr',
105 107 'pinterest' => 'Share_Pinterest',
106 - 'pocket' => 'Share_Pocket',
107 108 'telegram' => 'Share_Telegram',
109 + 'threads' => 'Share_Threads',
108 110 'jetpack-whatsapp' => 'Jetpack_Share_WhatsApp',
109 111 'mastodon' => 'Share_Mastodon',
110 112 'nextdoor' => 'Share_Nextdoor',
111 113 'x' => 'Share_X',
112 - // deprecated.
113 - 'skype' => 'Share_Skype',
114 + 'bluesky' => 'Share_Bluesky',
114 115 );
115 116
116 117 if ( is_multisite() && is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
117 118 $services['press-this'] = 'Share_PressThis';
@@ -119,10 +120,12 @@
119 120
120 121 if ( $include_custom ) {
121 122 // Add any custom services in
122 123 $options = $this->get_global_options();
123 - foreach ( (array) $options['custom'] as $custom_id ) {
124 - $services[ $custom_id ] = 'Share_Custom';
124 + if ( isset( $options['custom'] ) ) {
125 + foreach ( $options['custom'] as $custom_id ) {
126 + $services[ $custom_id ] = 'Share_Custom';
127 + }
125 128 }
126 129 }
127 130
128 131 /**
@@ -312,15 +315,15 @@
312 315 $enabled = apply_filters( 'sharing_default_services', $enabled );
313 316 }
314 317
315 318 // Cleanup after any filters that may have produced duplicate services
316 - if ( is_array( $enabled['visible'] ) ) {
319 + if ( isset( $enabled['visible'] ) && is_array( $enabled['visible'] ) ) {
317 320 $enabled['visible'] = array_unique( $enabled['visible'] );
318 321 } else {
319 322 $enabled['visible'] = array();
320 323 }
321 324
322 - if ( is_array( $enabled['hidden'] ) ) {
325 + if ( isset( $enabled['hidden'] ) && is_array( $enabled['hidden'] ) ) {
323 326 $enabled['hidden'] = array_unique( $enabled['hidden'] );
324 327 } else {
325 328 $enabled['hidden'] = array();
326 329 }
@@ -402,9 +405,9 @@
402 405 'button_style' => 'icon-text',
403 406 'sharing_label' => $this->default_sharing_label,
404 407 'open_links' => 'same',
405 408 'show' => ! isset( $options['global'] ) ? array( 'post', 'page' ) : array(),
406 - 'custom' => isset( $options['global']['custom'] ) ? $options['global']['custom'] : array(),
409 + 'custom' => $options['global']['custom'] ?? array(),
407 410 );
408 411
409 412 /**
410 413 * Filters global sharing settings.
@@ -498,9 +501,9 @@
498 501 break;
499 502 }
500 503 }
501 504
502 - if ( false === $this->global['sharing_label'] ) {
505 + if ( ! isset( $this->global['sharing_label'] ) || false === $this->global['sharing_label'] || $this->global['sharing_label'] === 'Share this:' ) {
503 506 $this->global['sharing_label'] = $this->default_sharing_label;
504 507 }
505 508
506 509 return $this->global;
@@ -508,14 +511,14 @@
508 511
509 512 /**
510 513 * Save a sharing service for use.
511 514 *
512 - * @param int $id Sharing unique ID.
513 - * @param Sharing_Source $service Sharing service.
515 + * @param string $id Sharing unique ID.
516 + * @param Sharing_Advanced_Source $service Sharing service.
514 517 *
515 518 * @return void
516 519 */
517 - public function set_service( $id, Sharing_Source $service ) {
520 + public function set_service( $id, Sharing_Advanced_Source $service ) {
518 521 // Update the options for this service
519 522 $options = get_option( 'sharing-options' );
520 523
521 524 // No options yet
@@ -686,9 +689,11 @@
686 689 $this->id = esc_html( $id );
687 690 $this->service = $services->get_service( $id );
688 691 $this->total = (int) $total;
689 692
690 - $this->name = $this->service->get_name();
693 + if ( $this->service instanceof Sharing_Source ) {
694 + $this->name = $this->service->get_name();
695 + }
691 696 }
692 697
693 698 /**
694 699 * Compare total shares between 2 posts.
@@ -867,9 +872,9 @@
867 872 if ( $sharing_post_urls ) :
868 873 ?>
869 874
870 875 <script type="text/javascript">
871 - window.WPCOM_sharing_counts = <?php echo wp_json_encode( array_flip( $sharing_post_urls ) ); ?>;
876 + window.WPCOM_sharing_counts = <?php echo wp_json_encode( array_flip( $sharing_post_urls ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>;
872 877 </script>
873 878 <?php
874 879 endif;
875 880 endif;
@@ -927,17 +932,21 @@
927 932 $service->process_request( $post, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
928 933 }
929 934 }
930 935 }
931 -add_action( 'template_redirect', 'sharing_process_requests', 9 );
932 936
937 +// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only checking for the data being present.
938 +if ( isset( $_GET['share'] ) ) {
939 + add_action( 'template_redirect', 'sharing_process_requests', 9 );
940 +}
941 +
933 942 /**
934 - * Gets the url to customise the sharing buttons in Calypso.
943 + * Gets the url to customise the sharing buttons in WP-Admin.
935 944 *
936 - * @return string the customisation URL or null if it couldn't be determinde.
945 + * @return string the customisation URL.
937 946 */
938 947 function get_sharing_buttons_customisation_url() {
939 - return Redirect::get_url( 'calypso-marketing-sharing-buttons', array( 'site' => ( new Status() )->get_site_suffix() ) );
948 + return admin_url( 'options-general.php?page=sharing' );
940 949 }
941 950
942 951 /**
943 952 * Append sharing links to text.
@@ -953,9 +962,10 @@
953 962 if ( Settings::is_syncing() ) {
954 963 return $text;
955 964 }
956 965
957 - if ( empty( $post ) ) {
966 + // We require the post to not be empty and be an actual WordPress post object. If it's not - we just return.
967 + if ( empty( $post ) || ! $post instanceof \WP_Post ) {
958 968 return $text;
959 969 }
960 970
961 971 if ( ( is_preview() || is_admin() ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
@@ -1099,9 +1109,9 @@
1099 1109 if ( is_countable( $enabled['all'] ) && ( count( $enabled['all'] ) > 0 ) ) {
1100 1110 $dir = get_option( 'text_direction' );
1101 1111
1102 1112 // Wrapper.
1103 - $sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . $global['button_style'] . ' sd-sharing">';
1113 + $sharing_content .= '<div class="sharedaddy sd-sharing-enabled"><div class="robots-nocontent sd-block sd-social sd-social-' . ( $global['button_style'] ?? 'icon-text' ) . ' sd-sharing">';
1104 1114 if ( '' !== $global['sharing_label'] ) {
1105 1115 $sharing_content .= sprintf(
1106 1116 /**
1107 1117 * Filter the sharing buttons' headline structure.