PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 14.4
Jetpack – WP Security, Backup, Speed, & Growth v14.4
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 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / extensions / plugins / sharing / sharing.php
sharing.php
58 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Block Editor - Sharing feature.
4 *
5 * @package automattic/jetpack
6 */
7
8 namespace Automattic\Jetpack\Extensions\Sharing;
9
10 use Jetpack_Gutenberg;
11
12 /**
13 * Register Sharing plugin.
14 *
15 * @return void
16 */
17 function register_plugins() {
18 // Register Sharing.
19 Jetpack_Gutenberg::set_extension_available( 'sharing' );
20 }
21
22 add_action( 'jetpack_register_gutenberg_extensions', __NAMESPACE__ . '\register_plugins' );
23
24 /**
25 * The Sharing panel is only displayed for post types that support sharing.
26 * The sharing module declares support for sharing for all the public post types.
27 * Let's do the same thing when the module isn't active yet.
28 */
29 add_action(
30 'rest_api_init',
31 function () {
32 if ( ! \Jetpack::is_module_active( 'sharedaddy' ) ) {
33 $post_types = get_post_types( array( 'public' => true ) );
34
35 foreach ( $post_types as $post_type ) {
36 register_rest_field(
37 $post_type,
38 'jetpack_sharing_enabled',
39 array(
40 'get_callback' => function ( array $post ) {
41 if ( ! isset( $post['id'] ) ) {
42 return false;
43 }
44
45 return (bool) ! get_post_meta( $post['id'], 'sharing_disabled', true );
46 },
47 'schema' => array(
48 'description' => __( 'Are sharing buttons enabled?', 'jetpack' ),
49 'type' => 'boolean',
50 ),
51 )
52 );
53 add_post_type_support( $post_type, 'jetpack-sharing-buttons' );
54 }
55 }
56 }
57 );
58