Better Click To Tweet - Version 4.10

Version Description

  • enhancement added a 'prompt' shortcode attribute, so not you can change the words "Click To Tweet" on a per-box basis. Thanks to @apearlman on the Wordpress.org support forums for the suggestion!
  • fix changed the way the shortcode attributes are called, because my IDE kept throwing strange errors because the code wasn't clean enough.
  • fix removed some unused local variables because I used to not know how to code things good.
  • dream thought about ways to monetize this plugin, but ultimately decided against it for now, because I hate dashboard nags. But if you like it, donate: http://benlikes.us/donate
  • change decided to go with 4.10 instead of 5.0 in an attempt to move toward a version numbering system that makes sense, because I have learned much since 0.X --> 1.0.
  • just for kicks and totally unrelated wrote a cool post about rolling back WordPress plugins: http://benlikes.us/fk
Download this release

Release Info

Developer ben.meredith@gmail.com
Plugin Icon 128x128 Better Click To Tweet
Version 4.10
Comparing to
See all releases

Code changes from version 4.9 to 4.10

Files changed (2) hide show
  1. better-click-to-tweet.php +17 -19
  2. readme.txt +11 -3
better-click-to-tweet.php CHANGED
@@ -2,7 +2,7 @@
2
/*
3
Plugin Name: Better Click To Tweet
4
Description: Add Click to Tweet boxes simply and elegantly to your posts or pages. All the features of a premium plugin, for FREE!
5
- Version: 4.9
6
Author: Ben Meredith
7
Author URI: https://www.wpsteward.com
8
Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
@@ -82,18 +82,19 @@ function bctt_shorten( $input, $length, $ellipsis = true, $strip_html = true ) {
82
83
function bctt_shortcode( $atts ) {
84
85
- extract( shortcode_atts( array(
86
'tweet' => '',
87
'via' => 'yes',
88
'username' => 'not-a-real-user',
89
'url' => 'yes',
90
'nofollow' => 'no',
91
- ), $atts ) );
92
93
//since 4.7: adds option to add in a per-box username to the tweet
94
- if ( $username != 'not-a-real-user' ) {
95
96
- $handle = $username;
97
98
} else {
99
@@ -111,7 +112,7 @@ function bctt_shortcode( $atts ) {
111
112
}
113
114
- if ( ! empty( $handle ) && $via != 'no' ) {
115
116
$handle_code = "&via=" . $handle . "&related=" . $handle;
117
@@ -121,21 +122,20 @@ function bctt_shortcode( $atts ) {
121
122
}
123
124
- if ( $via != 'yes' ) {
125
126
- $handle = '';
127
$handle_code = '';
128
$handle_length = 0;
129
130
}
131
132
- $text = $tweet;
133
134
- if ( filter_var( $url, FILTER_VALIDATE_URL ) ) {
135
136
- $bcttURL = '&url=' . $url;
137
138
- } elseif ( $url != 'no' ) {
139
140
if ( get_option( 'bctt-short-url' ) != false ) {
141
@@ -153,9 +153,7 @@ function bctt_shortcode( $atts ) {
153
154
}
155
156
- $bcttBttn = sprintf( _x( 'Click To Tweet', 'Text for the box on the reader-facing box', 'better-click-to-tweet' ) );
157
-
158
- if ( $url != 'no' ) {
159
160
$short = bctt_shorten( $text, ( 117 - ( $handle_length ) ) );
161
@@ -165,7 +163,7 @@ function bctt_shortcode( $atts ) {
165
166
}
167
168
- if ( $nofollow != 'no' ) {
169
170
$rel = "rel='nofollow'";
171
@@ -181,12 +179,12 @@ function bctt_shortcode( $atts ) {
181
182
if ( ! is_feed() ) {
183
184
- return "<span class='" . $bctt_span_class . "'><span class='" . $bctt_text_span_class . "'><a href='https://twitter.com/intent/tweet?text=" . rawurlencode( html_entity_decode( $short ) ) . $handle_code . $bcttURL . "' target='_blank'" . $rel . ">" . $short . " </a></span><a href='https://twitter.com/intent/tweet?text=" . rawurlencode( html_entity_decode( $short ) ) . $handle_code . $bcttURL . "' target='_blank' class='" . $bctt_button_span_class ."'" . $rel . ">" . $bcttBttn . "</a></span>";
185
} else {
186
187
- return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . rawurlencode( html_entity_decode( $short ) ) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'" . $rel . ">" . $bcttBttn . "</a><br /><hr />";
188
189
- };
190
}
191
192
add_shortcode( 'bctt', 'bctt_shortcode' );
2
/*
3
Plugin Name: Better Click To Tweet
4
Description: Add Click to Tweet boxes simply and elegantly to your posts or pages. All the features of a premium plugin, for FREE!
5
+ Version: 4.10
6
Author: Ben Meredith
7
Author URI: https://www.wpsteward.com
8
Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
82
83
function bctt_shortcode( $atts ) {
84
85
+ $atts = shortcode_atts( array(
86
'tweet' => '',
87
'via' => 'yes',
88
'username' => 'not-a-real-user',
89
'url' => 'yes',
90
'nofollow' => 'no',
91
+ 'prompt' => sprintf( _x( 'Click To Tweet', 'Text for the box on the reader-facing box', 'better-click-to-tweet' ) )
92
+ ), $atts, 'bctt' );
93
94
//since 4.7: adds option to add in a per-box username to the tweet
95
+ if ( $atts['username'] != 'not-a-real-user' ) {
96
97
+ $handle = $atts['username'];
98
99
} else {
100
112
113
}
114
115
+ if ( ! empty( $handle ) && $atts['via'] != 'no' ) {
116
117
$handle_code = "&amp;via=" . $handle . "&amp;related=" . $handle;
118
122
123
}
124
125
+ if ( $atts['via'] != 'yes' ) {
126
127
$handle_code = '';
128
$handle_length = 0;
129
130
}
131
132
+ $text = $atts['tweet'];
133
134
+ if ( filter_var( $atts['url'], FILTER_VALIDATE_URL ) ) {
135
136
+ $bcttURL = '&amp;url=' . $atts['url'];
137
138
+ } elseif ( $atts['url'] != 'no' ) {
139
140
if ( get_option( 'bctt-short-url' ) != false ) {
141
153
154
}
155
156
+ if ( $atts['url'] != 'no' ) {
157
158
$short = bctt_shorten( $text, ( 117 - ( $handle_length ) ) );
159
163
164
}
165
166
+ if ( $atts['nofollow'] != 'no' ) {
167
168
$rel = "rel='nofollow'";
169
179
180
if ( ! is_feed() ) {
181
182
+ return "<span class='" . $bctt_span_class . "'><span class='" . $bctt_text_span_class . "'><a href='https://twitter.com/intent/tweet?text=" . rawurlencode( html_entity_decode( $short ) ) . $handle_code . $bcttURL . "' target='_blank'" . $rel . ">" . $short . " </a></span><a href='https://twitter.com/intent/tweet?text=" . rawurlencode( html_entity_decode( $short ) ) . $handle_code . $bcttURL . "' target='_blank' class='" . $bctt_button_span_class ."'" . $rel . ">" . $atts['prompt'] . "</a></span>";
183
} else {
184
185
+ return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . rawurlencode( html_entity_decode( $short ) ) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'" . $rel . ">" . $atts['prompt'] . "</a><br /><hr />";
186
187
+ }
188
}
189
190
add_shortcode( 'bctt', 'bctt_shortcode' );
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
=== Better Click To Tweet ===
2
- Contributors: ben.meredith@gmail.com
3
Donate link: https://www.wpsteward.com/donations/plugin-support/
4
Tags: click to tweet, twitter, tweet,
5
Requires at least: 3.8
6
- Tested up to: 4.6
7
- Stable tag: 4.9
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -103,6 +103,14 @@ Donations: http://benlikes.us/donate
103
104
== Changelog ==
105
106
= 4.9 =
107
* enhancement - Made the function that registers and enqueues the scripts filterable, so that developers who want to put all styles for Better Click To Tweet boxes in their theme files are able to do so using this snippet: https://gist.github.com/Benunc/533985231bbfde551d019620f628a921
108
* two updates in a row with no love for the non developer, but MUCH love for the developer. Trust me, this one is big time for CSS developers to be able to add styles to themes.
1
=== Better Click To Tweet ===
2
+ Contributors: ben.meredith@gmail.com, wpsteward
3
Donate link: https://www.wpsteward.com/donations/plugin-support/
4
Tags: click to tweet, twitter, tweet,
5
Requires at least: 3.8
6
+ Tested up to: 4.7
7
+ Stable tag: 4.10
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
103
104
== Changelog ==
105
106
+ = 4.10 =
107
+ * enhancement — added a 'prompt' shortcode attribute, so not you can change the words "Click To Tweet" on a per-box basis. Thanks to @apearlman on the Wordpress.org support forums for the suggestion!
108
+ * fix — changed the way the shortcode attributes are called, because my IDE kept throwing strange errors because the code wasn't clean enough.
109
+ * fix — removed some unused local variables because I used to not know how to code things good.
110
+ * dream — thought about ways to monetize this plugin, but ultimately decided against it for now, because I hate dashboard nags. But if you like it, donate: http://benlikes.us/donate
111
+ * change — decided to go with 4.10 instead of 5.0 in an attempt to move toward a version numbering system that makes sense, because I have learned much since 0.X --> 1.0.
112
+ * just for kicks and totally unrelated — wrote a cool post about rolling back WordPress plugins: http://benlikes.us/fk
113
+
114
= 4.9 =
115
* enhancement - Made the function that registers and enqueues the scripts filterable, so that developers who want to put all styles for Better Click To Tweet boxes in their theme files are able to do so using this snippet: https://gist.github.com/Benunc/533985231bbfde551d019620f628a921
116
* two updates in a row with no love for the non developer, but MUCH love for the developer. Trust me, this one is big time for CSS developers to be able to add styles to themes.