', $data['name'], $from_email ); $headers[] = sprintf( 'Reply-To: %1$s <%2$s>', $data['name'], $data['source'] ); wp_mail( $data['target'], '['.__( 'Shared Post', 'jetpack' ).'] '.$data['post']->post_title, $content, $headers ); } /* Checks for spam using akismet if available. */ /* Return $data as it if email about to be send out is not spam. */ function sharing_email_check_for_spam_via_akismet( $data ) { if ( ! function_exists( 'akismet_http_post' ) && ! method_exists( 'Akismet', 'http_post' ) ) return $data; // Prepare the body_request for akismet $body_request = array( 'blog' => get_option( 'home' ), 'permalink' => get_permalink( $data['post']->ID ), 'comment_type' => 'share', 'comment_author' => $data['name'], 'comment_author_email' => $data['source'], 'comment_content' => sharing_email_send_post_content( $data ), 'user_agent' => ( isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : null ), ); if ( method_exists( 'Akismet', 'http_post' ) ) { $body_request['user_ip'] = Akismet::get_ip_address(); $response = Akismet::http_post( build_query( $body_request ), 'comment-check' ); } else { global $akismet_api_host, $akismet_api_port; $body_request['user_ip'] = ( isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null ); $response = akismet_http_post( build_query( $body_request ), $akismet_api_host, '/1.1/comment-check', $akismet_api_port ); } // The Response is spam lets not send the email. if ( ! empty( $response ) && isset( $response[1] ) && 'true' == trim( $response[1] ) ) { // 'true' is spam return false; // don't send the email } return $data; } function sharing_email_send_post_content( $data ) { /* translators: included in e-mail when post is shared via e-mail. First item is sender's name. Second is sender's e-mail address. */ $content = sprintf( __( '%1$s (%2$s) thinks you may be interested in the following post:', 'jetpack' ), $data['name'], $data['source'] ); $content .= "\n\n"; $content .= $data['post']->post_title."\n"; $content .= get_permalink( $data['post']->ID )."\n"; return $content; } function sharing_add_meta_box() { global $post; if ( empty( $post ) ) { // If a current post is not defined, such as when editing a comment. return; } /** * Filter whether to display the Sharing Meta Box or not. * * @module sharedaddy * * @since 3.8.0 * * @param bool true Display Sharing Meta Box. * @param $post Post. */ if ( ! apply_filters( 'sharing_meta_box_show', true, $post ) ) { return; } $post_types = get_post_types( array( 'public' => 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, 'advanced', 'high' ); } } } 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 ) { if ( current_user_can( 'edit_post', $post_id ) ) { if ( isset( $_POST['sharing_status_hidden'] ) ) { if ( !isset( $_POST['enable_post_sharing'] ) ) { update_post_meta( $post_id, 'sharing_disabled', 1 ); } else { delete_post_meta( $post_id, 'sharing_disabled' ); } } } } return $post_id; } function sharing_meta_box_protected( $protected, $meta_key, $meta_type ) { if ( 'sharing_disabled' == $meta_key ) $protected = true; return $protected; } add_filter( 'is_protected_meta', 'sharing_meta_box_protected', 10, 3 ); function sharing_plugin_settings( $links ) { $settings_link = ''.__( 'Settings', 'jetpack' ).''; array_unshift( $links, $settings_link ); return $links; } function sharing_add_plugin_settings($links, $file) { if ( $file == basename( dirname( __FILE__ ) ).'/'.basename( __FILE__ ) ) { $links[] = '' . __( 'Settings', 'jetpack' ) . ''; $links[] = '' . __( 'Support', 'jetpack' ) . ''; } return $links; } function sharing_restrict_to_single( $services ) { // This removes Press This from non-multisite blogs - doesn't make much sense if ( is_multisite() === false ) { unset( $services['press-this'] ); } return $services; } function sharing_init() { if ( get_option( 'sharedaddy_disable_resources' ) ) { add_filter( 'sharing_js', 'sharing_disable_js' ); remove_action( 'wp_head', 'sharing_add_header', 1 ); } } function sharing_disable_js() { return false; } function sharing_global_resources() { $disable = get_option( 'sharedaddy_disable_resources' ); ?>