WP to Twitter - Version 3.3.1

Version Description

  • Add temporary method to extend character count. Twitter has not yet released their new character counting library.
  • Minor style changes
Download this release

Release Info

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

Code changes from version 3.3.0 to 3.3.1

css/post-styles.css CHANGED
@@ -12,11 +12,31 @@
12
  position: absolute;
13
  right: 4%;
14
  bottom: 2px;
15
- font-size: 1.2em;
16
  font-weight: 700;
17
  color: #666;
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  #wp2t .warning {
21
  color: #700;
22
  }
12
  position: absolute;
13
  right: 4%;
14
  bottom: 2px;
15
+ font-size: 1.1em;
16
  font-weight: 700;
17
  color: #666;
18
  }
19
 
20
+ #wpt_custom_retweets .jtw2 label {
21
+ display: inline-block;
22
+ width: 4em;
23
+ }
24
+
25
+ #wpt_custom_retweets {
26
+ padding: .5em;
27
+ border: 1px solid #eee;
28
+ }
29
+
30
+
31
+ .wp-to-twitter .panel-toggle {
32
+ margin-bottom: 0;
33
+ }
34
+
35
+ #wpt_custom_retweets fieldset {
36
+ margin: 1em 0;
37
+ border-bottom: 1px solid #ccc;
38
+ }
39
+
40
  #wp2t .warning {
41
  color: #700;
42
  }
css/styles.css CHANGED
@@ -273,6 +273,13 @@ label[for='wpt_prepend_rt'], label[for='wpt_prepend_rt2'], label[for='wpt_prepen
273
  background: #233c7f;
274
  }
275
 
 
 
 
 
 
 
 
276
  .jcd-narrow .free .postbox, .jcd-narrow .free .postbox a, .jcd-narrow .free .postbox h3 {
277
  background: #233c7f;
278
  color: #fff;
273
  background: #233c7f;
274
  }
275
 
276
+ .tweet_length_control {
277
+ background: #ffd;
278
+ color: #000;
279
+ border: 2px solid #dd1;
280
+ padding: .5em;
281
+ }
282
+
283
  .jcd-narrow .free .postbox, .jcd-narrow .free .postbox a, .jcd-narrow .free .postbox h3 {
284
  background: #233c7f;
285
  color: #fff;
js/jquery.charcount.js CHANGED
@@ -34,21 +34,20 @@
34
  var urlcount = $(obj).val().indexOf('#url#') > -1 ? 18 : 0;
35
  var longurlcount = $(obj).val().indexOf('#longurl#') > -1 ? 14 : 0;
36
  if ( $( '#title' ).length ) {
37
- var titlecount = $(obj).val().indexOf('#title#') > -1 ? ( $('#title').val().length - 7 ) : 0;
38
  } else {
39
  var titlecount = 0;
40
  }
41
- var namecount = $(obj).val().indexOf('#blog#') > -1 ? ($('#wp-admin-bar-site-name a').val().length - 6) : 0;
42
- var imgcount = ( $('#wpt_image_yes:checked').length && $( '#remove-post-thumbnail' ).length ) ? 22 : 0;
43
-
44
  var available = options.allowed - ( count + urlcount + longurlcount + titlecount + namecount + imgcount );
45
 
46
- if (available <= options.warning && available >= 0) {
47
  $(obj).next().addClass(options.cssWarning);
48
  } else {
49
  $(obj).next().removeClass(options.cssWarning);
50
  }
51
- if (available < 0) {
52
  $(obj).next().addClass(options.cssExceeded);
53
  } else {
54
  $(obj).next().removeClass(options.cssExceeded);
@@ -69,4 +68,4 @@
69
 
70
  };
71
 
72
- })(jQuery);
34
  var urlcount = $(obj).val().indexOf('#url#') > -1 ? 18 : 0;
35
  var longurlcount = $(obj).val().indexOf('#longurl#') > -1 ? 14 : 0;
36
  if ( $( '#title' ).length ) {
37
+ var titlecount = $(obj).val().indexOf('#title#') > - 1 ? ( $('#title').val().length - 7 ) : 0;
38
  } else {
39
  var titlecount = 0;
40
  }
41
+ var namecount = $(obj).val().indexOf('#blog#') > -1 ? ($('#wp-admin-bar-site-name a').val().length - 6) : 0;
42
+ var imgcount = ( $('#wpt_image_yes:checked').length && $( '#remove-post-thumbnail' ).length ) ? 22 : 0;
 
43
  var available = options.allowed - ( count + urlcount + longurlcount + titlecount + namecount + imgcount );
44
 
45
+ if ( available <= options.warning && available >= 0 ) {
46
  $(obj).next().addClass(options.cssWarning);
47
  } else {
48
  $(obj).next().removeClass(options.cssWarning);
49
  }
50
+ if ( available < 0 ) {
51
  $(obj).next().addClass(options.cssExceeded);
52
  } else {
53
  $(obj).next().removeClass(options.cssExceeded);
68
 
69
  };
70
 
71
+ })(jQuery);
readme.txt CHANGED
@@ -3,10 +3,10 @@ Contributors: joedolson
3
  Donate link: http://www.joedolson.com/donate/
4
  Tags: twitter, microblogging, su.pr, bitly, yourls, redirect, shortener, post, links, social, sharing, media, tweet
5
  Requires at least: 4.4
6
- Tested up to: 4.8
7
  License: GPLv2 or later
8
  Text Domain: wp-to-twitter
9
- Stable tag: 3.3.0
10
 
11
  Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
12
 
@@ -64,6 +64,12 @@ Check out my <a href="https://github.com/joedolson/plugin-extensions/tree/master
64
 
65
  == Changelog ==
66
 
 
 
 
 
 
 
67
  = 3.3.0 =
68
 
69
  * Bug fix: Fix arguments when using keywords with YOURLS
3
  Donate link: http://www.joedolson.com/donate/
4
  Tags: twitter, microblogging, su.pr, bitly, yourls, redirect, shortener, post, links, social, sharing, media, tweet
5
  Requires at least: 4.4
6
+ Tested up to: 4.9
7
  License: GPLv2 or later
8
  Text Domain: wp-to-twitter
9
+ Stable tag: 3.3.1
10
 
11
  Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
12
 
64
 
65
  == Changelog ==
66
 
67
+
68
+ = 3.3.1 =
69
+
70
+ * Add temporary method to extend character count. Twitter has not yet released their new character counting library.
71
+ * Minor style changes
72
+
73
  = 3.3.0 =
74
 
75
  * Bug fix: Fix arguments when using keywords with YOURLS
wp-to-twitter-manager.php CHANGED
@@ -284,6 +284,7 @@ function wpt_update_settings() {
284
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
285
  echo "<div>$nonce</div>"; ?>
286
  <div>
 
287
  <?php echo apply_filters( 'wpt_pick_shortener', '' ); ?>
288
  <?php
289
  $post_types = get_post_types( array( 'public' => true ), 'objects' );
@@ -918,5 +919,25 @@ function wpt_do_server_check( $test = false ) {
918
  }
919
  echo $wpt_server_string;
920
  $admin_url = admin_url( 'admin.php?page=wp-tweets-pro&amp;refresh_wpt_server_string=true' );
 
921
  echo "<p><a href='" . $admin_url . "'>" . __( 'Test again', 'wp-to-twitter' ) . "</a></p>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
922
  }
284
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
285
  echo "<div>$nonce</div>"; ?>
286
  <div>
287
+ <?php echo apply_filters( 'wpt_tweet_length', '' ); ?>
288
  <?php echo apply_filters( 'wpt_pick_shortener', '' ); ?>
289
  <?php
290
  $post_types = get_post_types( array( 'public' => true ), 'objects' );
919
  }
920
  echo $wpt_server_string;
921
  $admin_url = admin_url( 'admin.php?page=wp-tweets-pro&amp;refresh_wpt_server_string=true' );
922
+
923
  echo "<p><a href='" . $admin_url . "'>" . __( 'Test again', 'wp-to-twitter' ) . "</a></p>";
924
+ }
925
+
926
+ add_filter( 'wpt_tweet_length', 'wpt_tweet_length' );
927
+ function wpt_tweet_length() {
928
+ $tweet_length = intval( ( get_option( 'wpt_tweet_length' ) ) ? get_option( 'wpt_tweet_length' ) : 140 );
929
+ $control = "<p class='tweet_length_control'>
930
+ <label for='wpt_tweet_length'>" . __( 'Tweet Length (max 280 characters)', 'wp-to-twitter' ) . "</label>
931
+ <input type='number' min='0' max='280' step='1' value='$tweet_length' id='wpt_tweet_length' name='wpt_tweet_length' />
932
+ <a href='https://www.joedolson.com/2017/11/twitter-expands-280-characters-sort/'>" . __( 'About this setting', 'wp-to-twitter' ) . "</a>
933
+ </p>";
934
+
935
+ return $control;
936
+ }
937
+
938
+ add_filter( 'wpt_settings', 'wpt_set_tweet_length' );
939
+ function wpt_set_tweet_length() {
940
+ if ( isset( $_POST['wpt_tweet_length'] ) ) {
941
+ update_option( 'wpt_tweet_length', intval( $_POST['wpt_tweet_length'] ) );
942
+ }
943
  }
wp-to-twitter.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP to Twitter
4
  Plugin URI: http://www.joedolson.com/wp-to-twitter/
5
  Description: Posts a Tweet when you update your WordPress blog or post a link, using your URL shortening service. Rich in features for customizing and promoting your Tweets.
6
- Version: 3.3.0
7
  Author: Joseph Dolson
8
  Text Domain: wp-to-twitter
9
  Domain Path: /lang
@@ -45,7 +45,7 @@ require_once( plugin_dir_path( __FILE__ ) . '/wpt-widget.php' );
45
  require_once( plugin_dir_path( __FILE__ ) . '/wpt-rate-limiting.php' );
46
 
47
  global $wpt_version;
48
- $wpt_version = "3.3.0";
49
 
50
  add_action( 'plugins_loaded', 'wpt_load_textdomain' );
51
  function wpt_load_textdomain() {
@@ -1272,7 +1272,7 @@ function wpt_add_twitter_inner_box( $post ) {
1272
  ?>
1273
  <div class='wptab' id='notes' aria-labelledby='tab_notes' role='tabpanel'>
1274
  <p>
1275
- <?php _e( "Tweets must be less than 140 characters; Twitter counts URLs as 22 or 23 characters. Template Tags: <code>#url#</code>, <code>#title#</code>, <code>#post#</code>, <code>#category#</code>, <code>#date#</code>, <code>#modified#</code>, <code>#author#</code>, <code>#account#</code>, <code>#tags#</code>, or <code>#blog#</code>, <code>#longurl#</code>.", 'wp-to-twitter' );
1276
  do_action( 'wpt_notes_tab', $post_id );
1277
  ?>
1278
  </p>
@@ -1489,10 +1489,12 @@ function wpt_admin_script() {
1489
  if ( $current_screen->base == 'post' || $current_screen->id == 'wp-tweets-pro_page_wp-to-twitter-schedule' ) {
1490
  wp_register_style( 'wpt-post-styles', plugins_url( 'css/post-styles.css', __FILE__ ) );
1491
  wp_enqueue_style( 'wpt-post-styles' );
 
 
1492
  if ( $current_screen->base == 'post' ) {
1493
- $allowed = 140 - mb_strlen( stripslashes( get_option( 'jd_twit_prepend' ) . get_option( 'jd_twit_append' ) ) );
1494
  } else {
1495
- $allowed = ( wpt_is_ssl( home_url() ) ) ? 137 : 138;
1496
  }
1497
  if ( function_exists( 'wpt_pro_exists' ) && get_option( 'jd_individual_twitter_users' ) == 1 ) {
1498
  $first = '#authors';
@@ -1506,6 +1508,7 @@ function wpt_admin_script() {
1506
  wp_localize_script( 'wpt-base-js', 'wptSettings', array(
1507
  'allowed' => $allowed,
1508
  'first' => $first,
 
1509
  'text' => __( 'Characters left: ', 'wp-to-twitter' )
1510
  ) );
1511
  echo "
3
  Plugin Name: WP to Twitter
4
  Plugin URI: http://www.joedolson.com/wp-to-twitter/
5
  Description: Posts a Tweet when you update your WordPress blog or post a link, using your URL shortening service. Rich in features for customizing and promoting your Tweets.
6
+ Version: 3.3.1
7
  Author: Joseph Dolson
8
  Text Domain: wp-to-twitter
9
  Domain Path: /lang
45
  require_once( plugin_dir_path( __FILE__ ) . '/wpt-rate-limiting.php' );
46
 
47
  global $wpt_version;
48
+ $wpt_version = "3.3.1";
49
 
50
  add_action( 'plugins_loaded', 'wpt_load_textdomain' );
51
  function wpt_load_textdomain() {
1272
  ?>
1273
  <div class='wptab' id='notes' aria-labelledby='tab_notes' role='tabpanel'>
1274
  <p>
1275
+ <?php _e( "Template Tags: <code>#url#</code>, <code>#title#</code>, <code>#post#</code>, <code>#category#</code>, <code>#date#</code>, <code>#modified#</code>, <code>#author#</code>, <code>#account#</code>, <code>#tags#</code>, <code>#blog#</code>, <code>#longurl#</code>.", 'wp-to-twitter' );
1276
  do_action( 'wpt_notes_tab', $post_id );
1277
  ?>
1278
  </p>
1489
  if ( $current_screen->base == 'post' || $current_screen->id == 'wp-tweets-pro_page_wp-to-twitter-schedule' ) {
1490
  wp_register_style( 'wpt-post-styles', plugins_url( 'css/post-styles.css', __FILE__ ) );
1491
  wp_enqueue_style( 'wpt-post-styles' );
1492
+ $config = wpt_max_length();
1493
+ // add one; character count starts from 1.
1494
  if ( $current_screen->base == 'post' ) {
1495
+ $allowed = $config['base_length'] - mb_strlen( stripslashes( get_option( 'jd_twit_prepend' ) . get_option( 'jd_twit_append' ) ) ) + 1;
1496
  } else {
1497
+ $allowed = $config['base_length'] + 1;
1498
  }
1499
  if ( function_exists( 'wpt_pro_exists' ) && get_option( 'jd_individual_twitter_users' ) == 1 ) {
1500
  $first = '#authors';
1508
  wp_localize_script( 'wpt-base-js', 'wptSettings', array(
1509
  'allowed' => $allowed,
1510
  'first' => $first,
1511
+ 'is_ssl' => ( wpt_is_ssl( home_url() ) ) ? 'true' : 'false',
1512
  'text' => __( 'Characters left: ', 'wp-to-twitter' )
1513
  ) );
1514
  echo "
wpt-truncate.php CHANGED
@@ -12,7 +12,6 @@ function wpt_max_length() {
12
  set_transient( 'wpt_twitter_config', $config, 60*60*24 );
13
  } else {
14
  $config = json_encode( array(
15
- 'base_length' => 139,
16
  'http_length' => 23,
17
  'https_length' => 23,
18
  'reserved_chars' => 24
@@ -27,7 +26,6 @@ function wpt_max_length() {
27
  $short_url_https = $decoded->short_url_length_https;
28
  $reserved_char = $decoded->characters_reserved_per_media;
29
  $values = array(
30
- 'base_length' => 139,
31
  'http_length' => $short_url_length,
32
  'https_length' => $short_url_https,
33
  'reserved_chars' => $reserved_char
@@ -36,12 +34,13 @@ function wpt_max_length() {
36
  } else {
37
  // if config query is invalid, use default values; these may become invalid
38
  $values = array(
39
- 'base_length' => 139,
40
  'http_length' => 23,
41
  'https_length' => 23,
42
  'reserved_chars' => 24
43
  );
44
  }
 
 
45
 
46
  return apply_filters( 'wpt_max_length', $values );
47
  }
12
  set_transient( 'wpt_twitter_config', $config, 60*60*24 );
13
  } else {
14
  $config = json_encode( array(
 
15
  'http_length' => 23,
16
  'https_length' => 23,
17
  'reserved_chars' => 24
26
  $short_url_https = $decoded->short_url_length_https;
27
  $reserved_char = $decoded->characters_reserved_per_media;
28
  $values = array(
 
29
  'http_length' => $short_url_length,
30
  'https_length' => $short_url_https,
31
  'reserved_chars' => $reserved_char
34
  } else {
35
  // if config query is invalid, use default values; these may become invalid
36
  $values = array(
 
37
  'http_length' => 23,
38
  'https_length' => 23,
39
  'reserved_chars' => 24
40
  );
41
  }
42
+
43
+ $values['base_length'] = intval( ( get_option( 'wpt_tweet_length' ) ) ? get_option( 'wpt_tweet_length' ) : 140 ) - 1;
44
 
45
  return apply_filters( 'wpt_max_length', $values );
46
  }