Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/sharedad...
File: sharedaddy.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Jetpack's Sharing feature, nee Sharedaddy.
[2] Fix | Delete
* The most super duper sharing tool on the interwebs.
[3] Fix | Delete
*
[4] Fix | Delete
* @package automattic/jetpack
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[8] Fix | Delete
exit( 0 );
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
// Set up Sharing in wp-admin.
[12] Fix | Delete
require_once plugin_dir_path( __FILE__ ) . 'sharing.php';
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* Add a meta box to the post editing screen for sharing.
[16] Fix | Delete
*
[17] Fix | Delete
* @return void
[18] Fix | Delete
*/
[19] Fix | Delete
function sharing_add_meta_box() {
[20] Fix | Delete
global $post;
[21] Fix | Delete
if ( empty( $post ) ) { // If a current post is not defined, such as when editing a comment.
[22] Fix | Delete
return;
[23] Fix | Delete
}
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Filter whether to display the Sharing Meta Box or not.
[27] Fix | Delete
*
[28] Fix | Delete
* @module sharedaddy
[29] Fix | Delete
*
[30] Fix | Delete
* @since 3.8.0
[31] Fix | Delete
*
[32] Fix | Delete
* @param bool true Display Sharing Meta Box.
[33] Fix | Delete
* @param $post Post.
[34] Fix | Delete
*/
[35] Fix | Delete
if ( ! apply_filters( 'sharing_meta_box_show', true, $post ) ) {
[36] Fix | Delete
return;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
$post_types = get_post_types( array( 'public' => true ) );
[40] Fix | Delete
/**
[41] Fix | Delete
* Filter the Sharing Meta Box title.
[42] Fix | Delete
*
[43] Fix | Delete
* @module sharedaddy
[44] Fix | Delete
*
[45] Fix | Delete
* @since 2.2.0
[46] Fix | Delete
*
[47] Fix | Delete
* @param string $var Sharing Meta Box title. Default is "Sharing".
[48] Fix | Delete
*/
[49] Fix | Delete
$title = apply_filters( 'sharing_meta_box_title', __( 'Sharing', 'jetpack' ) );
[50] Fix | Delete
if ( $post->ID !== get_option( 'page_for_posts' ) ) {
[51] Fix | Delete
foreach ( $post_types as $post_type ) {
[52] Fix | Delete
add_meta_box( 'sharing_meta', $title, 'sharing_meta_box_content', $post_type, 'side', 'default', array( '__back_compat_meta_box' => true ) );
[53] Fix | Delete
}
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Content of the meta box.
[59] Fix | Delete
*
[60] Fix | Delete
* @param WP_Post $post The post to share.
[61] Fix | Delete
*
[62] Fix | Delete
* @return void
[63] Fix | Delete
*/
[64] Fix | Delete
function sharing_meta_box_content( $post ) {
[65] Fix | Delete
/**
[66] Fix | Delete
* Fires before the sharing meta box content.
[67] Fix | Delete
*
[68] Fix | Delete
* @module sharedaddy
[69] Fix | Delete
*
[70] Fix | Delete
* @since 2.2.0
[71] Fix | Delete
*
[72] Fix | Delete
* @param WP_Post $post The post to share.
[73] Fix | Delete
*/
[74] Fix | Delete
do_action( 'start_sharing_meta_box_content', $post );
[75] Fix | Delete
[76] Fix | Delete
$disabled = get_post_meta( $post->ID, 'sharing_disabled', true ); ?>
[77] Fix | Delete
[78] Fix | Delete
<p>
[79] Fix | Delete
<label for="enable_post_sharing">
[80] Fix | Delete
<input type="checkbox" name="enable_post_sharing" id="enable_post_sharing" value="1" <?php checked( ! $disabled ); ?>>
[81] Fix | Delete
<?php esc_html_e( 'Show sharing buttons.', 'jetpack' ); ?>
[82] Fix | Delete
</label>
[83] Fix | Delete
<input type="hidden" name="sharing_status_hidden" value="1" />
[84] Fix | Delete
</p>
[85] Fix | Delete
[86] Fix | Delete
<?php
[87] Fix | Delete
/**
[88] Fix | Delete
* Fires after the sharing meta box content.
[89] Fix | Delete
*
[90] Fix | Delete
* @module sharedaddy
[91] Fix | Delete
*
[92] Fix | Delete
* @since 2.2.0
[93] Fix | Delete
*
[94] Fix | Delete
* @param WP_Post $post The post to share.
[95] Fix | Delete
*/
[96] Fix | Delete
do_action( 'end_sharing_meta_box_content', $post );
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Save new sharing status in post meta in the meta box.
[101] Fix | Delete
*
[102] Fix | Delete
* @param int $post_id Post ID.
[103] Fix | Delete
*
[104] Fix | Delete
* @return int
[105] Fix | Delete
*/
[106] Fix | Delete
function sharing_meta_box_save( $post_id ) {
[107] Fix | Delete
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
[108] Fix | Delete
return $post_id;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
if ( ! isset( $_POST['post_type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
[112] Fix | Delete
return $post_id;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
$post_type_object = get_post_type_object( sanitize_key( $_POST['post_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
[116] Fix | Delete
[117] Fix | Delete
// Record sharing disable.
[118] Fix | Delete
if (
[119] Fix | Delete
$post_type_object->public
[120] Fix | Delete
&& current_user_can( 'edit_post', $post_id )
[121] Fix | Delete
&& isset( $_POST['sharing_status_hidden'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
[122] Fix | Delete
) {
[123] Fix | Delete
if ( ! isset( $_POST['enable_post_sharing'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation.
[124] Fix | Delete
update_post_meta( $post_id, 'sharing_disabled', 1 );
[125] Fix | Delete
} else {
[126] Fix | Delete
delete_post_meta( $post_id, 'sharing_disabled' );
[127] Fix | Delete
}
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
return $post_id;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
/**
[134] Fix | Delete
* If Sharing is disabled, disable the meta box.
[135] Fix | Delete
*
[136] Fix | Delete
* @param bool $protected Whether the key is considered protected.
[137] Fix | Delete
* @param string $meta_key Metadata key.
[138] Fix | Delete
*
[139] Fix | Delete
* @return bool
[140] Fix | Delete
*/
[141] Fix | Delete
function sharing_meta_box_protected( $protected, $meta_key ) {
[142] Fix | Delete
if ( 'sharing_disabled' === $meta_key ) {
[143] Fix | Delete
$protected = true;
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
return $protected;
[147] Fix | Delete
}
[148] Fix | Delete
add_filter( 'is_protected_meta', 'sharing_meta_box_protected', 10, 2 );
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* Add link to sharing settings in the Plugins screen.
[152] Fix | Delete
*
[153] Fix | Delete
* @param array $links An array of plugin action links.
[154] Fix | Delete
*
[155] Fix | Delete
* @return array
[156] Fix | Delete
*/
[157] Fix | Delete
function sharing_plugin_settings( $links ) {
[158] Fix | Delete
$settings_link = '<a href="options-general.php?page=sharing.php">' . __( 'Settings', 'jetpack' ) . '</a>';
[159] Fix | Delete
array_unshift( $links, $settings_link );
[160] Fix | Delete
return $links;
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
/**
[164] Fix | Delete
* Add links to settings and support in the plugin row.
[165] Fix | Delete
*
[166] Fix | Delete
* @param array $links An array of the plugin's metadata, including the version, author, author URI, and plugin URI.
[167] Fix | Delete
* @param string $file Path to the plugin file relative to the plugins directory.
[168] Fix | Delete
*
[169] Fix | Delete
* @return array
[170] Fix | Delete
*/
[171] Fix | Delete
function sharing_add_plugin_settings( $links, $file ) {
[172] Fix | Delete
if ( $file === basename( __DIR__ ) . '/' . basename( __FILE__ ) ) {
[173] Fix | Delete
$links[] = '<a href="options-general.php?page=sharing.php">' . __( 'Settings', 'jetpack' ) . '</a>';
[174] Fix | Delete
$links[] = '<a href="https://support.wordpress.com/sharing/" rel="noopener noreferrer" target="_blank">' . __( 'Support', 'jetpack' ) . '</a>';
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
return $links;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Disable sharing on the frontend if disabled in the admin.
[182] Fix | Delete
*
[183] Fix | Delete
* @return void
[184] Fix | Delete
*/
[185] Fix | Delete
function sharing_init() {
[186] Fix | Delete
if ( Jetpack_Options::get_option_and_ensure_autoload( 'sharedaddy_disable_resources', '0' ) ) {
[187] Fix | Delete
add_filter( 'sharing_js', '__return_false' );
[188] Fix | Delete
remove_action( 'wp_head', 'sharing_add_header', 1 );
[189] Fix | Delete
}
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
/**
[193] Fix | Delete
* Add settings to disable CSS and JS normally enqueued by our feature.
[194] Fix | Delete
*
[195] Fix | Delete
* @return void
[196] Fix | Delete
*/
[197] Fix | Delete
function sharing_global_resources() {
[198] Fix | Delete
$disable = get_option( 'sharedaddy_disable_resources' );
[199] Fix | Delete
?>
[200] Fix | Delete
<tr valign="top">
[201] Fix | Delete
<th scope="row"><label for="disable_css"><?php esc_html_e( 'Disable CSS and JS', 'jetpack' ); ?></label></th>
[202] Fix | Delete
<td>
[203] Fix | Delete
<?php
[204] Fix | Delete
printf(
[205] Fix | Delete
'<input id="disable_css" type="checkbox" name="disable_resources"%1$s /> <small><em>%2$s</em></small>',
[206] Fix | Delete
( 1 == $disable ) ? ' checked="checked"' : '', // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
[207] Fix | Delete
esc_html__( 'Advanced. If this option is checked, you must include these files in your theme manually for the sharing links to work.', 'jetpack' )
[208] Fix | Delete
);
[209] Fix | Delete
?>
[210] Fix | Delete
</td>
[211] Fix | Delete
</tr>
[212] Fix | Delete
<?php
[213] Fix | Delete
}
[214] Fix | Delete
[215] Fix | Delete
/**
[216] Fix | Delete
* Save settings to disable CSS and JS normally enqueued by our feature.
[217] Fix | Delete
*
[218] Fix | Delete
* @return void
[219] Fix | Delete
*/
[220] Fix | Delete
function sharing_global_resources_save() {
[221] Fix | Delete
update_option( 'sharedaddy_disable_resources', isset( $_POST['disable_resources'] ) ? 1 : 0 ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce handling is handled for all elements at once.
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
add_action( 'init', 'sharing_init' );
[225] Fix | Delete
add_action( 'add_meta_boxes', 'sharing_add_meta_box' );
[226] Fix | Delete
add_action( 'save_post', 'sharing_meta_box_save' );
[227] Fix | Delete
add_action( 'edit_attachment', 'sharing_meta_box_save' );
[228] Fix | Delete
add_action( 'sharing_global_options', 'sharing_global_resources', 30 );
[229] Fix | Delete
add_action( 'sharing_admin_update', 'sharing_global_resources_save' );
[230] Fix | Delete
add_action( 'plugin_action_links_' . basename( __DIR__ ) . '/' . basename( __FILE__ ), 'sharing_plugin_settings', 10, 4 );
[231] Fix | Delete
add_filter( 'plugin_row_meta', 'sharing_add_plugin_settings', 10, 2 );
[232] Fix | Delete
[233] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function