Version Description
- Update connection instructions to match Project & App structure at Twitter.
- Update metabox design and layout.
- Toggle default length based on current locale.
- Remove stored URLs; no longer important to avoid repeat shortener queries.
- Mask app tokens after saving.
- Automatically switch to staging mode if environment query returns staging.
- Bug fix: remove whitespace in some settings inputs
- New: use wp_after_insert_post action (new in WP 5.6) so terms & metadata are saved at the time posts are published when using the block editor.
- Numerous updates for WP Tweets Pro users.
Download this release
Release Info
Developer | joedolson |
Plugin | WP to Twitter |
Version | 3.5.0 |
Comparing to | |
See all releases |
Code changes from version 3.4.10 to 3.5.0
- classes/class-wpt-twitterfeed.php +0 -1
- classes/class-wpt-twitteroauth.php +3 -3
- css/post-styles.css +50 -28
- css/styles.css +14 -31
- js/ajax.js +33 -33
- js/base.js +29 -29
- readme.txt +17 -4
- wp-to-twitter-manager.php +65 -35
- wp-to-twitter-oauth.php +72 -40
- wp-to-twitter.php +118 -123
- wp-tweets-pro-2.0.0.pdf +0 -0
- wpt-truncate.php +10 -15
- wpt-widget.php +2 -2
classes/class-wpt-twitterfeed.php
CHANGED
@@ -259,7 +259,6 @@ class WPT_TwitterFeed {
|
|
259 |
array(
|
260 |
'screen_name' => $screenname,
|
261 |
'count' => 20,
|
262 |
-
'include_ext_alt_text' => 'true',
|
263 |
)
|
264 |
);
|
265 |
|
259 |
array(
|
260 |
'screen_name' => $screenname,
|
261 |
'count' => 20,
|
|
|
262 |
)
|
263 |
);
|
264 |
|
classes/class-wpt-twitteroauth.php
CHANGED
@@ -363,10 +363,11 @@ if ( ! class_exists( 'Wpt_TwitterOAuth' ) ) {
|
|
363 |
$media_id = $response->media_id_string;
|
364 |
|
365 |
/**
|
366 |
-
*
|
367 |
-
|
368 |
$metadata_api = 'https://upload.twitter.com/1.1/media/metadata/create.json';
|
369 |
$alt_text = get_post_meta( $attachment, '_wp_attachment_image_alt', true );
|
|
|
370 |
if ( '' != $alt_text ) {
|
371 |
$image_alt = json_encode(
|
372 |
array(
|
@@ -387,7 +388,6 @@ if ( ! class_exists( 'Wpt_TwitterOAuth' ) ) {
|
|
387 |
)
|
388 |
);
|
389 |
}
|
390 |
-
*/
|
391 |
|
392 |
return $media_id;
|
393 |
}
|
363 |
$media_id = $response->media_id_string;
|
364 |
|
365 |
/**
|
366 |
+
* Add alt attributes to uploaded Twitter images.
|
367 |
+
*/
|
368 |
$metadata_api = 'https://upload.twitter.com/1.1/media/metadata/create.json';
|
369 |
$alt_text = get_post_meta( $attachment, '_wp_attachment_image_alt', true );
|
370 |
+
$alt_text = apply_filters( 'wpt_uploaded_image_alt', $alt_text, $attachment );
|
371 |
if ( '' != $alt_text ) {
|
372 |
$image_alt = json_encode(
|
373 |
array(
|
388 |
)
|
389 |
);
|
390 |
}
|
|
|
391 |
|
392 |
return $media_id;
|
393 |
}
|
css/post-styles.css
CHANGED
@@ -94,13 +94,8 @@
|
|
94 |
}
|
95 |
|
96 |
#wp2t .wpt_auth_users select {
|
97 |
-
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
#side-sortables #wp2t .wpt_auth_users select {
|
102 |
-
width: 98%;
|
103 |
-
max-height: 120px;
|
104 |
}
|
105 |
|
106 |
.panel-toggle a {
|
@@ -120,26 +115,22 @@
|
|
120 |
line-height: inherit;
|
121 |
}
|
122 |
|
123 |
-
.wp-to-twitter .dashicons-clock
|
|
|
124 |
font-size: 20px;
|
|
|
125 |
}
|
126 |
|
127 |
.wpt-options {
|
128 |
-
|
129 |
-
-webkit-column-count: 3;
|
130 |
-
column-count: 3;
|
131 |
}
|
132 |
|
133 |
.free .wpt-options {
|
134 |
-
|
135 |
-
-webkit-column-count: 2;
|
136 |
-
column-count: 2;
|
137 |
}
|
138 |
|
139 |
#side-sortables .wpt-options {
|
140 |
-
|
141 |
-
-webkit-column-count: 1;
|
142 |
-
column-count: 1;
|
143 |
}
|
144 |
|
145 |
.wpt-debug-details {
|
@@ -200,6 +191,18 @@
|
|
200 |
font-size: 1em;
|
201 |
}
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
button.time div {
|
204 |
vertical-align: text-bottom;
|
205 |
}
|
@@ -210,7 +213,6 @@ button.time div {
|
|
210 |
|
211 |
.wpt-options .tabs {
|
212 |
margin: 0;
|
213 |
-
padding: 0 2px;
|
214 |
position: relative;
|
215 |
top: 3px;
|
216 |
}
|
@@ -237,27 +239,47 @@ button.time div {
|
|
237 |
font-weight: 700;
|
238 |
}
|
239 |
|
240 |
-
.wpt_log, #
|
241 |
-
|
242 |
}
|
243 |
|
244 |
-
#
|
245 |
-
|
246 |
-
|
247 |
}
|
248 |
|
249 |
.tweet-buttons {
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
|
|
|
|
253 |
}
|
254 |
|
255 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
margin: 0;
|
|
|
|
|
257 |
}
|
258 |
|
259 |
.toggle-btn-group {
|
260 |
-
|
261 |
width: auto;
|
262 |
}
|
263 |
|
94 |
}
|
95 |
|
96 |
#wp2t .wpt_auth_users select {
|
97 |
+
width: calc( 100% - 24px );
|
98 |
+
max-height: 21em;
|
|
|
|
|
|
|
|
|
|
|
99 |
}
|
100 |
|
101 |
.panel-toggle a {
|
115 |
line-height: inherit;
|
116 |
}
|
117 |
|
118 |
+
.wp-to-twitter .dashicons-clock,
|
119 |
+
.wp-to-twitter .dashicons-upload {
|
120 |
font-size: 20px;
|
121 |
+
line-height: 1.4;
|
122 |
}
|
123 |
|
124 |
.wpt-options {
|
125 |
+
column-count: 3;
|
|
|
|
|
126 |
}
|
127 |
|
128 |
.free .wpt-options {
|
129 |
+
column-count: 2;
|
|
|
|
|
130 |
}
|
131 |
|
132 |
#side-sortables .wpt-options {
|
133 |
+
column-count: 1;
|
|
|
|
|
134 |
}
|
135 |
|
136 |
.wpt-debug-details {
|
191 |
font-size: 1em;
|
192 |
}
|
193 |
|
194 |
+
.wpt-player-card-settings {
|
195 |
+
padding: .5em;
|
196 |
+
margin: -.5em -.5em 0;
|
197 |
+
background: rgba( 0,0,0,.05 );
|
198 |
+
}
|
199 |
+
.wpt-player-card-settings input {
|
200 |
+
width: 100%;
|
201 |
+
}
|
202 |
+
.wpt-player-card-settings select {
|
203 |
+
width: calc(100% - 34px);
|
204 |
+
}
|
205 |
+
|
206 |
button.time div {
|
207 |
vertical-align: text-bottom;
|
208 |
}
|
213 |
|
214 |
.wpt-options .tabs {
|
215 |
margin: 0;
|
|
|
216 |
position: relative;
|
217 |
top: 3px;
|
218 |
}
|
239 |
font-weight: 700;
|
240 |
}
|
241 |
|
242 |
+
.wpt_log, #wpt_set_tweet_time {
|
243 |
+
padding: .5em;
|
244 |
}
|
245 |
|
246 |
+
#wpt_set_tweet_time {
|
247 |
+
background: #f6f6f6;
|
248 |
+
color: #333;
|
249 |
}
|
250 |
|
251 |
.tweet-buttons {
|
252 |
+
display: grid;
|
253 |
+
grid-template-columns: 48% 34% 18%;
|
254 |
+
column-gap: 2px;
|
255 |
+
padding: .75em 12px;
|
256 |
+
margin: -6px -14px 0;
|
257 |
+
background: #f3f3f3;
|
258 |
}
|
259 |
|
260 |
+
.wpt-wrap {
|
261 |
+
display: grid;
|
262 |
+
grid-template-columns: 1fr 44px;
|
263 |
+
}
|
264 |
+
|
265 |
+
.wpt-wrap input {
|
266 |
+
border-bottom-right-radius: 0;
|
267 |
+
border-top-right-radius: 0;
|
268 |
+
}
|
269 |
+
|
270 |
+
.wpt-wrap button {
|
271 |
+
border-bottom-left-radius: 0;
|
272 |
+
border-top-left-radius: 0;
|
273 |
+
}
|
274 |
+
|
275 |
+
.wp-to-twitter .wpt-template {
|
276 |
margin: 0;
|
277 |
+
padding: .5em;
|
278 |
+
background: rgba( 0, 0, 0, .05 );
|
279 |
}
|
280 |
|
281 |
.toggle-btn-group {
|
282 |
+
margin: .5em auto .5em !important;
|
283 |
width: auto;
|
284 |
}
|
285 |
|
css/styles.css
CHANGED
@@ -30,13 +30,14 @@
|
|
30 |
border: 1px solid #000;
|
31 |
}
|
32 |
|
33 |
-
.wpt-
|
34 |
list-style: disc;
|
35 |
margin-left: 2em;
|
|
|
36 |
}
|
37 |
|
38 |
#wp-to-twitter .inside em {
|
39 |
-
color: #
|
40 |
}
|
41 |
|
42 |
#wp-to-twitter .button-side {
|
@@ -46,10 +47,7 @@
|
|
46 |
}
|
47 |
|
48 |
#wp-to-twitter .tokens label {
|
49 |
-
width: 13em;
|
50 |
display: block;
|
51 |
-
float: left;
|
52 |
-
margin-top: 5px;
|
53 |
}
|
54 |
|
55 |
#wp-to-twitter .wpt-terms p {
|
@@ -105,25 +103,22 @@
|
|
105 |
display: block;
|
106 |
}
|
107 |
|
108 |
-
#wpt_license_key {
|
109 |
-
font-size: 1.3em;
|
110 |
-
padding: 5px;
|
111 |
-
letter-spacing: .5px;
|
112 |
-
}
|
113 |
-
|
114 |
#wp-to-twitter input {
|
115 |
max-width: 100%;
|
116 |
}
|
117 |
|
|
|
|
|
|
|
|
|
118 |
label[for="wpt_license_key"] {
|
119 |
font-size: 1.3em;
|
120 |
}
|
121 |
|
122 |
#wp-to-twitter .wpt-upgrade {
|
123 |
-
background: #
|
124 |
color: #fff;
|
125 |
-
text-shadow:
|
126 |
-
border-radius: 2px 2px 0 0;
|
127 |
}
|
128 |
|
129 |
.wp-tweets-pro .widefat input[type=text] {
|
@@ -182,12 +177,6 @@ label[for="wpt_license_key"] {
|
|
182 |
color: #213e7f;
|
183 |
}
|
184 |
|
185 |
-
#wpt_settings_page input[type=text] {
|
186 |
-
font-size: 1.3em;
|
187 |
-
padding: 4px;
|
188 |
-
margin: 0 0 4px;
|
189 |
-
}
|
190 |
-
|
191 |
.wpt-permissions .wptab {
|
192 |
padding: 10px;
|
193 |
min-height: 160px !important;
|
@@ -199,13 +188,14 @@ label[for="wpt_license_key"] {
|
|
199 |
}
|
200 |
|
201 |
.inside.purchase {
|
202 |
-
width:
|
|
|
203 |
margin: 0 auto;
|
204 |
-
min-width: 300px;
|
205 |
}
|
206 |
|
207 |
-
.inside.purchase
|
208 |
font-size: 1.8em;
|
|
|
209 |
}
|
210 |
|
211 |
.wpt-terms li {
|
@@ -263,7 +253,7 @@ label[for='wpt_prepend_rt'], label[for='wpt_prepend_rt2'], label[for='wpt_prepen
|
|
263 |
.wpt-button .cta a {
|
264 |
padding: 1em;
|
265 |
font-size: 1.2em;
|
266 |
-
background: #
|
267 |
color: #fff;
|
268 |
text-decoration: none;
|
269 |
display: inline-block;
|
@@ -278,13 +268,6 @@ label[for='wpt_prepend_rt'], label[for='wpt_prepend_rt2'], label[for='wpt_prepen
|
|
278 |
background: #233c7f;
|
279 |
}
|
280 |
|
281 |
-
.tweet_length_control {
|
282 |
-
background: #ffd;
|
283 |
-
color: #000;
|
284 |
-
border: 2px solid #dd1;
|
285 |
-
padding: .5em;
|
286 |
-
}
|
287 |
-
|
288 |
.jcd-narrow .free .postbox, .jcd-narrow .free .postbox a, .jcd-narrow .free .postbox h3 {
|
289 |
background: #233c7f;
|
290 |
color: #fff;
|
30 |
border: 1px solid #000;
|
31 |
}
|
32 |
|
33 |
+
.wpt-oauth-settings ul {
|
34 |
list-style: disc;
|
35 |
margin-left: 2em;
|
36 |
+
margin-top: .5em;
|
37 |
}
|
38 |
|
39 |
#wp-to-twitter .inside em {
|
40 |
+
color: #d33;
|
41 |
}
|
42 |
|
43 |
#wp-to-twitter .button-side {
|
47 |
}
|
48 |
|
49 |
#wp-to-twitter .tokens label {
|
|
|
50 |
display: block;
|
|
|
|
|
51 |
}
|
52 |
|
53 |
#wp-to-twitter .wpt-terms p {
|
103 |
display: block;
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
#wp-to-twitter input {
|
107 |
max-width: 100%;
|
108 |
}
|
109 |
|
110 |
+
#wp2t #wpt_custom_tweet {
|
111 |
+
width: 100%;
|
112 |
+
}
|
113 |
+
|
114 |
label[for="wpt_license_key"] {
|
115 |
font-size: 1.3em;
|
116 |
}
|
117 |
|
118 |
#wp-to-twitter .wpt-upgrade {
|
119 |
+
background: #c24822;
|
120 |
color: #fff;
|
121 |
+
text-shadow: 1px 1px 0 #000;
|
|
|
122 |
}
|
123 |
|
124 |
.wp-tweets-pro .widefat input[type=text] {
|
177 |
color: #213e7f;
|
178 |
}
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
.wpt-permissions .wptab {
|
181 |
padding: 10px;
|
182 |
min-height: 160px !important;
|
188 |
}
|
189 |
|
190 |
.inside.purchase {
|
191 |
+
max-width: 45em;
|
192 |
+
font-size: 1.1em;
|
193 |
margin: 0 auto;
|
|
|
194 |
}
|
195 |
|
196 |
+
.inside.purchase h3 {
|
197 |
font-size: 1.8em;
|
198 |
+
margin: 1.33em 0 0;
|
199 |
}
|
200 |
|
201 |
.wpt-terms li {
|
253 |
.wpt-button .cta a {
|
254 |
padding: 1em;
|
255 |
font-size: 1.2em;
|
256 |
+
background: #c24822;
|
257 |
color: #fff;
|
258 |
text-decoration: none;
|
259 |
display: inline-block;
|
268 |
background: #233c7f;
|
269 |
}
|
270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
.jcd-narrow .free .postbox, .jcd-narrow .free .postbox a, .jcd-narrow .free .postbox h3 {
|
272 |
background: #233c7f;
|
273 |
color: #fff;
|
js/ajax.js
CHANGED
@@ -1,44 +1,44 @@
|
|
1 |
(function ($) {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
visible = $( '.wpt_log' ).is( ':visible' );
|
18 |
if ( visible ) {
|
19 |
$( '.wpt_log' ).hide( 200 );
|
20 |
}
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
var auth = $('#wpt_authorized_users').val();
|
26 |
|
27 |
var upload = $('input:radio[name=_wpt_image]:checked').val();
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
'tweet_auth': auth,
|
36 |
'tweet_upload': upload,
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
}(jQuery));
|
1 |
(function ($) {
|
2 |
+
$(function () {
|
3 |
+
$('.wpt_log, #wpt_set_tweet_time').hide();
|
4 |
+
$('button.time').on("click", function (e) {
|
5 |
+
e.preventDefault();
|
6 |
+
if ($('#wpt_set_tweet_time').is(":visible")) {
|
7 |
+
$('#wpt_set_tweet_time').hide(250);
|
8 |
+
$('button.schedule').attr('disabled', 'disabled');
|
9 |
+
} else {
|
10 |
+
$('#wpt_set_tweet_time').show(250);
|
11 |
+
$('#wpt_date').focus();
|
12 |
+
$('button.schedule').removeAttr('disabled');
|
13 |
+
}
|
14 |
+
}
|
15 |
+
);
|
16 |
+
$('button.tweet').on('click', function (e) {
|
17 |
visible = $( '.wpt_log' ).is( ':visible' );
|
18 |
if ( visible ) {
|
19 |
$( '.wpt_log' ).hide( 200 );
|
20 |
}
|
21 |
+
e.preventDefault();
|
22 |
+
var text = $('#wpt_custom_tweet').val();
|
23 |
+
var date = $('#wpt_set_tweet_time .date').val();
|
24 |
+
var time = $('#wpt_set_tweet_time .time').val();
|
25 |
var auth = $('#wpt_authorized_users').val();
|
26 |
|
27 |
var upload = $('input:radio[name=_wpt_image]:checked').val();
|
28 |
+
var tweet_action = ( $(this).attr('data-action') === 'tweet' ) ? 'tweet' : 'schedule'
|
29 |
+
var data = {
|
30 |
+
'action': wpt_data.action,
|
31 |
+
'tweet_post_id': wpt_data.post_ID,
|
32 |
+
'tweet_text': text,
|
33 |
+
'tweet_schedule': date + ' ' + time,
|
34 |
+
'tweet_action': tweet_action,
|
35 |
'tweet_auth': auth,
|
36 |
'tweet_upload': upload,
|
37 |
+
'security': wpt_data.security
|
38 |
+
};
|
39 |
+
$.post(ajaxurl, data, function (response) {
|
40 |
+
$('.wpt_log').text(response).show(500);
|
41 |
+
});
|
42 |
+
});
|
43 |
+
});
|
44 |
}(jQuery));
|
js/base.js
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
jQuery(document).ready(function ($) {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
if ( $( '.wp-to-twitter .expandable' ).is( ':visible' ) ) {
|
21 |
$( '.wp-to-twitter .tweet-toggle span ').addClass( 'dashicons-plus' );
|
22 |
$( '.wp-to-twitter .tweet-toggle span' ).removeClass( 'dashicons-minus' );
|
23 |
} else {
|
24 |
$( '.wp-to-twitter .tweet-toggle span ').removeClass( 'dashicons-plus' );
|
25 |
-
$( '.wp-to-twitter .tweet-toggle span' ).addClass( 'dashicons-minus' );
|
26 |
-
}
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
if ( $( '.wp-to-twitter .history' ).is( ':visible' ) ) {
|
34 |
$( '.wp-to-twitter .history-toggle span ').addClass( 'dashicons-plus' );
|
35 |
$( '.wp-to-twitter .history-toggle span' ).removeClass( 'dashicons-minus' );
|
36 |
} else {
|
37 |
$( '.wp-to-twitter .history-toggle span ').removeClass( 'dashicons-plus' );
|
38 |
-
$( '.wp-to-twitter .history-toggle span' ).addClass( 'dashicons-minus' );
|
39 |
}
|
40 |
-
|
41 |
-
|
42 |
});
|
1 |
jQuery(document).ready(function ($) {
|
2 |
+
$('#wpt_custom_tweet, #wpt_retweet_0, #wpt_retweet_1, #wpt_retweet_3').charCount({
|
3 |
+
allowed: wptSettings.allowed,
|
4 |
+
counterText: wptSettings.text
|
5 |
+
});
|
6 |
+
$('#side-sortables .tabs a[href="' + wptSettings.first + '"]').addClass('active');
|
7 |
+
$('#side-sortables .wptab').not(wptSettings.first).hide();
|
8 |
+
$('#side-sortables .tabs a').on('click', function (e) {
|
9 |
+
e.preventDefault();
|
10 |
+
$('#side-sortables .tabs a').removeClass('active');
|
11 |
+
$(this).addClass('active');
|
12 |
+
var target = $(this).attr('href');
|
13 |
+
$('#side-sortables .wptab').not(target).hide();
|
14 |
+
$(target).show();
|
15 |
+
});
|
16 |
+
// add custom retweets
|
17 |
+
$('.wp-to-twitter .expandable').hide();
|
18 |
+
$('.wp-to-twitter .tweet-toggle').on('click', function (e) {
|
19 |
+
e.preventDefault();
|
20 |
if ( $( '.wp-to-twitter .expandable' ).is( ':visible' ) ) {
|
21 |
$( '.wp-to-twitter .tweet-toggle span ').addClass( 'dashicons-plus' );
|
22 |
$( '.wp-to-twitter .tweet-toggle span' ).removeClass( 'dashicons-minus' );
|
23 |
} else {
|
24 |
$( '.wp-to-twitter .tweet-toggle span ').removeClass( 'dashicons-plus' );
|
25 |
+
$( '.wp-to-twitter .tweet-toggle span' ).addClass( 'dashicons-minus' );
|
26 |
+
}
|
27 |
+
$('.wp-to-twitter .expandable').toggle('slow');
|
28 |
+
});
|
29 |
+
// tweet history log
|
30 |
+
$('.wp-to-twitter .history').hide();
|
31 |
+
$('.wp-to-twitter .history-toggle').on('click', function (e) {
|
32 |
+
e.preventDefault();
|
33 |
if ( $( '.wp-to-twitter .history' ).is( ':visible' ) ) {
|
34 |
$( '.wp-to-twitter .history-toggle span ').addClass( 'dashicons-plus' );
|
35 |
$( '.wp-to-twitter .history-toggle span' ).removeClass( 'dashicons-minus' );
|
36 |
} else {
|
37 |
$( '.wp-to-twitter .history-toggle span ').removeClass( 'dashicons-plus' );
|
38 |
+
$( '.wp-to-twitter .history-toggle span' ).addClass( 'dashicons-minus' );
|
39 |
}
|
40 |
+
$('.wp-to-twitter .history').toggle('slow');
|
41 |
+
});
|
42 |
});
|
readme.txt
CHANGED
@@ -3,11 +3,11 @@ Contributors: joedolson
|
|
3 |
Donate link: http://www.joedolson.com/donate/
|
4 |
Tags: twitter, microblogging, bitly, yourls, redirect, shortener, post, links, social, sharing, media, tweet
|
5 |
Requires at least: 4.4
|
6 |
-
Tested up to: 5.
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
Text Domain: wp-to-twitter
|
10 |
-
Stable tag: 3.
|
11 |
|
12 |
Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
|
13 |
|
@@ -44,10 +44,11 @@ Upgrade to [WP Tweets Pro](http://www.joedolson.com/wp-tweets-pro/) for extra fe
|
|
44 |
* Simultaneously Tweet to site and author Twitter accounts
|
45 |
* Preview and Tweet comments
|
46 |
* Filter Tweets by taxonomy (categories, tags, or custom taxonomies)
|
47 |
-
* Upload images to Twitter
|
48 |
* Integrated Twitter Card support
|
|
|
49 |
* Automatically schedule Tweets of old posts
|
50 |
-
* [
|
51 |
|
52 |
Want to stay up to date on WP to Twitter? [Follow me on Twitter!](https://twitter.com/joedolson)
|
53 |
|
@@ -63,6 +64,18 @@ Check out my <a href="https://github.com/joedolson/plugin-extensions/tree/master
|
|
63 |
|
64 |
== Changelog ==
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
= 3.4.10 =
|
67 |
|
68 |
* Feature: ability to add mentions in tags to be parsed with @ instead of #.
|
3 |
Donate link: http://www.joedolson.com/donate/
|
4 |
Tags: twitter, microblogging, bitly, yourls, redirect, shortener, post, links, social, sharing, media, tweet
|
5 |
Requires at least: 4.4
|
6 |
+
Tested up to: 5.6
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
Text Domain: wp-to-twitter
|
10 |
+
Stable tag: 3.5.0
|
11 |
|
12 |
Posts a Twitter update when you update your WordPress blog or add a link, with your chosen URL shortening service.
|
13 |
|
44 |
* Simultaneously Tweet to site and author Twitter accounts
|
45 |
* Preview and Tweet comments
|
46 |
* Filter Tweets by taxonomy (categories, tags, or custom taxonomies)
|
47 |
+
* Upload images to Twitter with alt attributes
|
48 |
* Integrated Twitter Card support
|
49 |
+
* Support for Player Cards with integrated captions
|
50 |
* Automatically schedule Tweets of old posts
|
51 |
+
* [Get a license for WP Tweets PRO!](http://www.joedolson.com/wp-tweets-pro/)
|
52 |
|
53 |
Want to stay up to date on WP to Twitter? [Follow me on Twitter!](https://twitter.com/joedolson)
|
54 |
|
64 |
|
65 |
== Changelog ==
|
66 |
|
67 |
+
= 3.5.0 =
|
68 |
+
|
69 |
+
* Update connection instructions to match Project & App structure at Twitter.
|
70 |
+
* Update metabox design and layout.
|
71 |
+
* Toggle default length based on current locale.
|
72 |
+
* Remove stored URLs; no longer important to avoid repeat shortener queries.
|
73 |
+
* Mask app tokens after saving.
|
74 |
+
* Automatically switch to staging mode if environment query returns staging.
|
75 |
+
* Bug fix: remove whitespace in some settings inputs
|
76 |
+
* New: use wp_after_insert_post action (new in WP 5.6) so terms & metadata are saved at the time posts are published when using the block editor.
|
77 |
+
* Numerous updates for WP Tweets Pro users.
|
78 |
+
|
79 |
= 3.4.10 =
|
80 |
|
81 |
* Feature: ability to add mentions in tags to be parsed with @ instead of #.
|
wp-to-twitter-manager.php
CHANGED
@@ -64,6 +64,12 @@ function wpt_updated_settings() {
|
|
64 |
<p>' . __( 'OAuth Authentication Failed. Your server time is not in sync with the Twitter servers. Talk to your hosting service to see what can be done.', 'wp-to-twitter' ) . '</p>
|
65 |
</div>
|
66 |
' );
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
} else {
|
68 |
print( '
|
69 |
<div id="message" class="error fade">
|
@@ -235,10 +241,8 @@ function wpt_update_settings() {
|
|
235 |
?>
|
236 |
<div class="ui-sortable meta-box-sortables">
|
237 |
<div class="postbox">
|
238 |
-
<h3 class='wpt-upgrade'><span><strong><?php _e( 'Upgrade Now!', 'wp-to-twitter' ); ?></strong></span></h3>
|
239 |
-
|
240 |
<div class="inside purchase">
|
241 |
-
<
|
242 |
<p>
|
243 |
<?php _e( 'WP Tweets PRO takes the great Tweeting abilities from WP to Twitter and puts them in high gear.', 'wp-to-twitter' ); ?>
|
244 |
</p>
|
@@ -246,12 +250,13 @@ function wpt_update_settings() {
|
|
246 |
<li><?php _e( 'Publish to unique Twitter accounts for each site author.', 'wp-to-twitter' ); ?></li>
|
247 |
<li><?php _e( 'Schedule up to 3 re-posts of Tweets at an interval of your choice.', 'wp-to-twitter' ); ?></li>
|
248 |
<li><?php _e( 'With a delay between publishing and Tweeting, verify your tweets before you share online.', 'wp-to-twitter' ); ?></li>
|
249 |
-
<li><?php _e( 'Automatically your
|
250 |
-
<li><?php _e( 'Upload
|
|
|
251 |
<li>
|
252 |
<?php
|
253 |
// Translators: Link to sales page.
|
254 |
-
printf( __( 'Take a look at the <a href="%s">
|
255 |
?>
|
256 |
</li>
|
257 |
</ul>
|
@@ -262,7 +267,7 @@ function wpt_update_settings() {
|
|
262 |
<strong class='cta'><a href="http://www.wptweetspro.com/wp-tweets-pro"><?php _e( 'Upgrade to <strong>WP Tweets PRO</strong>!', 'wp-to-twitter' ); ?></a></strong>
|
263 |
</p>
|
264 |
|
265 |
-
<
|
266 |
|
267 |
<p>
|
268 |
<?php _e( 'WP Tweets PRO is packed with features to help you increase engagement with your Twitter followers. Upload images, use 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' ); ?>
|
@@ -283,6 +288,13 @@ function wpt_update_settings() {
|
|
283 |
<p class='wpt-button'>
|
284 |
<strong class='cta'><a href="http://www.wptweetspro.com/wp-tweets-pro"><?php _e( 'Buy WP Tweets PRO today!', 'wp-to-twitter' ); ?></a></strong>
|
285 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
</div>
|
287 |
</div>
|
288 |
</div>
|
@@ -458,7 +470,7 @@ function wpt_update_settings() {
|
|
458 |
<form method="post" action="">
|
459 |
<div class="ui-sortable meta-box-sortables">
|
460 |
<div class="postbox">
|
461 |
-
<h3><span><?php _e( '
|
462 |
<div class="inside">
|
463 |
<div>
|
464 |
<?php
|
@@ -511,17 +523,16 @@ function wpt_update_settings() {
|
|
511 |
<label for="jd_post_excerpt"><?php _e( 'Post excerpt (#post#) in characters:', 'wp-to-twitter' ); ?></label>
|
512 |
<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' ) ) ); ?>"/>
|
513 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
<p>
|
515 |
<label for="jd_date_format"><?php _e( 'Date Format (#date#):', 'wp-to-twitter' ); ?></label>
|
516 |
-
<input type="text" aria-describedby="date_format_label" name="jd_date_format" id="jd_date_format" size="12" maxlength="12" value="
|
517 |
-
<?php
|
518 |
-
if ( '' === get_option( 'jd_date_format', '' ) ) {
|
519 |
-
echo( esc_attr( stripslashes( get_option( 'date_format' ) ) ) );
|
520 |
-
} else {
|
521 |
-
echo( esc_attr( get_option( 'jd_date_format' ) ) );
|
522 |
-
}
|
523 |
-
?>
|
524 |
-
"/>
|
525 |
<?php
|
526 |
if ( '' !== get_option( 'jd_date_format', '' ) ) {
|
527 |
echo date_i18n( get_option( 'jd_date_format' ) );
|
@@ -529,7 +540,7 @@ function wpt_update_settings() {
|
|
529 |
echo '<em>' . date_i18n( get_option( 'date_format' ) ) . '</em>';
|
530 |
}
|
531 |
?>
|
532 |
-
(<em id="date_format_label"><a href='
|
533 |
</p>
|
534 |
|
535 |
<p>
|
@@ -554,24 +565,32 @@ function wpt_update_settings() {
|
|
554 |
<div class="inside">
|
555 |
<fieldset>
|
556 |
<legend id="special_cases" class='screen-reader-text'><?php _e( 'Special Cases', 'wp-to-twitter' ); ?></legend>
|
557 |
-
<
|
558 |
-
<
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
<
|
563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
564 |
<input type="checkbox" name="wpt_rate_limiting" id="wpt_rate_limiting" value="1" <?php echo wpt_checkbox( 'wpt_rate_limiting' ); ?> />
|
565 |
-
<label for="wpt_rate_limiting"><?php _e( 'Enable Rate Limiting', 'wp-to-twitter' ); ?></label
|
566 |
<?php
|
567 |
if ( '1' === get_option( 'wpt_rate_limiting' ) ) {
|
568 |
?>
|
569 |
<input type="number" name="wpt_default_rate_limit" min="1" id="wpt_default_rate_limit" value="<?php echo wpt_default_rate_limit(); ?>" />
|
570 |
-
<label for="wpt_default_rate_limit"><?php _e( 'Default Rate Limit per category per hour', 'wp-to-twitter' ); ?></label
|
571 |
<?php
|
572 |
}
|
573 |
?>
|
574 |
-
|
|
|
575 |
</fieldset>
|
576 |
</div>
|
577 |
</div>
|
@@ -613,7 +632,7 @@ function wpt_update_settings() {
|
|
613 |
|
614 |
<p>
|
615 |
<input type="checkbox" name="jd_individual_twitter_users" id="jd_individual_twitter_users" value="1" <?php echo wpt_checkbox( 'jd_individual_twitter_users' ); ?> />
|
616 |
-
<label for="jd_individual_twitter_users"><?php _e( '
|
617 |
</p>
|
618 |
|
619 |
<div class='wpt-permissions'>
|
@@ -824,7 +843,7 @@ function wpt_sidebar() {
|
|
824 |
}
|
825 |
echo $support;
|
826 |
?>
|
827 |
-
<a href="
|
828 |
</div>
|
829 |
</div>
|
830 |
</div>
|
@@ -849,7 +868,7 @@ function wpt_sidebar() {
|
|
849 |
|
850 |
<div class="inside test">
|
851 |
<p>
|
852 |
-
<?php _e( 'Check whether WP to Twitter is
|
853 |
</p>
|
854 |
<form method="post" action="">
|
855 |
<input type="hidden" name="submit-type" value="check-support"/>
|
@@ -959,12 +978,23 @@ add_filter( 'wpt_tweet_length', 'wpt_tweet_length' );
|
|
959 |
* @return string HTML control.
|
960 |
*/
|
961 |
function wpt_tweet_length() {
|
962 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
963 |
$control = "<p class='tweet_length_control'>
|
964 |
-
<label for='wpt_tweet_length'>" . __( 'Tweet Length
|
965 |
<input type='number' min='0' max='280' step='1' value='$tweet_length' id='wpt_tweet_length' name='wpt_tweet_length' />
|
966 |
-
|
967 |
-
</p>';
|
968 |
|
969 |
return $control;
|
970 |
}
|
64 |
<p>' . __( 'OAuth Authentication Failed. Your server time is not in sync with the Twitter servers. Talk to your hosting service to see what can be done.', 'wp-to-twitter' ) . '</p>
|
65 |
</div>
|
66 |
' );
|
67 |
+
} elseif ( 'noconnection' === $oauth_message ) {
|
68 |
+
print( '
|
69 |
+
<div id="message" class="error fade">
|
70 |
+
<p>' . __( 'OAuth Authentication Failed. WP to Twitter was unable to complete a connection with those credentials.', 'wp-to-twitter' ) . '</p>
|
71 |
+
</div>
|
72 |
+
' );
|
73 |
} else {
|
74 |
print( '
|
75 |
<div id="message" class="error fade">
|
241 |
?>
|
242 |
<div class="ui-sortable meta-box-sortables">
|
243 |
<div class="postbox">
|
|
|
|
|
244 |
<div class="inside purchase">
|
245 |
+
<h3><strong><?php _e( 'What can WP Tweets PRO do for you?', 'wp-to-twitter' ); ?></strong></h3>
|
246 |
<p>
|
247 |
<?php _e( 'WP Tweets PRO takes the great Tweeting abilities from WP to Twitter and puts them in high gear.', 'wp-to-twitter' ); ?>
|
248 |
</p>
|
250 |
<li><?php _e( 'Publish to unique Twitter accounts for each site author.', 'wp-to-twitter' ); ?></li>
|
251 |
<li><?php _e( 'Schedule up to 3 re-posts of Tweets at an interval of your choice.', 'wp-to-twitter' ); ?></li>
|
252 |
<li><?php _e( 'With a delay between publishing and Tweeting, verify your tweets before you share online.', 'wp-to-twitter' ); ?></li>
|
253 |
+
<li><?php _e( 'Automatically Tweet your best old posts every few hours, days, or weeks!', 'wp-to-twitter' ); ?></li>
|
254 |
+
<li><?php _e( 'Upload images to Twitter with each Tweet', 'wp-to-twitter' ); ?></li>
|
255 |
+
<li><?php _e( 'Harness the power of video with support for Twitter\'s Player cards', 'wp-to-twitter' ); ?></li>
|
256 |
<li>
|
257 |
<?php
|
258 |
// Translators: Link to sales page.
|
259 |
+
printf( __( 'Take a look at the <a href="%1$s">feature list</a> or <a href="%2$s">read the user guide</a> to get the whole picture!', 'wp-to-twitter' ), 'http://www.wptweetspro.com/wp-tweets-pro/', 'https://www.joedolson.com/wp-content/uploads/wp-tweets-pro-users-guide-current.pdf' );
|
260 |
?>
|
261 |
</li>
|
262 |
</ul>
|
267 |
<strong class='cta'><a href="http://www.wptweetspro.com/wp-tweets-pro"><?php _e( 'Upgrade to <strong>WP Tweets PRO</strong>!', 'wp-to-twitter' ); ?></a></strong>
|
268 |
</p>
|
269 |
|
270 |
+
<h3><?php _e( 'What else does WP Tweets PRO do?', 'wp-to-twitter' ); ?></h3>
|
271 |
|
272 |
<p>
|
273 |
<?php _e( 'WP Tweets PRO is packed with features to help you increase engagement with your Twitter followers. Upload images, use 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' ); ?>
|
288 |
<p class='wpt-button'>
|
289 |
<strong class='cta'><a href="http://www.wptweetspro.com/wp-tweets-pro"><?php _e( 'Buy WP Tweets PRO today!', 'wp-to-twitter' ); ?></a></strong>
|
290 |
</p>
|
291 |
+
<h3><?php _e( 'Support WP to Twitter', 'wp-to-twitter' ); ?></h3>
|
292 |
+
<p>
|
293 |
+
<?php _e( 'The core WP to Twitter plug-in is free, and has been since 2008. WP Tweets Pro sales help keep this going, but they don\'t cover everything.', 'wp-to-twitter' ); ?>
|
294 |
+
</p>
|
295 |
+
<p>
|
296 |
+
<?php _e( 'I know that not everybody has a use for the features supported by WP Tweets Pro. If you\'re happy with what you\'ve found in WP to Twitter, you can still support me - either by <a href="%1$s">making a donation</a> or by <a href="%2$s">writing a review</a>. If you have the time or money, I\'ll sincerely appreciate anything you can do!', 'wp-to-twitter' ); ?>
|
297 |
+
</p>
|
298 |
</div>
|
299 |
</div>
|
300 |
</div>
|
470 |
<form method="post" action="">
|
471 |
<div class="ui-sortable meta-box-sortables">
|
472 |
<div class="postbox">
|
473 |
+
<h3><span><?php _e( 'Tag Settings', 'wp-to-twitter' ); ?></span></h3>
|
474 |
<div class="inside">
|
475 |
<div>
|
476 |
<?php
|
523 |
<label for="jd_post_excerpt"><?php _e( 'Post excerpt (#post#) in characters:', 'wp-to-twitter' ); ?></label>
|
524 |
<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' ) ) ); ?>"/>
|
525 |
</p>
|
526 |
+
<?php
|
527 |
+
if ( '' === get_option( 'jd_date_format', '' ) ) {
|
528 |
+
$format = ( esc_attr( stripslashes( get_option( 'date_format' ) ) ) );
|
529 |
+
} else {
|
530 |
+
$format = ( esc_attr( get_option( 'jd_date_format' ) ) );
|
531 |
+
}
|
532 |
+
?>
|
533 |
<p>
|
534 |
<label for="jd_date_format"><?php _e( 'Date Format (#date#):', 'wp-to-twitter' ); ?></label>
|
535 |
+
<input type="text" aria-describedby="date_format_label" name="jd_date_format" id="jd_date_format" size="12" maxlength="12" value="<?php echo trim( $format ); ?>" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
536 |
<?php
|
537 |
if ( '' !== get_option( 'jd_date_format', '' ) ) {
|
538 |
echo date_i18n( get_option( 'jd_date_format' ) );
|
540 |
echo '<em>' . date_i18n( get_option( 'date_format' ) ) . '</em>';
|
541 |
}
|
542 |
?>
|
543 |
+
(<em id="date_format_label"><a href='https://wordpress.org/support/article/formatting-date-and-time/'><?php _e( 'Date Formatting', 'wp-to-twitter' ); ?></a></em>)
|
544 |
</p>
|
545 |
|
546 |
<p>
|
565 |
<div class="inside">
|
566 |
<fieldset>
|
567 |
<legend id="special_cases" class='screen-reader-text'><?php _e( 'Special Cases', 'wp-to-twitter' ); ?></legend>
|
568 |
+
<ul>
|
569 |
+
<li>
|
570 |
+
<input type="checkbox" name="jd_tweet_default" id="jd_tweet_default" value="1" <?php echo wpt_checkbox( 'jd_tweet_default' ); ?> />
|
571 |
+
<label for="jd_tweet_default"><?php _e( 'Do not post Tweets by default', 'wp-to-twitter' ); ?></label>
|
572 |
+
</li>
|
573 |
+
<li>
|
574 |
+
<input type="checkbox" name="jd_tweet_default_edit" id="jd_tweet_default_edit" value="1" <?php echo wpt_checkbox( 'jd_tweet_default_edit' ); ?> />
|
575 |
+
<label for="jd_tweet_default_edit"><?php _e( 'Do not post Tweets by default (editing only)', 'wp-to-twitter' ); ?></label>
|
576 |
+
</li>
|
577 |
+
<li>
|
578 |
+
<input type="checkbox" name="wpt_inline_edits" id="wpt_inline_edits" value="1" <?php echo wpt_checkbox( 'wpt_inline_edits' ); ?> />
|
579 |
+
<label for="wpt_inline_edits"><?php _e( 'Allow status updates from Quick Edit', 'wp-to-twitter' ); ?></label>
|
580 |
+
</li>
|
581 |
+
<li>
|
582 |
<input type="checkbox" name="wpt_rate_limiting" id="wpt_rate_limiting" value="1" <?php echo wpt_checkbox( 'wpt_rate_limiting' ); ?> />
|
583 |
+
<label for="wpt_rate_limiting"><?php _e( 'Enable Rate Limiting', 'wp-to-twitter' ); ?></label>
|
584 |
<?php
|
585 |
if ( '1' === get_option( 'wpt_rate_limiting' ) ) {
|
586 |
?>
|
587 |
<input type="number" name="wpt_default_rate_limit" min="1" id="wpt_default_rate_limit" value="<?php echo wpt_default_rate_limit(); ?>" />
|
588 |
+
<label for="wpt_default_rate_limit"><?php _e( 'Default Rate Limit per category per hour', 'wp-to-twitter' ); ?></label>
|
589 |
<?php
|
590 |
}
|
591 |
?>
|
592 |
+
</li>
|
593 |
+
</ul>
|
594 |
</fieldset>
|
595 |
</div>
|
596 |
</div>
|
632 |
|
633 |
<p>
|
634 |
<input type="checkbox" name="jd_individual_twitter_users" id="jd_individual_twitter_users" value="1" <?php echo wpt_checkbox( 'jd_individual_twitter_users' ); ?> />
|
635 |
+
<label for="jd_individual_twitter_users"><?php _e( 'Enable User Account Settings', 'wp-to-twitter' ); ?></label>
|
636 |
</p>
|
637 |
|
638 |
<div class='wpt-permissions'>
|
843 |
}
|
844 |
echo $support;
|
845 |
?>
|
846 |
+
<a href="<?php echo plugins_url( 'wp-tweets-pro-2.0.0.pdf', __FILE__ ); ?>"><?php _e( 'Read the Manual', 'wp-to-twitter' ); ?></a>
|
847 |
</div>
|
848 |
</div>
|
849 |
</div>
|
868 |
|
869 |
<div class="inside test">
|
870 |
<p>
|
871 |
+
<?php _e( 'Check whether WP to Twitter is set up for Twitter and your URL Shortener. The test sends a status update to Twitter and shortens a URL.', 'wp-to-twitter' ); ?>
|
872 |
</p>
|
873 |
<form method="post" action="">
|
874 |
<input type="hidden" name="submit-type" value="check-support"/>
|
978 |
* @return string HTML control.
|
979 |
*/
|
980 |
function wpt_tweet_length() {
|
981 |
+
$language = get_locale();
|
982 |
+
switch ( $language ) {
|
983 |
+
case 'zh_CN':
|
984 |
+
case 'zh_HK':
|
985 |
+
case 'zh_HK':
|
986 |
+
case 'ja':
|
987 |
+
case 'ko_KR':
|
988 |
+
$default = 140;
|
989 |
+
break;
|
990 |
+
default:
|
991 |
+
$default = 280;
|
992 |
+
}
|
993 |
+
$tweet_length = intval( ( get_option( 'wpt_tweet_length' ) ) ? get_option( 'wpt_tweet_length' ) : $default );
|
994 |
$control = "<p class='tweet_length_control'>
|
995 |
+
<label for='wpt_tweet_length'>" . __( 'Maximum Tweet Length', 'wp-to-twitter' ) . "</label>
|
996 |
<input type='number' min='0' max='280' step='1' value='$tweet_length' id='wpt_tweet_length' name='wpt_tweet_length' />
|
997 |
+
</p>";
|
|
|
998 |
|
999 |
return $control;
|
1000 |
}
|
wp-to-twitter-oauth.php
CHANGED
@@ -121,15 +121,32 @@ function wpt_update_oauth_settings( $auth = false, $post = false ) {
|
|
121 |
$ot = trim( $post['wtt_oauth_token'] );
|
122 |
$ots = trim( $post['wtt_oauth_token_secret'] );
|
123 |
if ( ! $auth ) {
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
} else {
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
$message = 'failed';
|
135 |
$connection = wpt_oauth_connection( $auth );
|
@@ -181,6 +198,8 @@ function wpt_update_oauth_settings( $auth = false, $post = false ) {
|
|
181 |
print_r( $connection );
|
182 |
echo '</pre>';
|
183 |
}
|
|
|
|
|
184 |
}
|
185 |
} else {
|
186 |
$message = 'nodata';
|
@@ -240,7 +259,7 @@ function wtt_connect_oauth( $auth = false ) {
|
|
240 |
if ( ! wtt_oauth_test( $auth, 'verify' ) ) {
|
241 |
|
242 |
// show notification to authenticate with OAuth. No longer global; settings only.
|
243 |
-
if ( ! wpt_check_oauth() ) {
|
244 |
$admin_url = admin_url( 'admin.php?page=wp-tweets-pro' );
|
245 |
// Translators: Settings page to authenticate via OAuth.
|
246 |
$message = sprintf( __( "Twitter requires authentication by OAuth. You will need to <a href='%s'>update your settings</a> to complete installation of WP to Twitter.", 'wp-to-twitter' ), $admin_url );
|
@@ -256,59 +275,57 @@ function wtt_connect_oauth( $auth = false ) {
|
|
256 |
print( '
|
257 |
<h3><span>' . __( 'Connect to Twitter', 'wp-to-twitter' ) . '</span></h3>
|
258 |
<div class="inside ' . $class . '">
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
<li>' . __( 'Your app name cannot include the word "Twitter."', 'wp-to-twitter' ) . '</li>
|
267 |
-
<li>' . __( 'Your Application Description can be anything.', 'wp-to-twitter' ) . '</li>
|
268 |
-
<li>' . __( 'The WebSite and Callback URL should be: ', 'wp-to-twitter' ) . '<strong>' . esc_url( home_url() ) . '</strong></li>
|
269 |
-
<li>' . __( 'For this app, you do not need any other URL fields.', 'wp-to-twitter' ) . '</li>
|
270 |
-
<li>' . __( 'Describe how the app will be used. E.g. "This app will be used to send notifications about new WordPress posts or other types of WordPress content to Twitter on or after publication."' ) . '</li>
|
271 |
</ul>
|
272 |
-
|
273 |
-
<
|
274 |
<ul>
|
275 |
-
|
276 |
-
|
277 |
</ul>
|
278 |
-
|
|
|
279 |
<ul>
|
280 |
-
<li>' . __( '
|
281 |
-
<li>' . __( 'Copy your Access token and Access token secret from the "Your Access Token" section.', 'wp-to-twitter' ) . '</li>
|
282 |
</ul>
|
|
|
283 |
' . $form . '
|
284 |
-
<fieldset class="options">
|
285 |
<div class="tokens">
|
286 |
<p>
|
287 |
<label for="wtt_app_consumer_key">' . __( 'API Key', 'wp-to-twitter' ) . '</label>
|
288 |
-
<input type="text" size="45" name="wtt_app_consumer_key" id="wtt_app_consumer_key" value="' .
|
289 |
</p>
|
290 |
<p>
|
291 |
<label for="wtt_app_consumer_secret">' . __( 'API Secret', 'wp-to-twitter' ) . '</label>
|
292 |
-
<input type="text" size="45" name="wtt_app_consumer_secret" id="wtt_app_consumer_secret" value="' .
|
293 |
</p>
|
294 |
</div>
|
295 |
-
|
296 |
-
<
|
|
|
|
|
297 |
<div class="tokens">
|
298 |
<p>
|
299 |
<label for="wtt_oauth_token">' . __( 'Access Token', 'wp-to-twitter' ) . '</label>
|
300 |
-
<input type="text" size="45" name="wtt_oauth_token" id="wtt_oauth_token" value="' .
|
301 |
</p>
|
302 |
<p>
|
303 |
<label for="wtt_oauth_token_secret">' . __( 'Access Token Secret', 'wp-to-twitter' ) . '</label>
|
304 |
-
<input type="text" size="45" name="wtt_oauth_token_secret" id="wtt_oauth_token_secret" value="' .
|
305 |
</p>
|
306 |
</div>
|
307 |
-
</fieldset>
|
308 |
' . $submit . '
|
309 |
<input type="hidden" name="oauth_settings" value="wtt_oauth_test" class="hidden" style="display: none;" />
|
310 |
' . $nonce . '
|
311 |
</div>
|
|
|
|
|
312 |
' );
|
313 |
} elseif ( wtt_oauth_test( $auth ) ) {
|
314 |
$ack = ( ! $auth ) ? get_option( 'app_consumer_key' ) : get_user_meta( $auth, 'app_consumer_key', true );
|
@@ -332,10 +349,10 @@ function wtt_connect_oauth( $auth = false ) {
|
|
332 |
<fieldset class="options">
|
333 |
<ul>
|
334 |
<li><strong class="auth_label">' . __( 'Twitter Username ', 'wp-to-twitter' ) . '</strong> <code class="auth_code"><a href="http://twitter.com/' . esc_attr( $uname ) . '">' . esc_attr( $uname ) . '</a></code></li>
|
335 |
-
<li><strong class="auth_label">' . __( 'API Key ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' .
|
336 |
-
<li><strong class="auth_label">' . __( 'API Secret ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' .
|
337 |
-
<li><strong class="auth_label">' . __( 'Access Token ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' .
|
338 |
-
<li><strong class="auth_label">' . __( 'Access Token Secret ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' .
|
339 |
</ul>
|
340 |
</fieldset>
|
341 |
<div>
|
@@ -352,6 +369,21 @@ function wtt_connect_oauth( $auth = false ) {
|
|
352 |
}
|
353 |
}
|
354 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
/**
|
356 |
* Update stored set of authenticated users.
|
357 |
*/
|
121 |
$ot = trim( $post['wtt_oauth_token'] );
|
122 |
$ots = trim( $post['wtt_oauth_token_secret'] );
|
123 |
if ( ! $auth ) {
|
124 |
+
// If values are filled with asterisks, do not update; these are masked values.
|
125 |
+
if ( stripos( $ack, '***' ) === false ) {
|
126 |
+
update_option( 'app_consumer_key', $ack );
|
127 |
+
}
|
128 |
+
if ( stripos( $acs, '***' ) === false ) {
|
129 |
+
update_option( 'app_consumer_secret', $acs );
|
130 |
+
}
|
131 |
+
if ( stripos( $ot, '***' ) === false ) {
|
132 |
+
update_option( 'oauth_token', $ot );
|
133 |
+
}
|
134 |
+
if ( stripos( $ots, '***' ) === false ) {
|
135 |
+
update_option( 'oauth_token_secret', $ots );
|
136 |
+
}
|
137 |
} else {
|
138 |
+
if ( stripos( $ack, '***' ) === false ) {
|
139 |
+
update_user_meta( $auth, 'app_consumer_key', $ack );
|
140 |
+
}
|
141 |
+
if ( stripos( $acs, '***' ) === false ) {
|
142 |
+
update_user_meta( $auth, 'app_consumer_secret', $acs );
|
143 |
+
}
|
144 |
+
if ( stripos( $ot, '***' ) === false ) {
|
145 |
+
update_user_meta( $auth, 'oauth_token', $ot );
|
146 |
+
}
|
147 |
+
if ( stripos( $ots, '***' ) === false ) {
|
148 |
+
update_user_meta( $auth, 'oauth_token_secret', $ots );
|
149 |
+
}
|
150 |
}
|
151 |
$message = 'failed';
|
152 |
$connection = wpt_oauth_connection( $auth );
|
198 |
print_r( $connection );
|
199 |
echo '</pre>';
|
200 |
}
|
201 |
+
} else {
|
202 |
+
$message = 'noconnection';
|
203 |
}
|
204 |
} else {
|
205 |
$message = 'nodata';
|
259 |
if ( ! wtt_oauth_test( $auth, 'verify' ) ) {
|
260 |
|
261 |
// show notification to authenticate with OAuth. No longer global; settings only.
|
262 |
+
if ( ! wpt_check_oauth() && ! isset( $_GET['tab'] ) && 'connection' === $_GET['tab'] ) {
|
263 |
$admin_url = admin_url( 'admin.php?page=wp-tweets-pro' );
|
264 |
// Translators: Settings page to authenticate via OAuth.
|
265 |
$message = sprintf( __( "Twitter requires authentication by OAuth. You will need to <a href='%s'>update your settings</a> to complete installation of WP to Twitter.", 'wp-to-twitter' ), $admin_url );
|
275 |
print( '
|
276 |
<h3><span>' . __( 'Connect to Twitter', 'wp-to-twitter' ) . '</span></h3>
|
277 |
<div class="inside ' . $class . '">
|
278 |
+
<ol class="wpt-oauth-settings">
|
279 |
+
<li>' . __( 'Apply for a <a href="https://developer.twitter.com/en/apply-for-access">Developer Account with Twitter</a>', 'wp-to-twitter' ) . '</li>
|
280 |
+
<li>' . __( 'Add a new application in <a href="https://developer.twitter.com/en/portal/projects/new">Twitter\'s project and app portal</a>', 'wp-to-twitter' ) . '
|
281 |
+
<ul>
|
282 |
+
<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>
|
283 |
+
<li>' . __( 'Your app name cannot include the word "Twitter."', 'wp-to-twitter' ) . '</li>
|
284 |
+
<li>' . __( 'Your Application Description can be anything.', 'wp-to-twitter' ) . '</li>
|
|
|
|
|
|
|
|
|
|
|
285 |
</ul>
|
286 |
+
</li>
|
287 |
+
<li>' . __( 'Scroll to the "App Permissions" section', 'wp-to-twitter' ) . '
|
288 |
<ul>
|
289 |
+
<li>' . __( 'Edit, and select "Read and Write" for your app\'s Access Permissions', 'wp-to-twitter' ) . '</li>
|
290 |
+
<li>' . __( 'Save the application settings', 'wp-to-twitter' ) . '</li>
|
291 |
</ul>
|
292 |
+
</li>
|
293 |
+
<li>' . __( 'Switch to the Keys and Tokens tab at the top of the screen.', 'wp-to-twitter' ) . '
|
294 |
<ul>
|
295 |
+
<li>' . __( 'Regenerate your API key and secret from the "Consumer Keys" section.', 'wp-to-twitter' ) . '</li>
|
|
|
296 |
</ul>
|
297 |
+
|
298 |
' . $form . '
|
|
|
299 |
<div class="tokens">
|
300 |
<p>
|
301 |
<label for="wtt_app_consumer_key">' . __( 'API Key', 'wp-to-twitter' ) . '</label>
|
302 |
+
<input type="text" size="45" name="wtt_app_consumer_key" id="wtt_app_consumer_key" value="' . wpt_mask_attr( $ack ) . '" />
|
303 |
</p>
|
304 |
<p>
|
305 |
<label for="wtt_app_consumer_secret">' . __( 'API Secret', 'wp-to-twitter' ) . '</label>
|
306 |
+
<input type="text" size="45" name="wtt_app_consumer_secret" id="wtt_app_consumer_secret" value="' . wpt_mask_attr( $acs ) . '" />
|
307 |
</p>
|
308 |
</div>
|
309 |
+
</li>
|
310 |
+
<li>' . __( 'Regenerate your Access token and secret from the "Authentication Tokens" section.', 'wp-to-twitter' ) . '</li>
|
311 |
+
<li>' . __( 'Paste your Access Token and Secret into the fields below', 'wp-to-twitter' ) . '
|
312 |
+
<ul><li>' . __( 'If the Access Level for your Access Token is not "<em>Read and write</em>", return to step 3, change your permissions, and generate a new Access Token.', 'wp-to-twitter' ) . '</li></ul>
|
313 |
<div class="tokens">
|
314 |
<p>
|
315 |
<label for="wtt_oauth_token">' . __( 'Access Token', 'wp-to-twitter' ) . '</label>
|
316 |
+
<input type="text" size="45" name="wtt_oauth_token" id="wtt_oauth_token" value="' . wpt_mask_attr( $ot ) . '" />
|
317 |
</p>
|
318 |
<p>
|
319 |
<label for="wtt_oauth_token_secret">' . __( 'Access Token Secret', 'wp-to-twitter' ) . '</label>
|
320 |
+
<input type="text" size="45" name="wtt_oauth_token_secret" id="wtt_oauth_token_secret" value="' . wpt_mask_attr( $ots ) . '" />
|
321 |
</p>
|
322 |
</div>
|
|
|
323 |
' . $submit . '
|
324 |
<input type="hidden" name="oauth_settings" value="wtt_oauth_test" class="hidden" style="display: none;" />
|
325 |
' . $nonce . '
|
326 |
</div>
|
327 |
+
</li>
|
328 |
+
</ol>
|
329 |
' );
|
330 |
} elseif ( wtt_oauth_test( $auth ) ) {
|
331 |
$ack = ( ! $auth ) ? get_option( 'app_consumer_key' ) : get_user_meta( $auth, 'app_consumer_key', true );
|
349 |
<fieldset class="options">
|
350 |
<ul>
|
351 |
<li><strong class="auth_label">' . __( 'Twitter Username ', 'wp-to-twitter' ) . '</strong> <code class="auth_code"><a href="http://twitter.com/' . esc_attr( $uname ) . '">' . esc_attr( $uname ) . '</a></code></li>
|
352 |
+
<li><strong class="auth_label">' . __( 'API Key ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . wpt_mask_attr( $ack ) . '</code></li>
|
353 |
+
<li><strong class="auth_label">' . __( 'API Secret ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . wpt_mask_attr( $acs ) . '</code></li>
|
354 |
+
<li><strong class="auth_label">' . __( 'Access Token ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . wpt_mask_attr( $ot ) . '</code></li>
|
355 |
+
<li><strong class="auth_label">' . __( 'Access Token Secret ', 'wp-to-twitter' ) . '</strong> <code class="auth_code">' . wpt_mask_attr( $ots ) . '</code></li>
|
356 |
</ul>
|
357 |
</fieldset>
|
358 |
<div>
|
369 |
}
|
370 |
}
|
371 |
|
372 |
+
/**
|
373 |
+
* Mask secure values.
|
374 |
+
*
|
375 |
+
* @param string $value Original value.
|
376 |
+
*
|
377 |
+
* @return string
|
378 |
+
*/
|
379 |
+
function wpt_mask_attr( $value ) {
|
380 |
+
$count = strlen( $value );
|
381 |
+
$substr = substr( $value, -5 );
|
382 |
+
$return = str_pad( $substr, $count, '*', STR_PAD_LEFT );
|
383 |
+
|
384 |
+
return $return;
|
385 |
+
}
|
386 |
+
|
387 |
/**
|
388 |
* Update stored set of authenticated users.
|
389 |
*/
|
wp-to-twitter.php
CHANGED
@@ -17,7 +17,7 @@
|
|
17 |
* License: GPL-2.0+
|
18 |
* License URI: http://www.gnu.org/license/gpl-2.0.txt
|
19 |
* Domain Path: lang
|
20 |
-
* Version: 3.
|
21 |
*/
|
22 |
|
23 |
/*
|
@@ -46,6 +46,13 @@ define( 'WPT_DEBUG_BY_EMAIL', false ); // Email debugging no longer default as o
|
|
46 |
define( 'WPT_DEBUG_ADDRESS', get_option( 'admin_email' ) );
|
47 |
define( 'WPT_FROM', 'From: \"' . get_option( 'blogname' ) . '\" <' . get_option( 'admin_email' ) . '>' );
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
require_once( plugin_dir_path( __FILE__ ) . 'wpt-functions.php' );
|
50 |
require_once( plugin_dir_path( __FILE__ ) . 'wp-to-twitter-users.php' );
|
51 |
require_once( plugin_dir_path( __FILE__ ) . 'wp-to-twitter-oauth.php' );
|
@@ -57,7 +64,7 @@ require_once( plugin_dir_path( __FILE__ ) . 'wpt-widget.php' );
|
|
57 |
require_once( plugin_dir_path( __FILE__ ) . 'wpt-rate-limiting.php' );
|
58 |
|
59 |
global $wpt_version;
|
60 |
-
$wpt_version = '3.
|
61 |
|
62 |
add_action( 'init', 'wpt_load_textdomain' );
|
63 |
/**
|
@@ -378,6 +385,7 @@ function wpt_post_to_twitter( $twit, $auth = false, $id = false, $media = false
|
|
378 |
wpt_mail( 'Media Uploaded', "$auth, $media_id, $attachment", $id );
|
379 |
if ( $media_id ) {
|
380 |
$status['media_ids'] = $media_id;
|
|
|
381 |
}
|
382 |
}
|
383 |
}
|
@@ -408,7 +416,7 @@ function wpt_post_to_twitter( $twit, $auth = false, $id = false, $media = false
|
|
408 |
if ( $connection ) {
|
409 |
if ( isset( $connection->http_header['x-access-level'] ) && 'read' === $connection->http_header['x-access-level'] ) {
|
410 |
// Translators: Twitter App editing URL.
|
411 |
-
$supplement = sprintf( __( 'Your Twitter application does not have read and write permissions. Go to <a href="%s">your Twitter apps</a> to modify these settings.', 'wp-to-twitter' ), 'https://
|
412 |
} else {
|
413 |
$supplement = '';
|
414 |
}
|
@@ -712,12 +720,15 @@ function wpt_category_limit( $post_type, $post_info, $post_ID ) {
|
|
712 |
/**
|
713 |
* Set up a Tweet to be sent.
|
714 |
*
|
715 |
-
* @param int
|
716 |
-
* @param string
|
|
|
|
|
|
|
717 |
*
|
718 |
* @return int $post_ID
|
719 |
*/
|
720 |
-
function wpt_tweet( $post_ID, $type = 'instant' ) {
|
721 |
if ( wp_is_post_autosave( $post_ID ) || wp_is_post_revision( $post_ID ) ) {
|
722 |
return $post_ID;
|
723 |
}
|
@@ -846,7 +857,7 @@ function wpt_tweet( $post_ID, $type = 'instant' ) {
|
|
846 |
}
|
847 |
// filter selected users before using.
|
848 |
$wpt_selected_users = apply_filters( 'wpt_filter_users', $wpt_selected_users, $post_info );
|
849 |
-
if ( 0 === $post_info['wpt_delay_tweet'] || '' === $post_info['wpt_delay_tweet'] || 'on' === $post_info['wpt_no_delay'] ) {
|
850 |
foreach ( $wpt_selected_users as $acct ) {
|
851 |
if ( wtt_oauth_test( $acct, 'verify' ) ) {
|
852 |
wpt_post_to_twitter( $sentence2, $acct, $post_ID, $media );
|
@@ -871,7 +882,7 @@ function wpt_tweet( $post_ID, $type = 'instant' ) {
|
|
871 |
if ( WPT_DEBUG && function_exists( 'wpt_pro_exists' ) ) {
|
872 |
$author_id = ( $acct ) ? "#$acct" : 'Main';
|
873 |
wpt_mail(
|
874 |
-
"7a: Tweet Scheduled for author $author_id",
|
875 |
print_r(
|
876 |
array(
|
877 |
'id' => $acct,
|
@@ -1108,7 +1119,9 @@ function wpt_add_twitter_outer_box() {
|
|
1108 |
if ( is_array( $wpt_post_types ) ) {
|
1109 |
foreach ( $wpt_post_types as $key => $value ) {
|
1110 |
if ( '1' === (string) $value['post-published-update'] || '1' === (string) $value['post-edited-update'] ) {
|
1111 |
-
|
|
|
|
|
1112 |
}
|
1113 |
}
|
1114 |
}
|
@@ -1168,13 +1181,19 @@ function wpt_add_twitter_inner_box( $post ) {
|
|
1168 |
}
|
1169 |
$tweet = esc_attr( stripcslashes( get_post_meta( $post_id, '_jd_twitter', true ) ) );
|
1170 |
$tweet = apply_filters( 'wpt_user_text', $tweet, $status );
|
|
|
1171 |
$template = ( 'publish' === $status ) ? $options[ $type ]['post-edited-text'] : $options[ $type ]['post-published-text'];
|
1172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1173 |
if ( 'publish' === $status && '1' !== $options[ $type ]['post-edited-update'] ) {
|
1174 |
// Translators: post type.
|
1175 |
$tweet_status = sprintf( __( '%s will not be Tweeted on update.', 'wp-to-twitter' ), ucfirst( $type ) );
|
1176 |
}
|
1177 |
-
|
1178 |
if ( 'publish' === $status && ( current_user_can( 'wpt_tweet_now' ) || current_user_can( 'manage_options' ) ) ) {
|
1179 |
?>
|
1180 |
<div class='tweet-buttons'>
|
@@ -1186,7 +1205,7 @@ function wpt_add_twitter_inner_box( $post ) {
|
|
1186 |
<button type='button' class='time button-secondary'>
|
1187 |
<span class="dashicons dashicons-clock" aria-hidden="true"></span><span class="screen-reader-text"><?php _e( 'Set Date/Time', 'wp-to-twitter' ); ?></span>
|
1188 |
</button>
|
1189 |
-
<div id="
|
1190 |
<?php
|
1191 |
$datavalue = gmdate( 'Y-m-d', current_time( 'timestamp' ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
|
1192 |
$timevalue = date_i18n( 'h:s a', current_time( 'timestamp' ) + 3600 ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
|
@@ -1206,22 +1225,12 @@ function wpt_add_twitter_inner_box( $post ) {
|
|
1206 |
if ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'manage_options' ) ) {
|
1207 |
?>
|
1208 |
<p class='jtw'>
|
1209 |
-
<label for="
|
1210 |
-
<textarea class="wpt_tweet_box" name="_jd_twitter" id="
|
1211 |
<?php echo apply_filters( 'wpt_custom_box', '', $tweet, $post_id ); ?>
|
1212 |
</p>
|
1213 |
-
|
1214 |
-
|
1215 |
-
if ( '' !== get_option( 'jd_twit_prepend', '' ) ) {
|
1216 |
-
$expanded = "<span title='" . __( 'Your prepended Tweet text; not part of your template.', 'wp-to-twitter' ) . "'>" . stripslashes( get_option( 'jd_twit_prepend' ) ) . '</span> ' . $expanded;
|
1217 |
-
}
|
1218 |
-
if ( '' !== get_option( 'jd_twit_append', '' ) ) {
|
1219 |
-
$expanded = $expanded . " <span title='" . __( 'Your appended Tweet text; not part of your template.', 'wp-to-twitter' ) . "'>" . stripslashes( get_option( 'jd_twit_append' ) ) . '</span>';
|
1220 |
-
}
|
1221 |
-
?>
|
1222 |
-
<p class='template'>
|
1223 |
-
<?php _e( 'Template:', 'wp-to-twitter' ); ?><br />
|
1224 |
-
<code><?php echo stripcslashes( $expanded ); ?></code>
|
1225 |
<?php echo apply_filters( 'wpt_template_block', '', $expanded, $post_id ); ?>
|
1226 |
</p>
|
1227 |
<?php
|
@@ -1232,111 +1241,86 @@ function wpt_add_twitter_inner_box( $post ) {
|
|
1232 |
}
|
1233 |
} else {
|
1234 |
?>
|
1235 |
-
<input type="hidden" name='_jd_twitter' value='<?php echo esc_attr( $tweet ); ?>'/>
|
|
|
|
|
|
|
|
|
1236 |
<?php
|
1237 |
}
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
|
|
|
|
|
|
|
|
1244 |
} else {
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
?>
|
1249 |
-
<ul class='tabs' role="tablist">
|
1250 |
-
<?php if ( get_option( 'jd_individual_twitter_users' ) === '1' ) { ?>
|
1251 |
-
<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>
|
1252 |
-
<?php } ?>
|
1253 |
-
<li><a href='#custom' aria-controls="custom" role="tab" id="tab_custom"><?php _e( 'Options', 'wp-to-twitter' ); ?></a></li>
|
1254 |
-
<li><a href='#notes'<?php echo $free_active; ?> aria-controls="notes" role="tab" id="tab_notes"><?php _e( 'Notes', 'wp-to-twitter' ); ?></a></li>
|
1255 |
-
</ul>
|
1256 |
-
<?php
|
1257 |
-
// WPT PRO OPTIONS.
|
1258 |
-
if ( current_user_can( 'edit_others_posts' ) ) {
|
1259 |
-
if ( '1' === get_option( 'jd_individual_twitter_users' ) ) {
|
1260 |
-
echo "<div class='wptab' id='authors' aria-labelledby='tab_authors' role='tabpanel'>";
|
1261 |
-
$selected = ( get_post_meta( $post_id, '_wpt_authorized_users', true ) ) ? get_post_meta( $post_id, '_wpt_authorized_users', true ) : array();
|
1262 |
-
if ( function_exists( 'wpt_authorized_users' ) ) {
|
1263 |
-
echo wpt_authorized_users( $selected );
|
1264 |
-
do_action( 'wpt_authors_tab', $post_id, $selected );
|
1265 |
-
} else {
|
1266 |
-
echo '<p>';
|
1267 |
-
if ( function_exists( 'wpt_pro_exists' ) ) {
|
1268 |
-
// Translators: URL to account.
|
1269 |
-
printf( __( 'WP Tweets PRO allows you to select Twitter accounts. <a href="%s">Log in and download now!</a>', 'wp-to-twitter' ), 'http://www.wptweetspro.com/account/' );
|
1270 |
-
} else {
|
1271 |
-
// Translators: URL to buy WP Tweets Pro.
|
1272 |
-
printf( __( 'Upgrade to WP Tweets PRO to select Twitter accounts! <a href="%s">Upgrade now!</a>', 'wp-to-twitter' ), 'http://www.wptweetspro.com/wp-tweets-pro/' );
|
1273 |
-
}
|
1274 |
-
echo '</p>';
|
1275 |
-
}
|
1276 |
-
echo '</div>';
|
1277 |
-
}
|
1278 |
}
|
1279 |
?>
|
1280 |
-
<div class='
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
echo '<p>' . sprintf( __( 'Upgrade to WP Tweets PRO to configure options! <a href="%s">Upgrade now!</a>', 'wp-to-twitter' ), 'http://www.wptweetspro.com/wp-tweets-pro/' ) . '</p>';
|
1289 |
}
|
1290 |
-
}
|
1291 |
-
?>
|
1292 |
-
</div>
|
1293 |
-
<?php
|
1294 |
-
// WPT PRO.
|
1295 |
-
if ( ! current_user_can( 'wpt_twitter_custom' ) && ! current_user_can( 'manage_options' ) ) {
|
1296 |
?>
|
|
|
|
|
|
|
|
|
1297 |
<div class='wptab' id='custom' aria-labelledby='tab_custom' role='tabpanel'>
|
1298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1299 |
<?php
|
1300 |
if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() === true ) {
|
1301 |
wpt_schedule_values( $post_id, 'hidden' );
|
1302 |
do_action( 'wpt_custom_tab', $post_id, 'hidden' );
|
1303 |
}
|
1304 |
-
|
1305 |
-
</div>
|
1306 |
-
<?php
|
1307 |
-
}
|
1308 |
-
if ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'manage_options' ) ) {
|
1309 |
?>
|
|
|
1310 |
<div class='wptab' id='notes' aria-labelledby='tab_notes' role='tabpanel'>
|
1311 |
<p>
|
1312 |
<?php
|
1313 |
-
_e( 'Template Tags
|
1314 |
do_action( 'wpt_notes_tab', $post_id );
|
1315 |
?>
|
1316 |
</p>
|
1317 |
</div>
|
1318 |
-
<?php
|
1319 |
-
}
|
1320 |
-
?>
|
1321 |
</div>
|
1322 |
-
<?php
|
1323 |
-
if ( current_user_can( 'wpt_twitter_switch' ) || current_user_can( 'manage_options' ) ) {
|
1324 |
-
// "no" means 'Don't Tweet' (is checked)
|
1325 |
-
$nochecked = ( 'no' === $tweet_this ) ? ' checked="checked"' : '';
|
1326 |
-
$yeschecked = ( 'yes' === $tweet_this ) ? ' checked="checked"' : '';
|
1327 |
-
?>
|
1328 |
-
<p class='toggle-btn-group'>
|
1329 |
-
<input type="radio" name="_jd_tweet_this" value="no" id="jtn"<?php echo $nochecked; ?> /><label for="jtn"><?php _e( "Don't Tweet", 'wp-to-twitter' ); ?></label>
|
1330 |
-
<input type="radio" name="_jd_tweet_this" value="yes" id="jty"<?php echo $yeschecked; ?> /><label for="jty"><?php _e( 'Tweet', 'wp-to-twitter' ); ?></label>
|
1331 |
-
</p>
|
1332 |
-
<?php
|
1333 |
-
} else {
|
1334 |
-
?>
|
1335 |
-
<input type='hidden' name='_jd_tweet_this' value='<?php echo $tweet_this; ?>'/>
|
1336 |
-
<?php
|
1337 |
-
}
|
1338 |
-
wpt_show_tweets( $post_id );
|
1339 |
-
?>
|
1340 |
<p class="wpt-support">
|
1341 |
<?php
|
1342 |
if ( ! function_exists( 'wpt_pro_exists' ) ) {
|
@@ -1380,7 +1364,6 @@ function wpt_show_tweets( $post_id ) {
|
|
1380 |
}
|
1381 |
if ( ! empty( $previous_tweets ) || ! empty( $failed_tweets ) ) {
|
1382 |
?>
|
1383 |
-
<hr>
|
1384 |
<p class='panel-toggle'>
|
1385 |
<a href='#wpt_tweet_history' class='history-toggle'><span class='dashicons dashicons-plus' aria-hidden="true"></span><?php _e( 'View Tweet History', 'wp-to-twitter' ); ?></a>
|
1386 |
</p>
|
@@ -1551,9 +1534,7 @@ function wpt_admin_script() {
|
|
1551 |
} else {
|
1552 |
$allowed = $config['base_length'] + 1;
|
1553 |
}
|
1554 |
-
if ( function_exists( 'wpt_pro_exists' )
|
1555 |
-
$first = '#authors';
|
1556 |
-
} elseif ( function_exists( 'wpt_pro_exists' ) ) {
|
1557 |
$first = '#custom';
|
1558 |
} else {
|
1559 |
$first = '#notes';
|
@@ -1706,7 +1687,14 @@ if ( '1' === get_option( 'jd_twit_blogroll' ) ) {
|
|
1706 |
add_action( 'add_link', 'wpt_twit_link' );
|
1707 |
}
|
1708 |
|
1709 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1710 |
add_action( 'save_post', 'wpt_save_post', 10 );
|
1711 |
/**
|
1712 |
* Check whether a given post is in an allowed post type and has an update template configured.
|
@@ -1763,15 +1751,18 @@ function wpt_future_to_publish( $post ) {
|
|
1763 |
}
|
1764 |
|
1765 |
/**
|
1766 |
-
* Handle Tweeting posts published directly.
|
1767 |
*
|
1768 |
-
* @param
|
|
|
|
|
|
|
1769 |
*/
|
1770 |
-
function wpt_twit( $id ) {
|
1771 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || wp_is_post_revision( $id ) || ! wpt_in_post_type( $id ) ) {
|
1772 |
return;
|
1773 |
}
|
1774 |
-
$post = get_post( $id );
|
1775 |
if ( 'publish' !== $post->post_status ) {
|
1776 |
return;
|
1777 |
}
|
@@ -1779,7 +1770,7 @@ function wpt_twit( $id ) {
|
|
1779 |
// This is an issue only until the release of WP 4.7.
|
1780 |
remove_action( 'save_post', 'wpt_twit', 15 );
|
1781 |
wpt_mail( 'Tweeting published post', $id );
|
1782 |
-
wpt_twit_instant( $id );
|
1783 |
add_action( 'save_post', 'wpt_twit', 15 );
|
1784 |
}
|
1785 |
|
@@ -1793,7 +1784,8 @@ add_action( 'publish_phone', 'wpt_twit_xmlrpc' );
|
|
1793 |
*/
|
1794 |
function wpt_twit_future( $id ) {
|
1795 |
set_transient( '_wpt_twit_future', $id, 10 );
|
1796 |
-
// instant action has already run for this post.
|
|
|
1797 |
if ( get_transient( '_wpt_twit_instant' ) && (int) get_transient( '_wpt_twit_instant' ) === $id ) {
|
1798 |
delete_transient( '_wpt_twit_instant' );
|
1799 |
|
@@ -1806,9 +1798,12 @@ function wpt_twit_future( $id ) {
|
|
1806 |
/**
|
1807 |
* For immediate posts, check transients to see whether this post has already been published. Prevents duplicate Tweet attempts in older versions of WP or cases where a future action is being run after the initial action.
|
1808 |
*
|
1809 |
-
* @param
|
|
|
|
|
|
|
1810 |
*/
|
1811 |
-
function wpt_twit_instant( $id ) {
|
1812 |
set_transient( '_wpt_twit_instant', $id, 10 );
|
1813 |
// future action has already run for this post.
|
1814 |
if ( get_transient( '_wpt_twit_future' ) && (int) get_transient( '_wpt_twit_future' ) === $id ) {
|
@@ -1822,7 +1817,7 @@ function wpt_twit_instant( $id ) {
|
|
1822 |
|
1823 |
return;
|
1824 |
}
|
1825 |
-
wpt_tweet( $id, 'instant' );
|
1826 |
}
|
1827 |
|
1828 |
/**
|
17 |
* License: GPL-2.0+
|
18 |
* License URI: http://www.gnu.org/license/gpl-2.0.txt
|
19 |
* Domain Path: lang
|
20 |
+
* Version: 3.5.0
|
21 |
*/
|
22 |
|
23 |
/*
|
46 |
define( 'WPT_DEBUG_ADDRESS', get_option( 'admin_email' ) );
|
47 |
define( 'WPT_FROM', 'From: \"' . get_option( 'blogname' ) . '\" <' . get_option( 'admin_email' ) . '>' );
|
48 |
|
49 |
+
// If current environment tests as staging, enable staging mode.
|
50 |
+
if ( function_exists( 'wp_get_environment_type' ) ) {
|
51 |
+
if ( 'staging' === wp_get_environment_type() && ! defined( 'WPT_STAGING_MODE' ) ) {
|
52 |
+
define( 'WPT_STAGING_MODE', true );
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
require_once( plugin_dir_path( __FILE__ ) . 'wpt-functions.php' );
|
57 |
require_once( plugin_dir_path( __FILE__ ) . 'wp-to-twitter-users.php' );
|
58 |
require_once( plugin_dir_path( __FILE__ ) . 'wp-to-twitter-oauth.php' );
|
64 |
require_once( plugin_dir_path( __FILE__ ) . 'wpt-rate-limiting.php' );
|
65 |
|
66 |
global $wpt_version;
|
67 |
+
$wpt_version = '3.5.0';
|
68 |
|
69 |
add_action( 'init', 'wpt_load_textdomain' );
|
70 |
/**
|
385 |
wpt_mail( 'Media Uploaded', "$auth, $media_id, $attachment", $id );
|
386 |
if ( $media_id ) {
|
387 |
$status['media_ids'] = $media_id;
|
388 |
+
|
389 |
}
|
390 |
}
|
391 |
}
|
416 |
if ( $connection ) {
|
417 |
if ( isset( $connection->http_header['x-access-level'] ) && 'read' === $connection->http_header['x-access-level'] ) {
|
418 |
// Translators: Twitter App editing URL.
|
419 |
+
$supplement = sprintf( __( 'Your Twitter application does not have read and write permissions. Go to <a href="%s">your Twitter apps</a> to modify these settings.', 'wp-to-twitter' ), 'https://developer.twitter.com/en/portal/projects-and-apps' );
|
420 |
} else {
|
421 |
$supplement = '';
|
422 |
}
|
720 |
/**
|
721 |
* Set up a Tweet to be sent.
|
722 |
*
|
723 |
+
* @param int $post_ID Post ID.
|
724 |
+
* @param string $type Publishing context: instant, future, xmlrpc.
|
725 |
+
* @param object $post Post object.
|
726 |
+
* @param boolean $updated True if updated, false if inserted.
|
727 |
+
* @param object $post_before The post prior to this update, or null for new posts.
|
728 |
*
|
729 |
* @return int $post_ID
|
730 |
*/
|
731 |
+
function wpt_tweet( $post_ID, $type = 'instant', $post = null, $updated = null, $post_before = null ) {
|
732 |
if ( wp_is_post_autosave( $post_ID ) || wp_is_post_revision( $post_ID ) ) {
|
733 |
return $post_ID;
|
734 |
}
|
857 |
}
|
858 |
// filter selected users before using.
|
859 |
$wpt_selected_users = apply_filters( 'wpt_filter_users', $wpt_selected_users, $post_info );
|
860 |
+
if ( '0' === (string) $post_info['wpt_delay_tweet'] || '' === $post_info['wpt_delay_tweet'] || 'on' === $post_info['wpt_no_delay'] ) {
|
861 |
foreach ( $wpt_selected_users as $acct ) {
|
862 |
if ( wtt_oauth_test( $acct, 'verify' ) ) {
|
863 |
wpt_post_to_twitter( $sentence2, $acct, $post_ID, $media );
|
882 |
if ( WPT_DEBUG && function_exists( 'wpt_pro_exists' ) ) {
|
883 |
$author_id = ( $acct ) ? "#$acct" : 'Main';
|
884 |
wpt_mail(
|
885 |
+
"7a: Tweet Scheduled for author: $author_id",
|
886 |
print_r(
|
887 |
array(
|
888 |
'id' => $acct,
|
1119 |
if ( is_array( $wpt_post_types ) ) {
|
1120 |
foreach ( $wpt_post_types as $key => $value ) {
|
1121 |
if ( '1' === (string) $value['post-published-update'] || '1' === (string) $value['post-edited-update'] ) {
|
1122 |
+
if ( current_user_can( 'wpt_can_tweet' ) ) {
|
1123 |
+
add_meta_box( 'wp2t', 'WP to Twitter', 'wpt_add_twitter_inner_box', $key, 'side' );
|
1124 |
+
}
|
1125 |
}
|
1126 |
}
|
1127 |
}
|
1181 |
}
|
1182 |
$tweet = esc_attr( stripcslashes( get_post_meta( $post_id, '_jd_twitter', true ) ) );
|
1183 |
$tweet = apply_filters( 'wpt_user_text', $tweet, $status );
|
1184 |
+
// Formulate Template display.
|
1185 |
$template = ( 'publish' === $status ) ? $options[ $type ]['post-edited-text'] : $options[ $type ]['post-published-text'];
|
1186 |
+
$expanded = $template;
|
1187 |
+
if ( '' !== get_option( 'jd_twit_prepend', '' ) ) {
|
1188 |
+
$expanded = "<em>" . stripslashes( get_option( 'jd_twit_prepend' ) ) . '</em> ' . $expanded;
|
1189 |
+
}
|
1190 |
+
if ( '' !== get_option( 'jd_twit_append', '' ) ) {
|
1191 |
+
$expanded = $expanded . " <em>" . stripslashes( get_option( 'jd_twit_append' ) ) . '</em>';
|
1192 |
+
}
|
1193 |
if ( 'publish' === $status && '1' !== $options[ $type ]['post-edited-update'] ) {
|
1194 |
// Translators: post type.
|
1195 |
$tweet_status = sprintf( __( '%s will not be Tweeted on update.', 'wp-to-twitter' ), ucfirst( $type ) );
|
1196 |
}
|
|
|
1197 |
if ( 'publish' === $status && ( current_user_can( 'wpt_tweet_now' ) || current_user_can( 'manage_options' ) ) ) {
|
1198 |
?>
|
1199 |
<div class='tweet-buttons'>
|
1205 |
<button type='button' class='time button-secondary'>
|
1206 |
<span class="dashicons dashicons-clock" aria-hidden="true"></span><span class="screen-reader-text"><?php _e( 'Set Date/Time', 'wp-to-twitter' ); ?></span>
|
1207 |
</button>
|
1208 |
+
<div id="wpt_set_tweet_time">
|
1209 |
<?php
|
1210 |
$datavalue = gmdate( 'Y-m-d', current_time( 'timestamp' ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
|
1211 |
$timevalue = date_i18n( 'h:s a', current_time( 'timestamp' ) + 3600 ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
|
1225 |
if ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'manage_options' ) ) {
|
1226 |
?>
|
1227 |
<p class='jtw'>
|
1228 |
+
<label for="wpt_custom_tweet"><?php _e( 'Custom Twitter Post', 'wp-to-twitter' ); ?></label><br/>
|
1229 |
+
<textarea class="wpt_tweet_box" name="_jd_twitter" id="wpt_custom_tweet" rows="2" cols="60"><?php echo esc_attr( $tweet ); ?></textarea>
|
1230 |
<?php echo apply_filters( 'wpt_custom_box', '', $tweet, $post_id ); ?>
|
1231 |
</p>
|
1232 |
+
<p class='wpt-template'>
|
1233 |
+
<?php _e( 'Template:', 'wp-to-twitter' ); ?> <code><?php echo stripcslashes( $expanded ); ?></code>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1234 |
<?php echo apply_filters( 'wpt_template_block', '', $expanded, $post_id ); ?>
|
1235 |
</p>
|
1236 |
<?php
|
1241 |
}
|
1242 |
} else {
|
1243 |
?>
|
1244 |
+
<input type="hidden" name='_jd_twitter' value='<?php echo esc_attr( $tweet ); ?>' />
|
1245 |
+
<p class='wpt-template'>
|
1246 |
+
<?php _e( 'Template:', 'wp-to-twitter' ); ?> <code><?php echo stripcslashes( $expanded ); ?></code>
|
1247 |
+
<?php echo apply_filters( 'wpt_template_block', '', $expanded, $post_id ); ?>
|
1248 |
+
</p>
|
1249 |
<?php
|
1250 |
}
|
1251 |
+
if ( current_user_can( 'wpt_twitter_switch' ) || current_user_can( 'manage_options' ) ) {
|
1252 |
+
// "no" means 'Don't Tweet' (is checked)
|
1253 |
+
$nochecked = ( 'no' === $tweet_this ) ? ' checked="checked"' : '';
|
1254 |
+
$yeschecked = ( 'yes' === $tweet_this ) ? ' checked="checked"' : '';
|
1255 |
+
?>
|
1256 |
+
<p class='toggle-btn-group'>
|
1257 |
+
<input type="radio" name="_jd_tweet_this" value="no" id="jtn"<?php echo $nochecked; ?> /><label for="jtn"><?php _e( "Don't Tweet", 'wp-to-twitter' ); ?></label>
|
1258 |
+
<input type="radio" name="_jd_tweet_this" value="yes" id="jty"<?php echo $yeschecked; ?> /><label for="jty"><?php _e( 'Tweet', 'wp-to-twitter' ); ?></label>
|
1259 |
+
</p>
|
1260 |
+
<?php
|
1261 |
} else {
|
1262 |
+
?>
|
1263 |
+
<input type='hidden' name='_jd_tweet_this' value='<?php echo $tweet_this; ?>'/>
|
1264 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1265 |
}
|
1266 |
?>
|
1267 |
+
<div class='wpt-options'>
|
1268 |
+
<?php
|
1269 |
+
if ( 'pro' === $is_pro ) {
|
1270 |
+
$pro_active = " class='active'";
|
1271 |
+
$free_active = '';
|
1272 |
+
} else {
|
1273 |
+
$free_active = " class='active'";
|
1274 |
+
$pro_active = '';
|
|
|
1275 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
1276 |
?>
|
1277 |
+
<ul class='tabs' role="tablist">
|
1278 |
+
<li><a href='#custom' aria-controls="custom" role="tab" id="tab_custom"><?php _e( 'Options', 'wp-to-twitter' ); ?></a></li>
|
1279 |
+
<li><a href='#notes'<?php echo $free_active; ?> aria-controls="notes" role="tab" id="tab_notes"><?php _e( 'Help', 'wp-to-twitter' ); ?></a></li>
|
1280 |
+
</ul>
|
1281 |
<div class='wptab' id='custom' aria-labelledby='tab_custom' role='tabpanel'>
|
1282 |
+
<?php
|
1283 |
+
if ( function_exists( 'wpt_pro_exists' ) && true === wpt_pro_exists() && ( current_user_can( 'wpt_twitter_custom' ) || current_user_can( 'manage_options' ) ) ) {
|
1284 |
+
wpt_schedule_values( $post_id );
|
1285 |
+
do_action( 'wpt_custom_tab', $post_id, 'visible' );
|
1286 |
+
// WPT PRO OPTIONS.
|
1287 |
+
if ( current_user_can( 'edit_others_posts' ) ) {
|
1288 |
+
if ( '1' === get_option( 'jd_individual_twitter_users' ) ) {
|
1289 |
+
$selected = ( get_post_meta( $post_id, '_wpt_authorized_users', true ) ) ? get_post_meta( $post_id, '_wpt_authorized_users', true ) : array();
|
1290 |
+
if ( function_exists( 'wpt_authorized_users' ) ) {
|
1291 |
+
echo wpt_authorized_users( $selected );
|
1292 |
+
do_action( 'wpt_authors_tab', $post_id, $selected );
|
1293 |
+
}
|
1294 |
+
}
|
1295 |
+
}
|
1296 |
+
} else {
|
1297 |
+
if ( ! function_exists( 'wpt_pro_exists' ) ) {
|
1298 |
+
// Translators: premium sales link.
|
1299 |
+
echo '<p>' . sprintf( __( 'Upgrade to WP Tweets PRO to configure options and select multiple accounts! <a href="%s">Upgrade now!</a>', 'wp-to-twitter' ), 'http://www.wptweetspro.com/wp-tweets-pro/' ) . '</p>';
|
1300 |
+
}
|
1301 |
+
}
|
1302 |
+
// WPT PRO.
|
1303 |
+
if ( ! current_user_can( 'wpt_twitter_custom' ) && ! current_user_can( 'manage_options' ) ) {
|
1304 |
+
?>
|
1305 |
+
<p><?php _e( 'Customizing WP to Twitter options is not allowed for your user role.', 'wp-to-twitter' ); ?></p>
|
1306 |
<?php
|
1307 |
if ( function_exists( 'wpt_pro_exists' ) && wpt_pro_exists() === true ) {
|
1308 |
wpt_schedule_values( $post_id, 'hidden' );
|
1309 |
do_action( 'wpt_custom_tab', $post_id, 'hidden' );
|
1310 |
}
|
1311 |
+
}
|
|
|
|
|
|
|
|
|
1312 |
?>
|
1313 |
+
</div>
|
1314 |
<div class='wptab' id='notes' aria-labelledby='tab_notes' role='tabpanel'>
|
1315 |
<p>
|
1316 |
<?php
|
1317 |
+
_e( 'Template Tags:<br /><code>#url#</code>, <code>#title#</code>, <code>#post#</code>, <code>#category#</code>, <code>#categories#</code>, <code>#date#</code>, <code>#modified#</code>, <code>#author#</code>, <code>#account#</code>, <code>#tags#</code>, <code>#blog#</code>, <code>#longurl#</code>.', 'wp-to-twitter' );
|
1318 |
do_action( 'wpt_notes_tab', $post_id );
|
1319 |
?>
|
1320 |
</p>
|
1321 |
</div>
|
|
|
|
|
|
|
1322 |
</div>
|
1323 |
+
<?php wpt_show_tweets( $post_id ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1324 |
<p class="wpt-support">
|
1325 |
<?php
|
1326 |
if ( ! function_exists( 'wpt_pro_exists' ) ) {
|
1364 |
}
|
1365 |
if ( ! empty( $previous_tweets ) || ! empty( $failed_tweets ) ) {
|
1366 |
?>
|
|
|
1367 |
<p class='panel-toggle'>
|
1368 |
<a href='#wpt_tweet_history' class='history-toggle'><span class='dashicons dashicons-plus' aria-hidden="true"></span><?php _e( 'View Tweet History', 'wp-to-twitter' ); ?></a>
|
1369 |
</p>
|
1534 |
} else {
|
1535 |
$allowed = $config['base_length'] + 1;
|
1536 |
}
|
1537 |
+
if ( function_exists( 'wpt_pro_exists' ) ) {
|
|
|
|
|
1538 |
$first = '#custom';
|
1539 |
} else {
|
1540 |
$first = '#notes';
|
1687 |
add_action( 'add_link', 'wpt_twit_link' );
|
1688 |
}
|
1689 |
|
1690 |
+
if ( function_exists( 'wp_after_insert_post' ) ) {
|
1691 |
+
/**
|
1692 |
+
* @since WordPress 5.6
|
1693 |
+
*/
|
1694 |
+
add_action( 'wp_after_insert_post', 'wpt_twit', 10, 4 );
|
1695 |
+
} else {
|
1696 |
+
add_action( 'save_post', 'wpt_twit', 15 );
|
1697 |
+
}
|
1698 |
add_action( 'save_post', 'wpt_save_post', 10 );
|
1699 |
/**
|
1700 |
* Check whether a given post is in an allowed post type and has an update template configured.
|
1751 |
}
|
1752 |
|
1753 |
/**
|
1754 |
+
* Handle Tweeting posts published directly. As of 12/10/2020, supports new wp_after_insert_post to improve support when used with block editor.
|
1755 |
*
|
1756 |
+
* @param int $id Post ID.
|
1757 |
+
* @param object $post Post object.
|
1758 |
+
* @param boolean $updated True if updated, false if inserted.
|
1759 |
+
* @param object $post_before The post prior to this update, or null for new posts.
|
1760 |
*/
|
1761 |
+
function wpt_twit( $id, $post = null, $updated = null, $post_before = null ) {
|
1762 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE || wp_is_post_revision( $id ) || ! wpt_in_post_type( $id ) ) {
|
1763 |
return;
|
1764 |
}
|
1765 |
+
$post = ( null === $post ) ? get_post( $id ) : $post;
|
1766 |
if ( 'publish' !== $post->post_status ) {
|
1767 |
return;
|
1768 |
}
|
1770 |
// This is an issue only until the release of WP 4.7.
|
1771 |
remove_action( 'save_post', 'wpt_twit', 15 );
|
1772 |
wpt_mail( 'Tweeting published post', $id );
|
1773 |
+
wpt_twit_instant( $id, $post, $updated, $post_before );
|
1774 |
add_action( 'save_post', 'wpt_twit', 15 );
|
1775 |
}
|
1776 |
|
1784 |
*/
|
1785 |
function wpt_twit_future( $id ) {
|
1786 |
set_transient( '_wpt_twit_future', $id, 10 );
|
1787 |
+
// instant action has already run for this post.
|
1788 |
+
// prevent running actions twice (need both for older WP).
|
1789 |
if ( get_transient( '_wpt_twit_instant' ) && (int) get_transient( '_wpt_twit_instant' ) === $id ) {
|
1790 |
delete_transient( '_wpt_twit_instant' );
|
1791 |
|
1798 |
/**
|
1799 |
* For immediate posts, check transients to see whether this post has already been published. Prevents duplicate Tweet attempts in older versions of WP or cases where a future action is being run after the initial action.
|
1800 |
*
|
1801 |
+
* @param int $id Post ID.
|
1802 |
+
* @param object $post Post object.
|
1803 |
+
* @param boolean $updated True if updated, false if inserted.
|
1804 |
+
* @param object $post_before The post prior to this update, or null for new posts.
|
1805 |
*/
|
1806 |
+
function wpt_twit_instant( $id, $post, $updated, $post_before ) {
|
1807 |
set_transient( '_wpt_twit_instant', $id, 10 );
|
1808 |
// future action has already run for this post.
|
1809 |
if ( get_transient( '_wpt_twit_future' ) && (int) get_transient( '_wpt_twit_future' ) === $id ) {
|
1817 |
|
1818 |
return;
|
1819 |
}
|
1820 |
+
wpt_tweet( $id, 'instant', $post, $updated, $post_before );
|
1821 |
}
|
1822 |
|
1823 |
/**
|
wp-tweets-pro-2.0.0.pdf
ADDED
Binary file
|
wpt-truncate.php
CHANGED
@@ -361,25 +361,20 @@ function wpt_create_values( $post, $post_ID, $ref ) {
|
|
361 |
$category = trim( $post['category'] );
|
362 |
$categories = trim( $post['cats'] );
|
363 |
$cat_desc = trim( $post['cat_desc'] );
|
364 |
-
$user_account = get_user_meta( $auth, 'wtt_twitter_username', true );
|
365 |
$tags = wpt_generate_hash_tags( $post_ID );
|
366 |
$date = trim( $post['postDate'] );
|
367 |
$modified = trim( $post['postModified'] );
|
368 |
-
|
369 |
-
$
|
|
|
|
|
370 |
if ( '1' === get_option( 'jd_individual_twitter_users' ) ) {
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
} elseif ( 'mainAtTwitterPlus' === get_user_meta( $auth, 'wp-to-twitter-enable-user', true ) ) {
|
378 |
-
$user_account = stripcslashes( $user_meta . ' @' . get_option( 'wtt_twitter_username' ) );
|
379 |
-
$account = $user_account;
|
380 |
-
}
|
381 |
-
} elseif ( '' !== $user_account ) {
|
382 |
-
$account = $user_account;
|
383 |
}
|
384 |
}
|
385 |
$account = ( '' !== $account ) ? "@$account" : ''; // value of #account#.
|
361 |
$category = trim( $post['category'] );
|
362 |
$categories = trim( $post['cats'] );
|
363 |
$cat_desc = trim( $post['cat_desc'] );
|
|
|
364 |
$tags = wpt_generate_hash_tags( $post_ID );
|
365 |
$date = trim( $post['postDate'] );
|
366 |
$modified = trim( $post['postModified'] );
|
367 |
+
$account = get_option( 'wtt_twitter_username', '' );
|
368 |
+
$user_meta = get_user_meta( $auth, 'wp-to-twitter-user-username', true );
|
369 |
+
$user_account = get_user_meta( $auth, 'wtt_twitter_username', true );
|
370 |
+
$user_account = ( $user_account ) ? $user_account: $user_meta;
|
371 |
if ( '1' === get_option( 'jd_individual_twitter_users' ) ) {
|
372 |
+
if ( 'mainAtTwitter' === get_user_meta( $auth, 'wp-to-twitter-enable-user', true ) ) {
|
373 |
+
$account = $user_account;
|
374 |
+
} elseif ( 'mainAtTwitterPlus' === get_user_meta( $auth, 'wp-to-twitter-enable-user', true ) ) {
|
375 |
+
$account = stripcslashes( $user_account . ' @' . get_option( 'wtt_twitter_username' ) );
|
376 |
+
} else {
|
377 |
+
$account = ( $user_account ) ? $user_account : $account;
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
}
|
379 |
}
|
380 |
$account = ( '' !== $account ) ? "@$account" : ''; // value of #account#.
|
wpt-widget.php
CHANGED
@@ -141,7 +141,7 @@ function wpt_get_user( $twitter_id = false ) {
|
|
141 |
$token_secret = get_option( 'oauth_token_secret' );
|
142 |
if ( $key && $secret && $token && $token_secret ) {
|
143 |
$connection = new Wpt_TwitterOAuth( $key, $secret, $token, $token_secret );
|
144 |
-
$result = $connection->get( "https://api.twitter.com/1.1/users/show.json?screen_name=$twitter_id
|
145 |
|
146 |
return json_decode( $result );
|
147 |
} else {
|
@@ -225,7 +225,7 @@ function wpt_twitter_feed( $instance ) {
|
|
225 |
<p>
|
226 |
<img src='$avatar' alt='' class='wpt-twitter-avatar $img_alignment $verified' />
|
227 |
<span class='wpt-twitter-name'>$name</span><br />
|
228 |
-
<span class='wpt-twitter-id'><a href='$follow_url'>@" . esc_html( $twitter_id ) . '</a></span>
|
229 |
</p>';
|
230 |
$header .= '</div>';
|
231 |
} else {
|
141 |
$token_secret = get_option( 'oauth_token_secret' );
|
142 |
if ( $key && $secret && $token && $token_secret ) {
|
143 |
$connection = new Wpt_TwitterOAuth( $key, $secret, $token, $token_secret );
|
144 |
+
$result = $connection->get( "https://api.twitter.com/1.1/users/show.json?screen_name=$twitter_id", $options );
|
145 |
|
146 |
return json_decode( $result );
|
147 |
} else {
|
225 |
<p>
|
226 |
<img src='$avatar' alt='' class='wpt-twitter-avatar $img_alignment $verified' />
|
227 |
<span class='wpt-twitter-name'>$name</span><br />
|
228 |
+
<span class='wpt-twitter-id'><a href='$follow_url'>@" . esc_html( str_replace( '@', '', $twitter_id ) ) . '</a></span>
|
229 |
</p>';
|
230 |
$header .= '</div>';
|
231 |
} else {
|