PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
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 13.9.2 14.0.1 All 504 releases
← All changes | modules/sharedaddy/sharing-service.php +27 -19 13.9.216.3-a.1 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,9 +104,8 @@
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',
108 109 'threads' => 'Share_Threads',
109 110 'jetpack-whatsapp' => 'Jetpack_Share_WhatsApp',
110 111 'mastodon' => 'Share_Mastodon',
@@ -110,10 +111,8 @@
110 111 'mastodon' => 'Share_Mastodon',
111 112 'nextdoor' => 'Share_Nextdoor',
112 113 'x' => 'Share_X',
113 114 'bluesky' => 'Share_Bluesky',
114 - // deprecated.
115 - 'skype' => 'Share_Skype',
116 115 );
117 116
118 117 if ( is_multisite() && is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
119 118 $services['press-this'] = 'Share_PressThis';
@@ -121,10 +120,12 @@
121 120
122 121 if ( $include_custom ) {
123 122 // Add any custom services in
124 123 $options = $this->get_global_options();
125 - foreach ( (array) $options['custom'] as $custom_id ) {
126 - $services[ $custom_id ] = 'Share_Custom';
124 + if ( isset( $options['custom'] ) ) {
125 + foreach ( $options['custom'] as $custom_id ) {
126 + $services[ $custom_id ] = 'Share_Custom';
127 + }
127 128 }
128 129 }
129 130
130 131 /**
@@ -314,15 +315,15 @@
314 315 $enabled = apply_filters( 'sharing_default_services', $enabled );
315 316 }
316 317
317 318 // Cleanup after any filters that may have produced duplicate services
318 - if ( is_array( $enabled['visible'] ) ) {
319 + if ( isset( $enabled['visible'] ) && is_array( $enabled['visible'] ) ) {
319 320 $enabled['visible'] = array_unique( $enabled['visible'] );
320 321 } else {
321 322 $enabled['visible'] = array();
322 323 }
323 324
324 - if ( is_array( $enabled['hidden'] ) ) {
325 + if ( isset( $enabled['hidden'] ) && is_array( $enabled['hidden'] ) ) {
325 326 $enabled['hidden'] = array_unique( $enabled['hidden'] );
326 327 } else {
327 328 $enabled['hidden'] = array();
328 329 }
@@ -404,9 +405,9 @@
404 405 'button_style' => 'icon-text',
405 406 'sharing_label' => $this->default_sharing_label,
406 407 'open_links' => 'same',
407 408 'show' => ! isset( $options['global'] ) ? array( 'post', 'page' ) : array(),
408 - 'custom' => isset( $options['global']['custom'] ) ? $options['global']['custom'] : array(),
409 + 'custom' => $options['global']['custom'] ?? array(),
409 410 );
410 411
411 412 /**
412 413 * Filters global sharing settings.
@@ -500,9 +501,9 @@
500 501 break;
501 502 }
502 503 }
503 504
504 - if ( false === $this->global['sharing_label'] || $this->global['sharing_label'] === 'Share this:' ) {
505 + if ( ! isset( $this->global['sharing_label'] ) || false === $this->global['sharing_label'] || $this->global['sharing_label'] === 'Share this:' ) {
505 506 $this->global['sharing_label'] = $this->default_sharing_label;
506 507 }
507 508
508 509 return $this->global;
@@ -688,9 +689,11 @@
688 689 $this->id = esc_html( $id );
689 690 $this->service = $services->get_service( $id );
690 691 $this->total = (int) $total;
691 692
692 - $this->name = $this->service->get_name();
693 + if ( $this->service instanceof Sharing_Source ) {
694 + $this->name = $this->service->get_name();
695 + }
693 696 }
694 697
695 698 /**
696 699 * Compare total shares between 2 posts.
@@ -869,9 +872,9 @@
869 872 if ( $sharing_post_urls ) :
870 873 ?>
871 874
872 875 <script type="text/javascript">
873 - 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 ); ?>;
874 877 </script>
875 878 <?php
876 879 endif;
877 880 endif;
@@ -929,17 +932,21 @@
929 932 $service->process_request( $post, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
930 933 }
931 934 }
932 935 }
933 -add_action( 'template_redirect', 'sharing_process_requests', 9 );
934 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 +
935 942 /**
936 - * Gets the url to customise the sharing buttons in Calypso.
943 + * Gets the url to customise the sharing buttons in WP-Admin.
937 944 *
938 - * @return string the customisation URL or null if it couldn't be determinde.
945 + * @return string the customisation URL.
939 946 */
940 947 function get_sharing_buttons_customisation_url() {
941 - return Redirect::get_url( 'calypso-marketing-sharing-buttons', array( 'site' => ( new Status() )->get_site_suffix() ) );
948 + return admin_url( 'options-general.php?page=sharing' );
942 949 }
943 950
944 951 /**
945 952 * Append sharing links to text.
@@ -955,9 +962,10 @@
955 962 if ( Settings::is_syncing() ) {
956 963 return $text;
957 964 }
958 965
959 - 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 ) {
960 968 return $text;
961 969 }
962 970
963 971 if ( ( is_preview() || is_admin() ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
@@ -1101,9 +1109,9 @@
1101 1109 if ( is_countable( $enabled['all'] ) && ( count( $enabled['all'] ) > 0 ) ) {
1102 1110 $dir = get_option( 'text_direction' );
1103 1111
1104 1112 // Wrapper.
1105 - $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">';
1106 1114 if ( '' !== $global['sharing_label'] ) {
1107 1115 $sharing_content .= sprintf(
1108 1116 /**
1109 1117 * Filter the sharing buttons' headline structure.