PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
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 | extensions/plugins/publicize/publicize.php +18 -4 12.6.4 → 16.3-a.7 View file →
@@ -7,12 +7,17 @@
7 7
8 8 namespace Automattic\Jetpack\Extensions\Publicize;
9 9
10 10 use Automattic\Jetpack\Connection\Manager as Connection_Manager;
11 +use Automattic\Jetpack\Modules;
11 12 use Automattic\Jetpack\Status;
12 13 use Automattic\Jetpack\Status\Host;
13 14 use Jetpack_Gutenberg;
14 15
16 +if ( ! defined( 'ABSPATH' ) ) {
17 + exit( 0 );
18 +}
19 +
15 20 /**
16 21 * Register both Publicize and Republicize plugins.
17 22 *
18 23 * @return void
@@ -24,12 +29,21 @@
24 29 // Capability check.
25 30 if (
26 31 ! current_user_can( $capability )
27 32 ) {
28 - Jetpack_Gutenberg::set_extension_unavailable( 'jetpack/publicize', 'unauthorized' );
33 + Jetpack_Gutenberg::set_extension_unavailable( 'publicize', 'unauthorized' );
29 34 return;
30 35 }
31 36
37 + /*
38 + * The extension is available even when the module is not active,
39 + * so we can display a nudge to activate the module instead of the block.
40 + * However, since non-admins cannot activate modules, we do not display the empty block for them.
41 + */
42 + if ( ! ( new Modules() )->is_active( 'publicize' ) && ! current_user_can( 'jetpack_activate_modules' ) ) {
43 + return;
44 + }
45 +
32 46 // Connection check.
33 47 if (
34 48 ( new Host() )->is_wpcom_simple()
35 49 || ( ( new Connection_Manager( 'jetpack' ) )->has_connected_owner() && ! ( new Status() )->is_offline_mode() )
@@ -34,9 +48,9 @@
34 48 ( new Host() )->is_wpcom_simple()
35 49 || ( ( new Connection_Manager( 'jetpack' ) )->has_connected_owner() && ! ( new Status() )->is_offline_mode() )
36 50 ) {
37 51 // Register Publicize.
38 - Jetpack_Gutenberg::set_extension_available( 'jetpack/publicize' );
52 + Jetpack_Gutenberg::set_extension_available( 'publicize' );
39 53
40 54 // Set the republicize availability, depending on the site plan.
41 55 Jetpack_Gutenberg::set_availability_for_plan( 'republicize' );
42 56 }
@@ -47,9 +61,9 @@
47 61 add_filter(
48 62 'jetpack_set_available_extensions',
49 63 function ( $extensions ) {
50 64 return array_merge(
51 - $extensions,
65 + (array) $extensions,
52 66 array(
53 67 'republicize',
54 68 )
55 69 );
@@ -63,9 +77,9 @@
63 77 */
64 78 add_action(
65 79 'init',
66 80 function () {
67 - if ( ! \Jetpack::is_module_active( 'publicize' ) ) {
81 + if ( ! ( new Modules() )->is_active( 'publicize' ) ) {
68 82 add_post_type_support( 'post', 'publicize' );
69 83 }
70 84 }
71 85 );