Better Click To Tweet - Version 5.3

Version Description

  • enhancement cleaned up the various options checks that were happening on the front end (thanks @igmoweb on GitHub!)
  • Readme changes. I also celebrated a milestone of 20K active installs, which was cause for great celebration, and at least one undocumented happy dance.
Download this release

Release Info

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

Code changes from version 5.2.1 to 5.3

Files changed (3) hide show
  1. bctt_options.php +2 -2
  2. better-click-to-tweet.php +59 -12
  3. readme.txt +6 -2
bctt_options.php CHANGED
@@ -50,9 +50,9 @@ function bctt_validate_checkbox( $input ) {
50
  }
51
 
52
  function bctt_add_custom_style_option() {
53
- $bctt_dequeued_with_custom_funtion = get_option( 'bctt_style_dequeued' );
54
 
55
- $bctt_custom_style = get_option( 'bcct_custom_style_enqueued' );
56
 
57
  if ( $bctt_dequeued_with_custom_funtion || $bctt_custom_style ) {
58
  return true;
50
  }
51
 
52
  function bctt_add_custom_style_option() {
53
+ $bctt_dequeued_with_custom_funtion = bctt_is_default_styles_dequeued();
54
 
55
+ $bctt_custom_style = bctt_is_custom_stylesheet();
56
 
57
  if ( $bctt_dequeued_with_custom_funtion || $bctt_custom_style ) {
58
  return true;
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.2.1
6
  Author: Ben Meredith
7
  Author URI: https://www.wpsteward.com
8
  Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
@@ -212,8 +212,7 @@ add_shortcode( 'bctt', 'bctt_shortcode' );
212
 
213
  function bctt_scripts() {
214
 
215
- if ( get_option( 'bctt_disable_css' ) ) {
216
- add_option( 'bctt_style_dequeued', true );
217
  foreach ( wp_load_alloptions() as $option => $value ) {
218
  if ( strpos( $option, 'bcct_' ) === 0 ) {
219
  delete_option( $option );
@@ -223,31 +222,79 @@ function bctt_scripts() {
223
  return;
224
  }
225
 
226
- $dir = wp_upload_dir();
227
-
228
- $custom = file_exists( $dir['basedir'] . '/bcttstyle.css' );
229
 
230
  $tag = $custom ? 'bcct_custom_style' : 'bcct_style';
231
- $antitag = $custom ? 'bcct_style' : 'bcct_custom_style';
232
- $location = $custom ? $dir['baseurl'] . '/bcttstyle.css' : plugins_url( 'assets/css/styles.css', __FILE__ );
233
 
234
  $version = $custom ? '1.0' : '3.0';
235
 
236
  wp_register_style( $tag, $location, false, $version, 'all' );
237
 
238
  wp_enqueue_style( $tag );
 
239
 
240
- delete_option( 'bctt_style_dequeued' );
241
- add_option( $tag . '_enqueued', true );
242
- delete_option( $antitag . '_enqueued' );
243
 
 
244
 
 
 
 
 
 
 
 
245
  }
246
 
247
 
248
- add_action( 'wp_enqueue_scripts', 'bctt_scripts', 10 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
 
250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  /*
252
  * Delete options and shortcode on uninstall
253
  *
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.3
6
  Author: Ben Meredith
7
  Author URI: https://www.wpsteward.com
8
  Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
212
 
213
  function bctt_scripts() {
214
 
215
+ if ( bctt_is_default_styles_dequeued() ) {
 
216
  foreach ( wp_load_alloptions() as $option => $value ) {
217
  if ( strpos( $option, 'bcct_' ) === 0 ) {
218
  delete_option( $option );
222
  return;
223
  }
224
 
225
+ $custom = bctt_is_custom_stylesheet();
 
 
226
 
227
  $tag = $custom ? 'bcct_custom_style' : 'bcct_style';
228
+ $location = bctt_get_stylesheet_url();
 
229
 
230
  $version = $custom ? '1.0' : '3.0';
231
 
232
  wp_register_style( $tag, $location, false, $version, 'all' );
233
 
234
  wp_enqueue_style( $tag );
235
+ }
236
 
 
 
 
237
 
238
+ add_action( 'wp_enqueue_scripts', 'bctt_scripts', 10 );
239
 
240
+ /**
241
+ * Check if default stylesheet must not be enqueued
242
+ *
243
+ * @return bool
244
+ */
245
+ function bctt_is_default_styles_dequeued() {
246
+ return (bool) get_option( 'bctt_disable_css' );
247
  }
248
 
249
 
250
+ /**
251
+ * Check if there's a custo stylesheet that will be enqueued
252
+ */
253
+ function bctt_is_custom_stylesheet() {
254
+ return file_exists( bctt_get_custom_styles_path() );
255
+ }
256
+
257
+ /**
258
+ * Return the BCTT stylesheet URL
259
+ *
260
+ * Return custom styles URL if the file exists or the default one otherwise
261
+ *
262
+ * @return string
263
+ */
264
+ function bctt_get_stylesheet_url() {
265
+ return bctt_is_custom_stylesheet() ? bctt_get_custom_styles_url() : bctt_get_styles_url();
266
+ }
267
 
268
 
269
+ /**
270
+ * Return the custom stylesheet path
271
+ *
272
+ * @return string
273
+ */
274
+ function bctt_get_custom_styles_path() {
275
+ $dir = wp_upload_dir();
276
+ return $dir['basedir'] . '/bcttstyle.css';
277
+ }
278
+
279
+ /**
280
+ * Return the custom stylesheet URL
281
+ *
282
+ * @return string
283
+ */
284
+ function bctt_get_custom_styles_url() {
285
+ $dir = wp_upload_dir();
286
+ return $dir['baseurl'] . '/bcttstyle.css';
287
+ }
288
+
289
+ /**
290
+ * Return the default stylesheet path
291
+ *
292
+ * @return string
293
+ */
294
+ function bctt_get_styles_url() {
295
+ return plugins_url( 'assets/css/styles.css', __FILE__ );
296
+ }
297
+
298
  /*
299
  * Delete options and shortcode on uninstall
300
  *
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.8
7
- Stable tag: 5.2.1
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 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
 
@@ -101,6 +101,10 @@ Donations: http://benlikes.us/donate
101
 
102
  == Changelog ==
103
 
 
 
 
 
104
  = 5.2.1 =
105
  * fix — unused $handle_code variable has been removed. Was causing some errors for folks.
106
  * fix — code introduced in 5.2 messed up the "via" option and the option to not include the URL. This has been fixed.
4
  Tags: click to tweet, twitter, tweet,
5
  Requires at least: 3.8
6
  Tested up to: 4.8
7
+ Stable tag: 5.3
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 (by a mile), 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
 
101
 
102
  == Changelog ==
103
 
104
+ = 5.3 =
105
+ * enhancement — cleaned up the various options checks that were happening on the front end (thanks @igmoweb on GitHub!)
106
+ * Readme changes. I also celebrated a milestone of 20K active installs, which was cause for great celebration, and at least one undocumented happy dance.
107
+
108
  = 5.2.1 =
109
  * fix — unused $handle_code variable has been removed. Was causing some errors for folks.
110
  * fix — code introduced in 5.2 messed up the "via" option and the option to not include the URL. This has been fixed.