WP to Twitter - Version 3.0.7

Version Description

  • Bug fix: Twitter Feed search broken.
  • Bug fix: Display issue with support form textarea.
  • Address issue with input sources that have double encoded entities.
  • Improved: Error messages with Twitter Feed issues.
  • Add option to hide header on Twitter feed widget.
  • Language Update: Portuguese (Brazil)
Download this release

Release Info

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

Code changes from version 3.0.0 to 3.0.7

css/styles.css CHANGED
@@ -133,6 +133,7 @@ label[for="wpt_license_key"] {
133
  padding: 0 4px;
134
  position: relative;
135
  top: 1px;
 
136
  }
137
 
138
  #wpt_settings_page .tabs li {
@@ -143,7 +144,7 @@ label[for="wpt_license_key"] {
143
 
144
  #wpt_settings_page .tabs a {
145
  display: inline-block;
146
- padding: 4px 8px;
147
  border-radius: 4px 4px 0 0;
148
  border: 1px solid #ccc;
149
  background: #f3f3f3;
@@ -152,6 +153,9 @@ label[for="wpt_license_key"] {
152
  #wpt_settings_page .tabs a.active {
153
  border-bottom: 1px solid #fefefe;
154
  background: #fefefe;
 
 
 
155
  }
156
 
157
  #wpt_settings_page .wptab {
@@ -205,6 +209,48 @@ label[for="wpt_license_key"] {
205
  width: 20%;
206
  }
207
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  @media (max-width: 782px) {
209
  .jcd-narrow {
210
  width: 100%;
133
  padding: 0 4px;
134
  position: relative;
135
  top: 1px;
136
+ font-size: 1.2em;
137
  }
138
 
139
  #wpt_settings_page .tabs li {
144
 
145
  #wpt_settings_page .tabs a {
146
  display: inline-block;
147
+ padding: 6px 12px;
148
  border-radius: 4px 4px 0 0;
149
  border: 1px solid #ccc;
150
  background: #f3f3f3;
153
  #wpt_settings_page .tabs a.active {
154
  border-bottom: 1px solid #fefefe;
155
  background: #fefefe;
156
+ text-decoration: none;
157
+ color: #333;
158
+ font-weight: 700;
159
  }
160
 
161
  #wpt_settings_page .wptab {
209
  width: 20%;
210
  }
211
 
212
+ label[for='wpt_prepend_rt'], label[for='wpt_prepend_rt2'], label[for='wpt_prepend_rt3'] {
213
+ display: block;
214
+ }
215
+
216
+ .wpt-truncate {
217
+ display: inline-block;
218
+ padding: 4px;
219
+ }
220
+
221
+ .wpt-button {
222
+ text-align: center;
223
+ margin: 1em 0 !important;
224
+ }
225
+
226
+ .nav-tab-wrapper {
227
+ padding-left: 10px;
228
+ border-bottom: 1px solid #ccc;
229
+ }
230
+
231
+ .nav-tab-wrapper .nav-tab {
232
+ font-weight: 700;
233
+ font-size: 1.1em;
234
+ }
235
+
236
+ .wpt-button .cta a {
237
+ padding: 1em;
238
+ font-size: 1.2em;
239
+ background: #5993c1;
240
+ color: #fff;
241
+ text-decoration: none;
242
+ display: inline-block;
243
+ }
244
+
245
+ #wpt_settings_page iframe {
246
+ margin:10px auto!important;
247
+ }
248
+
249
+ .wpt-button .cta a:hover, .wpt-button .cta a:focus {
250
+ text-decoration: underline;
251
+ background: #233c7f;
252
+ }
253
+
254
  @media (max-width: 782px) {
255
  .jcd-narrow {
256
  width: 100%;
css/twitter-feed.css CHANGED
@@ -28,6 +28,11 @@
28
  text-align: center;
29
  }
30
 
 
 
 
 
 
31
  .wpt-intents a span {
32
  width: 16px;
33
  height: 16px;
@@ -67,4 +72,12 @@
67
 
68
  .favorited .wpt-intents .wpt-favorite span {
69
  background-position: -64px;
 
 
 
 
 
 
 
 
70
  }
28
  text-align: center;
29
  }
30
 
31
+ .wpt-twitter-image {
32
+ width: 100%;
33
+ height: auto;
34
+ }
35
+
36
  .wpt-intents a span {
37
  width: 16px;
38
  height: 16px;
72
 
73
  .favorited .wpt-intents .wpt-favorite span {
74
  background-position: -64px;
75
+ }
76
+
77
+ .wpt-intents a span.intent-text {
78
+ width: auto;
79
+ height: auto;
80
+ margin: 0;
81
+ top: 0;
82
+ background: none;
83
  }
js/ajax.js CHANGED
@@ -18,6 +18,7 @@
18
  var text = $('#jtw').val();
19
  var date = $('#jts .date').val();
20
  var time = $('#jts .time').val();
 
21
  var tweet_action = ( $(this).attr('data-action') === 'tweet' ) ? 'tweet' : 'schedule'
22
  var data = {
23
  'action': wpt_data.action,
@@ -25,6 +26,7 @@
25
  'tweet_text': text,
26
  'tweet_schedule': date + ' ' + time,
27
  'tweet_action': tweet_action,
 
28
  'security': wpt_data.security
29
  };
30
  $.post(ajaxurl, data, function (response) {
18
  var text = $('#jtw').val();
19
  var date = $('#jts .date').val();
20
  var time = $('#jts .time').val();
21
+ var auth = $('#jts #wpt_authorized_users').val();
22
  var tweet_action = ( $(this).attr('data-action') === 'tweet' ) ? 'tweet' : 'schedule'
23
  var data = {
24
  'action': wpt_data.action,
26
  'tweet_text': text,
27
  'tweet_schedule': date + ' ' + time,
28
  'tweet_action': tweet_action,
29
+ 'tweet_auth': auth,
30
  'security': wpt_data.security
31
  };
32
  $.post(ajaxurl, data, function (response) {
js/tabs.js CHANGED
@@ -1,30 +1,29 @@
1
  jQuery(document).ready(function ($) {
2
  var tabs = $('.wpt-settings .wptab').length;
3
- $('.wpt-settings .tabs a[href="#' + firstItem + '"]').addClass('active');
4
  if (tabs > 1) {
5
  $('.wpt-settings .wptab').not('#' + firstItem).hide();
6
  $('.wpt-settings .tabs a').on('click', function (e) {
7
  e.preventDefault();
8
- $('.wpt-settings .tabs a').removeClass('active');
9
- $(this).addClass('active');
10
  var target = $(this).attr('href');
11
  $('.wpt-settings .wptab').not(target).hide();
12
- $(target).show();
13
  });
14
- }
15
- ;
16
  var permissions = $('.wpt-permissions .wptab').length;
17
- $('.wpt-permissions .tabs a[href="#' + firstPerm + '"]').addClass('active');
18
  if (permissions > 1) {
19
  $('.wpt-permissions .wptab').not('#' + firstPerm).hide();
20
  $('.wpt-permissions .tabs a').on('click', function (e) {
21
  e.preventDefault();
22
- $('.wpt-permissions .tabs a').removeClass('active');
23
- $(this).addClass('active');
24
  var target = $(this).attr('href');
25
  $('.wpt-permissions .wptab').not(target).hide();
26
- $(target).show();
27
  });
28
- }
29
- ;
30
  });
1
  jQuery(document).ready(function ($) {
2
  var tabs = $('.wpt-settings .wptab').length;
3
+ $('.wpt-settings .tabs a[href="#' + firstItem + '"]').addClass('active').attr( 'aria-selected', 'true' );
4
  if (tabs > 1) {
5
  $('.wpt-settings .wptab').not('#' + firstItem).hide();
6
  $('.wpt-settings .tabs a').on('click', function (e) {
7
  e.preventDefault();
8
+ $('.wpt-settings .tabs a').removeClass('active').attr( 'aria-selected', 'false' );
9
+ $(this).addClass('active').attr( 'aria-selected', 'true' );
10
  var target = $(this).attr('href');
11
  $('.wpt-settings .wptab').not(target).hide();
12
+ $(target).show().attr( 'tabindex', '-1' ).focus();
13
  });
14
+ };
15
+
16
  var permissions = $('.wpt-permissions .wptab').length;
17
+ $('.wpt-permissions .tabs a[href="#' + firstPerm + '"]').addClass('active').attr( 'aria-selected', 'true' );
18
  if (permissions > 1) {
19
  $('.wpt-permissions .wptab').not('#' + firstPerm).hide();
20
  $('.wpt-permissions .tabs a').on('click', function (e) {
21
  e.preventDefault();
22
+ $('.wpt-permissions .tabs a').removeClass('active').attr( 'aria-selected', 'false' );
23
+ $(this).addClass('active').attr( 'aria-selected', 'true' );
24
  var target = $(this).attr('href');
25
  $('.wpt-permissions .wptab').not(target).hide();
26
+ $(target).show().attr( 'tabindex', '-1' ).focus();
27
  });
28
+ };
 
29
  });
lang/wp-to-twitter-es_ES.mo CHANGED
Binary file
lang/wp-to-twitter-ja.mo CHANGED
Binary file
lang/wp-to-twitter-pt_BR.mo CHANGED
Binary file
readme.txt CHANGED
@@ -1,12 +1,12 @@
1
  === WP to Twitter ===
2
  Contributors: joedolson
3
  Donate link: http://www.joedolson.com/donate/
4
- Tags: twitter, microblogging, su.pr, bitly, yourls, redirect, shortener, post, links
5
- Requires at least: 3.7.0
6
- Tested up to: 4.1
7
  License: GPLv2 or later
8
  Text Domain: wp-to-twitter
9
- Stable tag: 2.9.8
10
 
11
  Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
12
 
@@ -16,10 +16,10 @@ Posts a Twitter update when you update your WordPress blog or add a link, with y
16
 
17
  Yep. That's the basic functionality. But it's not the only thing you can do:
18
 
 
 
19
  * Shorten URLs in your Tweets with popular URL shorteners, or let Twitter to do it with [t.co](http://t.co).
20
- * Recent Tweets Widget: Display recent Tweets. Fetch Tweets from your own or any other account.
21
- * Tweet Search Widget: Display the Tweets resulting from a search.
22
-
23
  [Upgrade to WP Tweets Pro](http://www.joedolson.com/wp-tweets-pro/) and schedule Tweets, set up automatic reposts, upload images and more!
24
 
25
  WP to Twitter uses a customizable Tweet template for Tweets sent when updating or editing posts and pages or custom post types. You can customize your Tweet for each post, using custom template tags to generate the Tweet.
@@ -36,14 +36,16 @@ WP to Twitter uses a customizable Tweet template for Tweets sent when updating o
36
 
37
  Upgrade to [WP Tweets Pro](http://www.joedolson.com/wp-tweets-pro/) for extra features, including:
38
 
39
- * Each author can set up their own Twitter account
40
  * Time delayed Tweeting
41
  * Scheduled Tweet management
42
- * Co-Tweet to site and author Twitter accounts
43
  * Preview and Tweet comments
44
  * Filter Tweets by taxonomy (categories, tags, or custom taxonomies)
45
  * Upload images to Twitter
46
- * [...and more!](http://www.joedolson.com/wp-tweets-pro/)
 
 
47
 
48
  Want to stay up to date on WP to Twitter? [Follow me on Twitter!](https://twitter.com/joedolson)
49
 
@@ -52,7 +54,7 @@ Want to stay up to date on WP to Twitter? [Follow me on Twitter!](https://twitte
52
  Visit the [WP to Twitter translations page](http://translate.joedolson.com/projects/wp-to-twitter) to see how complete these are.
53
 
54
  Translations available (in order of completeness):
55
- Dutch, Italian, Russian, French, Danish, Catalan, Portuguese, Spanish, Chinese, Japanese, German, Romanian, Estonian, Swedish, Irish, Ukrainian, Lithuanian, Belarusian, Turkish
56
 
57
  Translating my plug-ins is always appreciated. Visit <a href="http://translate.joedolson.com">my translations site</a> to start getting your language into shape!
58
 
@@ -62,6 +64,58 @@ Translating my plug-ins is always appreciated. Visit <a href="http://translate.j
62
 
63
  * Use apply_filters( 'wpt_tweet_sentence', $tweet, $post_ID ) to pass custom taxonomy Tweet formats - Pending WordPress support for taxonomy meta.
64
  * Add regex filter to detect URLs typed into Tweet fields for counting/shortening purposes. [todo]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  = 3.0.0 =
67
 
@@ -1087,4 +1141,4 @@ Writing and maintaining a plug-in is a lot of work. You can help me by providing
1087
 
1088
  == Upgrade Notice ==
1089
 
1090
- * 3.0.0 - Changes storage format for short URL post meta. Upgrade cycle may take a while to process all posts.
1
  === WP to Twitter ===
2
  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: 3.9.2
6
+ Tested up to: 4.2.2
7
  License: GPLv2 or later
8
  Text Domain: wp-to-twitter
9
+ Stable tag: 3.0.6
10
 
11
  Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
12
 
16
 
17
  Yep. That's the basic functionality. But it's not the only thing you can do:
18
 
19
+ * Display your Recent Tweets: Widget for your recent Tweets. Fetch Tweets from your own or any other account.
20
+ * Display Tweets based on a search: Display the Tweets resulting from a search and limit by Geolocation.
21
  * Shorten URLs in your Tweets with popular URL shorteners, or let Twitter to do it with [t.co](http://t.co).
22
+
 
 
23
  [Upgrade to WP Tweets Pro](http://www.joedolson.com/wp-tweets-pro/) and schedule Tweets, set up automatic reposts, upload images and more!
24
 
25
  WP to Twitter uses a customizable Tweet template for Tweets sent when updating or editing posts and pages or custom post types. You can customize your Tweet for each post, using custom template tags to generate the Tweet.
36
 
37
  Upgrade to [WP Tweets Pro](http://www.joedolson.com/wp-tweets-pro/) for extra features, including:
38
 
39
+ * Authors can set up their own Twitter accounts in their profiles
40
  * Time delayed Tweeting
41
  * Scheduled Tweet management
42
+ * Simultaneously Tweet to site and author Twitter accounts
43
  * Preview and Tweet comments
44
  * Filter Tweets by taxonomy (categories, tags, or custom taxonomies)
45
  * Upload images to Twitter
46
+ * Integrated Twitter Card support
47
+ * Automatically schedule Tweets of old posts
48
+ * [Check out WP Tweets PRO!](http://www.joedolson.com/wp-tweets-pro/)
49
 
50
  Want to stay up to date on WP to Twitter? [Follow me on Twitter!](https://twitter.com/joedolson)
51
 
54
  Visit the [WP to Twitter translations page](http://translate.joedolson.com/projects/wp-to-twitter) to see how complete these are.
55
 
56
  Translations available (in order of completeness):
57
+ Japanese, Dutch, French, Italian, Russian, Danish, Catalan, Portuguese (Brazil), Spanish (Spain), Chinese (Taiwan), German, Romanian, Estonian, Polish, Lithuanian, Ukrainian, Irish, Swedish, Turkish
58
 
59
  Translating my plug-ins is always appreciated. Visit <a href="http://translate.joedolson.com">my translations site</a> to start getting your language into shape!
60
 
64
 
65
  * Use apply_filters( 'wpt_tweet_sentence', $tweet, $post_ID ) to pass custom taxonomy Tweet formats - Pending WordPress support for taxonomy meta.
66
  * Add regex filter to detect URLs typed into Tweet fields for counting/shortening purposes. [todo]
67
+ * 4.2 added compat function for mb_substr; drop mine when I drop support for 4.1
68
+
69
+ = 3.0.7 =
70
+
71
+ * Bug fix: Twitter Feed search broken.
72
+ * Bug fix: Display issue with support form textarea.
73
+ * Address issue with input sources that have double encoded entities.
74
+ * Improved: Error messages with Twitter Feed issues.
75
+ * Add option to hide header on Twitter feed widget.
76
+ * Language Update: Portuguese (Brazil)
77
+
78
+ = 3.0.6 =
79
+
80
+ * Bug fix: missing styles from Twitter feed
81
+ * Bug fix: test whether Tweet is possibly sensitive always returned true
82
+ * New feature: display uploaded images in Twitter feed instead of link to image.
83
+ * New template tag: #longurl# - use to Tweet the unshortened URL for a post.
84
+
85
+ = 3.0.5 =
86
+
87
+ * Bug fix: Typo in fix for settings update screwed things up.
88
+
89
+ = 3.0.4 =
90
+
91
+ * Bug fix: Error with YOURLS url handler. Two reversed variable definitions.
92
+ * Bug fix: Bad URL for testing time check when WP Tweets PRO active.
93
+ * Bug fix: Update could reset some settings to defaults.
94
+ * Grammar fix to one text string.
95
+ * Minor updates to Spanish & Portuguese translations
96
+
97
+ = 3.0.3 =
98
+
99
+ * Update Japanese translation
100
+ * Bug fix: accidentally left one debug message in override.
101
+
102
+ = 3.0.2 =
103
+
104
+ * Bug fix: obscure duplicating Tweets issue related to co-Tweeting and media uploads
105
+ * Bug fix: notice thrown if using Yourls and access to Yourls directory blocked at server.
106
+ * Revamped settings page.
107
+ * Updated user's guide.
108
+
109
+ = 3.0.1 =
110
+
111
+ * Changed priority of wpt_twit function on save_post action so that The Events Calendar can send Tweets.
112
+ * Bug fix: ensure that arguments passed to URL shorteners for analytics are URL encoded.
113
+ * Bug fix: Clear widget cache when widget is updated.
114
+ * Bug fix: invalid argument with obsolete category filters.
115
+ * Bug fix: inconsistent labeling of API key/consumer key.
116
+ * Bug fix: Errors in data migration for 3.0.0 fixed.
117
+ * Only show 'Tweet to' tab if individual authors options are enabled.
118
+ * Minor updates to application setup instructions.
119
 
120
  = 3.0.0 =
121
 
1141
 
1142
  == Upgrade Notice ==
1143
 
1144
+ * 3.0.5 - I don't think I'm sleeping enough. Sorry about all the rapid updates!
uninstall.php CHANGED
@@ -33,6 +33,7 @@ if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
33
 
34
  // Note that default options are set.
35
  delete_option( 'twitterInitialised' );
 
36
  delete_option( 'wp_twitter_failure' );
37
  delete_option( 'twitterlogin' );
38
  delete_option( 'twitterpw' );
33
 
34
  // Note that default options are set.
35
  delete_option( 'twitterInitialised' );
36
+ delete_option( 'wpt_twitter_setup' );
37
  delete_option( 'wp_twitter_failure' );
38
  delete_option( 'twitterlogin' );
39
  delete_option( 'twitterpw' );
wp-to-twitter-manager.php CHANGED
@@ -2,117 +2,11 @@
2
  if ( ! defined( 'ABSPATH' ) ) {
3
  exit;
4
  } // Exit if accessed directly
5
-
6
- function wpt_check_caps( $role, $cap ) {
7
- $role = get_role( $role );
8
- if ( $role->has_cap( $cap ) ) {
9
- return " checked='checked'";
10
- }
11
- return '';
12
- }
13
-
14
- function wpt_cap_checkbox( $role, $cap, $name ) {
15
- return "<li><input type='checkbox' id='wpt_caps_{$role}_$cap' name='wpt_caps[$role][$cap]' value='on'" . wpt_check_caps( $role, $cap ) . " /> <label for='wpt_caps_{$role}_$cap'>$name</label></li>";
16
- }
17
-
18
- // FUNCTION to see if checkboxes should be checked
19
- function jd_checkCheckbox( $field, $sub1 = false, $sub2 = '' ) {
20
- if ( $sub1 ) {
21
- $setting = get_option( $field );
22
- if ( isset( $setting[ $sub1 ] ) ) {
23
- $value = ( $sub2 != '' ) ? $setting[ $sub1 ][ $sub2 ] : $setting[ $sub1 ];
24
- } else {
25
- $value = 0;
26
- }
27
- if ( $value == 1 ) {
28
- return 'checked="checked"';
29
- }
30
- }
31
- if ( get_option( $field ) == '1' ) {
32
- return 'checked="checked"';
33
- }
34
- return '';
35
- }
36
-
37
- function jd_checkSelect( $field, $value, $type = 'select' ) {
38
- if ( get_option( $field ) == $value ) {
39
- return ( $type == 'select' ) ? 'selected="selected"' : 'checked="checked"';
40
- }
41
- return '';
42
- }
43
-
44
- function wpt_set_log( $data, $id, $message ) {
45
- if ( $id == 'test' ) {
46
- update_option( $data, $message );
47
- } else {
48
- update_post_meta( $id, '_' . $data, $message );
49
- }
50
- update_option( $data . '_last', array( $id, $message ) );
51
- }
52
-
53
- function wpt_log( $data, $id ) {
54
- if ( $id == 'test' ) {
55
- $log = get_option( $data );
56
- } else if ( $id == 'last' ) {
57
- $log = get_option( $data . '_last' );
58
- } else {
59
- $log = get_post_meta( $id, '_' . $data, true );
60
- }
61
-
62
- return $log;
63
- }
64
-
65
- function jd_check_functions() {
66
- $message = "<div class='update'><ul>";
67
- // grab or set necessary variables
68
- $testurl = get_bloginfo( 'url' );
69
- $testpost = false;
70
- $title = urlencode( 'Your blog home' );
71
- $shrink = apply_filters( 'wptt_shorten_link', $testurl, $title, false, true );
72
- if ( $shrink == false ) {
73
- $error = htmlentities( get_option( 'wpt_shortener_status' ) );
74
- $message .= __( "<li class=\"error\"><strong>WP to Twitter was unable to contact your selected URL shortening service.</strong></li>", 'wp-to-twitter' );
75
- if ( $error != '' ) {
76
- $message .= "<li><code>$error</code></li>";
77
- } else {
78
- $message .= "<li><code>" . __( 'No error message was returned.', 'wp-to-twitter' ) . "</code></li>";
79
- }
80
- } else {
81
- $message .= __( "<li><strong>WP to Twitter successfully contacted your selected URL shortening service.</strong> The following link should point to your blog homepage:", 'wp-to-twitter' );
82
- $message .= " <a href='$shrink'>$shrink</a></li>";
83
- }
84
- //check twitter credentials
85
- if ( wtt_oauth_test() ) {
86
- $rand = rand( 1000000, 9999999 );
87
- $testpost = jd_doTwitterAPIPost( "This is a test of WP to Twitter. $shrink ($rand)" );
88
- if ( $testpost ) {
89
- $message .= __( "<li><strong>WP to Twitter successfully submitted a status update to Twitter.</strong></li>", 'wp-to-twitter' );
90
- } else {
91
- $error = wpt_log( 'wpt_status_message', 'test' );
92
- $message .= __( "<li class=\"error\"><strong>WP to Twitter failed to submit an update to Twitter.</strong></li>", 'wp-to-twitter' );
93
- $message .= "<li class=\"error\">$error</li>";
94
- }
95
- } else {
96
- $message .= "<strong>" . _e( 'You have not connected WordPress to Twitter.', 'wp-to-twitter' ) . "</strong> ";
97
- }
98
- // If everything's OK, there's no reason to do this again.
99
- if ( $testpost == false && $shrink == false ) {
100
- $message .= __( "<li class=\"error\"><strong>Your server does not appear to support the required methods for WP to Twitter to function.</strong> You can try it anyway - these tests aren't perfect.</li>", 'wp-to-twitter' );
101
- } else {
102
- }
103
- if ( $testpost && $shrink ) {
104
- $message .= __( "<li><strong>Your server should run WP to Twitter successfully.</strong></li>", 'wp-to-twitter' );
105
- }
106
- $message .= "</ul>
107
- </div>";
108
-
109
- return $message;
110
- }
111
-
112
- function wpt_update_settings() {
113
  wpt_check_version();
114
 
115
- if ( ! empty( $_POST ) ) {
116
  $nonce = $_REQUEST['_wpnonce'];
117
  if ( ! wp_verify_nonce( $nonce, 'wp-to-twitter-nonce' ) ) {
118
  die( "Security check failed" );
@@ -127,80 +21,14 @@ function wpt_update_settings() {
127
 
128
  $message = "";
129
 
130
- // SET DEFAULT OPTIONS
131
- if ( get_option( 'twitterInitialised' ) != '1' ) {
132
- $initial_settings = array(
133
- 'post' => array(
134
- 'post-published-update' => 1,
135
- 'post-published-text' => 'New post: #title# #url#',
136
- 'post-edited-update' => 1,
137
- 'post-edited-text' => 'Post Edited: #title# #url#'
138
- ),
139
- 'page' => array(
140
- 'post-published-update' => 0,
141
- 'post-published-text' => 'New page: #title# #url#',
142
- 'post-edited-update' => 0,
143
- 'post-edited-text' => 'Page edited: #title# #url#'
144
- )
145
- );
146
- update_option( 'wpt_post_types', $initial_settings );
147
- update_option( 'jd_twit_blogroll', '1' );
148
- update_option( 'newlink-published-text', 'New link: #title# #url#' );
149
- update_option( 'jd_shortener', '1' );
150
- update_option( 'jd_strip_nonan', '0' );
151
- update_option( 'jd_max_tags', 3 );
152
- update_option( 'jd_max_characters', 15 );
153
- update_option( 'jd_replace_character', '' );
154
- $administrator = get_role( 'administrator' );
155
- $administrator->add_cap( 'wpt_twitter_oauth' );
156
- $administrator->add_cap( 'wpt_twitter_custom' );
157
- $administrator->add_cap( 'wpt_twitter_switch' );
158
- $administrator->add_cap( 'wpt_can_tweet' );
159
- $administrator->add_cap( 'wpt_tweet_now' );
160
- $editor = get_role( 'editor' );
161
- if ( is_object( $editor ) ) {
162
- $editor->add_cap( 'wpt_can_tweet' );
163
- }
164
- $author = get_role( 'author' );
165
- if ( is_object( $author ) ) {
166
- $author->add_cap( 'wpt_can_tweet' );
167
- }
168
- $contributor = get_role( 'contributor' );
169
- if ( is_object( $contributor ) ) {
170
- $contributor->add_cap( 'wpt_can_tweet' );
171
- }
172
-
173
- update_option( 'jd_twit_remote', '0' );
174
- update_option( 'jd_post_excerpt', 30 );
175
- // Use Google Analytics with Twitter
176
- update_option( 'twitter-analytics-campaign', 'twitter' );
177
- update_option( 'use-twitter-analytics', '0' );
178
- update_option( 'jd_dynamic_analytics', '0' );
179
- update_option( 'no-analytics', 1 );
180
- update_option( 'use_dynamic_analytics', 'category' );
181
- // Use custom external URLs to point elsewhere.
182
- update_option( 'jd_twit_custom_url', 'external_link' );
183
- // Error checking
184
- update_option( 'wp_url_failure', '0' );
185
- // Default publishing options.
186
- update_option( 'jd_tweet_default', '0' );
187
- update_option( 'jd_tweet_default_edit', '0' );
188
- update_option( 'wpt_inline_edits', '0' );
189
- // Note that default options are set.
190
- update_option( 'twitterInitialised', '1' );
191
- //YOURLS API
192
- update_option( 'jd_keyword_format', '0' );
193
- }
194
- if ( get_option( 'twitterInitialised' ) == '1' && get_option( 'jd_post_excerpt' ) == "" ) {
195
- update_option( 'jd_post_excerpt', 30 );
196
- }
197
-
198
- // notifications from oauth connection
199
  if ( isset( $_POST['oauth_settings'] ) ) {
200
  if ( $oauth_message == "success" ) {
 
 
201
  print( '
202
  <div id="message" class="updated fade">
203
- <p>' . __( 'WP to Twitter is now connected with Twitter.', 'wp-to-twitter' ) . '</p>
204
  </div>
205
  ' );
206
  } else if ( $oauth_message == "failed" ) {
@@ -323,54 +151,32 @@ function wpt_update_settings() {
323
 
324
  // Check whether the server has supported for needed functions.
325
  if ( isset( $_POST['submit-type'] ) && $_POST['submit-type'] == 'check-support' ) {
326
- $message = jd_check_functions();
327
  }
 
 
 
 
 
 
 
328
  ?>
329
  <div class="wrap" id="wp-to-twitter">
330
- <?php if ( $message ) { ?>
331
- <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
332
- <?php
333
- }
334
- $log = wpt_log( 'wpt_status_message', 'last' );
335
- if ( ! empty( $log ) && is_array( $log ) ) {
336
- $post_ID = $log[0];
337
- $post = get_post( $post_ID );
338
- if ( is_object( $post ) ) {
339
- $title = "<a href='" . get_edit_post_link( $post_ID ) . "'>$post->post_title</a>";
340
- } else {
341
- $title = __( 'No post associated with this Tweet', 'wp-to-twitter' );
342
- }
343
- $notice = $log[1];
344
- echo "<div class='updated fade'><p><strong>" . __( 'Last Tweet', 'wp-to-twitter' ) . "</strong>: $title &raquo; $notice</p></div>";
345
- }
346
- if ( isset( $_POST['submit-type'] ) && $_POST['submit-type'] == 'clear-error' ) {
347
- delete_option( 'wp_url_failure' );
348
- }
349
- if ( get_option( 'wp_url_failure' ) == '1' ) {
350
- ?>
351
- <div class="error">
352
- <?php
353
- if ( get_option( 'wp_url_failure' ) == '1' ) {
354
- _e( "<p>The query to the URL shortener API failed, and your URL was not shrunk. The full post URL was attached to your Tweet. Check with your URL shortening provider to see if there are any known issues.</p>", 'wp-to-twitter' );
355
- }
356
- $admin_url = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' ); ?>
357
- <form method="post" action="<?php echo $admin_url; ?>">
358
- <div><input type="hidden" name="submit-type" value="clear-error"/></div>
359
- <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
360
- echo "<div>$nonce</div>"; ?>
361
- <p><input type="submit" name="submit"
362
- value="<?php _e( "Clear 'WP to Twitter' Error Messages", 'wp-to-twitter' ); ?>"
363
- class="button-primary"/></p>
364
- </form>
365
- </div>
366
- <?php
367
- }
368
  ?>
 
369
  <h2><?php _e( "WP to Twitter Options", 'wp-to-twitter' ); ?></h2>
370
-
 
 
371
  <div id="wpt_settings_page" class="postbox-container jcd-wide">
372
 
373
  <?php
 
374
  if ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) {
375
  $debug = get_option( 'wpt_debug' );
376
  echo "<pre>";
@@ -383,12 +189,62 @@ function wpt_update_settings() {
383
  ?>
384
  <div class="metabox-holder">
385
 
386
- <?php if ( function_exists( 'wtt_connect_oauth' ) ) {
387
- wtt_connect_oauth();
388
- } ?>
389
- <?php if ( function_exists( 'wpt_pro_functions' ) ) {
390
- wpt_pro_functions();
391
- } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  <div class="ui-sortable meta-box-sortables">
393
  <div class="postbox">
394
  <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
@@ -399,23 +255,20 @@ function wpt_update_settings() {
399
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
400
  echo "<div>$nonce</div>"; ?>
401
  <div>
402
- <input type="submit" name="submit"
403
- value="<?php _e( "Save WP to Twitter Options", 'wp-to-twitter' ); ?>"
404
- class="button-primary button-side"/>
405
  <?php echo apply_filters( 'wpt_pick_shortener', '' ); ?>
406
  <?php
407
  $post_types = get_post_types( array( 'public' => true ), 'objects' );
408
  $wpt_settings = get_option( 'wpt_post_types' );
409
- $tabs = "<ul class='tabs'>";
410
  foreach ( $post_types as $type ) {
411
  $name = $type->labels->name;
412
  $slug = $type->name;
413
  if ( $slug == 'attachment' || $slug == 'nav_menu_item' || $slug == 'revision' ) {
414
  } else {
415
- $tabs .= "<li><a href='#wpt_$slug'>$name</a></li>";
416
  }
417
  }
418
- $tabs .= "<li><a href='#wpt_links'>" . __( 'Links', 'wp-to-twitter' ) . "</a></li>
419
  </ul>";
420
  echo $tabs;
421
  foreach ( $post_types as $type ) {
@@ -435,8 +288,10 @@ function wpt_update_settings() {
435
  }
436
  }
437
  ?>
438
- <div class='wptab wpt_types wpt_<?php echo $slug; ?>' id='wpt_<?php echo $slug; ?>'>
 
439
  <?php
 
440
  if ( get_option( 'limit_categories' ) != '0' && $slug == 'post' ) {
441
  $falseness = get_option( 'jd_twit_cats' );
442
  $categories = get_option( 'tweet_categories' );
@@ -446,9 +301,11 @@ function wpt_update_settings() {
446
  echo "<p>" . __( 'These categories are currently <strong>allowed</strong> by the deprecated WP to Twitter category filters.', 'wp-to-twitter' ) . "</p>";
447
  }
448
  echo "<ul>";
449
- foreach ( $categories as $cat ) {
450
- $category = get_the_category_by_ID( $cat );
451
- echo "<li>$category</li>";
 
 
452
  }
453
  echo "</ul>";
454
  if ( ! function_exists( 'wpt_pro_exists' ) ) {
@@ -512,10 +369,10 @@ function wpt_update_settings() {
512
  for="jd_twit_blogroll"><strong><?php _e( "Update Twitter when you post a Blogroll link", 'wp-to-twitter' ); ?></strong></label><br/>
513
  <label
514
  for="newlink-published-text"><?php _e( "Text for new link updates:", 'wp-to-twitter' ); ?></label>
515
- <input aria-labelledby="newlink-published-text-label" type="text"
516
  class="wpt-template" name="newlink-published-text"
517
  id="newlink-published-text" size="60" maxlength="120"
518
- value="<?php echo( esc_attr( stripslashes( get_option( 'newlink-published-text' ) ) ) ); ?>"/><br/><span
519
  id="newlink-published-text-label"><?php _e( 'Available shortcodes: <code>#url#</code>, <code>#title#</code>, and <code>#description#</code>.', 'wp-to-twitter' ); ?></span>
520
  </p>
521
  </fieldset>
@@ -533,9 +390,51 @@ function wpt_update_settings() {
533
  </div>
534
  </div>
535
  </div>
 
 
 
 
 
536
 
537
- <?php echo apply_filters( 'wpt_shortener_controls', '' ); ?>
538
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
  <div class="ui-sortable meta-box-sortables">
540
  <div class="postbox">
541
  <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
@@ -544,11 +443,10 @@ function wpt_update_settings() {
544
  <div class="inside">
545
  <form method="post" action="">
546
  <div>
547
- <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
548
- echo "<div>$nonce</div>"; ?>
549
- <input type="submit" name="submit"
550
- value="<?php _e( "Save Advanced WP to Twitter Options", 'wp-to-twitter' ); ?>"
551
- class="button-primary button-side"/>
552
 
553
  <fieldset>
554
  <legend><?php _e( 'Tags', 'wp-to-twitter' ); ?></legend>
@@ -569,20 +467,20 @@ function wpt_update_settings() {
569
  <label
570
  for="jd_replace_character"><?php _e( "Spaces in tags replaced with:", 'wp-to-twitter' ); ?></label>
571
  <input type="text" name="jd_replace_character" id="jd_replace_character"
572
- value="<?php echo esc_attr( get_option( 'jd_replace_character' ) ); ?>"
573
  size="3"/>
574
  </p>
575
 
576
  <p>
577
  <label
578
  for="jd_max_tags"><?php _e( "Maximum number of tags to include:", 'wp-to-twitter' ); ?></label>
579
- <input aria-labelledby="jd_max_characters_label" type="text" name="jd_max_tags"
580
- id="jd_max_tags" value="<?php echo esc_attr( get_option( 'jd_max_tags' ) ); ?>"
581
  size="3"/>
582
  <label
583
  for="jd_max_characters"><?php _e( "Maximum length in characters for included tags:", 'wp-to-twitter' ); ?></label>
584
  <input type="text" name="jd_max_characters" id="jd_max_characters"
585
- value="<?php echo esc_attr( get_option( 'jd_max_characters' ) ); ?>" size="3"/>
586
  </p>
587
  </fieldset>
588
  <fieldset>
@@ -590,16 +488,13 @@ function wpt_update_settings() {
590
  <p>
591
  <label
592
  for="jd_post_excerpt"><?php _e( "Length of post excerpt (in characters):", 'wp-to-twitter' ); ?></label>
593
- <input aria-labelledby="jd_post_excerpt_label" type="text" name="jd_post_excerpt"
594
- id="jd_post_excerpt" size="3" maxlength="3"
595
- value="<?php echo( esc_attr( get_option( 'jd_post_excerpt' ) ) ) ?>"/> (<em
596
- id="jd_post_excerpt_label"><?php _e( "Extracted from the post. If you use the 'Excerpt' field, it will be used instead.", 'wp-to-twitter' ); ?></em>)
597
  </p>
598
 
599
  <p>
600
  <label
601
  for="jd_date_format"><?php _e( "WP to Twitter Date Formatting:", 'wp-to-twitter' ); ?></label>
602
- <input type="text" aria-labelledby="date_format_label" name="jd_date_format"
603
  id="jd_date_format" size="12" maxlength="12"
604
  value="<?php if ( get_option( 'jd_date_format' ) == '' ) {
605
  echo( esc_attr( stripslashes( get_option( 'date_format' ) ) ) );
@@ -610,21 +505,21 @@ function wpt_update_settings() {
610
  } else {
611
  echo "<em>" . date_i18n( get_option( 'date_format' ) ) . "</em>";
612
  } ?> (<em
613
- id="date_format_label"><?php _e( "Default is from your general settings. <a href='http://codex.wordpress.org/Formatting_Date_and_Time'>Date Formatting Documentation</a>.", 'wp-to-twitter' ); ?></em>)
614
  </p>
615
 
616
  <p>
617
  <label
618
  for="jd_twit_prepend"><?php _e( "Custom text before all Tweets:", 'wp-to-twitter' ); ?></label>
619
  <input type="text" name="jd_twit_prepend" id="jd_twit_prepend" size="20"
620
- value="<?php echo( esc_attr( stripslashes( get_option( 'jd_twit_prepend' ) ) ) ) ?>"/>
621
  </p>
622
 
623
  <p>
624
  <label
625
  for="jd_twit_append"><?php _e( "Custom text after all Tweets:", 'wp-to-twitter' ); ?></label>
626
  <input type="text" name="jd_twit_append" id="jd_twit_append" size="20"
627
- value="<?php echo( esc_attr( stripslashes( get_option( 'jd_twit_append' ) ) ) ) ?>"/>
628
  </p>
629
 
630
  <p>
@@ -632,7 +527,7 @@ function wpt_update_settings() {
632
  for="jd_twit_custom_url"><?php _e( "Custom field for an alternate URL to be shortened and Tweeted:", 'wp-to-twitter' ); ?></label>
633
  <input type="text" name="jd_twit_custom_url" id="jd_twit_custom_url" size="40"
634
  maxlength="120"
635
- value="<?php echo( esc_attr( stripslashes( get_option( 'jd_twit_custom_url' ) ) ) ) ?>"/>
636
  </p>
637
  </fieldset>
638
 
@@ -661,14 +556,13 @@ function wpt_update_settings() {
661
  }
662
  asort( $default_order );
663
  foreach ( $default_order as $k => $v ) {
664
- $label = ucfirst( $k );
665
- $inputs .= "<input type='text' size='2' value='$v' name='wpt_truncation_order[$k]' /> <label for='$k-$v'>$label</label><br />";
666
  }
667
  ?>
668
  <fieldset>
669
  <legend><?php _e( 'Template tag priority order', 'wp-to-twitter' ); ?></legend>
670
- <p><?php _e( 'The order in which items will be abbreviated or removed from your Tweet if the Tweet is too long to send to Twitter.', 'wp-to-twitter' ); ?></p>
671
-
672
  <p>
673
  <?php echo $inputs; ?>
674
  </p>
@@ -698,19 +592,19 @@ function wpt_update_settings() {
698
  <input type="radio" name="twitter-analytics" id="use-twitter-analytics"
699
  value="1" <?php echo jd_checkCheckbox( 'use-twitter-analytics' ) ?> />
700
  <label
701
- for="use-twitter-analytics"><?php _e( "Use a Static Identifier with WP-to-Twitter", 'wp-to-twitter' ); ?></label><br/>
702
  <label
703
- for="twitter-analytics-campaign"><?php _e( "Static Campaign identifier for Google Analytics:", 'wp-to-twitter' ); ?></label>
704
  <input type="text" name="twitter-analytics-campaign" id="twitter-analytics-campaign"
705
  size="40" maxlength="120"
706
- value="<?php echo( esc_attr( get_option( 'twitter-analytics-campaign' ) ) ) ?>"/><br/>
707
  </p>
708
 
709
  <p>
710
  <input type="radio" name="twitter-analytics" id="use-dynamic-analytics"
711
  value="2" <?php echo jd_checkCheckbox( 'use_dynamic_analytics' ) ?> />
712
  <label
713
- for="use-dynamic-analytics"><?php _e( "Use a dynamic identifier with Google Analytics and WP-to-Twitter", 'wp-to-twitter' ); ?></label><br/>
714
  <label
715
  for="jd-dynamic-analytics"><?php _e( "What dynamic identifier would you like to use?", "wp-to-twitter" ); ?></label>
716
  <select name="jd-dynamic-analytics" id="jd-dynamic-analytics">
@@ -733,7 +627,7 @@ function wpt_update_settings() {
733
  <fieldset id="indauthors">
734
  <legend><?php _e( 'Author Settings', 'wp-to-twitter' ); ?></legend>
735
  <p>
736
- <input aria-labelledby="jd_individual_twitter_users_label" type="checkbox"
737
  name="jd_individual_twitter_users" id="jd_individual_twitter_users"
738
  value="1" <?php echo jd_checkCheckbox( 'jd_individual_twitter_users' ) ?> />
739
  <label
@@ -808,7 +702,9 @@ function wpt_update_settings() {
808
  </div>
809
  </div>
810
  </div>
811
-
 
 
812
  <div class="postbox" id="get-support">
813
  <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
814
  <h3 class='hndle'><span><?php _e( 'Get Plug-in Support', 'wp-to-twitter' ); ?></span></h3>
@@ -817,15 +713,17 @@ function wpt_update_settings() {
817
  <?php wpt_get_support_form(); ?>
818
  </div>
819
  </div>
820
-
 
 
 
821
  <form method="post" action="">
822
  <fieldset>
823
  <input type="hidden" name="submit-type" value="check-support"/>
824
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
825
  echo "<div>$nonce</div>"; ?>
826
  <p>
827
- <input type="submit" name="submit" value="<?php _e( 'Check Support', 'wp-to-twitter' ); ?>"
828
- class="button-primary"/> <?php _e( 'Check whether your server supports <a href="http://www.joedolson.com/wp-to-twitter/">WP to Twitter\'s</a> queries to the Twitter and URL shortening APIs. This test will send a status update to Twitter and shorten a URL using your selected methods.', 'wp-to-twitter' ); ?>
829
  </p>
830
  </fieldset>
831
  </form>
@@ -870,10 +768,10 @@ function wpt_sidebar() {
870
  } else {
871
  $support_url = admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' );
872
  } ?>
873
- <a href="<?php echo $support_url; ?>#get-support"><?php _e( "Get Support", 'wp-to-twitter' ); ?></a> &bull;
874
- <a href="https://www.joedolson.com/wp-content/uploads/wp-tweets-pro-users-guide-1.7.2.pdf"><?php _e( 'Read the Manual', 'wp-to-twitter' ); ?></a>
875
  <?php if ( get_option( 'jd_donations' ) != 1 && ! function_exists( 'wpt_pro_exists' ) ) { ?>
876
- <p><?php _e( '<a href="http://www.joedolson.com/donate.php">Make a donation today!</a><br />Every donation matters - donate $5, $20, or $100 today!', 'wp-to-twitter' ); ?></p>
877
  <div class='donations'>
878
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
879
  <div>
@@ -894,37 +792,6 @@ function wpt_sidebar() {
894
  </div>
895
  </div>
896
 
897
- <?php if ( ! function_exists( 'wpt_pro_exists' ) ) { ?>
898
- <div class="ui-sortable meta-box-sortables">
899
- <div class="postbox">
900
- <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
901
- <h3 class='wpt-upgrade hndle'><span><strong><?php _e( 'Upgrade Now!', 'wp-to-twitter' ); ?></strong></span>
902
- </h3>
903
-
904
- <div class="inside purchase">
905
- <strong><a
906
- href="http://www.joedolson.com/wp-tweets-pro/"><?php _e( 'Upgrade to <strong>WP Tweets PRO</strong>!', 'wp-to-twitter' ); ?></a></strong>
907
-
908
- <p><strong><?php _e( "What's in the premium add-on?", 'wp-to-twitter' ); ?></strong></p>
909
- <ul>
910
- <li><?php _e( 'Post to multiple Twitter accounts', 'wp-to-twitter' ); ?></li>
911
- <li><?php _e( 'Delay Tweets until after publishing', 'wp-to-twitter' ); ?></li>
912
- <li><?php _e( 'Automatically schedule Tweets to post again', 'wp-to-twitter' ); ?></li>
913
- <li><?php _e( 'Send Tweets for approved comments', 'wp-to-twitter' ); ?></li>
914
- <li><?php _e( 'Filter Tweets by category, tag, or custom taxonomy', 'wp-to-twitter' ); ?></li>
915
- <li><?php _e( 'Upload post images to Twitter', 'wp-to-twitter' ); ?></li>
916
- </ul>
917
-
918
- </div>
919
- </div>
920
- </div>
921
- <?php
922
- } else {
923
- if ( function_exists( 'wpt_notes' ) ) {
924
- wpt_notes();
925
- }
926
- } ?>
927
-
928
  <div class="ui-sortable meta-box-sortables">
929
  <div class="postbox">
930
  <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
@@ -935,44 +802,6 @@ function wpt_sidebar() {
935
  </div>
936
  </div>
937
  </div>
938
-
939
- <div class="ui-sortable meta-box-sortables">
940
- <div class="postbox">
941
- <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
942
- <h3 class='hndle'><span><?php _e( 'Shortcodes', 'wp-to-twitter' ); ?></span></h3>
943
-
944
- <div class="inside">
945
- <p><?php _e( "Available in post update templates:", 'wp-to-twitter' ); ?></p>
946
- <ul>
947
- <li><?php _e( "<code>#title#</code>: the title of your blog post", 'wp-to-twitter' ); ?></li>
948
- <li><?php _e( "<code>#blog#</code>: the title of your blog", 'wp-to-twitter' ); ?></li>
949
- <li><?php _e( "<code>#post#</code>: a short excerpt of the post content", 'wp-to-twitter' ); ?></li>
950
- <li><?php _e( "<code>#category#</code>: the first selected category for the post", 'wp-to-twitter' ); ?></li>
951
- <li><?php _e( "<code>#cat_desc#</code>: custom value from the category description field", 'wp-to-twitter' ); ?></li>
952
- <li><?php _e( "<code>#date#</code>: the post date", 'wp-to-twitter' ); ?></li>
953
- <li><?php _e( "<code>#modified#</code>: the post modified date", 'wp-to-twitter' ); ?></li>
954
- <li><?php _e( "<code>#url#</code>: the post URL", 'wp-to-twitter' ); ?></li>
955
- <li><?php _e( "<code>#author#</code>: the post author (@reference if available, otherwise display name)", 'wp-to-twitter' ); ?></li>
956
- <li><?php _e( "<code>#displayname#</code>: post author's display name", 'wp-to-twitter' ); ?></li>
957
- <li><?php _e( "<code>#account#</code>: the twitter @reference for the account (or the author, if author settings are enabled and set.)", 'wp-to-twitter' ); ?></li>
958
- <li><?php _e( "<code>#@#</code>: the twitter @reference for the author or blank, if not set", 'wp-to-twitter' ); ?></li>
959
- <li><?php _e( "<code>#tags#</code>: your tags modified into hashtags. See options in the Advanced Settings section, below.", 'wp-to-twitter' ); ?></li>
960
- <?php if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true ) { ?>
961
- <li><?php _e( "<code>#reference#</code>: Used only in co-tweeting. @reference to main account when posted to author account, @reference to author account in post to main account.", 'wp-to-twitter' ); ?></li>
962
- <?php } ?>
963
- </ul>
964
- <p>
965
- <?php
966
- _e( "Create custom shortcodes and access WordPress custom fields by using square brackets and the name of your custom field.", 'wp-to-twitter' );
967
- ?>
968
- <br />
969
- <?php
970
- _e( "<strong>Example:</strong> <code>[[custom_field]]</code>", 'wp-to-twitter' );
971
- ?>
972
- </p>
973
- </div>
974
- </div>
975
- </div>
976
  </div>
977
  <?php
978
  }
@@ -1031,6 +860,6 @@ function wpt_do_server_check( $test = false ) {
1031
  update_option( 'wpt_server_string', $wpt_server_string );
1032
  }
1033
  echo $wpt_server_string;
1034
- $admin_url = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php?refresh_wpt_server_string=true' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php&amp;refresh_wpt_server_string=true' );
1035
  echo "<p><a href='" . $admin_url . "'>" . __( 'Test again', 'wp-to-twitter' ) . "</a></p>";
1036
  }
2
  if ( ! defined( 'ABSPATH' ) ) {
3
  exit;
4
  } // Exit if accessed directly
5
+
6
+ function wpt_updated_settings() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  wpt_check_version();
8
 
9
+ if ( ! empty( $_POST['_wpnonce'] ) ) {
10
  $nonce = $_REQUEST['_wpnonce'];
11
  if ( ! wp_verify_nonce( $nonce, 'wp-to-twitter-nonce' ) ) {
12
  die( "Security check failed" );
21
 
22
  $message = "";
23
 
24
+ // notifications from oauth connection
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  if ( isset( $_POST['oauth_settings'] ) ) {
26
  if ( $oauth_message == "success" ) {
27
+ $admin_url = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro?tab=basic' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php&amp;tab=basic' );
28
+
29
  print( '
30
  <div id="message" class="updated fade">
31
+ <p>' . __( 'WP to Twitter is now connected with Twitter.', 'wp-to-twitter' ) . "<a href='$admin_url'>" . __( 'Configure your Tweet templates', 'wp-to-twitter' ) . '</a></p>
32
  </div>
33
  ' );
34
  } else if ( $oauth_message == "failed" ) {
151
 
152
  // Check whether the server has supported for needed functions.
153
  if ( isset( $_POST['submit-type'] ) && $_POST['submit-type'] == 'check-support' ) {
154
+ $message = wpt_check_functions();
155
  }
156
+
157
+ if ( $message ) {
158
+ echo '<div id="message" class="updated is-dismissible"><p>' . $message . '</p></div>';
159
+ }
160
+ }
161
+
162
+ function wpt_update_settings() {
163
  ?>
164
  <div class="wrap" id="wp-to-twitter">
165
+ <?php
166
+ wpt_updated_settings();
167
+ wpt_manual_migrate();
168
+ wpt_show_last_tweet();
169
+ wpt_handle_errors();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  ?>
171
+
172
  <h2><?php _e( "WP to Twitter Options", 'wp-to-twitter' ); ?></h2>
173
+ <div class='nav-tab-wrapper'>
174
+ <?php wpt_settings_tabs(); ?>
175
+ </div>
176
  <div id="wpt_settings_page" class="postbox-container jcd-wide">
177
 
178
  <?php
179
+ // Nothing triggers this. If you want some debugging information, just add the parameter to the URL.
180
  if ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) {
181
  $debug = get_option( 'wpt_debug' );
182
  echo "<pre>";
189
  ?>
190
  <div class="metabox-holder">
191
 
192
+ <?php
193
+ $default = ( get_option( 'wtt_twitter_username' ) == '' ) ? 'connection' : 'basic';
194
+ $current = ( isset( $_GET['tab'] ) ) ? $_GET['tab'] : $default;
195
+ if ( $current == 'connection' ) {
196
+ if ( function_exists( 'wtt_connect_oauth' ) ) {
197
+ wtt_connect_oauth();
198
+ }
199
+ }
200
+ if ( $current == 'pro' ) {
201
+ if ( function_exists( 'wpt_pro_functions' ) ) {
202
+ wpt_pro_functions();
203
+ if ( function_exists( 'wpt_notes' ) ) {
204
+ wpt_notes();
205
+ }
206
+ } else {
207
+ if ( ! function_exists( 'wpt_pro_exists' ) ) { ?>
208
+ <div class="ui-sortable meta-box-sortables">
209
+ <div class="postbox">
210
+ <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
211
+ <h3 class='wpt-upgrade hndle'><span><strong><?php _e( 'Upgrade Now!', 'wp-to-twitter' ); ?></strong></span>
212
+ </h3>
213
+
214
+ <div class="inside purchase">
215
+ <p>
216
+ <?php
217
+ _e( '<strong>What can WP Tweets PRO do for you?</strong> It takes the great Tweeting abilities from WP to Twitter and puts them in high gear: publish to unique Twitter accounts for every site author; schedule up to 3 re-posts of Tweets at an interval of your choice; and, with a delay between publishing and Tweeting, verify your tweets before you share them with your followers.', 'wp-to-twitter' );
218
+ ?>
219
+ </p>
220
+ <p class='wpt-button'>
221
+ <strong class='cta'><a href="https://www.joedolson.com/wp-tweets-pro/"><?php _e( 'Upgrade to <strong>WP Tweets PRO</strong>!', 'wp-to-twitter' ); ?></a></strong>
222
+ </p>
223
+
224
+ <h4><?php _e( 'What does WP Tweets PRO do?', 'wp-to-twitter' ); ?></h4>
225
+
226
+ <p>
227
+ <?php _e( 'WP Tweets PRO is packed with features to help you increase engagement with your Twitter followers. Upload images, support for Twitter Cards, and automated re-posting of your Tweets are just a few of the features available in the premium add-on to WP to Twitter.', 'wp-to-twitter' ); ?>
228
+ </p>
229
+
230
+ <h4><?php _e( 'Guy Kawasaki recommends WP to Twitter', 'wp-to-twitter' ); ?></h4>
231
+
232
+ <blockquote class="twitter-tweet" lang="en"><p>WP to Twitter = best Wordpress plugin according to <a href="https://twitter.com/GuyKawasaki">@GuyKawasaki</a> <a href="https://twitter.com/hashtag/SMMW15?src=hash">#SMMW15</a></p>&mdash; Cision (@Cision) <a href="https://twitter.com/Cision/status/581170603224371200">March 26, 2015</a></blockquote>
233
+ <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
234
+
235
+ <p class='wpt-button'>
236
+ <strong class='cta'><a href="https://www.joedolson.com/wp-tweets-pro/"><?php _e( 'Buy WP Tweets PRO today!', 'wp-to-twitter' ); ?></a></strong>
237
+ </p>
238
+
239
+ </div>
240
+ </div>
241
+ </div>
242
+ <?php
243
+ }
244
+ }
245
+ }
246
+ if ( $current == 'basic' ) {
247
+ ?>
248
  <div class="ui-sortable meta-box-sortables">
249
  <div class="postbox">
250
  <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
255
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
256
  echo "<div>$nonce</div>"; ?>
257
  <div>
 
 
 
258
  <?php echo apply_filters( 'wpt_pick_shortener', '' ); ?>
259
  <?php
260
  $post_types = get_post_types( array( 'public' => true ), 'objects' );
261
  $wpt_settings = get_option( 'wpt_post_types' );
262
+ $tabs = "<ul class='tabs' role='tablist'>";
263
  foreach ( $post_types as $type ) {
264
  $name = $type->labels->name;
265
  $slug = $type->name;
266
  if ( $slug == 'attachment' || $slug == 'nav_menu_item' || $slug == 'revision' ) {
267
  } else {
268
+ $tabs .= "<li><a href='#wpt_$slug' role='tab' id='tab_wpt_$slug' aria-controls='wpt_$slug'>$name</a></li>";
269
  }
270
  }
271
+ $tabs .= "<li><a href='#wpt_links' id='tab_wpt_links' aria-controls='wpt_links'>" . __( 'Links', 'wp-to-twitter' ) . "</a></li>
272
  </ul>";
273
  echo $tabs;
274
  foreach ( $post_types as $type ) {
288
  }
289
  }
290
  ?>
291
+
292
+ <div class='wptab wpt_types wpt_<?php echo $slug; ?>' aria-labelledby='tab_wpt_<?php echo $slug; ?>' role="tabpanel" id='wpt_<?php echo $slug; ?>'>
293
  <?php
294
+ // share information about any usage of pre 2.8 category filters
295
  if ( get_option( 'limit_categories' ) != '0' && $slug == 'post' ) {
296
  $falseness = get_option( 'jd_twit_cats' );
297
  $categories = get_option( 'tweet_categories' );
301
  echo "<p>" . __( 'These categories are currently <strong>allowed</strong> by the deprecated WP to Twitter category filters.', 'wp-to-twitter' ) . "</p>";
302
  }
303
  echo "<ul>";
304
+ if ( is_array( $categories ) ) {
305
+ foreach ( $categories as $cat ) {
306
+ $category = get_the_category_by_ID( $cat );
307
+ echo "<li>$category</li>";
308
+ }
309
  }
310
  echo "</ul>";
311
  if ( ! function_exists( 'wpt_pro_exists' ) ) {
369
  for="jd_twit_blogroll"><strong><?php _e( "Update Twitter when you post a Blogroll link", 'wp-to-twitter' ); ?></strong></label><br/>
370
  <label
371
  for="newlink-published-text"><?php _e( "Text for new link updates:", 'wp-to-twitter' ); ?></label>
372
+ <input aria-describedby="newlink-published-text-label" type="text"
373
  class="wpt-template" name="newlink-published-text"
374
  id="newlink-published-text" size="60" maxlength="120"
375
+ value="<?php esc_attr_e( stripslashes( get_option( 'newlink-published-text' ) ) ); ?>"/><br/><span
376
  id="newlink-published-text-label"><?php _e( 'Available shortcodes: <code>#url#</code>, <code>#title#</code>, and <code>#description#</code>.', 'wp-to-twitter' ); ?></span>
377
  </p>
378
  </fieldset>
390
  </div>
391
  </div>
392
  </div>
393
+
394
+ <div class="ui-sortable meta-box-sortables">
395
+ <div class="postbox">
396
+ <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
397
+ <h3 class='hndle'><span><?php _e( 'Tweet Template Tags', 'wp-to-twitter' ); ?></span></h3>
398
 
399
+ <div class="inside">
400
+ <ul>
401
+ <li><?php _e( "<code>#title#</code>: the title of your blog post", 'wp-to-twitter' ); ?></li>
402
+ <li><?php _e( "<code>#blog#</code>: the title of your blog", 'wp-to-twitter' ); ?></li>
403
+ <li><?php _e( "<code>#post#</code>: a short excerpt of the post content", 'wp-to-twitter' ); ?></li>
404
+ <li><?php _e( "<code>#category#</code>: the first selected category for the post", 'wp-to-twitter' ); ?></li>
405
+ <li><?php _e( "<code>#cat_desc#</code>: custom value from the category description field", 'wp-to-twitter' ); ?></li>
406
+ <li><?php _e( "<code>#date#</code>: the post date", 'wp-to-twitter' ); ?></li>
407
+ <li><?php _e( "<code>#modified#</code>: the post modified date", 'wp-to-twitter' ); ?></li>
408
+ <li><?php _e( "<code>#url#</code>: the post URL", 'wp-to-twitter' ); ?></li>
409
+ <li><?php _e( "<code>#longurl#</code>: the unshortened post URL", 'wp-to-twitter' ); ?></li>
410
+ <li><?php _e( "<code>#author#</code>: the post author (@reference if available, otherwise display name)", 'wp-to-twitter' ); ?></li>
411
+ <li><?php _e( "<code>#displayname#</code>: post author's display name", 'wp-to-twitter' ); ?></li>
412
+ <li><?php _e( "<code>#account#</code>: the twitter @reference for the account (or the author, if author settings are enabled and set.)", 'wp-to-twitter' ); ?></li>
413
+ <li><?php _e( "<code>#@#</code>: the twitter @reference for the author or blank, if not set", 'wp-to-twitter' ); ?></li>
414
+ <li><?php _e( "<code>#tags#</code>: your tags modified into hashtags. See options in the Advanced Settings section, below.", 'wp-to-twitter' ); ?></li>
415
+ <?php if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true ) { ?>
416
+ <li><?php _e( "<code>#reference#</code>: Used only in co-tweeting. @reference to main account when posted to author account, @reference to author account in post to main account.", 'wp-to-twitter' ); ?></li>
417
+ <?php } ?>
418
+ </ul>
419
+ <p>
420
+ <?php
421
+ _e( "Create custom shortcodes and access WordPress custom fields by using square brackets and the name of your custom field.", 'wp-to-twitter' );
422
+ ?>
423
+ <br />
424
+ <?php
425
+ _e( "<strong>Example:</strong> <code>[[custom_field]]</code>", 'wp-to-twitter' );
426
+ ?>
427
+ </p>
428
+ </div>
429
+ </div>
430
+ </div>
431
+ <?php }
432
+ if ( $current == 'shortener' ) {
433
+ echo apply_filters( 'wpt_shortener_controls', '' );
434
+ }
435
+
436
+ if ( $current == 'advanced' ) {
437
+ ?>
438
  <div class="ui-sortable meta-box-sortables">
439
  <div class="postbox">
440
  <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
443
  <div class="inside">
444
  <form method="post" action="">
445
  <div>
446
+ <?php
447
+ $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
448
+ echo "<div>$nonce</div>";
449
+ ?>
 
450
 
451
  <fieldset>
452
  <legend><?php _e( 'Tags', 'wp-to-twitter' ); ?></legend>
467
  <label
468
  for="jd_replace_character"><?php _e( "Spaces in tags replaced with:", 'wp-to-twitter' ); ?></label>
469
  <input type="text" name="jd_replace_character" id="jd_replace_character"
470
+ value="<?php esc_attr_e( get_option( 'jd_replace_character' ) ); ?>"
471
  size="3"/>
472
  </p>
473
 
474
  <p>
475
  <label
476
  for="jd_max_tags"><?php _e( "Maximum number of tags to include:", 'wp-to-twitter' ); ?></label>
477
+ <input aria-describedby="jd_max_characters_label" type="text" name="jd_max_tags"
478
+ id="jd_max_tags" value="<?php esc_attr_e( get_option( 'jd_max_tags' ) ); ?>"
479
  size="3"/>
480
  <label
481
  for="jd_max_characters"><?php _e( "Maximum length in characters for included tags:", 'wp-to-twitter' ); ?></label>
482
  <input type="text" name="jd_max_characters" id="jd_max_characters"
483
+ value="<?php esc_attr_e( get_option( 'jd_max_characters' ) ); ?>" size="3"/>
484
  </p>
485
  </fieldset>
486
  <fieldset>
488
  <p>
489
  <label
490
  for="jd_post_excerpt"><?php _e( "Length of post excerpt (in characters):", 'wp-to-twitter' ); ?></label>
491
+ <input type="text" name="jd_post_excerpt" id="jd_post_excerpt" size="3" maxlength="3" value="<?php echo( esc_attr( get_option( 'jd_post_excerpt' ) ) ) ?>"/>
 
 
 
492
  </p>
493
 
494
  <p>
495
  <label
496
  for="jd_date_format"><?php _e( "WP to Twitter Date Formatting:", 'wp-to-twitter' ); ?></label>
497
+ <input type="text" aria-describedby="date_format_label" name="jd_date_format"
498
  id="jd_date_format" size="12" maxlength="12"
499
  value="<?php if ( get_option( 'jd_date_format' ) == '' ) {
500
  echo( esc_attr( stripslashes( get_option( 'date_format' ) ) ) );
505
  } else {
506
  echo "<em>" . date_i18n( get_option( 'date_format' ) ) . "</em>";
507
  } ?> (<em
508
+ id="date_format_label"><a href='http://codex.wordpress.org/Formatting_Date_and_Time'><?php _e( "Date Formatting", 'wp-to-twitter' ); ?></a></em>)
509
  </p>
510
 
511
  <p>
512
  <label
513
  for="jd_twit_prepend"><?php _e( "Custom text before all Tweets:", 'wp-to-twitter' ); ?></label>
514
  <input type="text" name="jd_twit_prepend" id="jd_twit_prepend" size="20"
515
+ value="<?php esc_attr_e( stripslashes( get_option( 'jd_twit_prepend' ) ) ) ?>"/>
516
  </p>
517
 
518
  <p>
519
  <label
520
  for="jd_twit_append"><?php _e( "Custom text after all Tweets:", 'wp-to-twitter' ); ?></label>
521
  <input type="text" name="jd_twit_append" id="jd_twit_append" size="20"
522
+ value="<?php esc_attr_e( stripslashes( get_option( 'jd_twit_append' ) ) ) ?>"/>
523
  </p>
524
 
525
  <p>
527
  for="jd_twit_custom_url"><?php _e( "Custom field for an alternate URL to be shortened and Tweeted:", 'wp-to-twitter' ); ?></label>
528
  <input type="text" name="jd_twit_custom_url" id="jd_twit_custom_url" size="40"
529
  maxlength="120"
530
+ value="<?php esc_attr_e( stripslashes( get_option( 'jd_twit_custom_url' ) ) ) ?>"/>
531
  </p>
532
  </fieldset>
533
 
556
  }
557
  asort( $default_order );
558
  foreach ( $default_order as $k => $v ) {
559
+ $label = '<code>#' . $k . '#</code>';
560
+ $inputs .= "<div class='wpt-truncate'><label for='$k-$v'>$label</label><br /><input type='number' size='3' value='$v' name='wpt_truncation_order[$k]' /></div> ";
561
  }
562
  ?>
563
  <fieldset>
564
  <legend><?php _e( 'Template tag priority order', 'wp-to-twitter' ); ?></legend>
565
+ <p><?php _e( 'The order in which items will be abbreviated or removed from your Tweet if the Tweet is too long to send to Twitter.', 'wp-to-twitter' ); ?> <?php _e( 'Tags with lower values will be modified first.', 'wp-to-twitter' ); ?></p>
 
566
  <p>
567
  <?php echo $inputs; ?>
568
  </p>
592
  <input type="radio" name="twitter-analytics" id="use-twitter-analytics"
593
  value="1" <?php echo jd_checkCheckbox( 'use-twitter-analytics' ) ?> />
594
  <label
595
+ for="use-twitter-analytics"><?php _e( "Use a Static Identifier", 'wp-to-twitter' ); ?></label><br/>
596
  <label
597
+ for="twitter-analytics-campaign"><?php _e( "Static Campaign identifier", 'wp-to-twitter' ); ?></label>
598
  <input type="text" name="twitter-analytics-campaign" id="twitter-analytics-campaign"
599
  size="40" maxlength="120"
600
+ value="<?php esc_attr_e( get_option( 'twitter-analytics-campaign' ) ) ?>"/><br/>
601
  </p>
602
 
603
  <p>
604
  <input type="radio" name="twitter-analytics" id="use-dynamic-analytics"
605
  value="2" <?php echo jd_checkCheckbox( 'use_dynamic_analytics' ) ?> />
606
  <label
607
+ for="use-dynamic-analytics"><?php _e( "Use a dynamic identifier", 'wp-to-twitter' ); ?></label><br/>
608
  <label
609
  for="jd-dynamic-analytics"><?php _e( "What dynamic identifier would you like to use?", "wp-to-twitter" ); ?></label>
610
  <select name="jd-dynamic-analytics" id="jd-dynamic-analytics">
627
  <fieldset id="indauthors">
628
  <legend><?php _e( 'Author Settings', 'wp-to-twitter' ); ?></legend>
629
  <p>
630
+ <input aria-describedby="jd_individual_twitter_users_label" type="checkbox"
631
  name="jd_individual_twitter_users" id="jd_individual_twitter_users"
632
  value="1" <?php echo jd_checkCheckbox( 'jd_individual_twitter_users' ) ?> />
633
  <label
702
  </div>
703
  </div>
704
  </div>
705
+ <?php }
706
+ if ( $current == 'support' ) {
707
+ ?>
708
  <div class="postbox" id="get-support">
709
  <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
710
  <h3 class='hndle'><span><?php _e( 'Get Plug-in Support', 'wp-to-twitter' ); ?></span></h3>
713
  <?php wpt_get_support_form(); ?>
714
  </div>
715
  </div>
716
+ <?php } ?>
717
+ <p>
718
+ <?php _e( 'Check whether WP to Twitter is setup correctly for Twitter and your URL Shortener. The test sends a status update to Twitter and shortens a URL using your chosen shortener.', 'wp-to-twitter' ); ?>
719
+ </p>
720
  <form method="post" action="">
721
  <fieldset>
722
  <input type="hidden" name="submit-type" value="check-support"/>
723
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
724
  echo "<div>$nonce</div>"; ?>
725
  <p>
726
+ <input type="submit" name="submit" value="<?php _e( 'Test WP to Twitter', 'wp-to-twitter' ); ?>" class="button-primary" />
 
727
  </p>
728
  </fieldset>
729
  </form>
768
  } else {
769
  $support_url = admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' );
770
  } ?>
771
+ <a href="<?php echo esc_url( add_query_arg( 'tab', 'support', $support_url ) ); ?>#get-support"><?php _e( "Get Support", 'wp-to-twitter' ); ?></a> &bull;
772
+ <a href="https://www.joedolson.com/wp-content/uploads/wp-tweets-pro-users-guide-1.8.2.pdf"><?php _e( 'Read the Manual', 'wp-to-twitter' ); ?></a>
773
  <?php if ( get_option( 'jd_donations' ) != 1 && ! function_exists( 'wpt_pro_exists' ) ) { ?>
774
+ <p><?php _e( '<a href="https://www.joedolson.com/wp-tweets-pro/">Get WP Tweets Pro</a> or <a href="http://www.joedolson.com/donate.php">Make a donation</a> today!', 'wp-to-twitter' ); ?></p>
775
  <div class='donations'>
776
  <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
777
  <div>
792
  </div>
793
  </div>
794
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
795
  <div class="ui-sortable meta-box-sortables">
796
  <div class="postbox">
797
  <div class="handlediv"><span class="screen-reader-text">Click to toggle</span></div>
802
  </div>
803
  </div>
804
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
805
  </div>
806
  <?php
807
  }
860
  update_option( 'wpt_server_string', $wpt_server_string );
861
  }
862
  echo $wpt_server_string;
863
+ $admin_url = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro&amp;refresh_wpt_server_string=true' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php&amp;refresh_wpt_server_string=true' );
864
  echo "<p><a href='" . $admin_url . "'>" . __( 'Test again', 'wp-to-twitter' ) . "</a></p>";
865
  }
wp-to-twitter-oauth.php CHANGED
@@ -195,10 +195,10 @@ function wtt_connect_oauth( $auth = false ) {
195
  echo "<div class='error'><p>$message</p></div>";
196
  }
197
 
198
- $ack = ( ! $auth ) ? esc_attr( get_option( 'app_consumer_key' ) ) : esc_attr( get_user_meta( $auth, 'app_consumer_key', true ) );
199
- $acs = ( ! $auth ) ? esc_attr( get_option( 'app_consumer_secret' ) ) : esc_attr( get_user_meta( $auth, 'app_consumer_secret', true ) );
200
- $ot = ( ! $auth ) ? esc_attr( get_option( 'oauth_token' ) ) : esc_attr( get_user_meta( $auth, 'oauth_token', true ) );
201
- $ots = ( ! $auth ) ? esc_attr( get_option( 'oauth_token_secret' ) ) : esc_attr( get_user_meta( $auth, 'oauth_token_secret', true ) );
202
 
203
  $submit = ( ! $auth ) ? '<p class="submit"><input type="submit" name="submit" class="button-primary" value="' . __( 'Connect to Twitter', 'wp-to-twitter' ) . '" /></p>' : '';
204
  print( '
@@ -213,41 +213,41 @@ function wtt_connect_oauth( $auth = false ) {
213
  <li>' . __( 'If you\'re not currently logged in to Twitter, log-in to the account you want associated with this site', 'wp-to-twitter' ) . '</li>
214
  <li>' . __( 'Your application name cannot include the word "Twitter."', 'wp-to-twitter' ) . '</li>
215
  <li>' . __( 'Your Application Description can be anything.', 'wp-to-twitter' ) . '</li>
216
- <li>' . __( 'The WebSite and Callback URL should be ', 'wp-to-twitter' ) . '<strong>' . get_bloginfo( 'url' ) . '</strong></li>
217
  </ul>
218
- <p><em>' . __( 'Agree to the Developer Rules of the Road and continue.', 'wp-to-twitter' ) . '</em></p>
219
  <h4>' . __( '2. Switch to the "Permissions" tab in Twitter apps', 'wp-to-twitter' ) . '</h4>
220
  <ul>
221
  <li>' . __( 'Select "Read and Write" for the Application Type', 'wp-to-twitter' ) . '</li>
222
  <li>' . __( 'Update the application settings', 'wp-to-twitter' ) . '</li>
223
  </ul>
224
- <h4>' . __( '3. Switch to the API Keys tab and regenerate your API keys, then create your access token.', 'wp-to-twitter' ) . '</h4>
225
  <ul>
226
- <li>' . __( 'Copy your API key and API secret from the top section.', 'wp-to-twitter' ) . '</li>
227
- <li>' . __( 'Copy your Access token and Access token secret from the bottom section.', 'wp-to-twitter' ) . '</li>
228
  </ul>
229
  ' . $form . '
230
  <fieldset class="options">
231
  <div class="tokens">
232
  <p>
233
  <label for="wtt_app_consumer_key">' . __( 'API Key', 'wp-to-twitter' ) . '</label>
234
- <input type="text" size="45" name="wtt_app_consumer_key" id="wtt_app_consumer_key" value="' . $ack . '" />
235
  </p>
236
  <p>
237
  <label for="wtt_app_consumer_secret">' . __( 'API Secret', 'wp-to-twitter' ) . '</label>
238
- <input type="text" size="45" name="wtt_app_consumer_secret" id="wtt_app_consumer_secret" value="' . $acs . '" />
239
  </p>
240
  </div>
241
  <h4>' . __( '4. Copy and paste your Access Token and Access Token Secret into the fields below', 'wp-to-twitter' ) . '</h4>
242
- <p>' . __( 'If the Access level for your Access Token is not "<em>Read and write</em>", you must return to step 2 and generate a new Access Token.', 'wp-to-twitter' ) . '</p>
243
  <div class="tokens">
244
  <p>
245
  <label for="wtt_oauth_token">' . __( 'Access Token', 'wp-to-twitter' ) . '</label>
246
- <input type="text" size="45" name="wtt_oauth_token" id="wtt_oauth_token" value="' . $ot . '" />
247
  </p>
248
  <p>
249
  <label for="wtt_oauth_token_secret">' . __( 'Access Token Secret', 'wp-to-twitter' ) . '</label>
250
- <input type="text" size="45" name="wtt_oauth_token_secret" id="wtt_oauth_token_secret" value="' . $ots . '" />
251
  </p>
252
  </div>
253
  </fieldset>
@@ -265,7 +265,7 @@ function wtt_connect_oauth( $auth = false ) {
265
  $nonce = ( ! $auth ) ? wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false ) . '</form>' : '';
266
  if ( ! $auth ) {
267
  $submit = '
268
- <input type="submit" name="submit" class="button-primary" value="' . __( 'Disconnect Your WordPress and Twitter Account', 'wp-to-twitter' ) . '" />
269
  <input type="hidden" name="oauth_settings" value="wtt_twitter_disconnect" class="hidden" />
270
  ';
271
  } else {
@@ -281,8 +281,8 @@ function wtt_connect_oauth( $auth = false ) {
281
  <fieldset class="options">
282
  <ul>
283
  <li><strong class="auth_label">' . __( 'Twitter Username ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $uname . '</code></li>
284
- <li><strong class="auth_label">' . __( 'Consumer Key ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $ack . '</code></li>
285
- <li><strong class="auth_label">' . __( 'Consumer Secret ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $acs . '</code></li>
286
  <li><strong class="auth_label">' . __( 'Access Token ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $ot . '</code></li>
287
  <li><strong class="auth_label">' . __( 'Access Token Secret ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $ots . '</code></li>
288
  </ul>
195
  echo "<div class='error'><p>$message</p></div>";
196
  }
197
 
198
+ $ack = ( ! $auth ) ? get_option( 'app_consumer_key' ) : get_user_meta( $auth, 'app_consumer_key', true );
199
+ $acs = ( ! $auth ) ? get_option( 'app_consumer_secret' ) : get_user_meta( $auth, 'app_consumer_secret', true );
200
+ $ot = ( ! $auth ) ? get_option( 'oauth_token' ) : get_user_meta( $auth, 'oauth_token', true );
201
+ $ots = ( ! $auth ) ? get_option( 'oauth_token_secret' ) : get_user_meta( $auth, 'oauth_token_secret', true );
202
 
203
  $submit = ( ! $auth ) ? '<p class="submit"><input type="submit" name="submit" class="button-primary" value="' . __( 'Connect to Twitter', 'wp-to-twitter' ) . '" /></p>' : '';
204
  print( '
213
  <li>' . __( 'If you\'re not currently logged in to Twitter, log-in to the account you want associated with this site', 'wp-to-twitter' ) . '</li>
214
  <li>' . __( 'Your application name cannot include the word "Twitter."', 'wp-to-twitter' ) . '</li>
215
  <li>' . __( 'Your Application Description can be anything.', 'wp-to-twitter' ) . '</li>
216
+ <li>' . __( 'The WebSite and Callback URL should be ', 'wp-to-twitter' ) . '<strong>' . esc_url( home_url() ) . '</strong></li>
217
  </ul>
218
+ <p><em>' . __( 'Agree to the Twitter Developer Agreement and continue.', 'wp-to-twitter' ) . '</em></p>
219
  <h4>' . __( '2. Switch to the "Permissions" tab in Twitter apps', 'wp-to-twitter' ) . '</h4>
220
  <ul>
221
  <li>' . __( 'Select "Read and Write" for the Application Type', 'wp-to-twitter' ) . '</li>
222
  <li>' . __( 'Update the application settings', 'wp-to-twitter' ) . '</li>
223
  </ul>
224
+ <h4>' . __( '3. Switch to the Keys and Access Tokens tab and regenerate your consumer key and secret, then create your access token.', 'wp-to-twitter' ) . '</h4>
225
  <ul>
226
+ <li>' . __( 'Copy your API key and API secret from the "Application Settings" section.', 'wp-to-twitter' ) . '</li>
227
+ <li>' . __( 'Copy your Access token and Access token secret from the "Your Access Token" section.', 'wp-to-twitter' ) . '</li>
228
  </ul>
229
  ' . $form . '
230
  <fieldset class="options">
231
  <div class="tokens">
232
  <p>
233
  <label for="wtt_app_consumer_key">' . __( 'API Key', 'wp-to-twitter' ) . '</label>
234
+ <input type="text" size="45" name="wtt_app_consumer_key" id="wtt_app_consumer_key" value="' . esc_attr( $ack ) . '" />
235
  </p>
236
  <p>
237
  <label for="wtt_app_consumer_secret">' . __( 'API Secret', 'wp-to-twitter' ) . '</label>
238
+ <input type="text" size="45" name="wtt_app_consumer_secret" id="wtt_app_consumer_secret" value="' . esc_attr( $acs ) . '" />
239
  </p>
240
  </div>
241
  <h4>' . __( '4. Copy and paste your Access Token and Access Token Secret into the fields below', 'wp-to-twitter' ) . '</h4>
242
+ <p>' . __( 'If the Access Level for your Access Token is not "<em>Read and write</em>", you must return to step 2 and generate a new Access Token.', 'wp-to-twitter' ) . '</p>
243
  <div class="tokens">
244
  <p>
245
  <label for="wtt_oauth_token">' . __( 'Access Token', 'wp-to-twitter' ) . '</label>
246
+ <input type="text" size="45" name="wtt_oauth_token" id="wtt_oauth_token" value="' . esc_attr( $ot ) . '" />
247
  </p>
248
  <p>
249
  <label for="wtt_oauth_token_secret">' . __( 'Access Token Secret', 'wp-to-twitter' ) . '</label>
250
+ <input type="text" size="45" name="wtt_oauth_token_secret" id="wtt_oauth_token_secret" value="' . esc_attr( $ots ) . '" />
251
  </p>
252
  </div>
253
  </fieldset>
265
  $nonce = ( ! $auth ) ? wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false ) . '</form>' : '';
266
  if ( ! $auth ) {
267
  $submit = '
268
+ <input type="submit" name="submit" class="button-primary" value="' . __( 'Disconnect your WordPress and Twitter Account', 'wp-to-twitter' ) . '" />
269
  <input type="hidden" name="oauth_settings" value="wtt_twitter_disconnect" class="hidden" />
270
  ';
271
  } else {
281
  <fieldset class="options">
282
  <ul>
283
  <li><strong class="auth_label">' . __( 'Twitter Username ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $uname . '</code></li>
284
+ <li><strong class="auth_label">' . __( 'API Key ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $ack . '</code></li>
285
+ <li><strong class="auth_label">' . __( 'API Secret ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $acs . '</code></li>
286
  <li><strong class="auth_label">' . __( 'Access Token ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $ot . '</code></li>
287
  <li><strong class="auth_label">' . __( 'Access Token Secret ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . $ots . '</code></li>
288
  </ul>
wp-to-twitter-shorteners.php CHANGED
@@ -29,7 +29,7 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
29
  if ( $testmode != 'link' ) {
30
  $post = get_post( $post_ID );
31
  $post_author = $post->post_author;
32
- $campaign = get_the_author_meta( 'user_login', $post_author );
33
  } else {
34
  $campaign = '';
35
  }
@@ -37,8 +37,8 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
37
  } else {
38
  $campaign = get_option( 'twitter-analytics-campaign' );
39
  }
40
- $medium = apply_filters( 'wpt_utm_medium', 'twitter' );
41
- $source = apply_filters( 'wpt_utm_source', 'twitter' );
42
  $url = add_query_arg( array( 'utm_campaign'=>$campaign, 'utm_medium'=>$medium, 'utm_source'=>$source ), $url );
43
  }
44
  $url = urldecode( trim( $url ) ); // prevent double-encoding
@@ -135,9 +135,10 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
135
  ), $yourlsurl );
136
  }
137
  $json = jd_remote_json( $api_url, false );
138
- if ( $json ) {
139
  $shrink = $json->shorturl;
140
  } else {
 
141
  $shrink = false;
142
  }
143
  break;
@@ -343,14 +344,14 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
343
  <label
344
  for="suprlogin"><?php _e( "Your Su.pr Username:", 'wp-to-twitter' ); ?></label>
345
  <input type="text" name="suprlogin" id="suprlogin" size="40"
346
- value="<?php echo( esc_attr( get_option( 'suprlogin' ) ) ) ?>"/>
347
  </p>
348
 
349
  <p>
350
  <label
351
  for="suprapi"><?php _e( "Your Su.pr <abbr title='application programming interface'>API</abbr> Key:", 'wp-to-twitter' ); ?></label>
352
  <input type="text" name="suprapi" id="suprapi" size="40"
353
- value="<?php echo( esc_attr( get_option( 'suprapi' ) ) ) ?>"/>
354
  </p>
355
 
356
  <div>
@@ -358,10 +359,11 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
358
  </div>
359
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
360
  echo "<div>$nonce</div>"; ?>
361
- <p><input type="submit" name="submit" value="Save Su.pr API Key"
362
- class="button-primary"/> <input type="submit" name="clear"
363
- value="Clear Su.pr API Key"/>&raquo;
364
- <small><?php _e( "Don't have a Su.pr account or API key? <a href='http://su.pr/'>Get one here</a>!<br />You'll need an API key in order to associate the URLs you create with your Su.pr account.", 'wp-to-twitter' ); ?></small>
 
365
  </p>
366
  </div>
367
  </form>
@@ -378,14 +380,14 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
378
  <label
379
  for="bitlylogin"><?php _e( "Your Bit.ly username:", 'wp-to-twitter' ); ?></label>
380
  <input type="text" name="bitlylogin" id="bitlylogin"
381
- value="<?php echo( esc_attr( get_option( 'bitlylogin' ) ) ) ?>"/>
382
  </p>
383
 
384
  <p>
385
  <label
386
  for="bitlyapi"><?php _e( "Your Bit.ly <abbr title='application programming interface'>API</abbr> Key:", 'wp-to-twitter' ); ?></label>
387
  <input type="text" name="bitlyapi" id="bitlyapi" size="40"
388
- value="<?php echo( esc_attr( get_option( 'bitlyapi' ) ) ) ?>"/>
389
  </p>
390
 
391
  <p>
@@ -397,11 +399,8 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
397
  </div>
398
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
399
  echo "<div>$nonce</div>"; ?>
400
- <p><input type="submit" name="submit"
401
- value="<?php _e( 'Save Bit.ly API Key', 'wp-to-twitter' ); ?>"
402
- class="button-primary"/> <input type="submit" name="clear"
403
- value="<?php _e( 'Clear Bit.ly API Key', 'wp-to-twitter' ); ?>"/><br/>
404
- <small><?php _e( "A Bit.ly API key and username is required to shorten URLs via the Bit.ly API and WP to Twitter.", 'wp-to-twitter' ); ?></small>
405
  </p>
406
  </div>
407
  </form>
@@ -418,7 +417,7 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
418
  <label
419
  for="yourlspath"><?php _e( 'Path to your YOURLS config file (Local installations)', 'wp-to-twitter' ); ?></label><br/><input
420
  type="text" id="yourlspath" name="yourlspath" size="60"
421
- value="<?php echo( esc_attr( get_option( 'yourlspath' ) ) ); ?>"/><br/>
422
  <small><?php _e( 'Example:', 'wp-to-twitter' ); ?> <code>/home/username/www/www/yourls/user/config.php</code>
423
  </small>
424
  </p>
@@ -426,7 +425,7 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
426
  <label
427
  for="yourlsurl"><?php _e( 'URI to the YOURLS API (Remote installations)', 'wp-to-twitter' ); ?></label><br/><input
428
  type="text" id="yourlsurl" name="yourlsurl" size="60"
429
- value="<?php echo( esc_attr( get_option( 'yourlsurl' ) ) ); ?>"/><br/>
430
  <small><?php _e( 'Example:', 'wp-to-twitter' ); ?> <code>http://domain.com/yourls-api.php</code>
431
  </small>
432
  </p>
@@ -434,7 +433,7 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
434
  <label
435
  for="yourlstoken"><?php _e( "YOURLS signature token:", 'wp-to-twitter' ); ?></label>
436
  <input type="text" name="yourlstoken" id="yourlstoken" size="30"
437
- value="<?php echo( esc_attr( get_option( 'yourlstoken' ) ) ) ?>"/>
438
  </p>
439
  <?php if ( get_option( 'yourlsapi' ) && get_option( 'yourlslogin' ) ) { ?>
440
  <p>
@@ -461,11 +460,7 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
461
  </div>
462
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
463
  echo "<div>$nonce</div>"; ?>
464
- <p><input type="submit" name="submit"
465
- value="<?php _e( 'Save YOURLS Account Info', 'wp-to-twitter' ); ?>"
466
- class="button-primary"/> <input type="submit" name="clear"
467
- value="<?php _e( 'Clear YOURLS password', 'wp-to-twitter' ); ?>"/><br/>
468
- <small><?php _e( "A YOURLS password and username is required to shorten URLs via the remote YOURLS API and WP to Twitter.", 'wp-to-twitter' ); ?></small>
469
  </p>
470
  </div>
471
  </form>
@@ -482,14 +477,14 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
482
  <label
483
  for="joturllogin"><?php _e( "Your jotURL public <abbr title='application programming interface'>API</abbr> key:", 'wp-to-twitter' ); ?></label>
484
  <input type="text" name="joturllogin" id="joturllogin"
485
- value="<?php echo( esc_attr( get_option( 'joturllogin' ) ) ) ?>"/>
486
  </p>
487
 
488
  <p>
489
  <label
490
  for="joturlapi"><?php _e( "Your jotURL private <abbr title='application programming interface'>API</abbr> key:", 'wp-to-twitter' ); ?></label>
491
  <input type="text" name="joturlapi" id="joturlapi" size="40"
492
- value="<?php echo( esc_attr( get_option( 'joturlapi' ) ) ) ?>"/>
493
  </p>
494
 
495
  <p>
@@ -497,7 +492,7 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
497
  for="joturl_longurl_params"><?php _e( "Parameters to add to the long URL (before shortening):", 'wp-to-twitter' ); ?></label>
498
  <input type="text" name="joturl_longurl_params" id="joturl_longurl_params"
499
  size="40"
500
- value="<?php echo( esc_attr( get_option( 'joturl_longurl_params' ) ) ) ?>"/>
501
  </p>
502
 
503
  <p>
@@ -505,7 +500,7 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
505
  for="joturl_shorturl_params"><?php _e( "Parameters to add to the short URL (after shortening):", 'wp-to-twitter' ); ?></label>
506
  <input type="text" name="joturl_shorturl_params" id="joturl_shorturl_params"
507
  size="40"
508
- value="<?php echo( esc_attr( get_option( 'joturl_shorturl_params' ) ) ) ?>"/>
509
  </p>
510
 
511
  <p>
@@ -515,12 +510,9 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
515
  <div><input type="hidden" name="submit-type" value="joturlapi"/></div>
516
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
517
  echo "<div>$nonce</div>"; ?>
518
- <p><input type="submit" name="submit"
519
- value="<?php _e( 'Save jotURL settings', 'wp-to-twitter' ); ?>"
520
- class="button-primary"/> <input type="submit" name="clear"
521
- value="<?php _e( 'Clear jotURL settings', 'wp-to-twitter' ); ?>"/>
522
- <br/>
523
- <small><?php _e( "A jotURL public and private API key is required to shorten URLs via the jotURL API and WP to Twitter.", 'wp-to-twitter' ); ?></small>
524
  </p>
525
  </div>
526
  </form>
@@ -544,13 +536,7 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
544
  delete_option( 'yourlslogin' );
545
  $message .= __( 'YOURLS signature token updated.', 'wp-to-twitter' );
546
  }
547
- if ( $post['yourlsurl'] != '' ) {
548
- update_option( 'yourlsurl', trim( $post['yourlsurl'] ) );
549
- $message .= __( "YOURLS API url added. ", 'wp-to-twitter' );
550
- } else {
551
- update_option( 'yourlsurl', '' );
552
- $message .= __( "YOURLS API url removed. ", 'wp-to-twitter' );
553
- }
554
  if ( $post['yourlspath'] != '' ) {
555
  update_option( 'yourlspath', trim( $post['yourlspath'] ) );
556
  if ( file_exists( $post['yourlspath'] ) ) {
@@ -558,9 +544,6 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
558
  } else {
559
  $message .= __( "The path to your YOURLS installation is not correct. ", 'wp-to-twitter' );
560
  }
561
- } else {
562
- update_option( 'yourlspath', '' );
563
- $message .= __( "YOURLS local server path removed. ", 'wp-to-twitter' );
564
  }
565
  if ( $post['jd_keyword_format'] != '' ) {
566
  update_option( 'jd_keyword_format', $post['jd_keyword_format'] );
@@ -569,9 +552,15 @@ if ( ! function_exists( 'jd_shorten_link' ) ) { // prep work for future plug-in
569
  } else {
570
  $message .= __( "YOURLS will use your custom keyword for short URL slug.", 'wp-to-twitter' );
571
  }
572
- } else {
573
- update_option( 'jd_keyword_format', '' );
574
- $message .= __( "YOURLS will not use Post ID for the short URL slug.", 'wp-to-twitter' );
 
 
 
 
 
 
575
  }
576
  }
577
 
29
  if ( $testmode != 'link' ) {
30
  $post = get_post( $post_ID );
31
  $post_author = $post->post_author;
32
+ $campaign = urlencode( get_the_author_meta( 'user_login', $post_author ) );
33
  } else {
34
  $campaign = '';
35
  }
37
  } else {
38
  $campaign = get_option( 'twitter-analytics-campaign' );
39
  }
40
+ $medium = urlencode( trim( apply_filters( 'wpt_utm_medium', 'twitter' ) ) );
41
+ $source = urlencode( trim( apply_filters( 'wpt_utm_source', 'twitter' ) ) );
42
  $url = add_query_arg( array( 'utm_campaign'=>$campaign, 'utm_medium'=>$medium, 'utm_source'=>$source ), $url );
43
  }
44
  $url = urldecode( trim( $url ) ); // prevent double-encoding
135
  ), $yourlsurl );
136
  }
137
  $json = jd_remote_json( $api_url, false );
138
+ if ( is_object( $json ) ) {
139
  $shrink = $json->shorturl;
140
  } else {
141
+ $error = "Error code: " . $json->shorturl;
142
  $shrink = false;
143
  }
144
  break;
344
  <label
345
  for="suprlogin"><?php _e( "Your Su.pr Username:", 'wp-to-twitter' ); ?></label>
346
  <input type="text" name="suprlogin" id="suprlogin" size="40"
347
+ value="<?php esc_attr_e( get_option( 'suprlogin' ) ) ?>"/>
348
  </p>
349
 
350
  <p>
351
  <label
352
  for="suprapi"><?php _e( "Your Su.pr <abbr title='application programming interface'>API</abbr> Key:", 'wp-to-twitter' ); ?></label>
353
  <input type="text" name="suprapi" id="suprapi" size="40"
354
+ value="<?php esc_attr_e( get_option( 'suprapi' ) ) ?>"/>
355
  </p>
356
 
357
  <div>
359
  </div>
360
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
361
  echo "<div>$nonce</div>"; ?>
362
+ <p>
363
+ <input type="submit" name="submit" value="<?php _e( 'Save Su.pr API Key', 'wp-to-twitter' ); ?>" class="button-primary"/>
364
+ <input type="submit" name="clear" value="<?php _e( 'Clear Su.pr API Key', 'wp-to-twitter' ); ?>" class="button-secondary" />
365
+ <br />
366
+ <small><?php _e( "Don't have a Su.pr account or API key? <a href='http://su.pr/'>Get one here!</a> You'll need an API key in order to associate the URLs you create with your Su.pr account.", 'wp-to-twitter' ); ?></small>
367
  </p>
368
  </div>
369
  </form>
380
  <label
381
  for="bitlylogin"><?php _e( "Your Bit.ly username:", 'wp-to-twitter' ); ?></label>
382
  <input type="text" name="bitlylogin" id="bitlylogin"
383
+ value="<?php esc_attr_e( get_option( 'bitlylogin' ) ) ?>"/>
384
  </p>
385
 
386
  <p>
387
  <label
388
  for="bitlyapi"><?php _e( "Your Bit.ly <abbr title='application programming interface'>API</abbr> Key:", 'wp-to-twitter' ); ?></label>
389
  <input type="text" name="bitlyapi" id="bitlyapi" size="40"
390
+ value="<?php esc_attr_e( get_option( 'bitlyapi' ) ) ?>"/>
391
  </p>
392
 
393
  <p>
399
  </div>
400
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
401
  echo "<div>$nonce</div>"; ?>
402
+ <p>
403
+ <input type="submit" name="submit" value="<?php _e( 'Save Bit.ly API Key', 'wp-to-twitter' ); ?>" class="button-primary"/> <input type="submit" name="clear" value="<?php _e( 'Clear Bit.ly API Key', 'wp-to-twitter' ); ?>" class="button-secondary" />
 
 
 
404
  </p>
405
  </div>
406
  </form>
417
  <label
418
  for="yourlspath"><?php _e( 'Path to your YOURLS config file (Local installations)', 'wp-to-twitter' ); ?></label><br/><input
419
  type="text" id="yourlspath" name="yourlspath" size="60"
420
+ value="<?php esc_attr_e( get_option( 'yourlspath' ) ); ?>"/><br/>
421
  <small><?php _e( 'Example:', 'wp-to-twitter' ); ?> <code>/home/username/www/www/yourls/user/config.php</code>
422
  </small>
423
  </p>
425
  <label
426
  for="yourlsurl"><?php _e( 'URI to the YOURLS API (Remote installations)', 'wp-to-twitter' ); ?></label><br/><input
427
  type="text" id="yourlsurl" name="yourlsurl" size="60"
428
+ value="<?php esc_attr_e( get_option( 'yourlsurl' ) ); ?>"/><br/>
429
  <small><?php _e( 'Example:', 'wp-to-twitter' ); ?> <code>http://domain.com/yourls-api.php</code>
430
  </small>
431
  </p>
433
  <label
434
  for="yourlstoken"><?php _e( "YOURLS signature token:", 'wp-to-twitter' ); ?></label>
435
  <input type="text" name="yourlstoken" id="yourlstoken" size="30"
436
+ value="<?php esc_attr_e( get_option( 'yourlstoken' ) ) ?>"/>
437
  </p>
438
  <?php if ( get_option( 'yourlsapi' ) && get_option( 'yourlslogin' ) ) { ?>
439
  <p>
460
  </div>
461
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
462
  echo "<div>$nonce</div>"; ?>
463
+ <p><input type="submit" name="submit" value="<?php _e( 'Save YOURLS settings', 'wp-to-twitter' ); ?>" class="button-primary" /> <input type="submit" name="clear" value="<?php _e( 'Clear YOURLS settings', 'wp-to-twitter' ); ?>" class="button-secondary" />
 
 
 
 
464
  </p>
465
  </div>
466
  </form>
477
  <label
478
  for="joturllogin"><?php _e( "Your jotURL public <abbr title='application programming interface'>API</abbr> key:", 'wp-to-twitter' ); ?></label>
479
  <input type="text" name="joturllogin" id="joturllogin"
480
+ value="<?php esc_attr_e( get_option( 'joturllogin' ) ) ?>"/>
481
  </p>
482
 
483
  <p>
484
  <label
485
  for="joturlapi"><?php _e( "Your jotURL private <abbr title='application programming interface'>API</abbr> key:", 'wp-to-twitter' ); ?></label>
486
  <input type="text" name="joturlapi" id="joturlapi" size="40"
487
+ value="<?php esc_attr_e( get_option( 'joturlapi' ) ) ?>"/>
488
  </p>
489
 
490
  <p>
492
  for="joturl_longurl_params"><?php _e( "Parameters to add to the long URL (before shortening):", 'wp-to-twitter' ); ?></label>
493
  <input type="text" name="joturl_longurl_params" id="joturl_longurl_params"
494
  size="40"
495
+ value="<?php esc_attr_e( get_option( 'joturl_longurl_params' ) ) ?>"/>
496
  </p>
497
 
498
  <p>
500
  for="joturl_shorturl_params"><?php _e( "Parameters to add to the short URL (after shortening):", 'wp-to-twitter' ); ?></label>
501
  <input type="text" name="joturl_shorturl_params" id="joturl_shorturl_params"
502
  size="40"
503
+ value="<?php esc_attr_e( get_option( 'joturl_shorturl_params' ) ) ?>"/>
504
  </p>
505
 
506
  <p>
510
  <div><input type="hidden" name="submit-type" value="joturlapi"/></div>
511
  <?php $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
512
  echo "<div>$nonce</div>"; ?>
513
+ <p>
514
+ <input type="submit" name="submit" value="<?php _e( 'Save jotURL settings', 'wp-to-twitter' ); ?>" class="button-primary" />
515
+ <input type="submit" name="clear" value="<?php _e( 'Clear jotURL settings', 'wp-to-twitter' ); ?>" class="button-secondary" />
 
 
 
516
  </p>
517
  </div>
518
  </form>
536
  delete_option( 'yourlslogin' );
537
  $message .= __( 'YOURLS signature token updated.', 'wp-to-twitter' );
538
  }
539
+ update_option( 'yourlsurl', trim( $post['yourlsurl'] ) );
 
 
 
 
 
 
540
  if ( $post['yourlspath'] != '' ) {
541
  update_option( 'yourlspath', trim( $post['yourlspath'] ) );
542
  if ( file_exists( $post['yourlspath'] ) ) {
544
  } else {
545
  $message .= __( "The path to your YOURLS installation is not correct. ", 'wp-to-twitter' );
546
  }
 
 
 
547
  }
548
  if ( $post['jd_keyword_format'] != '' ) {
549
  update_option( 'jd_keyword_format', $post['jd_keyword_format'] );
552
  } else {
553
  $message .= __( "YOURLS will use your custom keyword for short URL slug.", 'wp-to-twitter' );
554
  }
555
+ }
556
+ if ( isset( $post['clear'] ) ) {
557
+ delete_option( 'yourlsapi' );
558
+ delete_option( 'yourlslogin' );
559
+ delete_option( 'yourlstoken' );
560
+ delete_option( 'jd_keyword_format' );
561
+ delete_option( 'yourlspath' );
562
+ delete_option( 'yourlsurl' );
563
+ $message .= __( 'YOURLS data cleared.', 'wp-to-twitter' );
564
  }
565
  }
566
 
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.0.0
7
  Author: Joseph Dolson
8
  Author URI: http://www.joedolson.com/
9
  */
@@ -27,7 +27,6 @@ if ( ! defined( 'ABSPATH' ) ) {
27
  exit;
28
  } // Exit if accessed directly
29
 
30
- apply_filters( 'debug', 'WP to Twitter Init' );
31
  global $wp_version;
32
  $wp_content_url = content_url();
33
  $wp_content_dir = str_replace( '/plugins/wp-to-twitter', '', plugin_dir_path( __FILE__ ) );
@@ -46,16 +45,16 @@ define( 'WPT_FROM', "From: \"" . get_option( 'blogname' ) . "\" <" . get_option(
46
  $wp_plugin_url = plugins_url();
47
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // required in order to access is_plugin_active()
48
 
 
49
  require_once( plugin_dir_path( __FILE__ ) . '/wp-to-twitter-oauth.php' );
50
  require_once( plugin_dir_path( __FILE__ ) . '/wp-to-twitter-shorteners.php' );
51
  require_once( plugin_dir_path( __FILE__ ) . '/wp-to-twitter-manager.php' );
52
  require_once( plugin_dir_path( __FILE__ ) . '/wpt-truncate.php' );
53
- require_once( plugin_dir_path( __FILE__ ) . '/wpt-functions.php' );
54
  require_once( plugin_dir_path( __FILE__ ) . '/wpt-feed.php' );
55
  require_once( plugin_dir_path( __FILE__ ) . '/wpt-widget.php' );
56
 
57
  global $wpt_version;
58
- $wpt_version = "3.0.0";
59
  load_plugin_textdomain( 'wp-to-twitter', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
60
 
61
  // check for OAuth configuration
@@ -71,13 +70,79 @@ function wpt_check_oauth( $auth = false ) {
71
 
72
  function wpt_check_version() {
73
  global $wpt_version;
74
- $prev_version = get_option( 'wp_to_twitter_version' );
75
  if ( version_compare( $prev_version, $wpt_version, "<" ) ) {
76
  wptotwitter_activate();
77
  }
78
  }
79
 
80
  function wptotwitter_activate() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  global $wpt_version;
82
  $prev_version = get_option( 'wp_to_twitter_version' );
83
  // this is a switch to plan for future versions
@@ -196,10 +261,17 @@ function wptotwitter_activate() {
196
  $administrator->add_cap( 'wpt_tweet_now' );
197
  }
198
 
199
- $upgrade = version_compare( $prev_version, "2.9.8", "<" );
200
  if ( $upgrade ) {
201
  // migrate stored short URL fields.
202
- wpt_migrate_url_meta();
 
 
 
 
 
 
 
203
  }
204
 
205
  update_option( 'wp_to_twitter_version', $wpt_version );
@@ -220,35 +292,35 @@ function wpt_migrate_url_meta() {
220
  )
221
  );
222
  foreach ( $posts as $post ) {
223
- $id = $post->ID;
224
  $short = '';
225
  if ( $short == "" ) {
226
  $short = get_post_meta( $post_id, '_wp_jd_goo', true );
227
- delete_post_meta( $id, '_wp_jd_goo' );
228
  }
229
  if ( $short == "" ) {
230
  $short = get_post_meta( $post_id, '_wp_jd_supr', true );
231
- delete_post_meta( $id, '_wp_jd_supr' );
232
  }
233
  if ( $short == "" ) {
234
  $short = get_post_meta( $post_id, '_wp_jd_wp', true );
235
- delete_post_meta( $id, '_wp_jd_wp' );
236
  }
237
  if ( $short == "" ) {
238
  $short = get_post_meta( $post_id, '_wp_jd_ind', true );
239
- delete_post_meta( $id, '_wp_jd_ind' );
240
  }
241
  if ( $short == "" ) {
242
  $short = get_post_meta( $post_id, '_wp_jd_yourls', true );
243
- delete_post_meta( $id, '_wp_jd_yourls' );
244
  }
245
  if ( $short == "" ) {
246
  $short = get_post_meta( $post_id, '_wp_jd_url', true );
247
- delete_post_meta( $id, '_wp_jd_url' );
248
  }
249
  if ( $short == "" ) {
250
  $short = get_post_meta( $post_id, '_wp_jd_joturl', true );
251
- delete_post_meta( $id, '_wp_jd_joturl' );
252
  }
253
  if ( $short == "" ) {
254
  // don't delete target link
@@ -256,10 +328,11 @@ function wpt_migrate_url_meta() {
256
  }
257
  if ( $short == "" ) {
258
  $short = get_post_meta( $post_id, '_wp_jd_clig', true );
259
- delete_post_meta( $id, '_wp_jd_clig' );
260
  }
261
- update_post_meta( $id, '_wpt_short_url', $short );
262
  }
 
263
  }
264
 
265
  // Function checks for an alternate URL to be Tweeted. Contribution by Bill Berry.
@@ -359,11 +432,11 @@ function jd_doTwitterAPIPost( $twit, $auth = false, $id = false, $media = false
359
 
360
  return false;
361
  } else {
362
- // if this post has already been tweeted with Media, we can skip the upload phase.
363
  $media_id = false;
364
  // must be designated as media and have a valid attachment
365
  $attachment = ( $media ) ? wpt_post_attachment( $id ) : false;
366
  if ( $attachment ) {
 
367
  $meta = wp_get_attachment_metadata( $attachment );
368
  if ( ! isset( $meta['width'], $meta['height'] ) ) {
369
  wpt_mail( "Image Data Does not Exist for Attachment #$attachment", print_r( $meta, 1 ) );
@@ -381,25 +454,17 @@ function jd_doTwitterAPIPost( $twit, $auth = false, $id = false, $media = false
381
  if ( wtt_oauth_test( $auth ) && ( $connection = wtt_oauth_connection( $auth ) ) ) {
382
  if ( $media && $attachment && !$media_id ) {
383
  $media_id = $connection->media( $upload_api, array( 'auth'=>$auth, 'media'=>$attachment ) );
 
384
  if ( $media_id ) {
385
  $status['media_ids'] = $media_id;
386
  }
387
  }
388
- $connection->post( $api, $status );
389
- $http_code = ( $connection ) ? $connection->http_code : 'failed';
390
- } else if ( wtt_oauth_test( false ) && ( $connection = wtt_oauth_connection( false ) ) ) {
391
- if ( $media && $attachment && !$media_id ) {
392
- $media_id = $connection->media( $upload_api, array( 'auth'=>$auth, 'media'=>$attachment ) );
393
-
394
- if ( $media_id ) {
395
- $status['media_ids'] = $media_id;
396
- }
397
- }
398
- $connection->post( $api, $status );
399
- $http_code = ( $connection ) ? $connection->http_code : 'failed';
400
  }
401
  if ( empty( $connection ) ) {
402
  $connection = array( 'connection' => 'undefined' );
 
 
 
403
  }
404
  wpt_mail( 'Twitter Connection', print_r( $connection, 1 ) . " - $twit, $auth, $id, $media" );
405
  if ( $connection ) {
@@ -613,11 +678,17 @@ function jd_post_info( $post_ID ) {
613
  $excerpt_length = get_option( 'jd_post_excerpt' );
614
  $post_excerpt = ( trim( $post->post_excerpt ) == "" ) ? @mb_substr( strip_tags( strip_shortcodes( $post->post_content ) ), 0, $excerpt_length ) : @mb_substr( strip_tags( strip_shortcodes( $post->post_excerpt ) ), 0, $excerpt_length );
615
  $values['postExcerpt'] = html_entity_decode( $post_excerpt, ENT_COMPAT, $encoding );
616
- $thisposttitle = stripcslashes( strip_tags( $post->post_title ) );
617
  if ( $thisposttitle == "" && isset( $_POST['title'] ) ) {
618
- $thisposttitle = stripcslashes( strip_tags( $_POST['title'] ) );
619
  }
620
- $values['postTitle'] = html_entity_decode( $thisposttitle, ENT_COMPAT, $encoding );
 
 
 
 
 
 
621
  $values['postLink'] = wpt_link( $post_ID );
622
  $values['blogTitle'] = get_bloginfo( 'name' );
623
  $values['shortUrl'] = wpt_short_url( $post_ID );
@@ -709,6 +780,7 @@ function jd_twit( $post_ID, $type = 'instant' ) {
709
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || wp_is_post_revision( $post_ID ) ) {
710
  return $post_ID;
711
  }
 
712
  wpt_check_version();
713
  $jd_tweet_this = get_post_meta( $post_ID, '_jd_tweet_this', true );
714
  $newpost = $oldpost = $is_inline_edit = false;
@@ -723,12 +795,12 @@ function jd_twit( $post_ID, $type = 'instant' ) {
723
  }
724
  }
725
  if ( get_option( 'jd_tweet_default' ) == 0 ) {
726
- $test = ( $jd_tweet_this != 'no' ) ? true : false;
727
  } else {
728
- $test = ( $jd_tweet_this == 'yes' ) ? true : false;
729
  }
730
  wpt_mail( "1: JD Tweet This Value: #$post_ID", "Tweet this: $jd_tweet_this /" . get_option( 'jd_tweet_default' ) . " / $type" ); // DEBUG
731
- if ( $test ) { // test switch: depend on default settings.
732
  $post_info = jd_post_info( $post_ID );
733
  $media = wpt_post_with_media( $post_ID, $post_info );
734
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true ) {
@@ -819,7 +891,7 @@ function jd_twit( $post_ID, $type = 'instant' ) {
819
  if ( empty( $wpt_selected_users ) && get_option( 'jd_individual_twitter_users' ) == 1 ) {
820
  $wpt_selected_users = ( $auth_verified ) ? array( $auth ) : array( false );
821
  }
822
- if ( $post_info['wpt_cotweet'] == 1 || get_option( 'jd_individual_twitter_users' ) != 1 ) {
823
  $wpt_selected_users['main'] = false;
824
  }
825
  // filter selected users before using
@@ -832,6 +904,9 @@ function jd_twit( $post_ID, $type = 'instant' ) {
832
  }
833
  } else {
834
  foreach ( $wpt_selected_users as $acct ) {
 
 
 
835
  if ( $auth != $acct ) {
836
  $offset = rand( 60, 480 ); // offset by 1-8 minutes for additional users
837
  } else {
@@ -959,6 +1034,13 @@ function jd_twit_link( $link_ID ) {
959
  } else {
960
  $sentence = str_ireplace( "#url#", $shrink, $sentence );
961
  }
 
 
 
 
 
 
 
962
  if ( $sentence != '' ) {
963
  jd_doTwitterAPIPost( $sentence, false, $link_ID );
964
  }
@@ -1075,7 +1157,7 @@ function jd_add_twitter_inner_box( $post ) {
1075
  $jd_tweet_this = 'no';
1076
  }
1077
  if ( isset( $_REQUEST['message'] ) && $_REQUEST['message'] != 10 ) { // don't display when draft is updated or if no message
1078
- if ( ! ( ( $_REQUEST['message'] == 1 ) && ( $status == 'publish' && $options[ $type ]['post-edited-update'] != 1 ) ) ) {
1079
  $log = wpt_log( 'wpt_status_message', $post_id );
1080
  $class = ( $log != __( 'Tweet sent successfully.', 'wp-to-twitter' ) ) ? 'error' : 'updated';
1081
  if ( $log != '' ) {
@@ -1152,7 +1234,7 @@ function jd_add_twitter_inner_box( $post ) {
1152
  }
1153
  } else {
1154
  ?>
1155
- <input type="hidden" name='_jd_twitter' value='<?php echo esc_attr( $tweet ); ?>'/>
1156
  <?php
1157
  }
1158
  if ( current_user_can( 'wpt_twitter_switch' ) || current_user_can( 'manage_options' ) ) {
@@ -1160,13 +1242,11 @@ function jd_add_twitter_inner_box( $post ) {
1160
  $nochecked = ( $jd_tweet_this == 'no' ) ? ' checked="checked"' : '';
1161
  $yeschecked = ( $jd_tweet_this == 'yes' ) ? ' checked="checked"' : '';
1162
  ?>
1163
- <p class='toggle-btn-group'><input type="radio" name="_jd_tweet_this" value="no"
1164
- id="jtn"<?php echo $nochecked; ?> /><label
1165
- for="jtn"><?php _e( "Don't Tweet post.", 'wp-to-twitter' ); ?></label> <input type="radio"
1166
- name="_jd_tweet_this"
1167
- value="yes"
1168
- id="jty"<?php echo $yeschecked; ?> />
1169
- <label for="jty"><?php _e( "Tweet post.", 'wp-to-twitter' ); ?></label></p>
1170
  <?php
1171
  } else {
1172
  ?>
@@ -1183,16 +1263,18 @@ function jd_add_twitter_inner_box( $post ) {
1183
  $pro_active = '';
1184
  }
1185
  ?>
1186
- <ul class='tabs'>
1187
- <li><a href='#authors'<?php echo $pro_active; ?>>Tweet to</a></li>
1188
- <li><a href='#custom'>Options</a></li>
1189
- <li><a href='#notes'<?php echo $free_active; ?>>Notes</a></li>
 
 
1190
  </ul>
1191
  <?php
1192
  /* WPT PRO OPTIONS */
1193
  if ( current_user_can( 'edit_others_posts' ) ) {
1194
- echo "<div class='wptab' id='authors'>";
1195
  if ( get_option( 'jd_individual_twitter_users' ) == 1 ) {
 
1196
  $selected = ( get_post_meta( $post_id, '_wpt_authorized_users', true ) ) ? get_post_meta( $post_id, '_wpt_authorized_users', true ) : array();
1197
  if ( function_exists( 'wpt_authorized_users' ) ) {
1198
  echo wpt_authorized_users( $selected );
@@ -1206,16 +1288,18 @@ function jd_add_twitter_inner_box( $post ) {
1206
  }
1207
  echo "</p>";
1208
  }
1209
- }
1210
- echo "</div>";
1211
  }
1212
  ?>
1213
- <div class='wptab' id='custom'><?php
1214
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true && ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'manage_options' ) ) ) {
1215
  wpt_schedule_values( $post_id );
1216
  do_action( 'wpt_custom_tab', $post_id, 'visible' );
1217
  } else {
1218
- printf( "<p>" . __( 'Upgrade to WP Tweets PRO to configure options! <a href="%s">Upgrade now!</a>' . "</p>", 'wp-to-twitter' ), 'http://www.joedolson.com/wp-tweets-pro/' );
 
 
1219
  }
1220
  ?>
1221
  </div>
@@ -1223,7 +1307,7 @@ function jd_add_twitter_inner_box( $post ) {
1223
  /* WPT PRO */
1224
  if ( ! current_user_can( 'wpt_twitter_custom' ) && ! current_user_can( 'manage_options' ) ) {
1225
  ?>
1226
- <div class='wptab' id='custom'>
1227
  <p><?php _e( 'Access to customizing WP to Twitter values is not allowed for your user role.', 'wp-to-twitter' ); ?></p>
1228
  <?php
1229
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true ) {
@@ -1235,9 +1319,9 @@ function jd_add_twitter_inner_box( $post ) {
1235
  }
1236
  if ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'manage_options' ) ) {
1237
  ?>
1238
- <div class='wptab' id='notes'>
1239
  <p>
1240
- <?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>.", 'wp-to-twitter' );
1241
  do_action( 'wpt_notes_tab', $post_id );
1242
  ?>
1243
  </p>
@@ -1246,14 +1330,15 @@ function jd_add_twitter_inner_box( $post ) {
1246
  } ?>
1247
  </div>
1248
  <p class="wpt-support">
1249
- <?php if ( ! function_exists( 'wpt_pro_exists' ) ) { ?>
 
 
1250
  <a target="_blank"
1251
- href="<?php echo admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' ); ?>#get-support"><?php _e( 'Get Support', 'wp-to-twitter', 'wp-to-twitter' ) ?></a> &bull;
1252
- <strong><a target="__blank"
1253
- href="https://www.joedolson.com/wp-tweets-pro/"><?php _e( 'Go Premium', 'wp-to-twitter', 'wp-to-twitter' ) ?></a></strong> &raquo;
1254
  <?php } else { ?>
1255
  <a target="_blank"
1256
- href="<?php echo admin_url( 'admin.php?page=wp-tweets-pro' ); ?>#get-support"><?php _e( 'Get Support', 'wp-to-twitter', 'wp-to-twitter' ) ?></a> &raquo;
1257
  <?php } ?>
1258
  </p>
1259
  <?php wpt_show_tweets( $previous_tweets, $failed_tweets ); ?>
@@ -1331,12 +1416,12 @@ add_action( 'admin_enqueue_scripts', 'wpt_admin_scripts', 10, 1 );
1331
  * Enqueue admin scripts for WP to Twitter and WP Tweets PRO.
1332
  */
1333
  function wpt_admin_scripts() {
1334
- global $current_screen;
1335
  if ( $current_screen->base == 'post' || $current_screen->id == 'wp-tweets-pro_page_wp-to-twitter-schedule' ) {
1336
- wp_enqueue_script( 'charCount', plugins_url( 'wp-to-twitter/js/jquery.charcount.js' ), array( 'jquery' ) );
1337
  }
1338
  if ( $current_screen->base == 'post' && isset( $_GET['post'] ) && ( current_user_can( 'wpt_tweet_now' ) || current_user_can( 'manage_options' ) ) ) {
1339
- wp_enqueue_script( 'wpt.ajax', plugins_url( 'js/ajax.js', __FILE__ ), array( 'jquery' ) );
1340
  wp_localize_script( 'wpt.ajax', 'wpt_data', array(
1341
  'post_ID' => (int) $_GET['post'],
1342
  'action' => 'wpt_tweet',
@@ -1344,7 +1429,7 @@ function wpt_admin_scripts() {
1344
  ) );
1345
  }
1346
  if ( $current_screen->id == 'settings_page_wp-to-twitter/wp-to-twitter' || $current_screen->id == 'toplevel_page_wp-tweets-pro' ) {
1347
- wp_enqueue_script( 'wpt.tabs', plugins_url( 'js/tabs.js', __FILE__ ), array( 'jquery' ) );
1348
  wp_localize_script( 'wpt.tabs', 'firstItem', 'wpt_post' );
1349
  wp_localize_script( 'wpt.tabs', 'firstPerm', 'wpt_editor' );
1350
  wp_enqueue_script( 'dashboard' );
@@ -1363,6 +1448,8 @@ function wpt_ajax_tweet() {
1363
  die;
1364
  }
1365
  $action = ( $_REQUEST['tweet_action'] == 'tweet' ) ? 'tweet' : 'schedule';
 
 
1366
  $current_user = wp_get_current_user();
1367
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() ) {
1368
  if ( wtt_oauth_test( $current_user->ID, 'verify' ) ) {
@@ -1671,7 +1758,7 @@ if ( get_option( 'jd_twit_blogroll' ) == '1' ) {
1671
  add_action( 'add_link', 'jd_twit_link' );
1672
  }
1673
 
1674
- add_action( 'save_post', 'wpt_twit', 16 );
1675
  add_action( 'save_post', 'post_jd_twitter', 10 );
1676
 
1677
  /**
@@ -1714,6 +1801,7 @@ function wpt_twit( $id ) {
1714
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || wp_is_post_revision( $id ) || ! wpt_in_post_type( $id ) ) {
1715
  return;
1716
  }
 
1717
  $post = get_post( $id );
1718
  if ( $post->post_status != 'publish' ) {
1719
  return;
@@ -1801,12 +1889,31 @@ add_action( 'admin_notices', 'wpt_promotion_notice' );
1801
  */
1802
  function wpt_promotion_notice() {
1803
  if ( current_user_can( 'activate_plugins' ) && get_option( 'wpt_promotion_scheduled' ) == 2 && get_option( 'jd_donations' ) != 1 ) {
1804
- $upgrade = "http://www.joedolson.com/wp-tweets-pro/";
1805
  $dismiss = admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php&dismiss=promotion' );
1806
  echo "<div class='updated fade'><p>" . sprintf( __( "I hope you've enjoyed <strong>WP to Twitter</strong>! Take a look at <a href='%s'>upgrading to WP Tweets PRO</a> for advanced Tweeting with WordPress! <a href='%s'>Dismiss</a>", 'wp-to-twitter' ), $upgrade, $dismiss ) . "</p></div>";
1807
  }
1808
  }
1809
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1810
  add_action( 'wp_enqueue_scripts', 'wpt_stylesheet' );
1811
  /**
1812
  * Enqueue front-end styles for Twitter Feed widget if enabled.
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.0.7
7
  Author: Joseph Dolson
8
  Author URI: http://www.joedolson.com/
9
  */
27
  exit;
28
  } // Exit if accessed directly
29
 
 
30
  global $wp_version;
31
  $wp_content_url = content_url();
32
  $wp_content_dir = str_replace( '/plugins/wp-to-twitter', '', plugin_dir_path( __FILE__ ) );
45
  $wp_plugin_url = plugins_url();
46
  include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // required in order to access is_plugin_active()
47
 
48
+ require_once( plugin_dir_path( __FILE__ ) . '/wpt-functions.php' );
49
  require_once( plugin_dir_path( __FILE__ ) . '/wp-to-twitter-oauth.php' );
50
  require_once( plugin_dir_path( __FILE__ ) . '/wp-to-twitter-shorteners.php' );
51
  require_once( plugin_dir_path( __FILE__ ) . '/wp-to-twitter-manager.php' );
52
  require_once( plugin_dir_path( __FILE__ ) . '/wpt-truncate.php' );
 
53
  require_once( plugin_dir_path( __FILE__ ) . '/wpt-feed.php' );
54
  require_once( plugin_dir_path( __FILE__ ) . '/wpt-widget.php' );
55
 
56
  global $wpt_version;
57
+ $wpt_version = "3.0.7";
58
  load_plugin_textdomain( 'wp-to-twitter', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
59
 
60
  // check for OAuth configuration
70
 
71
  function wpt_check_version() {
72
  global $wpt_version;
73
+ $prev_version = ( get_option( 'wp_to_twitter_version' ) != '' ) ? get_option( 'wp_to_twitter_version' ) : '1.0.0';
74
  if ( version_compare( $prev_version, $wpt_version, "<" ) ) {
75
  wptotwitter_activate();
76
  }
77
  }
78
 
79
  function wptotwitter_activate() {
80
+ // If this has never run before, do the initial setup.
81
+ $new_install = ( get_option( 'wpt_twitter_setup' ) == 1 || get_option( 'twitterInitialised' ) == 1 ) ? false : true;
82
+ if ( $new_install ) {
83
+ $initial_settings = array(
84
+ 'post' => array(
85
+ 'post-published-update' => 1,
86
+ 'post-published-text' => 'New post: #title# #url#',
87
+ 'post-edited-update' => 0,
88
+ 'post-edited-text' => 'Post Edited: #title# #url#'
89
+ ),
90
+ 'page' => array(
91
+ 'post-published-update' => 0,
92
+ 'post-published-text' => 'New page: #title# #url#',
93
+ 'post-edited-update' => 0,
94
+ 'post-edited-text' => 'Page edited: #title# #url#'
95
+ )
96
+ );
97
+ update_option( 'wpt_post_types', $initial_settings );
98
+ update_option( 'jd_twit_blogroll', '1' );
99
+ update_option( 'newlink-published-text', 'New link: #title# #url#' );
100
+ update_option( 'jd_shortener', '1' );
101
+ update_option( 'jd_strip_nonan', '0' );
102
+ update_option( 'jd_max_tags', 3 );
103
+ update_option( 'jd_max_characters', 15 );
104
+ update_option( 'jd_replace_character', '' );
105
+ $administrator = get_role( 'administrator' );
106
+ $administrator->add_cap( 'wpt_twitter_oauth' );
107
+ $administrator->add_cap( 'wpt_twitter_custom' );
108
+ $administrator->add_cap( 'wpt_twitter_switch' );
109
+ $administrator->add_cap( 'wpt_can_tweet' );
110
+ $administrator->add_cap( 'wpt_tweet_now' );
111
+ $editor = get_role( 'editor' );
112
+ if ( is_object( $editor ) ) {
113
+ $editor->add_cap( 'wpt_can_tweet' );
114
+ }
115
+ $author = get_role( 'author' );
116
+ if ( is_object( $author ) ) {
117
+ $author->add_cap( 'wpt_can_tweet' );
118
+ }
119
+ $contributor = get_role( 'contributor' );
120
+ if ( is_object( $contributor ) ) {
121
+ $contributor->add_cap( 'wpt_can_tweet' );
122
+ }
123
+
124
+ update_option( 'jd_twit_remote', '0' );
125
+ update_option( 'jd_post_excerpt', 30 );
126
+ // Use Google Analytics with Twitter
127
+ update_option( 'twitter-analytics-campaign', 'twitter' );
128
+ update_option( 'use-twitter-analytics', '0' );
129
+ update_option( 'jd_dynamic_analytics', '0' );
130
+ update_option( 'no-analytics', 1 );
131
+ update_option( 'use_dynamic_analytics', 'category' );
132
+ // Use custom external URLs to point elsewhere.
133
+ update_option( 'jd_twit_custom_url', 'external_link' );
134
+ // Error checking
135
+ update_option( 'wp_url_failure', '0' );
136
+ // Default publishing options.
137
+ update_option( 'jd_tweet_default', '0' );
138
+ update_option( 'jd_tweet_default_edit', '0' );
139
+ update_option( 'wpt_inline_edits', '0' );
140
+ // Note that default options are set.
141
+ update_option( 'wpt_twitter_setup', '1' );
142
+ //YOURLS API
143
+ update_option( 'jd_keyword_format', '0' );
144
+ }
145
+
146
  global $wpt_version;
147
  $prev_version = get_option( 'wp_to_twitter_version' );
148
  // this is a switch to plan for future versions
261
  $administrator->add_cap( 'wpt_tweet_now' );
262
  }
263
 
264
+ $upgrade = version_compare( $prev_version, "2.9.8", "<=" );
265
  if ( $upgrade ) {
266
  // migrate stored short URL fields.
267
+ $count_posts = wp_count_posts();
268
+ $published_posts = $count_posts->publish;
269
+ if ( $published_posts > 2 ) {
270
+ // if more than 1000 posts, don't run this during update process.
271
+ update_option( 'wpt_needs_migration', 'true' );
272
+ } else {
273
+ wpt_migrate_url_meta();
274
+ }
275
  }
276
 
277
  update_option( 'wp_to_twitter_version', $wpt_version );
292
  )
293
  );
294
  foreach ( $posts as $post ) {
295
+ $post_id = $post->ID;
296
  $short = '';
297
  if ( $short == "" ) {
298
  $short = get_post_meta( $post_id, '_wp_jd_goo', true );
299
+ delete_post_meta( $post_id, '_wp_jd_goo' );
300
  }
301
  if ( $short == "" ) {
302
  $short = get_post_meta( $post_id, '_wp_jd_supr', true );
303
+ delete_post_meta( $post_id, '_wp_jd_supr' );
304
  }
305
  if ( $short == "" ) {
306
  $short = get_post_meta( $post_id, '_wp_jd_wp', true );
307
+ delete_post_meta( $post_id, '_wp_jd_wp' );
308
  }
309
  if ( $short == "" ) {
310
  $short = get_post_meta( $post_id, '_wp_jd_ind', true );
311
+ delete_post_meta( $post_id, '_wp_jd_ind' );
312
  }
313
  if ( $short == "" ) {
314
  $short = get_post_meta( $post_id, '_wp_jd_yourls', true );
315
+ delete_post_meta( $post_id, '_wp_jd_yourls' );
316
  }
317
  if ( $short == "" ) {
318
  $short = get_post_meta( $post_id, '_wp_jd_url', true );
319
+ delete_post_meta( $post_id, '_wp_jd_url' );
320
  }
321
  if ( $short == "" ) {
322
  $short = get_post_meta( $post_id, '_wp_jd_joturl', true );
323
+ delete_post_meta( $post_id, '_wp_jd_joturl' );
324
  }
325
  if ( $short == "" ) {
326
  // don't delete target link
328
  }
329
  if ( $short == "" ) {
330
  $short = get_post_meta( $post_id, '_wp_jd_clig', true );
331
+ delete_post_meta( $post_id, '_wp_jd_clig' );
332
  }
333
+ update_post_meta( $post_id, '_wpt_short_url', $short );
334
  }
335
+ delete_option( 'wpt_needs_migration' );
336
  }
337
 
338
  // Function checks for an alternate URL to be Tweeted. Contribution by Bill Berry.
432
 
433
  return false;
434
  } else {
 
435
  $media_id = false;
436
  // must be designated as media and have a valid attachment
437
  $attachment = ( $media ) ? wpt_post_attachment( $id ) : false;
438
  if ( $attachment ) {
439
+ wpt_mail( 'Has Upload', "$auth, $attachment" );
440
  $meta = wp_get_attachment_metadata( $attachment );
441
  if ( ! isset( $meta['width'], $meta['height'] ) ) {
442
  wpt_mail( "Image Data Does not Exist for Attachment #$attachment", print_r( $meta, 1 ) );
454
  if ( wtt_oauth_test( $auth ) && ( $connection = wtt_oauth_connection( $auth ) ) ) {
455
  if ( $media && $attachment && !$media_id ) {
456
  $media_id = $connection->media( $upload_api, array( 'auth'=>$auth, 'media'=>$attachment ) );
457
+ wpt_mail( 'Media Uploaded', "$auth, $media_id, $attachment" );
458
  if ( $media_id ) {
459
  $status['media_ids'] = $media_id;
460
  }
461
  }
 
 
 
 
 
 
 
 
 
 
 
 
462
  }
463
  if ( empty( $connection ) ) {
464
  $connection = array( 'connection' => 'undefined' );
465
+ } else {
466
+ $connection->post( $api, $status );
467
+ $http_code = ( $connection ) ? $connection->http_code : 'failed';
468
  }
469
  wpt_mail( 'Twitter Connection', print_r( $connection, 1 ) . " - $twit, $auth, $id, $media" );
470
  if ( $connection ) {
678
  $excerpt_length = get_option( 'jd_post_excerpt' );
679
  $post_excerpt = ( trim( $post->post_excerpt ) == "" ) ? @mb_substr( strip_tags( strip_shortcodes( $post->post_content ) ), 0, $excerpt_length ) : @mb_substr( strip_tags( strip_shortcodes( $post->post_excerpt ) ), 0, $excerpt_length );
680
  $values['postExcerpt'] = html_entity_decode( $post_excerpt, ENT_COMPAT, $encoding );
681
+ $thisposttitle = $post->post_title;
682
  if ( $thisposttitle == "" && isset( $_POST['title'] ) ) {
683
+ $thisposttitle = $_POST['title'];
684
  }
685
+ $thisposttitle = strip_tags( apply_filters( 'the_title', stripcslashes( $thisposttitle ) ) );
686
+ // These are common sequences that don't get handled by html_entity_decode due to double encoding
687
+ $search = array( '&apos;', '&#039;', '&quot;', '&#034;', '&amp;', '&#038;' );
688
+ $replace = array( "'", '"', '"', '&', '&' );
689
+ $thisposttitle = str_replace( $search, $replace, $thisposttitle );
690
+ $values['postTitle'] = html_entity_decode( $thisposttitle, ENT_QUOTES, $encoding );
691
+
692
  $values['postLink'] = wpt_link( $post_ID );
693
  $values['blogTitle'] = get_bloginfo( 'name' );
694
  $values['shortUrl'] = wpt_short_url( $post_ID );
780
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || wp_is_post_revision( $post_ID ) ) {
781
  return $post_ID;
782
  }
783
+
784
  wpt_check_version();
785
  $jd_tweet_this = get_post_meta( $post_ID, '_jd_tweet_this', true );
786
  $newpost = $oldpost = $is_inline_edit = false;
795
  }
796
  }
797
  if ( get_option( 'jd_tweet_default' ) == 0 ) {
798
+ $default = ( $jd_tweet_this != 'no' ) ? true : false;
799
  } else {
800
+ $default = ( $jd_tweet_this == 'yes' ) ? true : false;
801
  }
802
  wpt_mail( "1: JD Tweet This Value: #$post_ID", "Tweet this: $jd_tweet_this /" . get_option( 'jd_tweet_default' ) . " / $type" ); // DEBUG
803
+ if ( $default ) { // default switch: depend on default settings.
804
  $post_info = jd_post_info( $post_ID );
805
  $media = wpt_post_with_media( $post_ID, $post_info );
806
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true ) {
891
  if ( empty( $wpt_selected_users ) && get_option( 'jd_individual_twitter_users' ) == 1 ) {
892
  $wpt_selected_users = ( $auth_verified ) ? array( $auth ) : array( false );
893
  }
894
+ if ( $post_info['wpt_cotweet'] == 1 || get_option( 'jd_individual_twitter_users' ) != 1 || in_array( 'main', $wpt_selected_users ) ) {
895
  $wpt_selected_users['main'] = false;
896
  }
897
  // filter selected users before using
904
  }
905
  } else {
906
  foreach ( $wpt_selected_users as $acct ) {
907
+ if ( $acct == 'main' ) {
908
+ $acct = false;
909
+ }
910
  if ( $auth != $acct ) {
911
  $offset = rand( 60, 480 ); // offset by 1-8 minutes for additional users
912
  } else {
1034
  } else {
1035
  $sentence = str_ireplace( "#url#", $shrink, $sentence );
1036
  }
1037
+
1038
+ if ( stripos( $sentence, "#longurl#" ) === false ) {
1039
+ $sentence = $sentence . " " . $thispostlink;
1040
+ } else {
1041
+ $sentence = str_ireplace( "#longurl#", $thispostlink, $sentence );
1042
+ }
1043
+
1044
  if ( $sentence != '' ) {
1045
  jd_doTwitterAPIPost( $sentence, false, $link_ID );
1046
  }
1157
  $jd_tweet_this = 'no';
1158
  }
1159
  if ( isset( $_REQUEST['message'] ) && $_REQUEST['message'] != 10 ) { // don't display when draft is updated or if no message
1160
+ if ( ! ( ( $_REQUEST['message'] == 1 ) && ( $status == 'publish' && $options[ $type ]['post-edited-update'] != 1 ) ) && $jd_tweet_this != 'no' ) {
1161
  $log = wpt_log( 'wpt_status_message', $post_id );
1162
  $class = ( $log != __( 'Tweet sent successfully.', 'wp-to-twitter' ) ) ? 'error' : 'updated';
1163
  if ( $log != '' ) {
1234
  }
1235
  } else {
1236
  ?>
1237
+ <input type="hidden" name='_jd_twitter' value='<?php esc_attr_e( $tweet ); ?>'/>
1238
  <?php
1239
  }
1240
  if ( current_user_can( 'wpt_twitter_switch' ) || current_user_can( 'manage_options' ) ) {
1242
  $nochecked = ( $jd_tweet_this == 'no' ) ? ' checked="checked"' : '';
1243
  $yeschecked = ( $jd_tweet_this == 'yes' ) ? ' checked="checked"' : '';
1244
  ?>
1245
+ <p class='toggle-btn-group'>
1246
+ <input type="radio" name="_jd_tweet_this" value="no" id="jtn"<?php echo $nochecked; ?> /><label for="jtn"><?php _e( "Don't Tweet post.", 'wp-to-twitter' ); ?></label>
1247
+ <input type="radio" name="_jd_tweet_this" value="yes" id="jty"<?php echo $yeschecked; ?> />
1248
+ <label for="jty"><?php _e( "Tweet post.", 'wp-to-twitter' ); ?></label>
1249
+ </p>
 
 
1250
  <?php
1251
  } else {
1252
  ?>
1263
  $pro_active = '';
1264
  }
1265
  ?>
1266
+ <ul class='tabs' role="tablist">
1267
+ <?php if ( get_option( 'jd_individual_twitter_users' ) == 1 ) { ?>
1268
+ <li><a href='#authors'<?php echo $pro_active; ?> aria-controls="authors" role="tab" id="tab_authors"><?php _e( 'Tweet to', 'wp-to-twitter' ); ?></a></li>
1269
+ <?php } ?>
1270
+ <li><a href='#custom' aria-controls="custom" role="tab" id="tab_custom"><?php _e( 'Options', 'wp-to-twitter' ); ?></a></li>
1271
+ <li><a href='#notes'<?php echo $free_active; ?> aria-controls="notes" role="tab" id="tab_notes"><?php _e( 'Notes', 'wp-to-twitter' ); ?></a></li>
1272
  </ul>
1273
  <?php
1274
  /* WPT PRO OPTIONS */
1275
  if ( current_user_can( 'edit_others_posts' ) ) {
 
1276
  if ( get_option( 'jd_individual_twitter_users' ) == 1 ) {
1277
+ echo "<div class='wptab' id='authors' aria-labelledby='tab_authors' role='tabpanel'>";
1278
  $selected = ( get_post_meta( $post_id, '_wpt_authorized_users', true ) ) ? get_post_meta( $post_id, '_wpt_authorized_users', true ) : array();
1279
  if ( function_exists( 'wpt_authorized_users' ) ) {
1280
  echo wpt_authorized_users( $selected );
1288
  }
1289
  echo "</p>";
1290
  }
1291
+ echo "</div>";
1292
+ }
1293
  }
1294
  ?>
1295
+ <div class='wptab' id='custom' aria-labelledby='tab_custom' role='tabpanel'><?php
1296
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true && ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'manage_options' ) ) ) {
1297
  wpt_schedule_values( $post_id );
1298
  do_action( 'wpt_custom_tab', $post_id, 'visible' );
1299
  } else {
1300
+ if ( function_exists( 'wpt_pro_exists' ) ) {
1301
+ echo "<p>" .sprintf( __( 'Upgrade to WP Tweets PRO to configure options! <a href="%s">Upgrade now!</a>', 'wp-to-twitter' ), 'http://www.joedolson.com/wp-tweets-pro/' ) . "</p>";
1302
+ }
1303
  }
1304
  ?>
1305
  </div>
1307
  /* WPT PRO */
1308
  if ( ! current_user_can( 'wpt_twitter_custom' ) && ! current_user_can( 'manage_options' ) ) {
1309
  ?>
1310
+ <div class='wptab' id='custom' aria-labelledby='tab_custom' role='tabpanel'>
1311
  <p><?php _e( 'Access to customizing WP to Twitter values is not allowed for your user role.', 'wp-to-twitter' ); ?></p>
1312
  <?php
1313
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true ) {
1319
  }
1320
  if ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'manage_options' ) ) {
1321
  ?>
1322
+ <div class='wptab' id='notes' aria-labelledby='tab_notes' role='tabpanel'>
1323
  <p>
1324
+ <?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' );
1325
  do_action( 'wpt_notes_tab', $post_id );
1326
  ?>
1327
  </p>
1330
  } ?>
1331
  </div>
1332
  <p class="wpt-support">
1333
+ <?php if ( ! function_exists( 'wpt_pro_exists' ) ) {
1334
+ /* These aren't actually usages that require esc_url. But using it will give people the illusion that it does something. */
1335
+ ?>
1336
  <a target="_blank"
1337
+ href="<?php echo esc_url( add_query_arg( 'tab', 'support', admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' ) ) ); ?>#get-support"><?php _e( 'Get Support', 'wp-to-twitter', 'wp-to-twitter' ); ?></a> &bull;
1338
+ <strong><a target="__blank" href="https://www.joedolson.com/wp-tweets-pro/"><?php _e( 'Go Premium', 'wp-to-twitter', 'wp-to-twitter' ) ?></a></strong> &raquo;
 
1339
  <?php } else { ?>
1340
  <a target="_blank"
1341
+ href="<?php echo esc_url( add_query_arg( 'tab', 'support', admin_url( 'admin.php?page=wp-tweets-pro' ) ) ); ?>#get-support"><?php _e( 'Get Support', 'wp-to-twitter', 'wp-to-twitter' ); ?></a> &raquo;
1342
  <?php } ?>
1343
  </p>
1344
  <?php wpt_show_tweets( $previous_tweets, $failed_tweets ); ?>
1416
  * Enqueue admin scripts for WP to Twitter and WP Tweets PRO.
1417
  */
1418
  function wpt_admin_scripts() {
1419
+ global $current_screen, $wpt_version;
1420
  if ( $current_screen->base == 'post' || $current_screen->id == 'wp-tweets-pro_page_wp-to-twitter-schedule' ) {
1421
+ wp_enqueue_script( 'charCount', plugins_url( 'wp-to-twitter/js/jquery.charcount.js' ), array( 'jquery' ), $wpt_version );
1422
  }
1423
  if ( $current_screen->base == 'post' && isset( $_GET['post'] ) && ( current_user_can( 'wpt_tweet_now' ) || current_user_can( 'manage_options' ) ) ) {
1424
+ wp_enqueue_script( 'wpt.ajax', plugins_url( 'js/ajax.js', __FILE__ ), array( 'jquery' ), $wpt_version );
1425
  wp_localize_script( 'wpt.ajax', 'wpt_data', array(
1426
  'post_ID' => (int) $_GET['post'],
1427
  'action' => 'wpt_tweet',
1429
  ) );
1430
  }
1431
  if ( $current_screen->id == 'settings_page_wp-to-twitter/wp-to-twitter' || $current_screen->id == 'toplevel_page_wp-tweets-pro' ) {
1432
+ wp_enqueue_script( 'wpt.tabs', plugins_url( 'js/tabs.js', __FILE__ ), array( 'jquery' ), $wpt_version );
1433
  wp_localize_script( 'wpt.tabs', 'firstItem', 'wpt_post' );
1434
  wp_localize_script( 'wpt.tabs', 'firstPerm', 'wpt_editor' );
1435
  wp_enqueue_script( 'dashboard' );
1448
  die;
1449
  }
1450
  $action = ( $_REQUEST['tweet_action'] == 'tweet' ) ? 'tweet' : 'schedule';
1451
+ // This isn't used right now, because of time.
1452
+ $authors = ( isset( $_REQUEST['tweet_auth'] ) && $_REQUEST['tweet_auth'] != null ) ? $_REQUEST['tweet_auth'] : false;
1453
  $current_user = wp_get_current_user();
1454
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() ) {
1455
  if ( wtt_oauth_test( $current_user->ID, 'verify' ) ) {
1758
  add_action( 'add_link', 'jd_twit_link' );
1759
  }
1760
 
1761
+ add_action( 'save_post', 'wpt_twit', 15 );
1762
  add_action( 'save_post', 'post_jd_twitter', 10 );
1763
 
1764
  /**
1801
  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || wp_is_post_revision( $id ) || ! wpt_in_post_type( $id ) ) {
1802
  return;
1803
  }
1804
+
1805
  $post = get_post( $id );
1806
  if ( $post->post_status != 'publish' ) {
1807
  return;
1889
  */
1890
  function wpt_promotion_notice() {
1891
  if ( current_user_can( 'activate_plugins' ) && get_option( 'wpt_promotion_scheduled' ) == 2 && get_option( 'jd_donations' ) != 1 ) {
1892
+ $upgrade = "https://www.joedolson.com/wp-tweets-pro/";
1893
  $dismiss = admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php&dismiss=promotion' );
1894
  echo "<div class='updated fade'><p>" . sprintf( __( "I hope you've enjoyed <strong>WP to Twitter</strong>! Take a look at <a href='%s'>upgrading to WP Tweets PRO</a> for advanced Tweeting with WordPress! <a href='%s'>Dismiss</a>", 'wp-to-twitter' ), $upgrade, $dismiss ) . "</p></div>";
1895
  }
1896
  }
1897
 
1898
+ add_action( 'admin_notices', 'wpt_migration_notice' );
1899
+ /**
1900
+ * Display migration notice if WPT was unable to auto migrate.
1901
+ */
1902
+ function wpt_migration_notice() {
1903
+ if ( current_user_can( 'activate_plugins' ) && get_option( 'wpt_needs_migration' ) == 'true' ) {
1904
+ $dismiss = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro&action=migration' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php&action=migration' );
1905
+ echo "<div class='updated fade'><p>" . sprintf( __( "WP to Twitter needs to perform a database update. This may take a few minutes. <a href='%s'>Update Database</a>", 'wp-to-twitter' ), $dismiss ) . "</p></div>";
1906
+ }
1907
+ }
1908
+
1909
+ function wpt_manual_migrate() {
1910
+ if ( isset( $_GET['action'] ) && $_GET['action'] == 'migration' ) {
1911
+ echo "<p>" . __( 'Processing data migration...', 'wp-to-twitter' ) . "</p>";
1912
+ wpt_migrate_url_meta();
1913
+ echo "<p>" . __( 'Data migration complete.', 'wp-to-twitter' ) . "</p>";
1914
+ }
1915
+ }
1916
+
1917
  add_action( 'wp_enqueue_scripts', 'wpt_stylesheet' );
1918
  /**
1919
  * Enqueue front-end styles for Twitter Feed widget if enabled.
wpt-feed.php CHANGED
@@ -33,7 +33,14 @@ class WPT_TwitterFeed {
33
  //I'd prefer to put username before count, but for backwards compatibility it's not really viable. :(
34
  function getTweets( $count = 20, $screenname = false, $options = false ) {
35
  if ( $count > 20 ) {
36
- $count = 20;
 
 
 
 
 
 
 
37
  }
38
  if ( $count < 1 ) {
39
  $count = 1;
@@ -96,8 +103,24 @@ class WPT_TwitterFeed {
96
  }
97
  }
98
 
 
 
 
 
 
 
 
 
 
99
  private function checkValidCache( $screenname, $options ) {
 
100
  $file = $this->getCacheLocation();
 
 
 
 
 
 
101
  if ( is_file( $file ) ) {
102
  $cache = file_get_contents( $file );
103
  $cache = @json_decode( $cache, true );
@@ -177,7 +200,16 @@ class WPT_TwitterFeed {
177
  }
178
  $result = json_decode( $result );
179
  if ( isset( $options['search'] ) ) {
180
- $result = $result->statuses;
 
 
 
 
 
 
 
 
 
181
  }
182
  if ( is_file( $this->getCacheLocation() ) ) {
183
  $cache = json_decode( file_get_contents( $this->getCacheLocation() ), true );
33
  //I'd prefer to put username before count, but for backwards compatibility it's not really viable. :(
34
  function getTweets( $count = 20, $screenname = false, $options = false ) {
35
  if ( $count > 20 ) {
36
+ /**
37
+ * Filters the max feed count. Default is 20, but you can change it.
38
+ *
39
+ * @param integer 20 - Default value
40
+ * @param integer $count - Widget variable
41
+ * @return integer
42
+ */
43
+ $count = apply_filters( 'wpt_feed_max_count', 20, $count );
44
  }
45
  if ( $count < 1 ) {
46
  $count = 1;
103
  }
104
  }
105
 
106
+ private function delete_cache( $file ) {
107
+ $is_writable = wpt_is_writable( $file );
108
+ if ( $is_writable ) {
109
+ unlink( $file );
110
+ } else {
111
+ delete_transient( 'wpt_cache' );
112
+ }
113
+ }
114
+
115
  private function checkValidCache( $screenname, $options ) {
116
+ $delete_cache = get_option( 'wpt_delete_cache' );
117
  $file = $this->getCacheLocation();
118
+
119
+ if ( $delete_cache == 'true' ) {
120
+ update_option( 'wpt_delete_cache', 'false' );
121
+ $this->delete_cache( $file );
122
+ }
123
+
124
  if ( is_file( $file ) ) {
125
  $cache = file_get_contents( $file );
126
  $cache = @json_decode( $cache, true );
200
  }
201
  $result = json_decode( $result );
202
  if ( isset( $options['search'] ) ) {
203
+ if ( !method_exists( $result, 'errors' ) ) {
204
+ $result = $result->statuses;
205
+ } else {
206
+ $errors = $result->errors;
207
+ $return = '';
208
+ foreach ( $errors as $error ) {
209
+ $return .= "<li>$error->message</li>";
210
+ }
211
+ echo "<ul>" . $return . "</ul>"; return;
212
+ }
213
  }
214
  if ( is_file( $this->getCacheLocation() ) ) {
215
  $cache = json_decode( file_get_contents( $this->getCacheLocation() ), true );
wpt-functions.php CHANGED
@@ -5,6 +5,184 @@ if ( ! defined( 'ABSPATH' ) ) {
5
  exit;
6
  } // Exit if accessed directly
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  function wpt_mail( $subject, $body, $override=false ) {
9
  if ( ( WPT_DEBUG && function_exists( 'wpt_pro_exists' ) ) || $override == true ) {
10
  $use_email = true;
@@ -388,7 +566,7 @@ $plugins_string
388
  $sitename = substr( $sitename, 4 );
389
  }
390
  $from_email = 'wordpress@' . $sitename;
391
- $from = "From: \"$current_user->display_name\" <$from_email>\r\nReply-to: \"$current_user->display_name\" <$current_user->user_email>\r\n";
392
 
393
  if ( ! $has_read_faq ) {
394
  echo "<div class='message error'><p>" . __( 'Please read the FAQ and other Help documents before making a support request.', 'wp-to-twitter' ) . "</p></div>";
@@ -398,12 +576,12 @@ $plugins_string
398
  $sent = wp_mail( "plugins@joedolson.com", $subject, $message, $from );
399
  if ( $sent ) {
400
  if ( $has_donated == 'Donor' ) {
401
- echo "<div class='message updated'><p>" . sprintf( __( 'Thank you for supporting the continuing development of this plug-in! I\'ll get back to you as soon as I can. Please ensure that you can receive email at <code>%s</code>.', 'wp-to-twitter' ), $current_user->user_email ) . "</p></div>";
402
  } else {
403
  echo "<div class='message updated'><p>" . sprintf( __( "Thanks for using WP to Twitter. Please ensure that you can receive email at <code>%s</code>.", 'wp-to-twitter' ), $current_user->user_email ) . "</p></div>";
404
  }
405
  } else {
406
- echo "<div class='message error'><p>" . __( "Sorry! I couldn't send that message. Here's the text of your request:", 'my-calendar' ) . "</p><p>" . sprintf( __( '<a href="%s">Contact me here</a>, instead</p>', 'wp-to-twitter' ), 'https://www.joedolson.com/contact/' ) . "<pre>$request</pre></div>";
407
  }
408
  }
409
  }
@@ -413,6 +591,8 @@ $plugins_string
413
  $checked = '';
414
  }
415
  $admin_url = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' );
 
 
416
  echo "
417
  <form method='post' action='$admin_url'>
418
  <div><input type='hidden' name='_wpnonce' value='" . wp_create_nonce( 'wp-to-twitter-nonce' ) . "' /></div>
@@ -435,7 +615,7 @@ $plugins_string
435
  <input type='checkbox' name='has_donated' id='has_donated' value='on' $checked /> <label for='has_donated'>" . sprintf( __( 'I have <a href="%1$s">made a donation to help support this plug-in</a>', 'wp-to-twitter' ), 'http://www.joedolson.com/donate.php' ) . "</label>
436
  </p>
437
  <p>
438
- <label for='support_request'>" . __( 'Support Request:', 'wp-to-twitter' ) . "</label><br /><textarea class='support-request' name='support_request' id='support_request' cols='80' rows='10'>" . stripslashes( esc_attr( $request ) ) . "</textarea>
439
  </p>
440
  <p>
441
  <input type='submit' value='" . __( 'Send Support Request', 'wp-to-twitter' ) . "' name='wpt_support' class='button-primary' />
5
  exit;
6
  } // Exit if accessed directly
7
 
8
+
9
+
10
+ // FUNCTION to see if checkboxes should be checked
11
+ function jd_checkCheckbox( $field, $sub1 = false, $sub2 = '' ) {
12
+ if ( $sub1 ) {
13
+ $setting = get_option( $field );
14
+ if ( isset( $setting[ $sub1 ] ) ) {
15
+ $value = ( $sub2 != '' ) ? $setting[ $sub1 ][ $sub2 ] : $setting[ $sub1 ];
16
+ } else {
17
+ $value = 0;
18
+ }
19
+ if ( $value == 1 ) {
20
+ return 'checked="checked"';
21
+ }
22
+ }
23
+ if ( get_option( $field ) == '1' ) {
24
+ return 'checked="checked"';
25
+ }
26
+ return '';
27
+ }
28
+
29
+ function jd_checkSelect( $field, $value, $type = 'select' ) {
30
+ if ( get_option( $field ) == $value ) {
31
+ return ( $type == 'select' ) ? 'selected="selected"' : 'checked="checked"';
32
+ }
33
+ return '';
34
+ }
35
+
36
+ function wpt_set_log( $data, $id, $message ) {
37
+ if ( $id == 'test' ) {
38
+ update_option( $data, $message );
39
+ } else {
40
+ update_post_meta( $id, '_' . $data, $message );
41
+ }
42
+ update_option( $data . '_last', array( $id, $message ) );
43
+ }
44
+
45
+ function wpt_log( $data, $id ) {
46
+ if ( $id == 'test' ) {
47
+ $log = get_option( $data );
48
+ } else if ( $id == 'last' ) {
49
+ $log = get_option( $data . '_last' );
50
+ } else {
51
+ $log = get_post_meta( $id, '_' . $data, true );
52
+ }
53
+
54
+ return $log;
55
+ }
56
+
57
+ function wpt_check_functions() {
58
+ $message = "<div class='update'><ul>";
59
+ // grab or set necessary variables
60
+ $testurl = get_bloginfo( 'url' );
61
+ $testpost = false;
62
+ $title = urlencode( 'Your blog home' );
63
+ $shrink = apply_filters( 'wptt_shorten_link', $testurl, $title, false, true );
64
+ if ( $shrink == false ) {
65
+ $error = htmlentities( get_option( 'wpt_shortener_status' ) );
66
+ $message .= __( "<li class=\"error\"><strong>WP to Twitter was unable to contact your selected URL shortening service.</strong></li>", 'wp-to-twitter' );
67
+ if ( $error != '' ) {
68
+ $message .= "<li><code>$error</code></li>";
69
+ } else {
70
+ $message .= "<li><code>" . __( 'No error message was returned.', 'wp-to-twitter' ) . "</code></li>";
71
+ }
72
+ } else {
73
+ $message .= __( "<li><strong>WP to Twitter successfully contacted your selected URL shortening service.</strong> The following link should point to your blog homepage:", 'wp-to-twitter' );
74
+ $message .= " <a href='$shrink'>$shrink</a></li>";
75
+ }
76
+ //check twitter credentials
77
+ if ( wtt_oauth_test() ) {
78
+ $rand = rand( 1000000, 9999999 );
79
+ $testpost = jd_doTwitterAPIPost( "This is a test of WP to Twitter. $shrink ($rand)" );
80
+ if ( $testpost ) {
81
+ $message .= __( "<li><strong>WP to Twitter successfully submitted a status update to Twitter.</strong></li>", 'wp-to-twitter' );
82
+ } else {
83
+ $error = wpt_log( 'wpt_status_message', 'test' );
84
+ $message .= __( "<li class=\"error\"><strong>WP to Twitter failed to submit an update to Twitter.</strong></li>", 'wp-to-twitter' );
85
+ $message .= "<li class=\"error\">$error</li>";
86
+ }
87
+ } else {
88
+ $message .= "<strong>" . _e( 'You have not connected WordPress to Twitter.', 'wp-to-twitter' ) . "</strong> ";
89
+ }
90
+ // If everything's OK, there's no reason to do this again.
91
+ if ( $testpost == false && $shrink == false ) {
92
+ $message .= __( "<li class=\"error\"><strong>Your server does not appear to support the required methods for WP to Twitter to function.</strong> You can try it anyway - these tests aren't perfect.</li>", 'wp-to-twitter' );
93
+ } else {
94
+ }
95
+ if ( $testpost && $shrink ) {
96
+ $message .= __( "<li><strong>Your server should run WP to Twitter successfully.</strong></li>", 'wp-to-twitter' );
97
+ }
98
+ $message .= "</ul>
99
+ </div>";
100
+
101
+ return $message;
102
+ }
103
+
104
+ function wpt_settings_tabs() {
105
+ $output = '';
106
+ $default = ( get_option( 'wtt_twitter_username' ) == '' ) ? 'connection' : 'basic';
107
+ $current = ( isset( $_GET['tab'] ) ) ? $_GET['tab'] : $default;
108
+ $pro_text = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? __( 'Pro Settings', 'wp-to-twitter' ) : __( 'Get WP Tweets PRO', 'wp-to-twitter' );
109
+ $pages = array(
110
+ 'connection'=> __( 'Twitter Connection', 'wp-to-twitter' ),
111
+ 'basic'=> __( 'Basic Settings', 'wp-to-twitter' ),
112
+ 'shortener'=> __( 'URL Shortener', 'wp-to-twitter' ),
113
+ 'advanced' => __( 'Advanced Settings', 'wp-to-twitter' ),
114
+ 'support' => __( 'Get Help', 'wp-to-twitter' ),
115
+ 'pro' => $pro_text
116
+ );
117
+ $pages = apply_filters( 'wpt_settings_tabs_pages', $pages, $current );
118
+ $admin_url = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' );
119
+
120
+ foreach ( $pages as $key => $value ) {
121
+ $selected = ( $key == $current ) ? " nav-tab-active" : '';
122
+ $url = esc_url( add_query_arg( 'tab', $key, $admin_url ) );
123
+ if ( $key == 'pro' ) {
124
+ $output .= "<a class='wpt-pro-tab nav-tab$selected' href='$url'>$value</a>";
125
+ } else {
126
+ $output .= "<a class='nav-tab$selected' href='$url'>$value</a>";
127
+ }
128
+ }
129
+ echo $output;
130
+ }
131
+
132
+ function wpt_show_last_tweet() {
133
+ if ( apply_filters( 'wpt_show_last_tweet', true ) ) {
134
+ $log = wpt_log( 'wpt_status_message', 'last' );
135
+ if ( ! empty( $log ) && is_array( $log ) ) {
136
+ $post_ID = $log[0];
137
+ $post = get_post( $post_ID );
138
+ if ( is_object( $post ) ) {
139
+ $title = "<a href='" . get_edit_post_link( $post_ID ) . "'>$post->post_title</a>";
140
+ } else {
141
+ $title = __( 'No post associated with this Tweet', 'wp-to-twitter' );
142
+ }
143
+ $notice = $log[1];
144
+ echo "<div class='updated'><p><strong>" . __( 'Last Tweet', 'wp-to-twitter' ) . "</strong>: $title &raquo; $notice</p></div>";
145
+ }
146
+ }
147
+ }
148
+
149
+
150
+ function wpt_handle_errors() {
151
+ if ( isset( $_POST['submit-type'] ) && $_POST['submit-type'] == 'clear-error' ) {
152
+ delete_option( 'wp_url_failure' );
153
+ }
154
+ if ( get_option( 'wp_url_failure' ) == '1' ) {
155
+ $admin_url = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' );
156
+ $nonce = wp_nonce_field( 'wp-to-twitter-nonce', '_wpnonce', true, false ) . wp_referer_field( false );
157
+ $error = '<div class="error">' .
158
+ __( "<p>The query to the URL shortener API failed, and your URL was not shrunk. The full post URL was attached to your Tweet. Check with your URL shortening provider to see if there are any known issues.</p>", 'wp-to-twitter' ) .
159
+ '<form method="post" action="' . $admin_url . '">
160
+ <div>
161
+ <input type="hidden" name="submit-type" value="clear-error"/>
162
+ '. $nonce . '
163
+ </div>
164
+ <p>
165
+ <input type="submit" name="submit" value="' . __( "Clear 'WP to Twitter' Error Messages", 'wp-to-twitter' ) . '" class="button-primary" />
166
+ </p>
167
+ </form>
168
+ </div>';
169
+ echo $error;
170
+ }
171
+ }
172
+ // verify user capabilities
173
+ function wpt_check_caps( $role, $cap ) {
174
+ $role = get_role( $role );
175
+ if ( $role->has_cap( $cap ) ) {
176
+ return " checked='checked'";
177
+ }
178
+ return '';
179
+ }
180
+
181
+ // output checkbox for user capabilities
182
+ function wpt_cap_checkbox( $role, $cap, $name ) {
183
+ return "<li><input type='checkbox' id='wpt_caps_{$role}_$cap' name='wpt_caps[$role][$cap]' value='on'" . wpt_check_caps( $role, $cap ) . " /> <label for='wpt_caps_{$role}_$cap'>$name</label></li>";
184
+ }
185
+
186
  function wpt_mail( $subject, $body, $override=false ) {
187
  if ( ( WPT_DEBUG && function_exists( 'wpt_pro_exists' ) ) || $override == true ) {
188
  $use_email = true;
566
  $sitename = substr( $sitename, 4 );
567
  }
568
  $from_email = 'wordpress@' . $sitename;
569
+ $from = "From: \"$current_user->display_name\" <$current_user->user_email>\r\nReply-to: \"$current_user->display_name\" <$current_user->user_email>\r\n";
570
 
571
  if ( ! $has_read_faq ) {
572
  echo "<div class='message error'><p>" . __( 'Please read the FAQ and other Help documents before making a support request.', 'wp-to-twitter' ) . "</p></div>";
576
  $sent = wp_mail( "plugins@joedolson.com", $subject, $message, $from );
577
  if ( $sent ) {
578
  if ( $has_donated == 'Donor' ) {
579
+ echo "<div class='message updated'><p>" . sprintf( __( 'Thank you for supporting WP to Twitter! I\'ll get back to you as soon as I can. Please make sure you can receive email at <code>%s</code>.', 'wp-to-twitter' ), $current_user->user_email ) . "</p></div>";
580
  } else {
581
  echo "<div class='message updated'><p>" . sprintf( __( "Thanks for using WP to Twitter. Please ensure that you can receive email at <code>%s</code>.", 'wp-to-twitter' ), $current_user->user_email ) . "</p></div>";
582
  }
583
  } else {
584
+ echo "<div class='message error'><p>" . __( "Sorry! I couldn't send that message. Here's the text of your request:", 'my-calendar' ) . "</p><p>" . sprintf( __( '<a href="%s">Contact me here</a>, instead.', 'wp-to-twitter' ), 'https://www.joedolson.com/contact/' ) . "</p><pre>$request</pre></div>";
585
  }
586
  }
587
  }
591
  $checked = '';
592
  }
593
  $admin_url = ( is_plugin_active( 'wp-tweets-pro/wpt-pro-functions.php' ) ) ? admin_url( 'admin.php?page=wp-tweets-pro' ) : admin_url( 'options-general.php?page=wp-to-twitter/wp-to-twitter.php' );
594
+ $admin_url = add_query_arg( 'tab', 'support', $admin_url );
595
+
596
  echo "
597
  <form method='post' action='$admin_url'>
598
  <div><input type='hidden' name='_wpnonce' value='" . wp_create_nonce( 'wp-to-twitter-nonce' ) . "' /></div>
615
  <input type='checkbox' name='has_donated' id='has_donated' value='on' $checked /> <label for='has_donated'>" . sprintf( __( 'I have <a href="%1$s">made a donation to help support this plug-in</a>', 'wp-to-twitter' ), 'http://www.joedolson.com/donate.php' ) . "</label>
616
  </p>
617
  <p>
618
+ <label for='support_request'>" . __( 'Support Request:', 'wp-to-twitter' ) . "</label><br /><textarea class='support-request' name='support_request' id='support_request' cols='80' rows='10' class='widefat'>" . stripslashes( esc_attr( $request ) ) . "</textarea>
619
  </p>
620
  <p>
621
  <input type='submit' value='" . __( 'Send Support Request', 'wp-to-twitter' ) . "' name='wpt_support' class='button-primary' />
wpt-truncate.php CHANGED
@@ -6,7 +6,7 @@ if ( ! defined( 'ABSPATH' ) ) {
6
  function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = false ) {
7
  // media file occupies 22 characters, need to account for in shortening.
8
  $maxlength = apply_filters( 'wpt_max_tweet_length', array( 'with_media' => 116, 'without_media' => 139 ) );
9
- $tweet_length = ( wpt_post_with_media( $post_ID ) ) ? $maxlength['with_media'] : $maxlength['without_media'];
10
  $tweet = apply_filters( 'wpt_tweet_sentence', $tweet, $post_ID );
11
  $tweet = trim( wpt_custom_shortcodes( $tweet, $post_ID ) );
12
  $shrink = ( $post['shortUrl'] != '' ) ? $post['shortUrl'] : apply_filters( 'wptt_shorten_link', $post['postLink'], $post['postTitle'], $post_ID, false );
@@ -76,12 +76,13 @@ function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = fa
76
  && strpos( $tweet, '#reference#' ) === false
77
  && strpos( $tweet, '#account#' ) === false
78
  && strpos( $tweet, '#@#' ) === false
79
- && strpos( $tweet, '#cat_desc' ) === false
 
80
  ) {
81
  // there are no tags in this Tweet. Truncate and return.
82
  $post_tweet = mb_substr( $tweet, 0, $tweet_length, $encoding );
83
 
84
- return $post_tweet;
85
  }
86
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true ) {
87
  $reference = ( $ref ) ? $account : '@' . get_option( 'wtt_twitter_username' );
@@ -104,7 +105,8 @@ function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = fa
104
  '#author#',
105
  '#displayname#',
106
  '#tags#',
107
- '#modified#'
 
108
  );
109
  $replace = array(
110
  $account,
@@ -120,7 +122,8 @@ function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = fa
120
  $author,
121
  $display_name,
122
  $tags,
123
- $modified
 
124
  );
125
  $post_tweet = str_ireplace( $search, $replace, $tweet );
126
 
@@ -132,7 +135,7 @@ function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = fa
132
  $post_tweet = mb_substr( $post_tweet, 0, $tweet_length, $encoding );
133
  }
134
 
135
- return $post_tweet; // return early if all is well without replacements.
136
  } else {
137
  // build an array of variable names and the number of characters in that variable.
138
  $length_array = array();
@@ -173,7 +176,7 @@ function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = fa
173
  $trim = $str_length - ( $tweet_length + 1 + $diff );
174
  $old_value = ${$key};
175
  // prevent URL from being modified
176
- $post_tweet = str_ireplace( $thisposturl, '#url#', $post_tweet );
177
  // modify the value and replace old with new
178
  if ( $key == 'account' || $key == 'author' || $key == 'category' || $key == 'date' || $key == 'modified' || $key == 'reference' || $key == '@' ) {
179
  // these elements make no sense if truncated, so remove them entirely.
@@ -193,11 +196,11 @@ function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = fa
193
  $new_value = mb_substr( $old_value, 0, - ( $trim ), $encoding );
194
  // trim rest of last word
195
  $last_space = strrpos( $new_value, ' ' );
196
- $new_value = mb_substr( $new_value, 0, $last_space, $encoding );
197
  }
198
  $post_tweet = str_ireplace( $old_value, $new_value, $post_tweet );
199
  // put URL back before checking length
200
- $post_tweet = str_ireplace( '#url#', $thisposturl, $post_tweet );
201
  } else {
202
  if ( mb_strlen( fake_normalize( $post_tweet ), $encoding ) > ( $tweet_length + 1 + $diff ) ) {
203
  $post_tweet = mb_substr( $post_tweet, 0, ( $tweet_length + $diff ), $encoding );
@@ -209,15 +212,15 @@ function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = fa
209
  // this is needed in case a tweet needs to be truncated outright and the truncation values aren't in the above.
210
  // 1) removes URL 2) checks length of remainder 3) Replaces URL
211
  if ( mb_strlen( fake_normalize( $post_tweet ) ) > $tweet_length + 1 ) {
212
- $temp = str_ireplace( $thisposturl, '#url#', $post_tweet );
213
  if ( mb_strlen( fake_normalize( $temp ) ) > ( ( $tweet_length + 1 ) - ( $tco - strlen( '#url#' ) ) ) && $temp != $post_tweet ) {
214
  $post_tweet = trim( mb_substr( $temp, 0, ( ( $tweet_length + 1 ) - ( $tco - strlen( '#url#' ) ) ), $encoding ) );
215
  // it's possible to trim off the #url# part in this process. If that happens, put it back.
216
  $sub_sentence = ( strpos( $tweet, '#url#' ) === false ) ? $post_tweet : $post_tweet . ' ' . $thisposturl;
217
- $post_tweet = ( strpos( $post_tweet, '#url#' ) === false ) ? $sub_sentence : str_ireplace( '#url#', $thisposturl, $post_tweet );
218
  }
219
  }
220
  }
221
 
222
- return apply_filters( 'wpt_custom_truncate', $post_tweet, $tweet, $post_ID, $retweet ); // catch all, should never happen. But no reason not to include it.
223
- }
6
  function jd_truncate_tweet( $tweet, $post, $post_ID, $retweet = false, $ref = false ) {
7
  // media file occupies 22 characters, need to account for in shortening.
8
  $maxlength = apply_filters( 'wpt_max_tweet_length', array( 'with_media' => 116, 'without_media' => 139 ) );
9
+ $tweet_length = ( wpt_post_with_media( $post_ID, $post ) ) ? $maxlength['with_media'] : $maxlength['without_media'];
10
  $tweet = apply_filters( 'wpt_tweet_sentence', $tweet, $post_ID );
11
  $tweet = trim( wpt_custom_shortcodes( $tweet, $post_ID ) );
12
  $shrink = ( $post['shortUrl'] != '' ) ? $post['shortUrl'] : apply_filters( 'wptt_shorten_link', $post['postLink'], $post['postTitle'], $post_ID, false );
76
  && strpos( $tweet, '#reference#' ) === false
77
  && strpos( $tweet, '#account#' ) === false
78
  && strpos( $tweet, '#@#' ) === false
79
+ && strpos( $tweet, '#cat_desc#' ) === false
80
+ && strpos( $tweet, '#longurl#' ) === false
81
  ) {
82
  // there are no tags in this Tweet. Truncate and return.
83
  $post_tweet = mb_substr( $tweet, 0, $tweet_length, $encoding );
84
 
85
+ return apply_filters( 'wpt_custom_truncate', $post_tweet, $tweet, $post_ID, $retweet );
86
  }
87
  if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() == true ) {
88
  $reference = ( $ref ) ? $account : '@' . get_option( 'wtt_twitter_username' );
105
  '#author#',
106
  '#displayname#',
107
  '#tags#',
108
+ '#modified#',
109
+ '#longurl#'
110
  );
111
  $replace = array(
112
  $account,
122
  $author,
123
  $display_name,
124
  $tags,
125
+ $modified,
126
+ $post['postLink']
127
  );
128
  $post_tweet = str_ireplace( $search, $replace, $tweet );
129
 
135
  $post_tweet = mb_substr( $post_tweet, 0, $tweet_length, $encoding );
136
  }
137
 
138
+ return apply_filters( 'wpt_custom_truncate', $post_tweet, $tweet, $post_ID, $retweet ); // return early if all is well without replacements.
139
  } else {
140
  // build an array of variable names and the number of characters in that variable.
141
  $length_array = array();
176
  $trim = $str_length - ( $tweet_length + 1 + $diff );
177
  $old_value = ${$key};
178
  // prevent URL from being modified
179
+ $post_tweet = str_ireplace( array( $thisposturl, $post['postLink'] ), array( '#url#', '#longurl#' ), $post_tweet );
180
  // modify the value and replace old with new
181
  if ( $key == 'account' || $key == 'author' || $key == 'category' || $key == 'date' || $key == 'modified' || $key == 'reference' || $key == '@' ) {
182
  // these elements make no sense if truncated, so remove them entirely.
196
  $new_value = mb_substr( $old_value, 0, - ( $trim ), $encoding );
197
  // trim rest of last word
198
  $last_space = strrpos( $new_value, ' ' );
199
+ $new_value = apply_filters( 'wpt_filter_truncated_value', mb_substr( $new_value, 0, $last_space, $encoding ), $key );
200
  }
201
  $post_tweet = str_ireplace( $old_value, $new_value, $post_tweet );
202
  // put URL back before checking length
203
+ $post_tweet = str_ireplace( array( '#url#', '#longurl#' ), array( $thisposturl, $post['postLink'] ), $post_tweet );
204
  } else {
205
  if ( mb_strlen( fake_normalize( $post_tweet ), $encoding ) > ( $tweet_length + 1 + $diff ) ) {
206
  $post_tweet = mb_substr( $post_tweet, 0, ( $tweet_length + $diff ), $encoding );
212
  // this is needed in case a tweet needs to be truncated outright and the truncation values aren't in the above.
213
  // 1) removes URL 2) checks length of remainder 3) Replaces URL
214
  if ( mb_strlen( fake_normalize( $post_tweet ) ) > $tweet_length + 1 ) {
215
+ $temp = str_ireplace( array( $thisposturl, $post['postLink'] ), array( '#url#', '#longurl#' ), $post_tweet );
216
  if ( mb_strlen( fake_normalize( $temp ) ) > ( ( $tweet_length + 1 ) - ( $tco - strlen( '#url#' ) ) ) && $temp != $post_tweet ) {
217
  $post_tweet = trim( mb_substr( $temp, 0, ( ( $tweet_length + 1 ) - ( $tco - strlen( '#url#' ) ) ), $encoding ) );
218
  // it's possible to trim off the #url# part in this process. If that happens, put it back.
219
  $sub_sentence = ( strpos( $tweet, '#url#' ) === false ) ? $post_tweet : $post_tweet . ' ' . $thisposturl;
220
+ $post_tweet = ( strpos( $post_tweet, '#url#' ) === false ) ? $sub_sentence : str_ireplace( array( '#url#', '#longurl#' ), array( $thisposturl, $post['postLink'] ), $post_tweet );
221
  }
222
  }
223
  }
224
 
225
+ return apply_filters( 'wpt_custom_truncate', $post_tweet, $tweet, $post_ID, $retweet );
226
+ }
wpt-widget.php CHANGED
@@ -30,7 +30,9 @@ function wpt_get_twitter_feed( $atts, $content ) {
30
  'mentions' => 1,
31
  'hashtags' => 0,
32
  'intents' => 1,
33
- 'source' => 0
 
 
34
  ), $atts, 'get_tweets' ) );
35
  $instance = array(
36
  'twitter_id' => $id,
@@ -42,7 +44,9 @@ function wpt_get_twitter_feed( $atts, $content ) {
42
  'link_mentions' => $mentions,
43
  'link_hashtags' => $hashtags,
44
  'intents' => $intents,
45
- 'source' => $source
 
 
46
  );
47
 
48
  return wpt_twitter_feed( $instance );
@@ -51,7 +55,8 @@ function wpt_get_twitter_feed( $atts, $content ) {
51
  function wpt_twitter_feed( $instance ) {
52
  $header = '';
53
  if ( ! isset( $instance['search'] ) ) {
54
- $user = wpt_get_user( $instance['twitter_id'] );
 
55
  if ( isset( $user->errors ) && $user->errors[0]->message ) {
56
  return __( "Error: ", 'wp-to-twitter' ) . $user->errors[0]->message;
57
  }
@@ -60,20 +65,20 @@ function wpt_twitter_feed( $instance ) {
60
  $verified = sanitize_title( $user->verified );
61
  $img_alignment = ( is_rtl() ) ? 'wpt-right' : 'wpt-left';
62
  $follow_alignment = ( is_rtl() ) ? 'wpt-left' : 'wpt-right';
63
- $follow_url = esc_url( 'https://twitter.com/' . $instance['twitter_id'] );
64
- $follow_button = apply_filters( 'wpt_follow_button', "<a href='$follow_url' class='twitter-follow-button $follow_alignment' data-width='30px' data-show-screen-name='false' data-size='large' data-show-count='false' data-lang='en'>Follow @$instance[twitter_id]</a>" );
65
  $header .= '<div class="wpt-header">';
66
  $header .= "<p>
67
  $follow_button
68
  <img src='$avatar' alt='' class='wpt-twitter-avatar $img_alignment $verified' />
69
  <span class='wpt-twitter-name'>$name</span><br />
70
- <span class='wpt-twitter-id'><a href='$follow_url'>@$instance[twitter_id]</a></span>
71
  </p>";
72
  $header .= '</div>';
73
  }
74
-
75
- $return = $header . '<ul>' . "\n";
76
-
77
  if ( ! isset( $instance['search'] ) ) {
78
  $options['exclude_replies'] = ( isset( $instance['twitter_hide_replies'] ) ) ? $instance['twitter_hide_replies'] : false;
79
  $options['include_rts'] = $instance['twitter_include_rts'];
@@ -83,9 +88,17 @@ function wpt_twitter_feed( $instance ) {
83
  $options['result_type'] = $instance['result_type'];
84
  $instance['twitter_id'] = get_option( 'wtt_twitter_username' );
85
  }
86
- $opts['links'] = $instance['link_links'];
87
- $opts['mentions'] = $instance['link_mentions'];
88
- $opts['hashtags'] = $instance['link_hashtags'];
 
 
 
 
 
 
 
 
89
  $rawtweets = WPT_getTweets( $instance['twitter_num'], $instance['twitter_id'], $options );
90
 
91
  if ( isset( $rawtweets['error'] ) ) {
@@ -106,11 +119,11 @@ function wpt_twitter_feed( $instance ) {
106
  }
107
  $tweet_classes = wpt_generate_classes( $tweet );
108
 
109
- $intents = ( $instance['intents'] ) ? "<div class='wpt-intents-border'></div><div class='wpt-intents'><a class='wpt-reply' href='https://twitter.com/intent/tweet?in_reply_to=$tweet[id_str]'><span></span>Reply</a> <a class='wpt-retweet' href='https://twitter.com/intent/retweet?tweet_id=$tweet[id_str]'><span></span>Retweet</a> <a class='wpt-favorite' href='https://twitter.com/intent/favorite?tweet_id=$tweet[id_str]'><span></span>Favorite</a></div>" : '';
110
  /** Add tweet to array */
111
  $before_tweet = apply_filters( 'wpt_before_tweet', '', $tweet );
112
  $after_tweet = apply_filters( 'wpt_after_tweet', '', $tweet );
113
- $tweets[] = '<li class="' . $tweet_classes . '">' . $before_tweet . WPT_tweet_linkify( $tweet['text'], $opts, $tweet ) . "<br /><span class='wpt-tweet-time'>$timetweet</span> $intents " . $after_tweet . "</li>\n";
114
  }
115
  }
116
  if ( is_array( $tweets ) ) {
@@ -151,7 +164,9 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
151
  'link_mentions' => '',
152
  'link_hashtags' => '',
153
  'intents' => '',
154
- 'source' => ''
 
 
155
  );
156
 
157
  $widget_ops = array(
@@ -179,6 +194,7 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
179
  wp_enqueue_script( 'twitter-platform', "https://platform.twitter.com/widgets.js" );
180
  /** Merge with defaults */
181
  $instance = wp_parse_args( (array) $instance, $this->defaults );
 
182
  echo $before_widget;
183
  if ( $instance['title'] ) {
184
  echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
@@ -202,8 +218,8 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
202
  * @return array Settings to save or bool false to cancel saving
203
  */
204
  function update( $new_instance, $old_instance ) {
205
- /** Force the transient to refresh */
206
- delete_transient( 'wpt_tdf_cache_expire' );
207
  $new_instance['title'] = strip_tags( $new_instance['title'] );
208
 
209
  return $new_instance;
@@ -236,7 +252,15 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
236
  name="<?php echo $this->get_field_name( 'twitter_id' ); ?>"
237
  value="<?php echo esc_attr( $instance['twitter_id'] ); ?>" class="widefat"/>
238
  </p>
239
-
 
 
 
 
 
 
 
 
240
  <p>
241
  <label
242
  for="<?php echo $this->get_field_id( 'twitter_num' ); ?>"><?php _e( 'Number of Tweets to Show', 'wp-to-twitter' ); ?>
@@ -249,7 +273,7 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
249
  <p>
250
  <input id="<?php echo $this->get_field_id( 'twitter_hide_replies' ); ?>" type="checkbox"
251
  name="<?php echo $this->get_field_name( 'twitter_hide_replies' ); ?>"
252
- value="1" <?php checked( $instance['twitter_hide_replies'] ); ?>/>
253
  <label
254
  for="<?php echo $this->get_field_id( 'twitter_hide_replies' ); ?>"><?php _e( 'Hide @ Replies', 'wp-to-twitter' ); ?></label>
255
  </p>
@@ -257,7 +281,7 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
257
  <p>
258
  <input id="<?php echo $this->get_field_id( 'twitter_include_rts' ); ?>" type="checkbox"
259
  name="<?php echo $this->get_field_name( 'twitter_include_rts' ); ?>"
260
- value="1" <?php checked( $instance['twitter_include_rts'] ); ?>/>
261
  <label
262
  for="<?php echo $this->get_field_id( 'twitter_include_rts' ); ?>"><?php _e( 'Include Retweets', 'wp-to-twitter' ); ?></label>
263
  </p>
@@ -265,7 +289,7 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
265
  <p>
266
  <input id="<?php echo $this->get_field_id( 'link_links' ); ?>" type="checkbox"
267
  name="<?php echo $this->get_field_name( 'link_links' ); ?>"
268
- value="1" <?php checked( $instance['link_links'] ); ?>/>
269
  <label
270
  for="<?php echo $this->get_field_id( 'link_links' ); ?>"><?php _e( 'Parse links', 'wp-to-twitter' ); ?></label>
271
  </p>
@@ -273,15 +297,23 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
273
  <p>
274
  <input id="<?php echo $this->get_field_id( 'link_mentions' ); ?>" type="checkbox"
275
  name="<?php echo $this->get_field_name( 'link_mentions' ); ?>"
276
- value="1" <?php checked( $instance['link_mentions'] ); ?>/>
277
  <label
278
  for="<?php echo $this->get_field_id( 'link_mentions' ); ?>"><?php _e( 'Parse @mentions', 'wp-to-twitter' ); ?></label>
279
  </p>
 
 
 
 
 
 
 
 
280
 
281
  <p>
282
  <input id="<?php echo $this->get_field_id( 'link_hashtags' ); ?>" type="checkbox"
283
  name="<?php echo $this->get_field_name( 'link_hashtags' ); ?>"
284
- value="1" <?php checked( $instance['link_hashtags'] ); ?>/>
285
  <label
286
  for="<?php echo $this->get_field_id( 'link_hashtags' ); ?>"><?php _e( 'Parse #hashtags', 'wp-to-twitter' ); ?></label>
287
  </p>
@@ -289,7 +321,7 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
289
  <p>
290
  <input id="<?php echo $this->get_field_id( 'intents' ); ?>" type="checkbox"
291
  name="<?php echo $this->get_field_name( 'intents' ); ?>"
292
- value="1" <?php checked( $instance['intents'] ); ?>/>
293
  <label
294
  for="<?php echo $this->get_field_id( 'intents' ); ?>"><?php _e( 'Include Reply/Retweet/Favorite Links', 'wp-to-twitter' ); ?></label>
295
  </p>
@@ -297,7 +329,7 @@ class WPT_Latest_Tweets_Widget extends WP_Widget {
297
  <p>
298
  <input id="<?php echo $this->get_field_id( 'source' ); ?>" type="checkbox"
299
  name="<?php echo $this->get_field_name( 'source' ); ?>"
300
- value="1" <?php checked( $instance['source'] ); ?>/>
301
  <label
302
  for="<?php echo $this->get_field_id( 'source' ); ?>"><?php _e( 'Include Tweet source', 'wp-to-twitter' ); ?></label>
303
  </p>
@@ -385,8 +417,8 @@ class WPT_Search_Tweets_Widget extends WP_Widget {
385
  * @return array Settings to save or bool false to cancel saving
386
  */
387
  function update( $new_instance, $old_instance ) {
388
- /** Force the transient to refresh */
389
- delete_transient( 'wpt_tdf_cache_expire' );
390
  $new_instance['title'] = strip_tags( $new_instance['title'] );
391
 
392
  return $new_instance;
@@ -511,7 +543,23 @@ add_action( 'widgets_init', create_function( '', "register_widget('WPT_Search_Tw
511
  *
512
  * @return string Linkified tweet content
513
  */
514
- function WPT_tweet_linkify( $text, $opts, $tweet ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  $text = ( $opts['links'] == true ) ? preg_replace( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", '\\1<a href="\\2" rel="nofollow">\\2</a>', $text ) : $text;
516
  $text = ( $opts['links'] == true ) ? preg_replace( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", '\\1<a href="http://\\2" rel="nofollow">\\2</a>', $text ) : $text;
517
  $text = ( $opts['mentions'] == true ) ? preg_replace( '/@(\w+)/', '<a href="https://www.twitter.com/\\1" rel="nofollow">@\\1</a>', $text ) : $text;
@@ -519,6 +567,7 @@ function WPT_tweet_linkify( $text, $opts, $tweet ) {
519
  $urls = $tweet['entities']['urls'];
520
  if ( is_array( $urls ) ) {
521
  foreach ( $urls as $url ) {
 
522
  $text = str_replace( ">$url[url]<", ">$url[display_url]<", $text );
523
  }
524
  }
@@ -552,7 +601,7 @@ function wpt_generate_classes( $tweet ) {
552
  // take Tweet array and parse selected options into classes.
553
  $classes[] = ( $tweet['favorited'] ) ? 'favorited' : '';
554
  $clasees[] = ( $tweet['retweeted'] ) ? 'retweeted' : '';
555
- $classes[] = ( isset( $tweet['possibly_sensitive'] ) ) ? 'sensitive' : '';
556
  $classes[] = 'lang-' . $tweet['lang'];
557
  $class = trim( implode( ' ', $classes ) );
558
 
30
  'mentions' => 1,
31
  'hashtags' => 0,
32
  'intents' => 1,
33
+ 'source' => 0,
34
+ 'show_images' => 1,
35
+ 'hide_header' => 0
36
  ), $atts, 'get_tweets' ) );
37
  $instance = array(
38
  'twitter_id' => $id,
44
  'link_mentions' => $mentions,
45
  'link_hashtags' => $hashtags,
46
  'intents' => $intents,
47
+ 'source' => $source,
48
+ 'show_images' => $show_images,
49
+ 'hide_header' => $hide_header
50
  );
51
 
52
  return wpt_twitter_feed( $instance );
55
  function wpt_twitter_feed( $instance ) {
56
  $header = '';
57
  if ( ! isset( $instance['search'] ) ) {
58
+ $twitter_ID = esc_html( ( isset( $instance['twitter_id'] ) && $instance['twitter_id'] != '' ) ? $instance['twitter_id'] : get_option( 'wtt_twitter_username' ) );
59
+ $user = wpt_get_user( $twitter_ID );
60
  if ( isset( $user->errors ) && $user->errors[0]->message ) {
61
  return __( "Error: ", 'wp-to-twitter' ) . $user->errors[0]->message;
62
  }
65
  $verified = sanitize_title( $user->verified );
66
  $img_alignment = ( is_rtl() ) ? 'wpt-right' : 'wpt-left';
67
  $follow_alignment = ( is_rtl() ) ? 'wpt-left' : 'wpt-right';
68
+ $follow_url = esc_url( 'https://twitter.com/' . $twitter_ID );
69
+ $follow_button = apply_filters( 'wpt_follow_button', "<a href='$follow_url' class='twitter-follow-button $follow_alignment' data-width='30px' data-show-screen-name='false' data-size='large' data-show-count='false' data-lang='en'>Follow @$twitter_ID</a>" );
70
  $header .= '<div class="wpt-header">';
71
  $header .= "<p>
72
  $follow_button
73
  <img src='$avatar' alt='' class='wpt-twitter-avatar $img_alignment $verified' />
74
  <span class='wpt-twitter-name'>$name</span><br />
75
+ <span class='wpt-twitter-id'><a href='$follow_url'>@$twitter_ID</a></span>
76
  </p>";
77
  $header .= '</div>';
78
  }
79
+
80
+ $hide_header = ( $instance['hide_header'] == 1 ) ? true : false;
81
+
82
  if ( ! isset( $instance['search'] ) ) {
83
  $options['exclude_replies'] = ( isset( $instance['twitter_hide_replies'] ) ) ? $instance['twitter_hide_replies'] : false;
84
  $options['include_rts'] = $instance['twitter_include_rts'];
88
  $options['result_type'] = $instance['result_type'];
89
  $instance['twitter_id'] = get_option( 'wtt_twitter_username' );
90
  }
91
+
92
+ if ( $hide_header ) {
93
+ $header = '';
94
+ }
95
+
96
+ $return = $header . '<ul>' . "\n";
97
+
98
+ $opts['links'] = $instance['link_links'];
99
+ $opts['mentions'] = $instance['link_mentions'];
100
+ $opts['hashtags'] = $instance['link_hashtags'];
101
+ $opts['show_images'] = isset( $instance['show_images'] ) ? $instance['show_images'] : false;
102
  $rawtweets = WPT_getTweets( $instance['twitter_num'], $instance['twitter_id'], $options );
103
 
104
  if ( isset( $rawtweets['error'] ) ) {
119
  }
120
  $tweet_classes = wpt_generate_classes( $tweet );
121
 
122
+ $intents = ( $instance['intents'] ) ? "<div class='wpt-intents-border'></div><div class='wpt-intents'><a class='wpt-reply' href='https://twitter.com/intent/tweet?in_reply_to=$tweet[id_str]'><span></span><span class='intent-text reply-text'>Reply</span></a> <a class='wpt-retweet' href='https://twitter.com/intent/retweet?tweet_id=$tweet[id_str]'><span></span><span class='intent-text retweet-text'>Retweet</span></a> <a class='wpt-favorite' href='https://twitter.com/intent/favorite?tweet_id=$tweet[id_str]'><span></span><span class='intent-text favorite-text'>Favorite</span></a></div>" : '';
123
  /** Add tweet to array */
124
  $before_tweet = apply_filters( 'wpt_before_tweet', '', $tweet );
125
  $after_tweet = apply_filters( 'wpt_after_tweet', '', $tweet );
126
+ $tweets[] = '<li class="' . $tweet_classes . '">' . $before_tweet . wpt_tweet_linkify( $tweet['text'], $opts, $tweet ) . "<br /><span class='wpt-tweet-time'>$timetweet</span> $intents " . $after_tweet . "</li>\n";
127
  }
128
  }
129
  if ( is_array( $tweets ) ) {
164
  'link_mentions' => '',
165
  'link_hashtags' => '',
166
  'intents' => '',
167
+ 'source' => '',
168
+ 'show_images' => '',
169
+ 'hide_header' => 0
170
  );
171
 
172
  $widget_ops = array(
194
  wp_enqueue_script( 'twitter-platform', "https://platform.twitter.com/widgets.js" );
195
  /** Merge with defaults */
196
  $instance = wp_parse_args( (array) $instance, $this->defaults );
197
+
198
  echo $before_widget;
199
  if ( $instance['title'] ) {
200
  echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title;
218
  * @return array Settings to save or bool false to cancel saving
219
  */
220
  function update( $new_instance, $old_instance ) {
221
+ /** Force the cache to refresh */
222
+ update_option( 'wpt_delete_cache', 'true' );
223
  $new_instance['title'] = strip_tags( $new_instance['title'] );
224
 
225
  return $new_instance;
252
  name="<?php echo $this->get_field_name( 'twitter_id' ); ?>"
253
  value="<?php echo esc_attr( $instance['twitter_id'] ); ?>" class="widefat"/>
254
  </p>
255
+
256
+ <p>
257
+ <input id="<?php echo $this->get_field_id( 'hide_header' ); ?>" type="checkbox"
258
+ name="<?php echo $this->get_field_name( 'hide_header' ); ?>"
259
+ value="1" <?php checked( $instance['hide_header'], 1 ); ?>/>
260
+ <label
261
+ for="<?php echo $this->get_field_id( 'hide_header' ); ?>"><?php _e( 'Hide Widget Header', 'wp-to-twitter' ); ?></label>
262
+ </p>
263
+
264
  <p>
265
  <label
266
  for="<?php echo $this->get_field_id( 'twitter_num' ); ?>"><?php _e( 'Number of Tweets to Show', 'wp-to-twitter' ); ?>
273
  <p>
274
  <input id="<?php echo $this->get_field_id( 'twitter_hide_replies' ); ?>" type="checkbox"
275
  name="<?php echo $this->get_field_name( 'twitter_hide_replies' ); ?>"
276
+ value="1" <?php checked( $instance['twitter_hide_replies'], 1 ); ?>/>
277
  <label
278
  for="<?php echo $this->get_field_id( 'twitter_hide_replies' ); ?>"><?php _e( 'Hide @ Replies', 'wp-to-twitter' ); ?></label>
279
  </p>
281
  <p>
282
  <input id="<?php echo $this->get_field_id( 'twitter_include_rts' ); ?>" type="checkbox"
283
  name="<?php echo $this->get_field_name( 'twitter_include_rts' ); ?>"
284
+ value="1" <?php checked( $instance['twitter_include_rts'], 1 ); ?>/>
285
  <label
286
  for="<?php echo $this->get_field_id( 'twitter_include_rts' ); ?>"><?php _e( 'Include Retweets', 'wp-to-twitter' ); ?></label>
287
  </p>
289
  <p>
290
  <input id="<?php echo $this->get_field_id( 'link_links' ); ?>" type="checkbox"
291
  name="<?php echo $this->get_field_name( 'link_links' ); ?>"
292
+ value="1" <?php checked( $instance['link_links'], 1 ); ?>/>
293
  <label
294
  for="<?php echo $this->get_field_id( 'link_links' ); ?>"><?php _e( 'Parse links', 'wp-to-twitter' ); ?></label>
295
  </p>
297
  <p>
298
  <input id="<?php echo $this->get_field_id( 'link_mentions' ); ?>" type="checkbox"
299
  name="<?php echo $this->get_field_name( 'link_mentions' ); ?>"
300
+ value="1" <?php checked( $instance['link_mentions'], 1 ); ?>/>
301
  <label
302
  for="<?php echo $this->get_field_id( 'link_mentions' ); ?>"><?php _e( 'Parse @mentions', 'wp-to-twitter' ); ?></label>
303
  </p>
304
+
305
+ <p>
306
+ <input id="<?php echo $this->get_field_id( 'show_images' ); ?>" type="checkbox"
307
+ name="<?php echo $this->get_field_name( 'show_images' ); ?>"
308
+ value="1" <?php checked( $instance['show_images'], 1 ); ?>/>
309
+ <label
310
+ for="<?php echo $this->get_field_id( 'show_images' ); ?>"><?php _e( 'Show Images', 'wp-to-twitter' ); ?></label>
311
+ </p>
312
 
313
  <p>
314
  <input id="<?php echo $this->get_field_id( 'link_hashtags' ); ?>" type="checkbox"
315
  name="<?php echo $this->get_field_name( 'link_hashtags' ); ?>"
316
+ value="1" <?php checked( $instance['link_hashtags'], 1 ); ?>/>
317
  <label
318
  for="<?php echo $this->get_field_id( 'link_hashtags' ); ?>"><?php _e( 'Parse #hashtags', 'wp-to-twitter' ); ?></label>
319
  </p>
321
  <p>
322
  <input id="<?php echo $this->get_field_id( 'intents' ); ?>" type="checkbox"
323
  name="<?php echo $this->get_field_name( 'intents' ); ?>"
324
+ value="1" <?php checked( $instance['intents'], 1 ); ?>/>
325
  <label
326
  for="<?php echo $this->get_field_id( 'intents' ); ?>"><?php _e( 'Include Reply/Retweet/Favorite Links', 'wp-to-twitter' ); ?></label>
327
  </p>
329
  <p>
330
  <input id="<?php echo $this->get_field_id( 'source' ); ?>" type="checkbox"
331
  name="<?php echo $this->get_field_name( 'source' ); ?>"
332
+ value="1" <?php checked( $instance['source'], 1 ); ?>/>
333
  <label
334
  for="<?php echo $this->get_field_id( 'source' ); ?>"><?php _e( 'Include Tweet source', 'wp-to-twitter' ); ?></label>
335
  </p>
417
  * @return array Settings to save or bool false to cancel saving
418
  */
419
  function update( $new_instance, $old_instance ) {
420
+ /** Force the cache to refresh */
421
+ update_option( 'wpt_delete_cache', 'true' );
422
  $new_instance['title'] = strip_tags( $new_instance['title'] );
423
 
424
  return $new_instance;
543
  *
544
  * @return string Linkified tweet content
545
  */
546
+ function wpt_tweet_linkify( $text, $opts, $tweet ) {
547
+ if ( $opts['show_images'] == true ) {
548
+ $media = $tweet['entities']['media'];
549
+ $media_urls = array();
550
+ if ( !empty( $media ) ) {
551
+ foreach ( $media as $image ) {
552
+ $media_urls[] = $image['url'];
553
+ // alt attributes are not available on Twitter.
554
+ $text .= "<img src='$image[media_url_https]' alt='' class='wpt-twitter-image' />";
555
+ }
556
+ }
557
+ if ( !empty( $media_urls ) ) {
558
+ foreach ( $media_urls as $media_url ) {
559
+ $text = str_replace( "$media_url", '', $text );
560
+ }
561
+ }
562
+ }
563
  $text = ( $opts['links'] == true ) ? preg_replace( "#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", '\\1<a href="\\2" rel="nofollow">\\2</a>', $text ) : $text;
564
  $text = ( $opts['links'] == true ) ? preg_replace( "#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", '\\1<a href="http://\\2" rel="nofollow">\\2</a>', $text ) : $text;
565
  $text = ( $opts['mentions'] == true ) ? preg_replace( '/@(\w+)/', '<a href="https://www.twitter.com/\\1" rel="nofollow">@\\1</a>', $text ) : $text;
567
  $urls = $tweet['entities']['urls'];
568
  if ( is_array( $urls ) ) {
569
  foreach ( $urls as $url ) {
570
+
571
  $text = str_replace( ">$url[url]<", ">$url[display_url]<", $text );
572
  }
573
  }
601
  // take Tweet array and parse selected options into classes.
602
  $classes[] = ( $tweet['favorited'] ) ? 'favorited' : '';
603
  $clasees[] = ( $tweet['retweeted'] ) ? 'retweeted' : '';
604
+ $classes[] = ( isset( $tweet['possibly_sensitive'] ) && $tweet['possibly_sensitive'] ) ? 'sensitive' : '';
605
  $classes[] = 'lang-' . $tweet['lang'];
606
  $class = trim( implode( ' ', $classes ) );
607
 
wpt_twitter_oauth.php CHANGED
@@ -6,7 +6,6 @@
6
  *
7
  */
8
 
9
- /* Load WPOAuth lib. You can find it at http://WPOAuth.net */
10
  if ( ! defined( 'ABSPATH' ) ) {
11
  exit;
12
  } // Exit if accessed directly
6
  *
7
  */
8
 
 
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  exit;
11
  } // Exit if accessed directly