Better Click To Tweet - Version 5.1

Version Description

  • enhancement I added a highly dismissable notice to the plugins page upon update, encouraging people to purchase my Premium styles add-on. The notice only shows to folks who have not previously customized their own styles, and once dismissed will never be shown to that user again.
  • enhancement I made several changes to the readme file so that the plugin is showcased nicely in the WordPress Plugin Directory's new design.
Download this release

Release Info

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

Code changes from version 5.0.2 to 5.1

admin-nags.php ADDED
@@ -0,0 +1,117 @@
1
+ <?php
2
+
3
+ function bctt_alerts() {
4
+ if (is_plugin_active('better-click-to-tweet-premium-styles/better-click-to-tweet-premium-styles.php')) {
5
+ return;
6
+ }
7
+
8
+ $screen = get_current_screen();
9
+
10
+ $screenparent = $screen->parent_file;
11
+
12
+
13
+ if ( $screenparent == 'plugins.php' && current_user_can( 'install_plugins' ) ) {
14
+
15
+ $user_id = wp_get_current_user()->ID;
16
+ $has_dismissed = get_user_meta( $user_id, 'bctt_has_dismissed_nag', true );
17
+
18
+ if ( ! $has_dismissed && ! bctt_add_custom_style_option() ) {
19
+ //add style inline so that it isn't enqueued if not used
20
+ ?>
21
+ <style>
22
+ span.bctt-addon-nag-header {
23
+ font-size: large;
24
+ font-weight: bold;
25
+ }
26
+
27
+ .updated.bctt-addon-nag {
28
+ padding: 1em;
29
+ }
30
+
31
+ p.bctt-addon-nag-copy {
32
+
33
+ }
34
+
35
+ ul.bctt-addon-nag-list {
36
+ list-style-type: none;
37
+ margin-left: 2em;
38
+ }
39
+
40
+ .bctt-addon-nag-list li:before {
41
+ content: "\f155";
42
+ display: inline-block;
43
+ -webkit-font-smoothing: antialiased;
44
+ font: normal 16px/1 'dashicons';
45
+ color: #46b450;
46
+ margin-right: 10px;
47
+ word-wrap: break-word;
48
+ }
49
+
50
+ .bctt-addon-nag-dismiss {
51
+ float: right;
52
+ text-decoration: none;
53
+ }
54
+ .bctt-nag-photo {
55
+ float: right;
56
+ margin:0;
57
+ max-height:105px;
58
+ max-width:98%;
59
+ }
60
+ @media screen and (max-width: 782px) {
61
+ .bctt-nag-photo {
62
+ float:none;
63
+ }
64
+ }
65
+ .bctt-nag-purchase-link {
66
+ font-size: large;
67
+ }
68
+ </style>
69
+ <div class="updated bctt-addon-nag">
70
+
71
+ <a href="<?php
72
+ //The Dismiss Button.
73
+ $nag_meta_key = 'bctt_has_dismissed_nag';
74
+ $nag_admin_dismiss_url = 'plugins.php?' . $nag_meta_key . '=0';
75
+ echo admin_url( $nag_admin_dismiss_url ); ?>" class="dismiss bctt-addon-nag-dismiss">Dismiss this <span
76
+ class="dashicons dashicons-dismiss"></span></a>
77
+ <h3
78
+ class="bctt-addon-nag-header"><?php esc_html_e( 'Add Premium Style to your Better Click To Tweet boxes!', 'better-click-to-tweet' ) ?></h3>
79
+
80
+ <a href="http://benlikes.us/bcttnag"
81
+ target="_blank"><img class="bctt-nag-photo" src="<?php echo plugins_url() . '/better-click-to-tweet/assets/img/premium_style.png'?>"/></a>
82
+
83
+ <p class="bctt-addon-nag-copy"><?php esc_attr_e( 'Choose from multiple options when styling your Better Click To Tweet boxes, with no code.', 'better-click-to-tweet' ) ?></p>
84
+ <ul class="bctt-addon-nag-list">
85
+ <li><?php esc_html_e( 'Make your Better Click To Tweet boxes stand out.', 'better-click-to-tweet' ) ?></li>
86
+ <li><?php esc_html_e( 'Get more clicks and tweets.', 'better-click-to-tweet' ) ?></li>
87
+ <li><?php esc_html_e( 'Support the development of Better Click To Tweet!', 'better-click-to-tweet' ) ?></li>
88
+ </ul>
89
+ <p class="bctt-addon-nag-copy">
90
+ <a class="bctt-nag-purchase-link" href="http://benlikes.us/bcttnag"
91
+ target="_blank"><?php esc_html_e( 'Purchase it today', 'better-click-to-tweet' ) ?></a> <?php esc_html_e( 'Save 8% with the code NAGSareTHEbest', 'better-click-to-tweet') ?></p>
92
+ </div>
93
+ <?php
94
+ }
95
+ }
96
+ }
97
+
98
+ add_action( 'admin_notices', 'bctt_alerts' );
99
+
100
+ function bctt_addon_notice_ignore() {
101
+
102
+ /**
103
+ * If user clicks to ignore the notice, add that to their user meta the banner then checks whether this tag exists already or not.
104
+ * See here: http://codex.wordpress.org/Function_Reference/add_user_meta
105
+ */
106
+
107
+ if ( isset( $_GET['bctt_has_dismissed_nag'] ) && '0' == $_GET['bctt_has_dismissed_nag'] ) {
108
+
109
+ //Get the global user
110
+ $current_user = wp_get_current_user();
111
+ $user_id = $current_user->ID;
112
+
113
+ add_user_meta( $user_id, 'bctt_has_dismissed_nag', 'true', true );
114
+ }
115
+ }
116
+
117
+ add_action( 'current_screen', 'bctt_addon_notice_ignore' );
assets/img/premium_style.png ADDED
Binary file
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: 5.0.2
6
Author: Ben Meredith
7
Author URI: https://www.wpsteward.com
8
Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
@@ -12,7 +12,7 @@ Text Domain: better-click-to-tweet
12
include 'i18n-module.php';
13
include 'bctt_options.php';
14
include 'bctt-i18n.php';
15
-
16
17
defined( 'ABSPATH' ) or die( "No soup for you. You leave now." );
18
@@ -26,6 +26,7 @@ defined( 'ABSPATH' ) or die( "No soup for you. You leave now." );
26
* @param bool $strip_html ensures that html is stripped from text string
27
*/
28
29
function bctt_shorten( $input, $length, $ellipsis = true, $strip_html = true ) {
30
31
if ( $strip_html ) {
@@ -82,14 +83,14 @@ function bctt_shorten( $input, $length, $ellipsis = true, $strip_html = true ) {
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' ) {
@@ -179,12 +180,13 @@ function bctt_shortcode( $atts ) {
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' );
@@ -256,9 +258,12 @@ function bctt_on_uninstall() {
256
257
remove_shortcode( 'bctt' );
258
259
}
260
261
- ;
262
263
register_uninstall_hook( __FILE__, 'bctt_on_uninstall' );
264
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: 5.1
6
Author: Ben Meredith
7
Author URI: https://www.wpsteward.com
8
Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
12
include 'i18n-module.php';
13
include 'bctt_options.php';
14
include 'bctt-i18n.php';
15
+ include 'admin-nags.php';
16
17
defined( 'ABSPATH' ) or die( "No soup for you. You leave now." );
18
26
* @param bool $strip_html ensures that html is stripped from text string
27
*/
28
29
+
30
function bctt_shorten( $input, $length, $ellipsis = true, $strip_html = true ) {
31
32
if ( $strip_html ) {
83
84
function bctt_shortcode( $atts ) {
85
86
+ $atts = shortcode_atts( apply_filters( 'bctt_atts', array(
87
'tweet' => '',
88
'via' => 'yes',
89
'username' => 'not-a-real-user',
90
'url' => 'yes',
91
'nofollow' => 'no',
92
'prompt' => sprintf( _x( 'Click To Tweet', 'Text for the box on the reader-facing box', 'better-click-to-tweet' ) )
93
+ ) ), $atts, 'bctt' );
94
95
//since 4.7: adds option to add in a per-box username to the tweet
96
if ( $atts['username'] != 'not-a-real-user' ) {
180
181
if ( ! is_feed() ) {
182
183
+ $output = "<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>";
184
} else {
185
186
+ $output = "<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 />";
187
188
}
189
+ return apply_filters( 'bctt_output', $output, $short, $bctt_button_span_class, $bctt_span_class, $bctt_text_span_class, $bcttURL, $handle_code, $rel, $atts );
190
}
191
192
add_shortcode( 'bctt', 'bctt_shortcode' );
258
259
remove_shortcode( 'bctt' );
260
261
+ delete_metadata( 'user', 0, 'bctt_has_dismissed_nag', '', true );
262
+
263
+
264
}
265
266
+
267
268
register_uninstall_hook( __FILE__, 'bctt_on_uninstall' );
269
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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: 5.0.2
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -12,7 +12,7 @@ Insert click to tweet boxes into your posts, simply and securely. This plugin is
12
13
== Description ==
14
15
- = The Best Click To Tweet Plugin on the Market, FREE! =
16
17
This plugin allows you to easily create tweetable content for your readers. Using a simple shortcode, your selected text is highlighted and made tweetable.
18
@@ -48,7 +48,12 @@ Translation is now managed at [the official WordPress translation page](https://
48
49
== Frequently Asked Questions ==
50
51
- = How Does Better Click To Tweet Work? =
52
Better Click To Tweet enables you to create beautiful Click To Tweet boxes in your blog posts. Once you've installed and activated the plugin, click on the settings link to put in your Twitter username, and save the settings.
53
54
Then, wherever you want to insert a Click to Tweet quote, use a shortcode in the format `[bctt tweet="xxxxxxxxxxxx"]` replacing the `xxxxxxx` with your tweetable quote.
@@ -76,21 +81,14 @@ On the settings page for Better Click To Tweet, simply check the box indicating
76
77
If you run into any issues with my plugin not working alongside a certain link shortener, start a [support thread](https://wordpress.org/support/plugin/better-click-to-tweet "support forum") and include a link to the other plugin. I'll see what I can do to work with the other developer.
78
79
- I've also written a tutorial at http://benlikes.us/79 for how to set up the shortlinks with bit.ly and yourls.org.
80
81
= Are there any other hidden tricks? =
82
- Yes! Because I want the majority of users (who aren't as concerned with options like nofollow links and getting rid of the URL in the tweet) to be happy, most options are hidden. I've written a tutorial for using those advanced options over at http://benlikes.us/7r
83
84
= What do I do if it's not working right? =
85
I am active in [the support forums](https://wordpress.org/support/plugin/better-click-to-tweet "BCTT Support"), and in patching the plugin. Start a thread there, and I will gladly help you out. Most of the time you can expect a day or two before a response. I'm in the eastern US, and I like playing with my kids at night, so you might not hear back immediately. Don't panic.
86
87
- = What are the differences between this plugin and Click To Tweet by Todaymade? =
88
- I originally was planning on contacting Justin at Todaymade to suggest some improvements to the code on his plugin, and in the midst of that, his plugin was unexpectedly pulled from the official repository, for having a (frowned upon) "Powered By" link. So, I set about fully overhauling the plugin.
89
-
90
- Since that time Justin and the team over at Todaymade have rereleased a version of their plugin without the "Powered By" link. His plugin (which was originally released before the advent of the shortcode API) still doesn't use it, and for that reason is less secure than mine. For him to change to support the shortcode API is a more complicated issue, as he'll need to still provide support for how his plugin currently handles the pseudo-shortcode system, or risk breaking every current user's website.
91
-
92
- I've pushed out many releases with bug fixes, improvements, and additional functionality, while the other plugin remains unchanged. There's no way in which my plugin doesn't live up to it's name.
93
-
94
= How can I help? =
95
Translations: https://translate.wordpress.org/projects/wp-plugins/better-click-to-tweet
96
Pull Requests: https://github.com/Benunc/better-click-to-tweet
@@ -103,6 +101,10 @@ Donations: http://benlikes.us/donate
103
104
== Changelog ==
105
106
= 5.0.2 =
107
* fix — I was incorrectly calling translation module, breaking things when people updated to the latest version of Yoast SEO.
108
4
Tags: click to tweet, twitter, tweet,
5
Requires at least: 3.8
6
Tested up to: 4.7
7
+ Stable tag: 5.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
12
13
== Description ==
14
15
+ = The most popular Click To Tweet Plugin for WordPress, for good reason. =
16
17
This plugin allows you to easily create tweetable content for your readers. Using a simple shortcode, your selected text is highlighted and made tweetable.
18
48
49
== Frequently Asked Questions ==
50
51
+ = Are there other style options? =
52
+ Yes! If you are a developer, there are [limitless options for styling](http://benlikes.us/bcttcustom "custom style for Better Click To Tweet").
53
+
54
+ If you are not a developer, I have released a premium add-on for selecting among several (and growing) different style options. Check out [Premium Styles](http://benlikes.us/bcttps "Premium Styles for Better Click To Tweet")
55
+
56
+ = How does Better Click To Tweet work? =
57
Better Click To Tweet enables you to create beautiful Click To Tweet boxes in your blog posts. Once you've installed and activated the plugin, click on the settings link to put in your Twitter username, and save the settings.
58
59
Then, wherever you want to insert a Click to Tweet quote, use a shortcode in the format `[bctt tweet="xxxxxxxxxxxx"]` replacing the `xxxxxxx` with your tweetable quote.
81
82
If you run into any issues with my plugin not working alongside a certain link shortener, start a [support thread](https://wordpress.org/support/plugin/better-click-to-tweet "support forum") and include a link to the other plugin. I'll see what I can do to work with the other developer.
83
84
+ I've also written [a tutorial](http://benlikes.us/79 "shortlink tutorial") for how to set up the shortlinks with bit.ly and yourls.org.
85
86
= Are there any other hidden tricks? =
87
+ Yes! Because I want the majority of users (who aren't as concerned with options like nofollow links and getting rid of the URL in the tweet) to be happy, most options are hidden. I've written [a tutorial for using those advanced options](http://benlikes.us/7r "power user guide")
88
89
= What do I do if it's not working right? =
90
I am active in [the support forums](https://wordpress.org/support/plugin/better-click-to-tweet "BCTT Support"), and in patching the plugin. Start a thread there, and I will gladly help you out. Most of the time you can expect a day or two before a response. I'm in the eastern US, and I like playing with my kids at night, so you might not hear back immediately. Don't panic.
91
92
= How can I help? =
93
Translations: https://translate.wordpress.org/projects/wp-plugins/better-click-to-tweet
94
Pull Requests: https://github.com/Benunc/better-click-to-tweet
101
102
== Changelog ==
103
104
+ = 5.1 =
105
+ * enhancement — I added a highly dismissable notice to the plugins page upon update, encouraging people to purchase my Premium styles add-on. The notice only shows to folks who have not previously customized their own styles, and once dismissed will never be shown to that user again.
106
+ * enhancement — I made several changes to the readme file so that the plugin is showcased nicely in the WordPress Plugin Directory's new design.
107
+
108
= 5.0.2 =
109
* fix — I was incorrectly calling translation module, breaking things when people updated to the latest version of Yoast SEO.
110