Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/extensio.../plugins/publiciz...
File: publicize.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Block Editor - Publicize and Republicize features.
[2] Fix | Delete
*
[3] Fix | Delete
* @package automattic/jetpack
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
namespace Automattic\Jetpack\Extensions\Publicize;
[7] Fix | Delete
[8] Fix | Delete
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
[9] Fix | Delete
use Automattic\Jetpack\Modules;
[10] Fix | Delete
use Automattic\Jetpack\Status;
[11] Fix | Delete
use Automattic\Jetpack\Status\Host;
[12] Fix | Delete
use Jetpack_Gutenberg;
[13] Fix | Delete
[14] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[15] Fix | Delete
exit( 0 );
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Register both Publicize and Republicize plugins.
[20] Fix | Delete
*
[21] Fix | Delete
* @return void
[22] Fix | Delete
*/
[23] Fix | Delete
function register_plugins() {
[24] Fix | Delete
/** This filter is documented in projects/packages/publicize/src/class-publicize-base.php */
[25] Fix | Delete
$capability = apply_filters( 'jetpack_publicize_capability', 'publish_posts' );
[26] Fix | Delete
[27] Fix | Delete
// Capability check.
[28] Fix | Delete
if (
[29] Fix | Delete
! current_user_can( $capability )
[30] Fix | Delete
) {
[31] Fix | Delete
Jetpack_Gutenberg::set_extension_unavailable( 'publicize', 'unauthorized' );
[32] Fix | Delete
return;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/*
[36] Fix | Delete
* The extension is available even when the module is not active,
[37] Fix | Delete
* so we can display a nudge to activate the module instead of the block.
[38] Fix | Delete
* However, since non-admins cannot activate modules, we do not display the empty block for them.
[39] Fix | Delete
*/
[40] Fix | Delete
if ( ! ( new Modules() )->is_active( 'publicize' ) && ! current_user_can( 'jetpack_activate_modules' ) ) {
[41] Fix | Delete
return;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
// Connection check.
[45] Fix | Delete
if (
[46] Fix | Delete
( new Host() )->is_wpcom_simple()
[47] Fix | Delete
|| ( ( new Connection_Manager( 'jetpack' ) )->has_connected_owner() && ! ( new Status() )->is_offline_mode() )
[48] Fix | Delete
) {
[49] Fix | Delete
// Register Publicize.
[50] Fix | Delete
Jetpack_Gutenberg::set_extension_available( 'publicize' );
[51] Fix | Delete
[52] Fix | Delete
// Set the republicize availability, depending on the site plan.
[53] Fix | Delete
Jetpack_Gutenberg::set_availability_for_plan( 'republicize' );
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
add_action( 'jetpack_register_gutenberg_extensions', __NAMESPACE__ . '\register_plugins' );
[57] Fix | Delete
[58] Fix | Delete
// Populate the available extensions with republicize.
[59] Fix | Delete
add_filter(
[60] Fix | Delete
'jetpack_set_available_extensions',
[61] Fix | Delete
function ( $extensions ) {
[62] Fix | Delete
return array_merge(
[63] Fix | Delete
(array) $extensions,
[64] Fix | Delete
array(
[65] Fix | Delete
'republicize',
[66] Fix | Delete
)
[67] Fix | Delete
);
[68] Fix | Delete
}
[69] Fix | Delete
);
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Publicize declares its support for the 'post' post type by default.
[73] Fix | Delete
* Let's do it here as well, when the module hasn't been activated yet.
[74] Fix | Delete
* It helps us display the Publicize UI in the editor.
[75] Fix | Delete
*/
[76] Fix | Delete
add_action(
[77] Fix | Delete
'init',
[78] Fix | Delete
function () {
[79] Fix | Delete
if ( ! ( new Modules() )->is_active( 'publicize' ) ) {
[80] Fix | Delete
add_post_type_support( 'post', 'publicize' );
[81] Fix | Delete
}
[82] Fix | Delete
}
[83] Fix | Delete
);
[84] Fix | Delete
[85] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function