Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/extensio.../plugins/sharing
File: sharing.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Block Editor - Sharing feature.
[2] Fix | Delete
*
[3] Fix | Delete
* @package automattic/jetpack
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
namespace Automattic\Jetpack\Extensions\Sharing;
[7] Fix | Delete
[8] Fix | Delete
use Automattic\Jetpack\Modules;
[9] Fix | Delete
use Jetpack_Gutenberg;
[10] Fix | Delete
[11] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[12] Fix | Delete
exit( 0 );
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Register Sharing plugin.
[17] Fix | Delete
*
[18] Fix | Delete
* @return void
[19] Fix | Delete
*/
[20] Fix | Delete
function register_plugins() {
[21] Fix | Delete
/*
[22] Fix | Delete
* The extension is available even when the module is not active,
[23] Fix | Delete
* so we can display a nudge to activate the module instead of the block.
[24] Fix | Delete
* However, since non-admins cannot activate modules, we do not display the empty block for them.
[25] Fix | Delete
*/
[26] Fix | Delete
if ( ! ( new Modules() )->is_active( 'sharedaddy' ) && ! current_user_can( 'jetpack_activate_modules' ) ) {
[27] Fix | Delete
return;
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
Jetpack_Gutenberg::set_extension_available( 'sharing' );
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
add_action( 'jetpack_register_gutenberg_extensions', __NAMESPACE__ . '\register_plugins' );
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* The Sharing panel is only displayed for post types that support sharing.
[37] Fix | Delete
* The sharing module declares support for sharing for all the public post types.
[38] Fix | Delete
* Let's do the same thing when the module isn't active yet.
[39] Fix | Delete
*/
[40] Fix | Delete
add_action(
[41] Fix | Delete
'rest_api_init',
[42] Fix | Delete
function () {
[43] Fix | Delete
if ( ! ( new Modules() )->is_active( 'sharedaddy' ) ) {
[44] Fix | Delete
$post_types = get_post_types( array( 'public' => true ) );
[45] Fix | Delete
[46] Fix | Delete
foreach ( $post_types as $post_type ) {
[47] Fix | Delete
register_rest_field(
[48] Fix | Delete
$post_type,
[49] Fix | Delete
'jetpack_sharing_enabled',
[50] Fix | Delete
array(
[51] Fix | Delete
'get_callback' => function ( array $post ) {
[52] Fix | Delete
if ( ! isset( $post['id'] ) ) {
[53] Fix | Delete
return false;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
return ! get_post_meta( $post['id'], 'sharing_disabled', true );
[57] Fix | Delete
},
[58] Fix | Delete
'schema' => array(
[59] Fix | Delete
'description' => __( 'Are sharing buttons enabled?', 'jetpack' ),
[60] Fix | Delete
'type' => 'boolean',
[61] Fix | Delete
),
[62] Fix | Delete
)
[63] Fix | Delete
);
[64] Fix | Delete
add_post_type_support( $post_type, 'jetpack-sharing-buttons' );
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
}
[68] Fix | Delete
);
[69] Fix | Delete
[70] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function