Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules
File: publicize.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
[0] Fix | Delete
/**
[1] Fix | Delete
* Module Name: Jetpack Social
[2] Fix | Delete
* Module Description: Auto‑share your posts to social networks and track engagement in one place.
[3] Fix | Delete
* Sort Order: 10
[4] Fix | Delete
* Recommendation Order: 7
[5] Fix | Delete
* First Introduced: 2.0
[6] Fix | Delete
* Requires Connection: Yes
[7] Fix | Delete
* Requires User Connection: Yes
[8] Fix | Delete
* Auto Activate: No
[9] Fix | Delete
* Module Tags: Social, Recommended
[10] Fix | Delete
* Feature: Engagement
[11] Fix | Delete
* Additional Search Queries: facebook, bluesky, threads, mastodon, instagram, jetpack publicize, tumblr, linkedin, social, tweet, connections, sharing, social media, automated, automated sharing, auto publish, auto tweet and like, auto tweet, facebook auto post, facebook posting
[12] Fix | Delete
*
[13] Fix | Delete
* @package automattic/jetpack
[14] Fix | Delete
*/
[15] Fix | Delete
[16] Fix | Delete
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
[17] Fix | Delete
[18] Fix | Delete
use Automattic\Jetpack\Status\Host;
[19] Fix | Delete
[20] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[21] Fix | Delete
exit( 0 );
[22] Fix | Delete
}
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* Class Jetpack_Publicize
[26] Fix | Delete
*
[27] Fix | Delete
* @phan-constructor-used-for-side-effects
[28] Fix | Delete
*/
[29] Fix | Delete
class Jetpack_Publicize {
[30] Fix | Delete
/**
[31] Fix | Delete
* Jetpack_Publicize constructor.
[32] Fix | Delete
*/
[33] Fix | Delete
public function __construct() {
[34] Fix | Delete
global $publicize_ui;
[35] Fix | Delete
[36] Fix | Delete
if ( ! ( new Host() )->is_wpcom_simple() ) {
[37] Fix | Delete
Jetpack::enable_module_configurable( __FILE__ );
[38] Fix | Delete
[39] Fix | Delete
/*
[40] Fix | Delete
* The Publicize Options array does not currently have UI since it is being added
[41] Fix | Delete
* for a specific purpose and not part of a broader Publicize sprint.
[42] Fix | Delete
*
[43] Fix | Delete
* In order to pass the settings up to WordPress.com, we are updating an option to Sync will pass it up.
[44] Fix | Delete
* To make it relatively easy for use, we are creating a filter that checks if the option and filter match.
[45] Fix | Delete
*
[46] Fix | Delete
* This only runs when a post is saved to avoid it running too much.
[47] Fix | Delete
*/
[48] Fix | Delete
add_action(
[49] Fix | Delete
'save_post',
[50] Fix | Delete
function () {
[51] Fix | Delete
$publicize_options = get_option( 'jetpack_publicize_options', array() );
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Filters the options for Publicize.
[55] Fix | Delete
*
[56] Fix | Delete
* As of Jetpack 8.5, the array keys could be:
[57] Fix | Delete
* attach_media bool If Publicize should send the image to the social media platform. Default false.
[58] Fix | Delete
*
[59] Fix | Delete
* @module publicize
[60] Fix | Delete
*
[61] Fix | Delete
* @since 8.5.0
[62] Fix | Delete
*
[63] Fix | Delete
* @param array $options Array of Publicize options.
[64] Fix | Delete
*/
[65] Fix | Delete
$filtered = (array) apply_filters( 'jetpack_publicize_options', $publicize_options );
[66] Fix | Delete
[67] Fix | Delete
if ( $publicize_options !== $filtered ) {
[68] Fix | Delete
update_option( 'jetpack_publicize_options', $filtered, false );
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
);
[72] Fix | Delete
} else {
[73] Fix | Delete
global $publicize;
[74] Fix | Delete
require_once WP_CONTENT_DIR . '/mu-plugins/keyring/keyring.php';
[75] Fix | Delete
require_once WP_CONTENT_DIR . '/admin-plugins/publicize/publicize-wpcom.php';
[76] Fix | Delete
$publicize = new \Publicize();
[77] Fix | Delete
$publicize_ui = new Automattic\Jetpack\Publicize\Publicize_UI();
[78] Fix | Delete
}
[79] Fix | Delete
}
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
// On Jetpack, we instantiate Jetpack_Publicize only if the Publicize module is active.
[83] Fix | Delete
if ( ! ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ) {
[84] Fix | Delete
global $publicize;
[85] Fix | Delete
[86] Fix | Delete
// None of this should be the case, but we can get here with a broken user connection. If that's the case
[87] Fix | Delete
// then we want to stop loading any more of the module code.
[88] Fix | Delete
if (
[89] Fix | Delete
! Jetpack::is_module_active( 'publicize' )
[90] Fix | Delete
|| ! Jetpack::connection()->has_connected_user()
[91] Fix | Delete
|| ! $publicize
[92] Fix | Delete
) {
[93] Fix | Delete
return;
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
new Jetpack_Publicize();
[97] Fix | Delete
[98] Fix | Delete
if ( ! function_exists( 'publicize_init' ) ) {
[99] Fix | Delete
/**
[100] Fix | Delete
* Helper for grabbing a Publicize object from the "front-end" (non-admin) of
[101] Fix | Delete
* a site. Normally Publicize is only loaded in wp-admin, so there's a little
[102] Fix | Delete
* set up that you might need to do if you want to use it on the front end.
[103] Fix | Delete
* Just call this function and it returns a Publicize object.
[104] Fix | Delete
*
[105] Fix | Delete
* @return \Automattic\Jetpack\Publicize\Publicize|\Publicize Object
[106] Fix | Delete
*/
[107] Fix | Delete
function publicize_init() {
[108] Fix | Delete
global $publicize;
[109] Fix | Delete
[110] Fix | Delete
return $publicize;
[111] Fix | Delete
}
[112] Fix | Delete
}
[113] Fix | Delete
} else {
[114] Fix | Delete
// On wpcom, instantiate Jetpack_Publicize without any other checks.
[115] Fix | Delete
new Jetpack_Publicize();
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function