PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 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 All 507 releases
← All changes | extensions/plugins/sharing/sharing.php +17 -3 13.3.3 → 16.3-beta View file →
@@ -6,10 +6,15 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Extensions\Sharing;
9 9
10 +use Automattic\Jetpack\Modules;
10 11 use Jetpack_Gutenberg;
11 12
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit( 0 );
15 +}
16 +
12 17 /**
13 18 * Register Sharing plugin.
14 19 *
15 20 * @return void
@@ -14,9 +19,18 @@
14 19 *
15 20 * @return void
16 21 */
17 22 function register_plugins() {
18 - // Register Sharing.
23 + /*
24 + * The extension is available even when the module is not active,
25 + * so we can display a nudge to activate the module instead of the block.
26 + * We skip that nudge for non-admins, who cannot activate modules, and on block themes,
27 + * where the answer is the Sharing Buttons block in a template rather than the legacy module.
28 + */
29 + if ( ! ( new Modules() )->is_active( 'sharedaddy' ) && ( ! current_user_can( 'jetpack_activate_modules' ) || wp_is_block_theme() ) ) {
30 + return;
31 + }
32 +
19 33 Jetpack_Gutenberg::set_extension_available( 'sharing' );
20 34 }
21 35
22 36 add_action( 'jetpack_register_gutenberg_extensions', __NAMESPACE__ . '\register_plugins' );
@@ -28,9 +42,9 @@
28 42 */
29 43 add_action(
30 44 'rest_api_init',
31 45 function () {
32 - if ( ! \Jetpack::is_module_active( 'sharedaddy' ) ) {
46 + if ( ! ( new Modules() )->is_active( 'sharedaddy' ) ) {
33 47 $post_types = get_post_types( array( 'public' => true ) );
34 48
35 49 foreach ( $post_types as $post_type ) {
36 50 register_rest_field(
@@ -41,9 +55,9 @@
41 55 if ( ! isset( $post['id'] ) ) {
42 56 return false;
43 57 }
44 58
45 - return (bool) ! get_post_meta( $post['id'], 'sharing_disabled', true );
59 + return ! get_post_meta( $post['id'], 'sharing_disabled', true );
46 60 },
47 61 'schema' => array(
48 62 'description' => __( 'Are sharing buttons enabled?', 'jetpack' ),
49 63 'type' => 'boolean',