Better Click To Tweet - Version 5.2

Version Description

  • security fix adds (more) escaping throughout the plugin. Thanks to Paul de Wouters from HumanMade for the PR!
  • enhancement tested for compatibility with WordPress core 4.8
  • but seriously, you should check out Premium Styles. http://benlikes.us/bcttps
Download this release

Release Info

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

Code changes from version 5.1 to 5.2

Files changed (4) hide show
  1. admin-nags.php +2 -2
  2. better-click-to-tweet.php +20 -11
  3. i18n-module.php +3 -3
  4. readme.txt +7 -2
admin-nags.php CHANGED
@@ -72,13 +72,13 @@ function bctt_alerts() {
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">
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 esc_url( 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 esc_url( 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">
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.1
6
  Author: Ben Meredith
7
  Author URI: https://www.wpsteward.com
8
  Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
@@ -114,12 +114,13 @@ function bctt_shortcode( $atts ) {
114
  }
115
 
116
  if ( ! empty( $handle ) && $atts['via'] != 'no' ) {
117
-
118
- $handle_code = "&amp;via=" . $handle . "&amp;related=" . $handle;
119
-
120
  } else {
121
 
122
- $handle_code = '';
 
123
 
124
  }
125
 
@@ -134,17 +135,17 @@ function bctt_shortcode( $atts ) {
134
 
135
  if ( filter_var( $atts['url'], FILTER_VALIDATE_URL ) ) {
136
 
137
- $bcttURL = '&amp;url=' . $atts['url'];
138
 
139
  } elseif ( $atts['url'] != 'no' ) {
140
 
141
  if ( get_option( 'bctt-short-url' ) != false ) {
142
 
143
- $bcttURL = '&amp;url=' . wp_get_shortlink();
144
 
145
  } else {
146
 
147
- $bcttURL = '&amp;url=' . get_permalink();
148
 
149
  }
150
 
@@ -178,12 +179,20 @@ function bctt_shortcode( $atts ) {
178
  $bctt_text_span_class = apply_filters( 'bctt_text_span_class', 'bctt-ctt-text' );
179
  $bctt_button_span_class = apply_filters( 'bctt_button_span_class', 'bctt-ctt-btn' );
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 );
@@ -271,7 +280,7 @@ function bctt_options_link( $links ) {
271
 
272
  $settingsText = sprintf( _x( 'Settings', 'text for the link on the plugins page', 'better-click-to-tweet' ) );
273
 
274
- $settings_link = '<a href="admin.php?page=better-click-to-tweet">' . $settingsText . '</a>';
275
 
276
  array_unshift( $links, $settings_link );
277
 
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.2
6
  Author: Ben Meredith
7
  Author URI: https://www.wpsteward.com
8
  Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
114
  }
115
 
116
  if ( ! empty( $handle ) && $atts['via'] != 'no' ) {
117
+
118
+ $via = $handle;
119
+ $related = $handle;
120
  } else {
121
 
122
+ $via = '';
123
+ $related = '';
124
 
125
  }
126
 
135
 
136
  if ( filter_var( $atts['url'], FILTER_VALIDATE_URL ) ) {
137
 
138
+ $bcttURL = $atts['url'];
139
 
140
  } elseif ( $atts['url'] != 'no' ) {
141
 
142
  if ( get_option( 'bctt-short-url' ) != false ) {
143
 
144
+ $bcttURL = wp_get_shortlink();
145
 
146
  } else {
147
 
148
+ $bcttURL = get_permalink();
149
 
150
  }
151
 
179
  $bctt_text_span_class = apply_filters( 'bctt_text_span_class', 'bctt-ctt-text' );
180
  $bctt_button_span_class = apply_filters( 'bctt_button_span_class', 'bctt-ctt-btn' );
181
 
182
+
183
+ $href = add_query_arg( array(
184
+ 'url' => $bcttURL,
185
+ 'text' => rawurlencode( html_entity_decode( $short ) ),
186
+ 'via' => $via,
187
+ 'related' => $related,
188
+ ), 'https://twitter.com/intent/tweet' );
189
+
190
  if ( ! is_feed() ) {
191
 
192
+ $output = "<span class='" . esc_attr( $bctt_span_class ) . "'><span class='" . esc_attr( $bctt_text_span_class ) . "'><a href='" . esc_url( $href ) . "' target='_blank'" . $rel . ">" . esc_html( $short ) . " </a></span><a href='" . esc_url( $href ) . "' target='_blank' class='" . esc_attr( $bctt_button_span_class ) . "'" . $rel . ">" . esc_html( $atts['prompt'] ) . "</a></span>";
193
  } else {
194
 
195
+ $output = "<hr /><p><em>" . esc_html( $short ) . "</em><br /><a href='" . esc_url( $href ) . "' target='_blank' class='bctt-ctt-btn' " . $rel . " >" . esc_html( $atts['prompt'] ) . "</a><br /><hr />";
196
 
197
  }
198
  return apply_filters( 'bctt_output', $output, $short, $bctt_button_span_class, $bctt_span_class, $bctt_text_span_class, $bcttURL, $handle_code, $rel, $atts );
280
 
281
  $settingsText = sprintf( _x( 'Settings', 'text for the link on the plugins page', 'better-click-to-tweet' ) );
282
 
283
+ $settings_link = '<a href="admin.php?page=better-click-to-tweet">' . esc_html( $settingsText ) . '</a>';
284
 
285
  array_unshift( $links, $settings_link );
286
 
i18n-module.php CHANGED
@@ -192,11 +192,11 @@ class bctt_i18n {
192
  echo '<div id="i18n_promo_box" style="border:1px solid #ccc;background-color:#fff;padding:1em 2em;max-width:100%;min-height:220px;">';
193
  echo '<a href="' . esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ) . '" style="color:#333;text-decoration:none;font-weight:bold;font-size:16px;border:1px solid #ccc;padding:1px 4px;" class="alignright">X</a>';
194
  if ( isset( $this->glotpress_logo ) && '' != $this->glotpress_logo ) {
195
- echo '<a href="https://translate.wordpress.org/projects/wp-plugins/better-click-to-tweet/"><img style="float: right;margin: 15px 5px 5px 5px;padding: 0 1em;width: 200px;" src="' . $this->glotpress_logo . '" alt="' . $this->glotpress_name . '"/></a>';
196
  }
197
- echo '<h2>' . sprintf( __( 'Translation of %s', 'better-click-to-tweet' ), $this->plugin_name ) . '</h2>';
198
 
199
- echo '<p>' . $message . '</p>';
200
  echo '<p><a href="https://translate.wordpress.org/projects/wp-plugins/better-click-to-tweet/">' . __( 'Register now &raquo;', 'better-click-to-tweet' ) . '</a></p>';
201
  echo '</div>';
202
  }
192
  echo '<div id="i18n_promo_box" style="border:1px solid #ccc;background-color:#fff;padding:1em 2em;max-width:100%;min-height:220px;">';
193
  echo '<a href="' . esc_url( add_query_arg( array( 'remove_i18n_promo' => '1' ) ) ) . '" style="color:#333;text-decoration:none;font-weight:bold;font-size:16px;border:1px solid #ccc;padding:1px 4px;" class="alignright">X</a>';
194
  if ( isset( $this->glotpress_logo ) && '' != $this->glotpress_logo ) {
195
+ echo '<a href="https://translate.wordpress.org/projects/wp-plugins/better-click-to-tweet/"><img style="float: right;margin: 15px 5px 5px 5px;padding: 0 1em;width: 200px;" src="' . esc_url( $this->glotpress_logo ) . '" alt="' . esc_attr( $this->glotpress_name ) . '"/></a>';
196
  }
197
+ echo '<h2>' . sprintf( __( 'Translation of %s', 'better-click-to-tweet' ), esc_html( $this->plugin_name ) ) . '</h2>';
198
 
199
+ echo '<p>' . esc_html( $message ) . '</p>';
200
  echo '<p><a href="https://translate.wordpress.org/projects/wp-plugins/better-click-to-tweet/">' . __( 'Register now &raquo;', 'better-click-to-tweet' ) . '</a></p>';
201
  echo '</div>';
202
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ 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: 5.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -101,6 +101,11 @@ Donations: http://benlikes.us/donate
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.
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.8
7
+ Stable tag: 5.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
101
 
102
  == Changelog ==
103
 
104
+ = 5.2 =
105
+ * security fix — adds (more) escaping throughout the plugin. Thanks to Paul de Wouters from HumanMade for the PR!
106
+ * enhancement — tested for compatibility with WordPress core 4.8
107
+ * but seriously, you should check out Premium Styles. http://benlikes.us/bcttps
108
+
109
  = 5.1 =
110
  * 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.
111
  * enhancement — I made several changes to the readme file so that the plugin is showcased nicely in the WordPress Plugin Directory's new design.