Better Click To Tweet - Version 2.0

Version Description

  • Major version release for internationalization: added Spanish (ES) translation, and updated code throughout for internationalization. Still to-do: add translation support for the tinymce plugin on the visual editor.
Download this release

Release Info

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

Code changes from version 1.0 to 2.0

bctt-i18n.php ADDED
@@ -0,0 +1,7 @@
1
+ <?php
2
+
3
+ add_action( 'plugins_loaded', 'bctt_load_textdomain' );
4
+
5
+ function bctt_load_textdomain() {
6
+ load_plugin_textdomain( 'better-click-to-tweet', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
7
+ }
bctt_options.php CHANGED
@@ -29,11 +29,11 @@ function bctt_tinymce_register_button($buttons) {
29
}
30
31
function bctt_tinymce_register_plugin($plugin_array) {
32
- $plugin_array['bctt_clicktotweet'] = plugins_url( '/assets/js/bctt_clicktotweet_plugin.js', __FILE__);
33
return $plugin_array;
34
}
35
36
-
37
function bctt_admin_menu() {
38
add_action('admin_init', 'bctt_register_settings');
39
add_options_page('Better Click To Tweet Options', 'Better Click To Tweet', 'manage_options', 'better-click-to-tweet', 'bctt_settings_page');
@@ -49,7 +49,7 @@ function bctt_validate_settings($input) {
49
50
function bctt_settings_page() {
51
if ( !current_user_can( 'manage_options' ) ) {
52
- wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
53
} ?>
54
55
<div class="wrap">
@@ -59,23 +59,23 @@ function bctt_settings_page() {
59
60
<hr/>
61
62
- <h2>Instructions</h2>
63
<p>
64
- To add styled click-to-tweet quote boxes include the Better Click To Tweet shortcode in your post.</p>
65
- <p>Here's how you format the shortcode: <pre>[bctt tweet="Meaningful, tweetable quote."]</pre></p>
66
- <p>If you are using the visual editor, click the BCTT birdie in the toolbar to add a pre-formatted shortcode to your post.</p>
67
- <p>Tweet length will be automatically shortened to 117 characters minus the length of your twitter name, to leave room for it and a link back to the post.
68
</p>
69
70
- <h2>Settings</h2>
71
72
- <p>Enter your Twitter handle to add "via @yourhandle" to your tweets. Do not include the @ symbol.</p>
73
<form method="post" action="options.php" style="display: inline-block;">
74
<?php settings_fields( 'bctt_clicktotweet-options' ); ?>
75
76
<table class="form-table">
77
<tr valign="top">
78
- <th style="width: 200px;"><label>Your Twitter Handle</label></th>
79
<td><input type="text" name="bctt-twitter-handle" value="<?php echo get_option('bctt-twitter-handle'); ?>" /></td>
80
</tr>
81
<tr>
@@ -85,11 +85,11 @@ function bctt_settings_page() {
85
</form>
86
87
<hr/>
88
- <em>An open source plugin by <a href="http://benandjacq.com" target="_blank">Ben Meredith</a></em>
89
- <p>Are you a developer? Help make it the (even) Better Click To Tweet plugin. Check out the <a target="_blank" href="https://github.com/Benunc/better-click-to-tweet">plugin on Github.</a></p>
90
- <p>The best way you can support this and other plugins is to <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ" target="_blank">donate</a>. The second best way is to <a href="https://wordpress.org/support/view/plugin-reviews/better-click-to-tweet" target="_blank">leave an honest review.</a></p>
91
- <p>Did this plugin save you enough time to be worth $3?</p>
92
- <p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ" target="_blank">Click here to buy me a Coke to say thanks.</a></p>
93
</div>
94
<?php
95
}
29
}
30
31
function bctt_tinymce_register_plugin($plugin_array) {
32
+ $plugin_array['better_click_to_tweet'] = plugins_url( '/assets/js/bctt_clicktotweet_plugin.js', __FILE__);
33
return $plugin_array;
34
}
35
36
+
37
function bctt_admin_menu() {
38
add_action('admin_init', 'bctt_register_settings');
39
add_options_page('Better Click To Tweet Options', 'Better Click To Tweet', 'manage_options', 'better-click-to-tweet', 'bctt_settings_page');
49
50
function bctt_settings_page() {
51
if ( !current_user_can( 'manage_options' ) ) {
52
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'bctt-lang' ) );
53
} ?>
54
55
<div class="wrap">
59
60
<hr/>
61
62
+ <h2><?php _e( 'Instructions', 'better-click-to-tweet'); ?></h2>
63
<p>
64
+ <?php /* translators: Treat "Better Click To Tweet" as a brand name, don't translate it */ _e('To add styled click-to-tweet quote boxes include the Better Click To Tweet shortcode in your post.', 'better-click-to-tweet' ); ?></p>
65
+ <p><?php _e( 'Here\'s how you format the shortcode:', 'better-click-to-tweet' ); ?><pre>[bctt tweet="<?php /* translators: This text shows up as a sample tweet in the instructions for how to use the plugin. */ _e('Meaningful, tweetable quote.', 'better-click-to-tweet' ); ?>"]</pre></p>
66
+ <p><?php /* translators: Also, treat "BCTT" as a brand name, don't translate it */ _e( 'If you are using the visual editor, click the BCTT birdie in the toolbar to add a pre-formatted shortcode to your post.', 'better-click-to-tweet' ); ?></p>
67
+ <p><?php _e( 'Tweet length is automatically shortened to 117 characters minus the length of your twitter name, to leave room for it and a link back to the post.', 'better-click-to-tweet' ); ?>
68
</p>
69
70
+ <h2><?php _e( 'Settings', 'better-click-to-tweet' ); ?></h2>
71
72
+ <p><?php _e( 'Enter your Twitter handle to add "via @yourhandle" to your tweets. Do not include the @ symbol.', 'better-click-to-tweet' ); ?></p>
73
<form method="post" action="options.php" style="display: inline-block;">
74
<?php settings_fields( 'bctt_clicktotweet-options' ); ?>
75
76
<table class="form-table">
77
<tr valign="top">
78
+ <th style="width: 200px;"><label><?php _e('Your Twitter Handle', 'better-click-to-tweet'); ?></label></th>
79
<td><input type="text" name="bctt-twitter-handle" value="<?php echo get_option('bctt-twitter-handle'); ?>" /></td>
80
</tr>
81
<tr>
85
</form>
86
87
<hr/>
88
+ <em><?php $url = 'http://benandjacq.com'; $link = sprintf( __( 'An open source plugin by <a href=%s>Ben Meredith</a>', 'better-click-to-tweet'), esc_url($url) ); echo $link; ?></em>
89
+ <p><?php $url2 = 'https://github.com/Benunc/better-click-to-tweet'; $link2 = sprintf( __( 'Are you a developer? I would love your help making this plugin better. Check out the <a href=%s>plugin on Github.</a>' , 'better-click-to-tweet'), esc_url($url2 ) ); echo $link2; ?></p>
90
+ <p><?php $url3 = 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ'; $link3 = sprintf( __( 'The best way you can support this and other plugins is to <a href=%s>donate</a>', 'better-click-to-tweet' ), esc_url($url3) ); echo $link3; ?></a>. <?php $url4 = 'https://wordpress.org/support/view/plugin-reviews/better-click-to-tweet'; $link4 = sprintf( __( 'The second best way is to <a href=%s>leave an honest review.</a>', 'better-click-to-tweet'), esc_url($url4) ); echo $link4; ?></p>
91
+ <p><?php _e( 'Did this plugin save you enough time to be worth some money?', 'better-click-to-tweet'); ?></p>
92
+ <p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ" target="_blank"><?php _e( 'Click here to buy me a Coke to say thanks.', 'better-click-to-tweet' ); ?></a></p>
93
</div>
94
<?php
95
}
better-click-to-tweet.php CHANGED
@@ -2,13 +2,15 @@
2
/*
3
Plugin Name: Better Click To Tweet
4
Description: Add click to tweet boxes to your WordPress posts, easily. This is a new, fully renovated version of the late "Click to Tweet" plugin by Todaymade. I overhauled the plugin using the shortcode API, and (perhaps most importantly) removed the "powered by" link.
5
- Version: 1.0
6
Author: Ben Meredith
7
Author URI: http://benandjacq.com
8
Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
9
License: GPL2
10
*/
11
include 'bctt_options.php';
12
13
defined( 'ABSPATH' ) or die( "No script kiddies please!" );
14
@@ -39,8 +41,9 @@ function bctt_shortcode( $atts, $content ) {
39
'handle' => '$handle_code'
40
), $atts ) );
41
$text = $tweet;
42
- $short = bctt_shorten( $text, ( 117 - strlen( $handle ) ) );
43
- return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=".urlencode($short).$handle_code."&url=".get_permalink()."' target='_blank'>".$short."</a></span><a href='https://twitter.com/intent/tweet?text=".urlencode($short).$handle_code."&url=".get_permalink()."' target='_blank' class='bctt-ctt-btn'>Click To Tweet</a></div>";
44
}
45
46
add_shortcode('bctt', 'bctt_shortcode');
@@ -68,10 +71,12 @@ function bctt_on_uninstall(){
68
69
register_uninstall_hook( __FILE__, 'bctt_on_uninstall' );
70
71
- function bctt_options_link($links) {
72
- $settings_link = '<a href="options-general.php?page=better-click-to-tweet">Settings</a>';
73
array_unshift( $links, $settings_link );
74
return $links;
75
}
76
$bcttlink = plugin_basename(__FILE__);
77
add_filter("plugin_action_links_$bcttlink", 'bctt_options_link' );
2
/*
3
Plugin Name: Better Click To Tweet
4
Description: Add click to tweet boxes to your WordPress posts, easily. This is a new, fully renovated version of the late "Click to Tweet" plugin by Todaymade. I overhauled the plugin using the shortcode API, and (perhaps most importantly) removed the "powered by" link.
5
+ Version: 2.0
6
Author: Ben Meredith
7
Author URI: http://benandjacq.com
8
Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
9
License: GPL2
10
+ Text Domain: better-click-to-tweet
11
*/
12
include 'bctt_options.php';
13
+ include 'bctt-i18n.php';
14
15
defined( 'ABSPATH' ) or die( "No script kiddies please!" );
16
41
'handle' => '$handle_code'
42
), $atts ) );
43
$text = $tweet;
44
+ $bcttBttn = sprintf( __( 'Click To Tweet', 'better-click-to-tweet' ) );
45
+ $short = bctt_shorten( $text, ( 117 - mb_strlen( $handle ) ) );
46
+ return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=".urlencode($short).$handle_code."&url=".get_permalink()."' target='_blank'>".$short."</a></span><a href='https://twitter.com/intent/tweet?text=".urlencode($short).$handle_code."&url=".get_permalink()."' target='_blank' class='bctt-ctt-btn'>".$bcttBttn."</a></div>";
47
}
48
49
add_shortcode('bctt', 'bctt_shortcode');
71
72
register_uninstall_hook( __FILE__, 'bctt_on_uninstall' );
73
74
+ function bctt_options_link($links) {
75
+ $settingsText = sprintf( __( 'Settings', 'better-click-to-tweet'));
76
+ $settings_link = '<a href="options-general.php?page=better-click-to-tweet">'.$settingsText.'</a>';
77
array_unshift( $links, $settings_link );
78
return $links;
79
}
80
$bcttlink = plugin_basename(__FILE__);
81
add_filter("plugin_action_links_$bcttlink", 'bctt_options_link' );
82
+
languages/better-click-to-tweet-es_ES.mo ADDED
Binary file
languages/better-click-to-tweet-es_ES.po ADDED
@@ -0,0 +1,120 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Better Click To Tweet\n"
4
+ "POT-Creation-Date: 2014-12-17 10:04-0500\n"
5
+ "PO-Revision-Date: 2014-12-17 10:38-0500\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "Language: es_ES\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.7.1\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
16
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
17
+ "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
18
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+
21
+ #: bctt_options.php:52
22
+ msgid "You do not have sufficient permissions to access this page."
23
+ msgstr "Usted no tiene los permisos necesarios para acceder a esta página."
24
+
25
+ #: bctt_options.php:62
26
+ msgid "Instructions"
27
+ msgstr "Instrucciones"
28
+
29
+ #. translators: Treat "Better Click To Tweet" as a brand name, don't translate it
30
+ #: bctt_options.php:64
31
+ msgid ""
32
+ "To add styled click-to-tweet quote boxes include the Better Click To Tweet "
33
+ "shortcode in your post."
34
+ msgstr ""
35
+ "Para añadir casillas de texto de estilo \"click to tweet\" incluya el "
36
+ "shortcode \"Better Click To Tweet\" en su mensaje."
37
+
38
+ #: bctt_options.php:65
39
+ msgid "Here's how you format the shortcode:"
40
+ msgstr "Aquí está cómo formatear el shortcode:"
41
+
42
+ #. translators: This text shows up as a sample tweet in the instructions for how to use the plugin.
43
+ #: bctt_options.php:65
44
+ msgid "Meaningful, tweetable quote."
45
+ msgstr "Algo significativo para Twittear."
46
+
47
+ #. translators: Also, treat "BCTT" as a brand name, don't translate it
48
+ #: bctt_options.php:66
49
+ msgid ""
50
+ "If you are using the visual editor, click the BCTT birdie in the toolbar to "
51
+ "add a pre-formatted shortcode to your post."
52
+ msgstr ""
53
+ "Si está utilizando el editor visual, haga clic en el pajarito BCTT en la "
54
+ "barra de herramientas para añadir un shortcode formateado previamente a su "
55
+ "mensaje."
56
+
57
+ #: bctt_options.php:67
58
+ msgid ""
59
+ "Tweet length is automatically shortened to 117 characters minus the length "
60
+ "of your twitter name, to leave room for it and a link back to the post."
61
+ msgstr ""
62
+ "La longitud del tweet se acortará automáticamente a 117 caracteres menos la "
63
+ "longitud de su nombre de Twitter, para dejar espacio para ella y un enlace "
64
+ "de vuelta al tweet."
65
+
66
+ #: bctt_options.php:70 better-click-to-tweet.php:75
67
+ msgid "Settings"
68
+ msgstr "Ajustes"
69
+
70
+ #: bctt_options.php:72
71
+ msgid ""
72
+ "Enter your Twitter handle to add \"via @yourhandle\" to your tweets. Do not "
73
+ "include the @ symbol."
74
+ msgstr ""
75
+ "Ingrese su nombre identificador de Twitter para agregar \"via "
76
+ "@nombreIdentificador\" a sus tweets. No incluya el símbolo @."
77
+
78
+ #: bctt_options.php:78
79
+ msgid "Your Twitter Handle"
80
+ msgstr "Su Identificador de Twitter"
81
+
82
+ #: bctt_options.php:88
83
+ #, php-format
84
+ msgid "An open source plugin by <a href=%s>Ben Meredith</a>"
85
+ msgstr "Un plugin de código abierto por <a href=%s>Ben Meredith</a>"
86
+
87
+ #: bctt_options.php:89
88
+ #, php-format
89
+ msgid ""
90
+ "Are you a developer? I would love your help making this plugin better. Check "
91
+ "out the <a href=%s>plugin on Github.</a>"
92
+ msgstr ""
93
+ "¿Eres desarrollador? Me encantaría su ayuda para hacer mejor este plugin. "
94
+ "Echa un vistazo al <a href=%s>plugin en Github.</a>"
95
+
96
+ #: bctt_options.php:90
97
+ #, php-format
98
+ msgid ""
99
+ "The best way you can support this and other plugins is to <a href=%s>donate</"
100
+ "a>"
101
+ msgstr ""
102
+ "La mejor manera en que usted puede apoyar este y otros plugins es <a href="
103
+ "%s>donar</a>"
104
+
105
+ #: bctt_options.php:90
106
+ #, php-format
107
+ msgid "The second best way is to <a href=%s>leave an honest review.</a>"
108
+ msgstr "La segunda mejor manera es <a href=%s>dejar una revisión honesta.</a>"
109
+
110
+ #: bctt_options.php:91
111
+ msgid "Did this plugin save you enough time to be worth some money?"
112
+ msgstr "¿Este plugin le ahorra suficiente tiempo para valer algo de dinero?"
113
+
114
+ #: bctt_options.php:92
115
+ msgid "Click here to buy me a Coke to say thanks."
116
+ msgstr "Haga clic aquí y compre una Coca-Cola para decir gracias."
117
+
118
+ #: better-click-to-tweet.php:44
119
+ msgid "Click To Tweet"
120
+ msgstr "Click Para Twittear"
readme.txt CHANGED
@@ -4,23 +4,27 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
Tags: click to tweet, twitter, tweet, twitter plugin, Twitter boxes, share, social media, post, posts, plugin, auto post
5
Requires at least: 3.8
6
Tested up to: 4.1
7
- Stable tag: 1.0
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
11
- Add click to tweet boxes securely, using the official WordPress API. An overhaul of the Click To Tweet plugin by Todaymade.
12
13
== Description ==
14
15
This plugin allows you to easily create tweetable content for your readers. Using a simple shortcode, your selected text is highlighted and made tweetable.
16
17
- This is a complete retool of the "Click To Tweet" plugin by Todaymade. It now uses the WordPress shortcode API, making it more secure, and I've cleaned up the CSS from the old plugin. Perhaps most significantly, I removed the "powered by Coschedule" link. For more on the differences between this plugin and the Click To Tweet plugin by Todaymade, read the FAQ section.
18
-
19
- I am working on a tutorial to swtich to my plugin from the previous version in a way that doesn't mean you have to switch every shortcode by hand. Stay tuned!
20
21
Don't be scared to donate, if this plugin makes your blogging life any better.
22
23
- Also, developers, please hop in and suggest improvements. You can submit pull requests at the [github repo](https://github.com/Benunc/better-click-to-tweet "plugin github repo") for this plugin, or go through the official svn repo here.
24
25
== Installation ==
26
@@ -58,6 +62,9 @@ The bottom line for an end user is that both plugins are great, with the main di
58
59
Also from an end user perspective, I am more active in the support forums than Justin (who has a paid product to support, which justifiably takes more of his time and energy), and you can count on my response and resolution to your issues!
60
61
== Screenshots ==
62
63
1. This in the editor...
@@ -65,6 +72,13 @@ Also from an end user perspective, I am more active in the support forums than J
65
66
== Changelog ==
67
68
= 1.0 =
69
* updated the tweet length math to correctly parse text with non-standard characters. Thanks to WordPress forum user zachop at https://wordpress.org/support/topic/incorrect-handling-length-count-of-multi-byte-strings for the tip.
70
* various code cleanup issues, to make my code more readable and complaint with WordPress standards.
@@ -81,3 +95,10 @@ Also from an end user perspective, I am more active in the support forums than J
81
82
= 0.1 =
83
* Initial release.
4
Tags: click to tweet, twitter, tweet, twitter plugin, Twitter boxes, share, social media, post, posts, plugin, auto post
5
Requires at least: 3.8
6
Tested up to: 4.1
7
+ Stable tag: 2.0.1
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
11
+ Correctly counts characters, taking into account username length and non-Roman characters. Simply put: as Click to Tweet plugins go, this one's BETTER. Also: translation ready, as of version 2.0!
12
13
== Description ==
14
15
This plugin allows you to easily create tweetable content for your readers. Using a simple shortcode, your selected text is highlighted and made tweetable.
16
+ ><strong> Why Better?</strong><br>
17
+ >This plugin started as a complete retool of the "Click To Tweet" plugin by Todaymade. There are a number of improvements under the hood, namely correct character counting when dealing with non-Roman characters, providing multi-language support, and use of the official shortcode API (which means security and forward-compatibility)
18
19
+ I am working on a tutorial to switch to my plugin from any other similar plugin in a way that doesn't mean you have to switch every shortcode or pseudo-shortcode by hand. Stay tuned!
20
21
Don't be scared to donate, if this plugin makes your blogging life any better.
22
23
+ Also, developers, please hop in and suggest improvements. You can submit pull requests at the [github repo](https://github.com/Benunc/better-click-to-tweet "plugin github repo") for this plugin, or go through the official svn repo here. I'm also actively seeking translators to bring the usefulness of this plugin to non-English speakers. Please message me in the forums.
24
+
25
+ Translators:
26
+
27
+ Español (es): Jordi Rosalez
28
29
== Installation ==
30
62
63
Also from an end user perspective, I am more active in the support forums than Justin (who has a paid product to support, which justifiably takes more of his time and energy), and you can count on my response and resolution to your issues!
64
65
+ = How can I help? =
66
+ I want to maximize the usefulness of this plugin by translating it into multiple languages. So far I have included Spanish. If you have experience translating .po files, please consider helping in that way. To include those translations in the official plugin, email me, or submit pull requests at Github.
67
+
68
== Screenshots ==
69
70
1. This in the editor...
72
73
== Changelog ==
74
75
+ = 2.0.1 =
76
+ * added in support for RSS feeds: when outputting to an RSS feed, the click-to-tweet text will be smartly formatted.
77
+ * added css declarations to deal with issues in the Twenty Fifteen theme.
78
+
79
+ = 2.0 =
80
+ * Major version release for internationalization: added Spanish (ES) translation, and updated code throughout for internationalization. Still to-do: add translation support for the tinymce plugin on the visual editor.
81
+
82
= 1.0 =
83
* updated the tweet length math to correctly parse text with non-standard characters. Thanks to WordPress forum user zachop at https://wordpress.org/support/topic/incorrect-handling-length-count-of-multi-byte-strings for the tip.
84
* various code cleanup issues, to make my code more readable and complaint with WordPress standards.
95
96
= 0.1 =
97
* Initial release.
98
+
99
+ == Upgrade Notice ==
100
+
101
+ = 2.0 =
102
+ Adds internationalization, and out of the box support for Spanish (ES) language.
103
+
104
+