WP to Twitter - Version 3.4.4

Version Description

  • Bug fix: Due to external add-ons, need to test URL shortener settings as strings, not integers.
  • Bugfix: If YOURLS JSON object does not exist, it cannot have values.
  • Change: Support custom domains in jotURL.
  • Change: Add user info to debugging records.
Download this release

Release Info

Developer joedolson
Plugin Icon 128x128 WP to Twitter
Version 3.4.4
Comparing to
See all releases

Code changes from version 3.4.3 to 3.4.4

Files changed (3) hide show
  1. readme.txt +9 -2
  2. wp-to-twitter-shorteners.php +23 -10
  3. wp-to-twitter.php +3 -2
readme.txt CHANGED
@@ -3,11 +3,11 @@ Contributors: joedolson
3
  Donate link: http://www.joedolson.com/donate/
4
  Tags: twitter, microblogging, bitly, yourls, redirect, shortener, post, links, social, sharing, media, tweet
5
  Requires at least: 4.4
6
- Tested up to: 5.2
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  Text Domain: wp-to-twitter
10
- Stable tag: 3.4.3
11
 
12
  Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
13
 
@@ -63,6 +63,13 @@ Check out my <a href="https://github.com/joedolson/plugin-extensions/tree/master
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
 
66
  = 3.4.3 =
67
 
68
  * Bug fix: Failed to account for a URL value that could be false in template parsing.
3
  Donate link: http://www.joedolson.com/donate/
4
  Tags: twitter, microblogging, bitly, yourls, redirect, shortener, post, links, social, sharing, media, tweet
5
  Requires at least: 4.4
6
+ Tested up to: 5.3
7
  Requires PHP: 5.3
8
  License: GPLv2 or later
9
  Text Domain: wp-to-twitter
10
+ Stable tag: 3.4.4
11
 
12
  Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
13
 
63
 
64
  == Changelog ==
65
 
66
+ = 3.4.4 =
67
+
68
+ * Bug fix: Due to external add-ons, need to test URL shortener settings as strings, not integers.
69
+ * Bugfix: If YOURLS JSON object does not exist, it cannot have values.
70
+ * Change: Support custom domains in jotURL.
71
+ * Change: Add user info to debugging records.
72
+
73
  = 3.4.3 =
74
 
75
  * Bug fix: Failed to account for a URL value that could be false in template parsing.
wp-to-twitter-shorteners.php CHANGED
@@ -177,7 +177,7 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
177
  if ( is_object( $json ) ) {
178
  $shrink = $json->shorturl;
179
  } else {
180
- $error = 'Error code: ' . $json->shorturl . ' ' . $json->message;
181
  $shrink = false;
182
  }
183
  break;
@@ -194,6 +194,7 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
194
  $joturlapi = trim( get_option( 'joturlapi' ) );
195
  $joturllogin = trim( get_option( 'joturllogin' ) );
196
  $joturl_longurl_params = trim( get_option( 'joturl_longurl_params' ) );
 
197
  if ( '' != $joturl_longurl_params ) {
198
  if ( false === strpos( $url, '%3F' ) && false == strpos( $url, '?' ) ) {
199
  $ct = '?';
@@ -203,7 +204,8 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
203
  $url .= $ct . $joturl_longurl_params;
204
  $encoded = urlencode( urldecode( trim( $url ) ) ); // prevent double-encoding.
205
  }
206
- $decoded = wpt_fetch_url( 'https://api.joturl.com/a/v1/shorten?url=' . $encoded . '&login=' . $joturllogin . '&key=' . $joturlapi . '&format=plain' );
 
207
  if ( false !== $decoded ) {
208
  $shrink = $decoded;
209
  $joturl_shorturl_params = trim( get_option( 'joturl_shorturl_params' ) );
@@ -425,6 +427,10 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
425
  <label for="joturlapi"><?php _e( "Your jotURL private <abbr title='application programming interface'>API</abbr> key:", 'wp-to-twitter' ); ?></label>
426
  <input type="text" name="joturlapi" id="joturlapi" size="40" value="<?php echo esc_attr( get_option( 'joturlapi' ) ); ?>"/>
427
  </p>
 
 
 
 
428
  <p>
429
  <label for="joturl_longurl_params"><?php _e( 'Parameters to add to the long URL (before shortening):', 'wp-to-twitter' ); ?></label>
430
  <input type="text" name="joturl_longurl_params" id="joturl_longurl_params" size="40" value="<?php echo esc_attr( get_option( 'joturl_longurl_params' ) ); ?>"/>
@@ -539,7 +545,7 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
539
  update_option( 'joturllogin', '' );
540
  $message = __( 'jotURL public API Key deleted. You cannot use the jotURL API without providing your public API Key.', 'wp-to-twitter' );
541
  } else {
542
- $message = __( "jotURL public API Key not added - <a href='https://www.joturl.com/reserved/api.html'>get one here</a>! ", 'wp-to-twitter' );
543
  }
544
  if ( '' != $post['joturl_longurl_params'] && isset( $post['submit'] ) ) {
545
  $v = trim( $post['joturl_longurl_params'] );
@@ -552,6 +558,13 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
552
  update_option( 'joturl_longurl_params', '' );
553
  $message = __( 'Long URL parameters deleted.', 'wp-to-twitter' );
554
  }
 
 
 
 
 
 
 
555
  if ( '' != $post['joturl_shorturl_params'] && isset( $post['submit'] ) ) {
556
  $v = trim( $post['joturl_shorturl_params'] );
557
  if ( substr( $v, 0, 1 ) == '&' || substr( $v, 0, 1 ) == '?' ) {
@@ -585,12 +598,12 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
585
  return;
586
  }
587
  update_option( 'jd_shortener', sanitize_key( $post['jd_shortener'] ) );
588
- $short = absint( get_option( 'jd_shortener' ) );
589
  $admin_url = admin_url( 'admin.php?page=wp-tweets-pro' );
590
  $admin_url = add_query_arg( 'tab', 'shortener', $admin_url );
591
 
592
  // these are the URL shorteners which require settings.
593
- if ( 2 === $short || 10 === $short || 6 === $short ) {
594
  // Translators: Settings URL for shortener configuration.
595
  $message .= sprintf( __( 'You must <a href="%s">configure your URL shortener settings</a>.', 'wp-to-twitter' ), $admin_url );
596
  }
@@ -607,8 +620,8 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
607
  * Form to select your shortener.
608
  */
609
  function wpt_pick_shortener() {
610
- $shortener = absint( get_option( 'jd_shortener' ) );
611
- if ( 2 === $shortener ) {
612
  echo '<p>' . __( 'The Bit.ly URL shortener API will be removed from WP to Twitter in March 2020. The version 3 API will be shut down on March 1st, and the plug-in will not be updated to version 4.', 'wp-to-twitter' ) . '</p>';
613
  }
614
  ?>
@@ -618,12 +631,12 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
618
  <option value="3" <?php selected( $shortener, '3' ); ?>><?php _e( "Don't shorten URLs.", 'wp-to-twitter' ); ?></option>
619
  <option value="4" <?php selected( $shortener, '4' ); ?>>WordPress</option>
620
  <?php
621
- if ( 2 === $shortener ) { // If Bit.ly is currently enabled, leave available.
622
  ?>
623
  <option value="2" <?php selected( $shortener, '2' ); ?>>Bit.ly</option>
624
  <?php
625
  }
626
- if ( 5 === $shortener ) { // if the user has already selected local server, leave available.
627
  ?>
628
  <option value="5" <?php selected( $shortener, '5' ); ?>><?php _e( 'YOURLS (this server)', 'wp-to-twitter' ); ?></option>
629
  <?php
@@ -637,7 +650,7 @@ if ( ! function_exists( 'wpt_shorten_url' ) ) {
637
  ?>
638
  </select>
639
  <?php
640
- if ( 3 !== $shortener ) {
641
  ?>
642
  <input type='checkbox' value='false' name='wpt_use_stored_urls' id='wpt_use_stored_urls' <?php checked( get_option( 'wpt_use_stored_urls' ), 'false' ); ?>> <label for='wpt_use_stored_urls'><?php _e( 'Always request a new short URL for Tweets', 'wp-to-twitter' ); ?></label>
643
  <?php
177
  if ( is_object( $json ) ) {
178
  $shrink = $json->shorturl;
179
  } else {
180
+ $error = 'Error code: YOURLS response is not an object';
181
  $shrink = false;
182
  }
183
  break;
194
  $joturlapi = trim( get_option( 'joturlapi' ) );
195
  $joturllogin = trim( get_option( 'joturllogin' ) );
196
  $joturl_longurl_params = trim( get_option( 'joturl_longurl_params' ) );
197
+ $domain = trim( get_option( 'joturl_domain', false ) );
198
  if ( '' != $joturl_longurl_params ) {
199
  if ( false === strpos( $url, '%3F' ) && false == strpos( $url, '?' ) ) {
200
  $ct = '?';
204
  $url .= $ct . $joturl_longurl_params;
205
  $encoded = urlencode( urldecode( trim( $url ) ) ); // prevent double-encoding.
206
  }
207
+ $domain = ( $domain ) ? '&domain=' . $domain : '';
208
+ $decoded = wpt_fetch_url( 'https://api.joturl.com/a/v1/shorten?url=' . $encoded . '&login=' . $joturllogin . '&key=' . $joturlapi . '&format=plain' . $domain );
209
  if ( false !== $decoded ) {
210
  $shrink = $decoded;
211
  $joturl_shorturl_params = trim( get_option( 'joturl_shorturl_params' ) );
427
  <label for="joturlapi"><?php _e( "Your jotURL private <abbr title='application programming interface'>API</abbr> key:", 'wp-to-twitter' ); ?></label>
428
  <input type="text" name="joturlapi" id="joturlapi" size="40" value="<?php echo esc_attr( get_option( 'joturlapi' ) ); ?>"/>
429
  </p>
430
+ <p>
431
+ <label for="joturl_domain"><?php _e( "Your jotURL custom domain:", 'wp-to-twitter' ); ?></label>
432
+ <input type="text" name="joturl_domain" id="joturl_domain" size="40" value="<?php echo esc_attr( get_option( 'joturl_domain' ) ); ?>"/>
433
+ </p>
434
  <p>
435
  <label for="joturl_longurl_params"><?php _e( 'Parameters to add to the long URL (before shortening):', 'wp-to-twitter' ); ?></label>
436
  <input type="text" name="joturl_longurl_params" id="joturl_longurl_params" size="40" value="<?php echo esc_attr( get_option( 'joturl_longurl_params' ) ); ?>"/>
545
  update_option( 'joturllogin', '' );
546
  $message = __( 'jotURL public API Key deleted. You cannot use the jotURL API without providing your public API Key.', 'wp-to-twitter' );
547
  } else {
548
+ $message = __( "jotURL public API Key not added - <a href='https://www.joturl.com/reserved/settings.html#tools-api'>get one here</a>! ", 'wp-to-twitter' );
549
  }
550
  if ( '' != $post['joturl_longurl_params'] && isset( $post['submit'] ) ) {
551
  $v = trim( $post['joturl_longurl_params'] );
558
  update_option( 'joturl_longurl_params', '' );
559
  $message = __( 'Long URL parameters deleted.', 'wp-to-twitter' );
560
  }
561
+ if ( '' != $post['joturl_domain'] && isset( $post['submit'] ) ) {
562
+ update_option( 'joturl_domain', $post['joturl_domain'] );
563
+ $message .= __( 'Custom jotURL domain saved.', 'wp-to-twitter' );
564
+ } elseif ( isset( $post['clear'] ) ) {
565
+ update_option( 'joturl_domain', '' );
566
+ $message = __( 'Custom jotURL domain deleted.', 'wp-to-twitter' );
567
+ }
568
  if ( '' != $post['joturl_shorturl_params'] && isset( $post['submit'] ) ) {
569
  $v = trim( $post['joturl_shorturl_params'] );
570
  if ( substr( $v, 0, 1 ) == '&' || substr( $v, 0, 1 ) == '?' ) {
598
  return;
599
  }
600
  update_option( 'jd_shortener', sanitize_key( $post['jd_shortener'] ) );
601
+ $short = (string) get_option( 'jd_shortener' );
602
  $admin_url = admin_url( 'admin.php?page=wp-tweets-pro' );
603
  $admin_url = add_query_arg( 'tab', 'shortener', $admin_url );
604
 
605
  // these are the URL shorteners which require settings.
606
+ if ( '2' === $short || '10' === $short || '6' === $short ) {
607
  // Translators: Settings URL for shortener configuration.
608
  $message .= sprintf( __( 'You must <a href="%s">configure your URL shortener settings</a>.', 'wp-to-twitter' ), $admin_url );
609
  }
620
  * Form to select your shortener.
621
  */
622
  function wpt_pick_shortener() {
623
+ $shortener = (string) get_option( 'jd_shortener' );
624
+ if ( '2' === $shortener ) {
625
  echo '<p>' . __( 'The Bit.ly URL shortener API will be removed from WP to Twitter in March 2020. The version 3 API will be shut down on March 1st, and the plug-in will not be updated to version 4.', 'wp-to-twitter' ) . '</p>';
626
  }
627
  ?>
631
  <option value="3" <?php selected( $shortener, '3' ); ?>><?php _e( "Don't shorten URLs.", 'wp-to-twitter' ); ?></option>
632
  <option value="4" <?php selected( $shortener, '4' ); ?>>WordPress</option>
633
  <?php
634
+ if ( '2' === $shortener ) { // If Bit.ly is currently enabled, leave available.
635
  ?>
636
  <option value="2" <?php selected( $shortener, '2' ); ?>>Bit.ly</option>
637
  <?php
638
  }
639
+ if ( '5' === $shortener ) { // if the user has already selected local server, leave available.
640
  ?>
641
  <option value="5" <?php selected( $shortener, '5' ); ?>><?php _e( 'YOURLS (this server)', 'wp-to-twitter' ); ?></option>
642
  <?php
650
  ?>
651
  </select>
652
  <?php
653
+ if ( '3' !== $shortener ) {
654
  ?>
655
  <input type='checkbox' value='false' name='wpt_use_stored_urls' id='wpt_use_stored_urls' <?php checked( get_option( 'wpt_use_stored_urls' ), 'false' ); ?>> <label for='wpt_use_stored_urls'><?php _e( 'Always request a new short URL for Tweets', 'wp-to-twitter' ); ?></label>
656
  <?php
wp-to-twitter.php CHANGED
@@ -17,7 +17,7 @@
17
  * License: GPL-2.0+
18
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
19
  * Domain Path: lang
20
- * Version: 3.4.3
21
  */
22
 
23
  /*
@@ -57,7 +57,7 @@ require_once( plugin_dir_path( __FILE__ ) . 'wpt-widget.php' );
57
  require_once( plugin_dir_path( __FILE__ ) . 'wpt-rate-limiting.php' );
58
 
59
  global $wpt_version;
60
- $wpt_version = '3.4.3';
61
 
62
  add_action( 'init', 'wpt_load_textdomain' );
63
  /**
@@ -892,6 +892,7 @@ function wpt_tweet( $post_ID, $type = 'instant' ) {
892
  'timezone' => get_option( 'gmt_offset' ),
893
  'timestring' => date( 'Y-m-d H:i:s', time() + $time + $offset ),
894
  'current_ts' => date( 'Y-m-d H:i:s', time() ),
 
895
  ),
896
  1
897
  ),
17
  * License: GPL-2.0+
18
  * License URI: http://www.gnu.org/license/gpl-2.0.txt
19
  * Domain Path: lang
20
+ * Version: 3.4.4
21
  */
22
 
23
  /*
57
  require_once( plugin_dir_path( __FILE__ ) . 'wpt-rate-limiting.php' );
58
 
59
  global $wpt_version;
60
+ $wpt_version = '3.4.4';
61
 
62
  add_action( 'init', 'wpt_load_textdomain' );
63
  /**
892
  'timezone' => get_option( 'gmt_offset' ),
893
  'timestring' => date( 'Y-m-d H:i:s', time() + $time + $offset ),
894
  'current_ts' => date( 'Y-m-d H:i:s', time() ),
895
+ 'users' => $wpt_selected_users,
896
  ),
897
  1
898
  ),