Version Description
- Fixed issues with certain themes using get_the_excerpt method
- Fixed issue with Share layer and Recommended layer showing up in wrong order
- Fixed issue with Recommended layer showing up page title instead of Recommended layer title
- Fixed PHP warnings in Divi theme
Download this release
Release Info
Developer | kirk-at-addthis |
Plugin | WordPress Share Buttons Plugin – AddThis |
Version | 4.0.4 |
Comparing to | |
See all releases |
Code changes from version 4.0.3 to 4.0.4
- addthis-toolbox.php +45 -7
- addthis_social_widget.php +3 -3
- includes/addthis_addjs_new.php +25 -1
- includes/js/add-divs-to-coded-excerpts.js +76 -0
- readme.txt +42 -10
addthis-toolbox.php
CHANGED
@@ -73,9 +73,43 @@ class Addthis_ToolBox
|
|
73 |
if ( has_excerpt()) {
|
74 |
add_filter('the_excerpt', array($this, 'addWidget'));
|
75 |
} else {
|
76 |
-
add_filter('get_the_excerpt', array($this, '
|
77 |
}
|
78 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
/**
|
81 |
* Adds toolbox to wp pages
|
@@ -109,10 +143,10 @@ class Addthis_ToolBox
|
|
109 |
} else if (is_single()) {
|
110 |
if($at_flag == '' || $at_flag == '1'){
|
111 |
$content = self::_buildDiv(self::AT_ABOVE_POST) .
|
112 |
-
self::_buildDiv(self::AT_CONTENT_ABOVE_POST) .
|
113 |
$content;
|
114 |
$content .= self::_buildDiv(self::AT_BELOW_POST);
|
115 |
-
$content .= self::_buildDiv(self::AT_CONTENT_BELOW_POST);
|
116 |
}
|
117 |
} else if (is_category()) {
|
118 |
if($at_flag == '' || $at_flag == '1'){
|
@@ -143,13 +177,17 @@ class Addthis_ToolBox
|
|
143 |
*
|
144 |
* @return string
|
145 |
*/
|
146 |
-
private static function _buildDiv($class)
|
147 |
{
|
148 |
$title = get_the_title();
|
149 |
$url = get_permalink();
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
|
155 |
/**
|
73 |
if ( has_excerpt()) {
|
74 |
add_filter('the_excerpt', array($this, 'addWidget'));
|
75 |
} else {
|
76 |
+
add_filter('get_the_excerpt', array($this, 'addExcerptCode'));
|
77 |
}
|
78 |
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Prepends a 3-letter non-printing code to a raw excerpt string.
|
82 |
+
* The order of the code identifies a type of post (archive, category, etc).
|
83 |
+
*
|
84 |
+
* A piece of javascript later queries for this code, and inserts
|
85 |
+
* sharetoolbox and recommendedbox divs on either side of the excerpt.
|
86 |
+
*
|
87 |
+
* @param string $content Excerpt contents
|
88 |
+
*
|
89 |
+
* @return string
|
90 |
+
*/
|
91 |
+
public function addExcerptCode($content)
|
92 |
+
{
|
93 |
+
if(preg_match('/[\005-\007]{3}/', $content) == false) {
|
94 |
+
//Homepage = 567
|
95 |
+
if (is_home() || is_front_page()) {
|
96 |
+
return chr(5) . chr(6) . chr(7) . $content;
|
97 |
+
//Page = 576
|
98 |
+
} else if (is_page()) {
|
99 |
+
return chr(5) . chr(7) . chr(6) . $content;
|
100 |
+
//Single Post = 675
|
101 |
+
} else if (is_single()) {
|
102 |
+
return chr(6) . chr(7) . chr(5) . $content;
|
103 |
+
//Category = 657
|
104 |
+
} else if (is_category()) {
|
105 |
+
return chr(6) . chr(5) . chr(7) . $content;
|
106 |
+
//Archive = 756
|
107 |
+
} else if (is_archive()) {
|
108 |
+
return chr(7) . chr(5) . chr(6) . $content;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
return $content;
|
112 |
+
}
|
113 |
|
114 |
/**
|
115 |
* Adds toolbox to wp pages
|
143 |
} else if (is_single()) {
|
144 |
if($at_flag == '' || $at_flag == '1'){
|
145 |
$content = self::_buildDiv(self::AT_ABOVE_POST) .
|
146 |
+
self::_buildDiv(self::AT_CONTENT_ABOVE_POST, false) .
|
147 |
$content;
|
148 |
$content .= self::_buildDiv(self::AT_BELOW_POST);
|
149 |
+
$content .= self::_buildDiv(self::AT_CONTENT_BELOW_POST, false);
|
150 |
}
|
151 |
} else if (is_category()) {
|
152 |
if($at_flag == '' || $at_flag == '1'){
|
177 |
*
|
178 |
* @return string
|
179 |
*/
|
180 |
+
private static function _buildDiv($class, $inline_data = true)
|
181 |
{
|
182 |
$title = get_the_title();
|
183 |
$url = get_permalink();
|
184 |
+
if($inline_data == true){
|
185 |
+
return "<div class='".$class." addthis-toolbox at-wordpress-hide'".
|
186 |
+
" data-title='".$title."' data-url='".$url."'>".
|
187 |
+
"</div>";
|
188 |
+
} else {
|
189 |
+
return "<div class='".$class." addthis-toolbox at-wordpress-hide'></div>";
|
190 |
+
}
|
191 |
}
|
192 |
|
193 |
/**
|
addthis_social_widget.php
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
* Plugin Name: AddThis for WordPress
|
24 |
* Plugin URI: http://www.addthis.com
|
25 |
* Description: Use the AddThis suite of website tools which includes sharing, following, recommended content, and conversion tools to help you make your website smarter. With AddThis, you can see how your users are engaging with your content, provide a personalized experience for each user and encourage them to share, subscribe or follow.
|
26 |
-
* Version: 4.0.
|
27 |
*
|
28 |
* Author: The AddThis Team
|
29 |
* Author URI: http://www.addthis.com/blog
|
@@ -32,8 +32,8 @@ if (!defined('ADDTHIS_INIT')) define('ADDTHIS_INIT', 1);
|
|
32 |
else return;
|
33 |
|
34 |
define( 'addthis_style_default' , 'fb_tw_p1_sc');
|
35 |
-
define( 'ADDTHIS_PLUGIN_VERSION' , '4.0.
|
36 |
-
define( 'ADDTHIS_PRODUCT_VERSION' , 'wpp-4.0.
|
37 |
define( 'ADDTHIS_ATVERSION', '300');
|
38 |
define( 'ADDTHIS_ATVERSION_MANUAL_UPDATE', -1);
|
39 |
define( 'ADDTHIS_ATVERSION_AUTO_UPDATE', 0);
|
23 |
* Plugin Name: AddThis for WordPress
|
24 |
* Plugin URI: http://www.addthis.com
|
25 |
* Description: Use the AddThis suite of website tools which includes sharing, following, recommended content, and conversion tools to help you make your website smarter. With AddThis, you can see how your users are engaging with your content, provide a personalized experience for each user and encourage them to share, subscribe or follow.
|
26 |
+
* Version: 4.0.4
|
27 |
*
|
28 |
* Author: The AddThis Team
|
29 |
* Author URI: http://www.addthis.com/blog
|
32 |
else return;
|
33 |
|
34 |
define( 'addthis_style_default' , 'fb_tw_p1_sc');
|
35 |
+
define( 'ADDTHIS_PLUGIN_VERSION' , '4.0.4');
|
36 |
+
define( 'ADDTHIS_PRODUCT_VERSION' , 'wpp-4.0.4');
|
37 |
define( 'ADDTHIS_ATVERSION', '300');
|
38 |
define( 'ADDTHIS_ATVERSION_MANUAL_UPDATE', -1);
|
39 |
define( 'ADDTHIS_ATVERSION_AUTO_UPDATE', 0);
|
includes/addthis_addjs_new.php
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
3 |
/**
|
4 |
* Class for managing AddThis script includes across all its plugins.
|
5 |
*/
|
@@ -155,15 +157,31 @@ Class AddThis_addjs{
|
|
155 |
}
|
156 |
}
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
function addWidgetToJs(){
|
159 |
if (!is_404()) {
|
|
|
|
|
160 |
//Load addthis script only if the page is not 404
|
161 |
$addthis_settings_options = get_option('addthis_settings');
|
162 |
$addthis_asynchronous_loading = (isset($addthis_settings_options['addthis_asynchronous_loading']))?$addthis_settings_options['addthis_asynchronous_loading']:false;
|
163 |
$this->jsToAdd .= '<script type="text/javascript" src="//s7.addthis.com/js/'.$this->atversion.'/addthis_widget.js#pubid='. urlencode( $this->pubid ).'" async="async"></script>';
|
164 |
}
|
165 |
}
|
166 |
-
|
167 |
function addAfterToJs(){
|
168 |
if (! empty($this->jsAfterAdd)) {
|
169 |
$this->jsToAdd .= '<script type="text/javascript">' . $this->jsAfterAdd . '</script>';
|
@@ -218,6 +236,12 @@ Class AddThis_addjs{
|
|
218 |
*/
|
219 |
function save_at_flag(){
|
220 |
global $post;
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
if(isset($_POST['_at_widget']))
|
222 |
update_post_meta($post->ID, '_at_widget', $_POST['_at_widget']);
|
223 |
else
|
1 |
<?php
|
2 |
|
3 |
+
define('ADD_DIVS_TO_CODED_EXCERPTS_PATH', 'js/add-divs-to-coded-excerpts.js');
|
4 |
+
|
5 |
/**
|
6 |
* Class for managing AddThis script includes across all its plugins.
|
7 |
*/
|
157 |
}
|
158 |
}
|
159 |
|
160 |
+
/**
|
161 |
+
* Queries window.document for a 3-letter non-printing code
|
162 |
+
* The order of the code identifies a type of excerpt (archive, category, etc).
|
163 |
+
* Inserts sharetoolbox and recommendedbox divs on either side of the excerpt.
|
164 |
+
*
|
165 |
+
* @alters window.document
|
166 |
+
*/
|
167 |
+
function addDivsToCodedExcerpts() {
|
168 |
+
wp_enqueue_script(
|
169 |
+
'addThisDivScript',
|
170 |
+
plugins_url(ADD_DIVS_TO_CODED_EXCERPTS_PATH, __FILE__)
|
171 |
+
);
|
172 |
+
}
|
173 |
+
|
174 |
function addWidgetToJs(){
|
175 |
if (!is_404()) {
|
176 |
+
$this->addDivsToCodedExcerpts();
|
177 |
+
|
178 |
//Load addthis script only if the page is not 404
|
179 |
$addthis_settings_options = get_option('addthis_settings');
|
180 |
$addthis_asynchronous_loading = (isset($addthis_settings_options['addthis_asynchronous_loading']))?$addthis_settings_options['addthis_asynchronous_loading']:false;
|
181 |
$this->jsToAdd .= '<script type="text/javascript" src="//s7.addthis.com/js/'.$this->atversion.'/addthis_widget.js#pubid='. urlencode( $this->pubid ).'" async="async"></script>';
|
182 |
}
|
183 |
}
|
184 |
+
|
185 |
function addAfterToJs(){
|
186 |
if (! empty($this->jsAfterAdd)) {
|
187 |
$this->jsToAdd .= '<script type="text/javascript">' . $this->jsAfterAdd . '</script>';
|
236 |
*/
|
237 |
function save_at_flag(){
|
238 |
global $post;
|
239 |
+
|
240 |
+
//Ignore if trigger is by theme specific actions without post object
|
241 |
+
if (!isset($post)) {
|
242 |
+
return;
|
243 |
+
}
|
244 |
+
|
245 |
if(isset($_POST['_at_widget']))
|
246 |
update_post_meta($post->ID, '_at_widget', $_POST['_at_widget']);
|
247 |
else
|
includes/js/add-divs-to-coded-excerpts.js
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Retrieves all of the nodes in window.document whose 'data'
|
3 |
+
* attributes contain 3 consecutive ASCII 0x5,0x6,or 0x7
|
4 |
+
*
|
5 |
+
* @return An array of DOM nodes
|
6 |
+
*/
|
7 |
+
function getDocumentNodesWithCode(node) {
|
8 |
+
var descs = [];
|
9 |
+
node = node || document;
|
10 |
+
if(node) {
|
11 |
+
var childNodes = node.childNodes;
|
12 |
+
for(var i=0; i<childNodes.length; i++) {
|
13 |
+
var childNode = childNodes[i];
|
14 |
+
var data = childNode.data;
|
15 |
+
if(data && data.match && data.match(/[\005-\007]{3}/g)) {
|
16 |
+
descs.push(childNode);
|
17 |
+
}
|
18 |
+
descs = descs.concat(getDocumentNodesWithCode(childNode));
|
19 |
+
}
|
20 |
+
}
|
21 |
+
return descs;
|
22 |
+
};
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Queries window.document for a 3-letter non-printing code
|
26 |
+
* The order of the code identifies a type of excerpt (archive, category, etc).
|
27 |
+
* Inserts sharetoolbox and recommendedbox divs on either side of the excerpt.
|
28 |
+
*
|
29 |
+
* @alters window.document
|
30 |
+
*/
|
31 |
+
function addDivsToCodedExcerpts() {
|
32 |
+
var excerptNodes = getDocumentNodesWithCode();
|
33 |
+
for(var i=0; i<excerptNodes.length; i++) {
|
34 |
+
var excerptNode = excerptNodes[i];
|
35 |
+
var excerptCode = excerptNode.data.substring(0,3);
|
36 |
+
var suffix = "";
|
37 |
+
|
38 |
+
if(excerptCode === String.fromCharCode(5,6,7)) {
|
39 |
+
suffix = "-homepage";
|
40 |
+
} else if(excerptCode === String.fromCharCode(5,7,6)) {
|
41 |
+
suffix = "-page";
|
42 |
+
} else if(excerptCode === String.fromCharCode(6,7,5)) {
|
43 |
+
suffix = "";
|
44 |
+
} else if(excerptCode === String.fromCharCode(6,5,7)) {
|
45 |
+
suffix = "-cat-page";
|
46 |
+
} else if(excerptCode === String.fromCharCode(7,5,6)) {
|
47 |
+
suffix = "-arch-page";
|
48 |
+
}
|
49 |
+
|
50 |
+
var parentElement = excerptNode.parentElement;
|
51 |
+
|
52 |
+
var above = document.createElement("div");
|
53 |
+
above.className = "at-above-post" + suffix;
|
54 |
+
|
55 |
+
var below = document.createElement("div");
|
56 |
+
below.className = "at-below-post" + suffix;
|
57 |
+
|
58 |
+
var aboveRecommended = document.createElement("div");
|
59 |
+
aboveRecommended.className = "at-above-post" + suffix + "-recommended";
|
60 |
+
|
61 |
+
var belowRecommended = document.createElement("div");
|
62 |
+
belowRecommended.className = "at-below-post" + suffix + "-recommended";
|
63 |
+
|
64 |
+
parentElement.appendChild(below);
|
65 |
+
parentElement.appendChild(belowRecommended);
|
66 |
+
|
67 |
+
parentElement.insertBefore(
|
68 |
+
above, parentElement.childNodes[0]);
|
69 |
+
parentElement.insertBefore(
|
70 |
+
aboveRecommended, parentElement.childNodes[0]);
|
71 |
+
|
72 |
+
excerptNode.data = excerptNode.data.replace(/[\005-\007]/g, "");
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
addDivsToCodedExcerpts();
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: srijith.v, solchea, _mjk_, addthis_paul, abramsm
|
|
3 |
Tags: AddThis, addtoany, bookmark, bookmarking, email, e-mail, sharing buttons, share, share this, facebook, google+, pinterest, instagram, linkedin, whatsapp, social tools, website tools, twitter, content marketing, recommended content, conversion tool, subscription button, conversion tools, email tools, ecommerce tools, social marketing, personalization tools
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.1
|
6 |
-
Stable tag: 4.0.
|
7 |
|
8 |
AddThis provides the best sharing, social, recommended content, and conversion tools to help you make
|
9 |
your website smarter.
|
@@ -82,18 +82,34 @@ PHP 5+ is preferred; PHP 4 is supported.
|
|
82 |
|
83 |
== Changelog ==
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
= 4.0.3 =
|
86 |
-
*
|
|
|
87 |
|
88 |
= 4.0.2 =
|
89 |
* Control inline share buttons for each page/post
|
90 |
-
*
|
|
|
|
|
|
|
|
|
91 |
|
92 |
= 4.0.1 =
|
93 |
-
* Frictionless integration with AddThis Dashboard.
|
|
|
|
|
|
|
94 |
|
95 |
= 4.0 =
|
96 |
-
* Integrated with AddThis Dashboard.
|
|
|
|
|
97 |
|
98 |
= 3.5.10 =
|
99 |
* Minor bug fix
|
@@ -283,18 +299,34 @@ Fixed nondeterministic bug with the_title(), causing the title to occasionally a
|
|
283 |
|
284 |
== Upgrade Notice ==
|
285 |
|
286 |
-
= 4.0.
|
287 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
= 4.0.2 =
|
290 |
* Control inline share buttons for each page/post
|
291 |
-
*
|
|
|
|
|
|
|
|
|
292 |
|
293 |
= 4.0.1 =
|
294 |
-
*
|
|
|
|
|
|
|
295 |
|
296 |
= 4.0 =
|
297 |
-
*
|
|
|
|
|
298 |
|
299 |
= 3.5.10 =
|
300 |
* Minor bug fix
|
3 |
Tags: AddThis, addtoany, bookmark, bookmarking, email, e-mail, sharing buttons, share, share this, facebook, google+, pinterest, instagram, linkedin, whatsapp, social tools, website tools, twitter, content marketing, recommended content, conversion tool, subscription button, conversion tools, email tools, ecommerce tools, social marketing, personalization tools
|
4 |
Requires at least: 3.0
|
5 |
Tested up to: 4.1
|
6 |
+
Stable tag: 4.0.4
|
7 |
|
8 |
AddThis provides the best sharing, social, recommended content, and conversion tools to help you make
|
9 |
your website smarter.
|
82 |
|
83 |
== Changelog ==
|
84 |
|
85 |
+
= 4.0.4 =
|
86 |
+
* Fixed issues with certain themes using get_the_excerpt method
|
87 |
+
* Fixed issue with Share layer and Recommended layer showing up in wrong order
|
88 |
+
* Fixed issue with Recommended layer showing up page title instead of Recommended layer title
|
89 |
+
* Fixed PHP warnings in Divi theme
|
90 |
+
|
91 |
= 4.0.3 =
|
92 |
+
* Removed addthis initialization function (addthis.init()) to avoid javascript error in async mode.
|
93 |
+
* Added option to show inline sharing buttons on category and archive pages
|
94 |
|
95 |
= 4.0.2 =
|
96 |
* Control inline share buttons for each page/post
|
97 |
+
* Implemented asynchronous script loading
|
98 |
+
* Added option to add checkbox to show/hide Addthis sharing buttons in admin post add/edit page.
|
99 |
+
* Prevented buttons showing on 404 error pages
|
100 |
+
* CSS fixes
|
101 |
+
* Added css classes to prevent inline div from taking extra spaces
|
102 |
|
103 |
= 4.0.1 =
|
104 |
+
* Frictionless integration with AddThis Dashboard.
|
105 |
+
* Updated services list in description
|
106 |
+
* Added new snapshots to give more idea on the new plugin flow
|
107 |
+
* Minor text changes
|
108 |
|
109 |
= 4.0 =
|
110 |
+
* Integrated with AddThis Dashboard.
|
111 |
+
* Managed the plugin in such a way that, tool settings can be controlled from AddThis Dashboard
|
112 |
+
* Provided options to upgrade to new setup for the existing users
|
113 |
|
114 |
= 3.5.10 =
|
115 |
* Minor bug fix
|
299 |
|
300 |
== Upgrade Notice ==
|
301 |
|
302 |
+
= 4.0.4 =
|
303 |
+
* Fixed issues with certain themes using get_the_excerpt method
|
304 |
+
* Fixed issue with Share layer and Recommended layer showing up in wrong order
|
305 |
+
* Fixed issue with Recommended layer showing up page title instead of Recommended layer title
|
306 |
+
* Fixed PHP warnings in Divi theme
|
307 |
+
|
308 |
+
= 4.0.3 =
|
309 |
+
* Removed addthis initialization function (addthis.init()) to avoid javascript error in async mode.
|
310 |
+
* Added option to show inline sharing buttons on category and archive pages
|
311 |
|
312 |
= 4.0.2 =
|
313 |
* Control inline share buttons for each page/post
|
314 |
+
* Implemented asynchronous script loading
|
315 |
+
* Added option to add checkbox to show/hide Addthis sharing buttons in admin post add/edit page.
|
316 |
+
* Prevented buttons showing on 404 error pages
|
317 |
+
* CSS fixes
|
318 |
+
* Added css classes to prevent inline div from taking extra spaces
|
319 |
|
320 |
= 4.0.1 =
|
321 |
+
* Frictionless integration with AddThis Dashboard.
|
322 |
+
* Updated services list in description
|
323 |
+
* Added new snapshots to give more idea on the new plugin flow
|
324 |
+
* Minor text changes
|
325 |
|
326 |
= 4.0 =
|
327 |
+
* Integrated with AddThis Dashboard.
|
328 |
+
* Managed the plugin in such a way that, tool settings can be controlled from AddThis Dashboard
|
329 |
+
* Provided options to upgrade to new setup for the existing users
|
330 |
|
331 |
= 3.5.10 =
|
332 |
* Minor bug fix
|