true ) ); /** * Filter the Sharing Meta Box title. * * @module sharedaddy * * @since 2.2.0 * * @param string $var Sharing Meta Box title. Default is "Sharing". */ $title = apply_filters( 'sharing_meta_box_title', __( 'Sharing', 'jetpack' ) ); if ( $post->ID !== get_option( 'page_for_posts' ) ) { foreach ( $post_types as $post_type ) { add_meta_box( 'sharing_meta', $title, 'sharing_meta_box_content', $post_type, 'side', 'default', array( '__back_compat_meta_box' => true ) ); } } } /** * Content of the meta box. * * @param WP_Post $post The post to share. * * @return void */ function sharing_meta_box_content( $post ) { /** * Fires before the sharing meta box content. * * @module sharedaddy * * @since 2.2.0 * * @param WP_Post $post The post to share. */ do_action( 'start_sharing_meta_box_content', $post ); $disabled = get_post_meta( $post->ID, 'sharing_disabled', true ); ?>
public && current_user_can( 'edit_post', $post_id ) && isset( $_POST['sharing_status_hidden'] ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation. ) { if ( ! isset( $_POST['enable_post_sharing'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Core takes care of the validation. update_post_meta( $post_id, 'sharing_disabled', 1 ); } else { delete_post_meta( $post_id, 'sharing_disabled' ); } } return $post_id; } /** * If Sharing is disabled, disable the meta box. * * @param bool $protected Whether the key is considered protected. * @param string $meta_key Metadata key. * * @return bool */ function sharing_meta_box_protected( $protected, $meta_key ) { if ( 'sharing_disabled' === $meta_key ) { $protected = true; } return $protected; } add_filter( 'is_protected_meta', 'sharing_meta_box_protected', 10, 2 ); /** * Add link to sharing settings in the Plugins screen. * * @param array $links An array of plugin action links. * * @return array */ function sharing_plugin_settings( $links ) { $settings_link = '' . __( 'Settings', 'jetpack' ) . ''; array_unshift( $links, $settings_link ); return $links; } /** * Add links to settings and support in the plugin row. * * @param array $links An array of the plugin's metadata, including the version, author, author URI, and plugin URI. * @param string $file Path to the plugin file relative to the plugins directory. * * @return array */ function sharing_add_plugin_settings( $links, $file ) { if ( $file === basename( __DIR__ ) . '/' . basename( __FILE__ ) ) { $links[] = '' . __( 'Settings', 'jetpack' ) . ''; $links[] = '' . __( 'Support', 'jetpack' ) . ''; } return $links; } /** * Disable sharing on the frontend if disabled in the admin. * * @return void */ function sharing_init() { if ( Jetpack_Options::get_option_and_ensure_autoload( 'sharedaddy_disable_resources', '0' ) ) { add_filter( 'sharing_js', '__return_false' ); remove_action( 'wp_head', 'sharing_add_header', 1 ); } } /** * Add settings to disable CSS and JS normally enqueued by our feature. * * @return void */ function sharing_global_resources() { $disable = get_option( 'sharedaddy_disable_resources' ); ?>