Skip to content

Commit e9cb5f0

Browse files
author
George Stephanis
committed
Deprecate and remove G+ Profile module.
Google has dropped support for this, so there’s not much reason to keep it around. @see https://support.google.com/webmasters/answer/6083347
1 parent 18c1733 commit e9cb5f0

11 files changed

+14
-765
lines changed

.jshintignore

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ modules/shortcodes/js/jmpress.min.js
1010
modules/shortcodes/js/jquery.cycle.js
1111
modules/theme-tools/responsive-videos/responsive-videos.min.js
1212

13-
needs to be merged first:
14-
modules/gplus-authorship/admin/connect.js
15-
1613
todo:
1714
modules/infinite-scroll/infinity.js
1815
modules/sharedaddy/sharing.js

Gruntfile.js

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ var admincss = [
5656
var frontendcss = [
5757
'modules/carousel/jetpack-carousel.css',
5858
'modules/contact-form/css/grunion.css',
59-
'modules/gplus-authorship/style.css',
6059
'modules/infinite-scroll/infinity.css',
6160
'modules/likes/style.css',
6261
'modules/related-posts/related-posts.css',

class.jetpack.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ class Jetpack {
8686
'Easy Contact Forms' => 'easy-contact-forms/easy-contact-forms.php',
8787
'Fast Secure Contact Form' => 'si-contact-form/si-contact-form.php',
8888
),
89-
'gplus-authorship' => array(
90-
'WP SEO by Yoast' => 'wordpress-seo/wp-seo.php',
91-
),
9289
'minileven' => array(
9390
'WPtouch' => 'wptouch/wptouch.php',
9491
),
@@ -304,6 +301,13 @@ function plugin_upgrade() {
304301
}
305302
}
306303
}
304+
305+
// Clean up legacy G+ Authorship data.
306+
if ( get_option( 'gplus_authors' ) ) {
307+
delete_option( 'gplus_authors' );
308+
delete_option( 'hide_gplus' );
309+
delete_metadata( 'post', 0, 'gplus_authorship_disabled', null, true );
310+
}
307311
}
308312

309313
/**
@@ -1153,8 +1157,9 @@ public static function get_default_modules( $min_version = false, $max_version =
11531157
*/
11541158
function handle_deprecated_modules( $modules ) {
11551159
$deprecated_modules = array(
1156-
'debug' => null, // Closed out and moved to ./class.jetpack-debugger.php
1157-
'wpcc' => 'sso', // Closed out in 2.6 -- SSO provides the same functionality.
1160+
'debug' => null, // Closed out and moved to ./class.jetpack-debugger.php
1161+
'wpcc' => 'sso', // Closed out in 2.6 -- SSO provides the same functionality.
1162+
'gplus-authorship' => null, // Closed out in 3.2 -- Google dropped support.
11581163
);
11591164

11601165
// Don't activate SSO if they never completed activating WPCC.
@@ -4737,7 +4742,6 @@ public function implode_frontend_css() {
47374742
$to_dequeue = array(
47384743
'jetpack-carousel',
47394744
'grunion.css',
4740-
'gplus',
47414745
'the-neverending-homepage',
47424746
'jetpack_likes',
47434747
'jetpack_related-posts',

modules/gplus-authorship.php

+4-199
Original file line numberDiff line numberDiff line change
@@ -1,201 +1,6 @@
11
<?php
22
/**
3-
* Module Name: Google+ Profile
4-
* Module Description: Give users the ability to share posts to Google+, and add your site link to your Google+ profile.
5-
* Sort Order: 18
6-
* First Introduced: 2.5
7-
* Requires Connection: Yes
8-
* Auto Activate: Yes
9-
*/
10-
function jetpack_init_gplus_authorship() {
11-
new GPlus_Authorship;
12-
}
13-
add_action( 'init', 'jetpack_init_gplus_authorship' );
14-
15-
class GPlus_Authorship {
16-
17-
private $byline_displayed = false;
18-
19-
function __construct() {
20-
$this->in_jetpack = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? false : true;
21-
if ( $this->in_jetpack ) {
22-
require dirname( __FILE__ ) . "/gplus-authorship/admin/ui.php";
23-
$gplus_admin = new GPlus_Authorship_Admin;
24-
add_action( 'save_post', array( 'GPlus_Authorship_Admin', 'save_post_meta' ) );
25-
add_action( 'wp_ajax_save_gplus_profile_data', array( $this, 'save_profile_data' ) );
26-
add_filter( 'the_content', array( $this, 'post_output_wrapper' ), 22, 1 );
27-
} else {
28-
add_filter( 'post_flair', array( $this, 'post_output_wrapper' ), 22 );
29-
}
30-
add_action( 'wp_head', array( $this, 'link_tag_styles_and_scripts' ) );
31-
add_filter( 'the_author', array( $this, 'overwrite_the_author' ) );
32-
add_filter( 'the_content', array( $this, 'overwrite_rel_attrs' ) );
33-
}
34-
35-
function show_on_this_post() {
36-
global $post;
37-
if ( ! apply_filters( 'gplus_authorship_show', true, $post ) ) {
38-
return false;
39-
}
40-
$author = $this->information( $post->post_author );
41-
if ( empty( $author ) )
42-
return false;
43-
$meta = get_post_meta( $post->ID, 'gplus_authorship_disabled', true );
44-
if ( isset( $meta ) && true == $meta )
45-
return false;
46-
return true;
47-
}
48-
49-
function information( $author ) {
50-
$authors = get_option( 'gplus_authors', array() );
51-
return ( empty( $authors[ $author ] ) ? array() : $authors[ $author ] );
52-
}
53-
54-
/**
55-
* Both overwrite_rel_attrs and rel_callback remove 'author' from the rel attribute of a link if it is found
56-
* and if the post is being viewed on a single page, with G+ authorship enabled.
57-
* based on prior art from privatize_link in wp-content/mu-plugins/private-blog.php
58-
*/
59-
function overwrite_rel_attrs( $content ) {
60-
if ( !is_single() ) // don't bother unless we are on a page where the G+ authorship link is actually being displayed
61-
return $content;
62-
if ( !$this->show_on_this_post() ) // G+ isn't enabled
63-
return $content;
64-
if ( ! is_main_query() || ! in_the_loop() )
65-
return $content;
66-
return preg_replace_callback( '#<a\s+[^>]+>#i', array( $this, 'rel_callback' ), $content );
67-
}
68-
69-
function rel_callback( $link ) {
70-
$link = $link[0]; // preg replace returns as array
71-
72-
// See if the link contains a rel="author ..." attribute, and if so, remove the author part
73-
$link = preg_replace_callback( '/rel\s*=\s*("|\').*author[^"\']*("|\')/i', array( $this, 'rel_attr_callback' ), $link );
74-
75-
// See if we have an empty rel attribute now and remove it if need be
76-
$link = preg_replace( '/rel\s*=\s*("|\')\s*("|\')\s*/i', '', $link );
77-
78-
return $link;
79-
}
80-
81-
function rel_attr_callback( $attr ) {
82-
$attr = $attr[0];
83-
$attr = preg_replace( '/author\s*/i', '', $attr );
84-
return $attr;
85-
}
86-
87-
/**
88-
* Jetpack Only
89-
*/
90-
function save_profile_data() {
91-
global $current_user;
92-
check_ajax_referer( 'gplus-connect', 'state' );
93-
if ( !is_numeric( $_POST['id'] ) )
94-
return;
95-
$connections = get_option( 'gplus_authors', array() );
96-
$connections[ $current_user->ID ]['name'] = stripslashes( $_POST['name'] );
97-
$connections[ $current_user->ID ]['id'] = $_POST['id'];
98-
$connections[ $current_user->ID ]['url'] = esc_url_raw( $_POST['url'] );
99-
$connections[ $current_user->ID ]['profile_image'] = esc_url_raw( $_POST['profile_image'] );
100-
update_option( 'gplus_authors', $connections );
101-
}
102-
103-
/**
104-
* Google+ insits we don't have two different bylines..
105-
* so we will display their G+ username in the byline here too
106-
*/
107-
function overwrite_the_author( $author_name ) {
108-
global $post;
109-
110-
if ( !$this->show_on_this_post() )
111-
return $author_name;
112-
113-
if ( ! is_main_query() || ! in_the_loop() )
114-
return $author_name;
115-
116-
$author = $this->information( $post->post_author );
117-
return esc_html( $author['name'] );
118-
}
119-
120-
function byline( $post ) {
121-
$author = $this->information( $post->post_author );
122-
$image = '<img src="' . esc_url( $author['profile_image'] ) . '?sz=40" alt="' . esc_attr( $author['name'] ) . '" width="20" height="20" align="absmiddle" /> ';
123-
$byline = sprintf( '<a href="%1$s">%2$s</a><a rel="author" href="%1$s" class="gplus-profile">%3$s</a>', esc_url( $author['url'] ), $image, esc_html( $author['name'] ) );
124-
return apply_filters( 'gplus_authorship_byline', $byline, $post );
125-
}
126-
127-
function link_tag_styles_and_scripts() {
128-
if ( !is_single() )
129-
return;
130-
if ( get_post_type() != 'post' )
131-
return;
132-
if ( !$this->show_on_this_post() )
133-
return;
134-
135-
global $post;
136-
$author = $this->information( $post->post_author );
137-
echo '<link rel="author" href="'. esc_url( $author['url'] ) .'" title="' . esc_attr( $author['name'] ) . ' ' . __( 'on Google+', 'jetpack' ) .'" /> ' . "\n";
138-
if ( $this->in_jetpack )
139-
$css = plugins_url( 'gplus-authorship/style.css', __FILE__ );
140-
else
141-
$css = plugins_url( 'gplus/style.css', __FILE__ );
142-
wp_enqueue_style( 'gplus', $css );
143-
wp_enqueue_script( 'plusone', '//apis.google.com/js/plusone.js' );
144-
}
145-
146-
function follow_button( $post ) {
147-
$author = $this->information( $post->post_author );
148-
return '<span class="g-follow-wrapper"><span class="g-follow" data-href="' . esc_url( $author['url'] ) . '" data-rel="author" data-height="15"></span></span>';
149-
}
150-
151-
function post_output_wrapper( $text = '', $echo = false ) {
152-
global $post, $wp_current_filter;
153-
if ( true == get_option( 'hide_gplus', false ) )
154-
return $text;
155-
if ( !is_single() )
156-
return $text;
157-
if ( get_post_type() != 'post' )
158-
return $text;
159-
if ( true === $this->byline_displayed )
160-
return $text;
161-
$author = $this->information( $post->post_author );
162-
if ( empty( $author ) )
163-
return $text;
164-
165-
// Don't allow G+ to be added to the_content more than once (prevent infinite loops)
166-
$done = false;
167-
foreach ( $wp_current_filter as $filter ) {
168-
if ( 'the_content' == $filter ) {
169-
if ( $done )
170-
return $text;
171-
else
172-
$done = true;
173-
}
174-
}
175-
176-
if ( !$this->show_on_this_post())
177-
return $text;
178-
179-
if ( ! is_main_query() || ! in_the_loop() )
180-
return $text;
181-
182-
$output = '';
183-
$output .= '<div class="sharedaddy sd-block sd-social sd-gplus">';
184-
$output .= '<h3 class="sd-title">' . __( 'Google+', 'jetpack' ) . '</h3>';
185-
$output .= '<div class="sd-content">';
186-
$output .= $this->byline( $post );
187-
$output .= $this->follow_button( $post );
188-
$output .= '</div>';
189-
$output .= '</div>';
190-
191-
$this->byline_displayed = true;
192-
193-
if ( $echo )
194-
echo $text . $output;
195-
else
196-
return $text . $output;
197-
}
198-
199-
}
200-
201-
?>
3+
* Deprecated. No longer needed.
4+
*
5+
* @package Jetpack
6+
*/

modules/gplus-authorship/admin/connect.js

-42
This file was deleted.

modules/gplus-authorship/admin/listener.js

-61
This file was deleted.

0 commit comments

Comments
 (0)