Version Description
Download this release
Release Info
Developer | codeinwp |
Plugin | Revive Old Posts – Auto Post to Social Media |
Version | 3.3.1 |
Comparing to | |
See all releases |
Version 3.3.1
- Include/top-debug.php +60 -0
- Include/top-oauth.php +389 -0
- css/tweet-old-post.css +76 -0
- images/twitter.png +0 -0
- log.txt +10 -0
- readme.txt +621 -0
- top-admin.php +842 -0
- top-core.php +543 -0
- top-excludepost.php +343 -0
- tweet-old-post.php +84 -0
- xml.php +130 -0
Include/top-debug.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function top_DEBUG( $str ) {
|
4 |
+
global $top_debug;
|
5 |
+
$top_enable_log = get_option('top_enable_log');
|
6 |
+
if($top_enable_log)
|
7 |
+
{
|
8 |
+
$top_debug->enable(true);
|
9 |
+
}
|
10 |
+
|
11 |
+
$top_debug->add_to_log( $str );
|
12 |
+
}
|
13 |
+
|
14 |
+
function top_is_debug_enabled() {
|
15 |
+
global $top_debug;
|
16 |
+
|
17 |
+
return $top_debug->is_enabled();
|
18 |
+
}
|
19 |
+
|
20 |
+
class topDebug {
|
21 |
+
var $debug_file;
|
22 |
+
var $log_messages;
|
23 |
+
|
24 |
+
function topDebug() {
|
25 |
+
$this->debug_file = false;
|
26 |
+
}
|
27 |
+
|
28 |
+
function is_enabled() {
|
29 |
+
return ( $this->debug_file );
|
30 |
+
}
|
31 |
+
|
32 |
+
function enable( $enable_or_disable ) {
|
33 |
+
if ( $enable_or_disable ) {
|
34 |
+
$this->debug_file = fopen( WP_CONTENT_DIR . '/plugins/tweet-old-post/log.txt', 'a+t' );
|
35 |
+
$this->log_messages = 0;
|
36 |
+
} else if ( $this->debug_file ) {
|
37 |
+
fclose( $this->debug_file );
|
38 |
+
$this->debug_file = false;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
function add_to_log( $str ) {
|
43 |
+
if ( $this->debug_file ) {
|
44 |
+
|
45 |
+
$log_string = $str;
|
46 |
+
|
47 |
+
// Write the data to the log file
|
48 |
+
fwrite( $this->debug_file, sprintf( "%12s %s\n", time(), $log_string ) );
|
49 |
+
fflush( $this->debug_file );
|
50 |
+
|
51 |
+
$this->log_messages++;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
global $top_debug;
|
57 |
+
$top_debug = &new topDebug;
|
58 |
+
|
59 |
+
|
60 |
+
?>
|
Include/top-oauth.php
ADDED
@@ -0,0 +1,389 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
+
|
3 |
+
if (!class_exists('WP_Http')) {
|
4 |
+
include_once( ABSPATH . WPINC . '/class-http.php' );
|
5 |
+
}
|
6 |
+
|
7 |
+
require_once( 'top-debug.php' );
|
8 |
+
|
9 |
+
define('TOP_OAUTH_CONSUMER_KEY', 'ofaYongByVpa3NDEbXa2g');
|
10 |
+
|
11 |
+
define('TOP_OAUTH_REQUEST_URL', 'http://api.twitter.com/oauth/request_token');
|
12 |
+
define('TOP_OAUTH_ACCESS_URL', 'http://api.twitter.com/oauth/access_token');
|
13 |
+
define('TOP_OAUTH_AUTHORIZE_URL', 'http://api.twitter.com/oauth/authorize');
|
14 |
+
define('TOP_OAUTH_REALM', 'http://twitter.com/');
|
15 |
+
|
16 |
+
class TOPOAuth {
|
17 |
+
|
18 |
+
var $duplicate_tweet;
|
19 |
+
var $can_use_curl;
|
20 |
+
var $response_code;
|
21 |
+
var $oauth_time_offset;
|
22 |
+
var $error_message;
|
23 |
+
var $oauth_consumer_key;
|
24 |
+
var $oauth_consumer_secret;
|
25 |
+
|
26 |
+
function TOPOAuth() {
|
27 |
+
$this->duplicate_tweet = false;
|
28 |
+
$this->can_use_curl = true;
|
29 |
+
$this->response_code = false;
|
30 |
+
$this->error_message = false;
|
31 |
+
$this->oauth_time_offset = 0;
|
32 |
+
$this->set_defeault_oauth_tokens();
|
33 |
+
}
|
34 |
+
|
35 |
+
function set_defeault_oauth_tokens() {
|
36 |
+
$this->oauth_consumer_key = TOP_OAUTH_CONSUMER_KEY;
|
37 |
+
$this->oauth_consumer_secret = "vTzszlMujMZCY3mVtTE6WovUKQxqv3LVgiVku276M";
|
38 |
+
}
|
39 |
+
|
40 |
+
function set_oauth_tokens($key, $secret) {
|
41 |
+
$this->oauth_consumer_key = $key;
|
42 |
+
$this->oauth_consumer_secret = $secret;
|
43 |
+
}
|
44 |
+
|
45 |
+
function get_response_code() {
|
46 |
+
return $this->response_code;
|
47 |
+
}
|
48 |
+
|
49 |
+
function get_error_message() {
|
50 |
+
return $this->error_message;
|
51 |
+
}
|
52 |
+
|
53 |
+
function enable_curl($value) {
|
54 |
+
$this->can_use_curl = $value;
|
55 |
+
}
|
56 |
+
|
57 |
+
function encode($string) {
|
58 |
+
return str_replace('+', ' ', str_replace('%7E', '~', rawurlencode($string)));
|
59 |
+
}
|
60 |
+
|
61 |
+
function create_signature_base_string($get_method, $base_url, $params) {
|
62 |
+
if ($get_method) {
|
63 |
+
$base_string = "GET&";
|
64 |
+
} else {
|
65 |
+
$base_string = "POST&";
|
66 |
+
}
|
67 |
+
|
68 |
+
$base_string .= $this->encode($base_url) . "&";
|
69 |
+
|
70 |
+
// Sort the parameters
|
71 |
+
ksort($params);
|
72 |
+
|
73 |
+
$encoded_params = array();
|
74 |
+
foreach ($params as $key => $value) {
|
75 |
+
$encoded_params[] = $this->encode($key) . '=' . $this->encode($value);
|
76 |
+
}
|
77 |
+
|
78 |
+
$base_string = $base_string . $this->encode(implode($encoded_params, "&"));
|
79 |
+
|
80 |
+
TOP_DEBUG('Signature base string is: ' . $base_string);
|
81 |
+
return $base_string;
|
82 |
+
}
|
83 |
+
|
84 |
+
function params_to_query_string($params) {
|
85 |
+
$query_string = array();
|
86 |
+
foreach ($params as $key => $value) {
|
87 |
+
$query_string[$key] = $key . '=' . $value;
|
88 |
+
}
|
89 |
+
|
90 |
+
ksort($query_string);
|
91 |
+
|
92 |
+
return implode('&', $query_string);
|
93 |
+
}
|
94 |
+
|
95 |
+
function do_get_request($url) {
|
96 |
+
$request = new WP_Http;
|
97 |
+
$result = $request->request($url);
|
98 |
+
$this->response_code = $result['response']['code'];
|
99 |
+
TOP_DEBUG('do get request returned status code of ' . $this->response_code . ' for url - ' . $url);
|
100 |
+
if ($result['response']['code'] == '200') {
|
101 |
+
return $result['body'];
|
102 |
+
} else {
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
function check_rate_limit()
|
108 |
+
{
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
function do_request($url, $oauth_header, $body_params = '') {
|
113 |
+
TOP_DEBUG('Doing POST request, OAUTH header is ' . $oauth_header);
|
114 |
+
|
115 |
+
if (function_exists('curl_init') && $this->can_use_curl) {
|
116 |
+
|
117 |
+
|
118 |
+
|
119 |
+
$ch = curl_init($url);
|
120 |
+
|
121 |
+
TOP_DEBUG('..using CURL transport');
|
122 |
+
|
123 |
+
// we're doing a POST request
|
124 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
125 |
+
|
126 |
+
$body_array = array();
|
127 |
+
foreach ($body_params as $key => $value) {
|
128 |
+
$body_array[] = urlencode($key) . '=' . urlencode($value);
|
129 |
+
}
|
130 |
+
|
131 |
+
if (top_is_debug_enabled()) {
|
132 |
+
$param_str = print_r($body_array, true);
|
133 |
+
TOP_DEBUG('..POST parameters are ' . $param_str);
|
134 |
+
}
|
135 |
+
|
136 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, implode($body_array, '&'));
|
137 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: ' . $oauth_header));
|
138 |
+
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
139 |
+
|
140 |
+
// Don't use this option in safe mode
|
141 |
+
if (!ini_get('safe_mode')) {
|
142 |
+
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
143 |
+
|
144 |
+
TOP_DEBUG('..CURLOPT_FOLLOWLOCATION is ON');
|
145 |
+
}
|
146 |
+
|
147 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
148 |
+
|
149 |
+
if (( $contents = curl_exec($ch))) {
|
150 |
+
$response = curl_getinfo($ch);
|
151 |
+
curl_close($ch);
|
152 |
+
|
153 |
+
TOP_DEBUG('..CURL returned a status code of ' . $response['http_code']);
|
154 |
+
|
155 |
+
$this->response_code = $response['http_code'];
|
156 |
+
if ($response['http_code'] == 200) {
|
157 |
+
return $contents;
|
158 |
+
} else {
|
159 |
+
TOP_DEBUG('..RESPONSE was ' . print_r($response, true));
|
160 |
+
|
161 |
+
switch ($response['http_code']) {
|
162 |
+
case 403:
|
163 |
+
$this->duplicate_tweet = true;
|
164 |
+
break;
|
165 |
+
}
|
166 |
+
|
167 |
+
$error_message_found = preg_match('#<error>(.*)</error>#i', $contents, $matches);
|
168 |
+
if ($error_message_found) {
|
169 |
+
$this->error_message = $matches[1];
|
170 |
+
}
|
171 |
+
}
|
172 |
+
} else {
|
173 |
+
TOP_DEBUG("..CURL didn't return any contents");
|
174 |
+
curl_close($ch);
|
175 |
+
}
|
176 |
+
} else {
|
177 |
+
$request = new WP_Http;
|
178 |
+
TOP_DEBUG('..using WP transport');
|
179 |
+
$params = array();
|
180 |
+
if ($body_params) {
|
181 |
+
foreach ($body_params as $key => $value) {
|
182 |
+
$body_params[$key] = ( $value );
|
183 |
+
}
|
184 |
+
|
185 |
+
$params['body'] = $body_params;
|
186 |
+
}
|
187 |
+
|
188 |
+
$params['method'] = 'POST';
|
189 |
+
$params['headers'] = array('Authorization' => $oauth_header);
|
190 |
+
|
191 |
+
$result = $request->request($url, $params);
|
192 |
+
|
193 |
+
if (!is_wp_error($result)) {
|
194 |
+
|
195 |
+
TOP_DEBUG('..WP transport returned a status code of ' . $result['response']['code']);
|
196 |
+
|
197 |
+
$this->response_code = $result['response']['code'];
|
198 |
+
|
199 |
+
if ($result['response']['code'] == '200') {
|
200 |
+
return $result['body'];
|
201 |
+
} else {
|
202 |
+
TOP_DEBUG('..RESPONSE was ' . print_r($result['response'], true));
|
203 |
+
|
204 |
+
switch ($result['response']['code']) {
|
205 |
+
case 403:
|
206 |
+
$this->duplicate_tweet = true;
|
207 |
+
break;
|
208 |
+
}
|
209 |
+
|
210 |
+
$error_message_found = preg_match('#<error>(.*)</error>#i', $result['body'], $matches);
|
211 |
+
if ($error_message_found) {
|
212 |
+
$this->error_message = $matches[1];
|
213 |
+
}
|
214 |
+
}
|
215 |
+
} else {
|
216 |
+
TOP_DEBUG("..WP transport returned an error, " . $result->get_error_message());
|
217 |
+
}
|
218 |
+
}
|
219 |
+
return false;
|
220 |
+
}
|
221 |
+
|
222 |
+
function get_nonce() {
|
223 |
+
return md5(mt_rand() + mt_rand());
|
224 |
+
}
|
225 |
+
|
226 |
+
function parse_params($string_params) {
|
227 |
+
$good_params = array();
|
228 |
+
|
229 |
+
$params = explode('&', $string_params);
|
230 |
+
foreach ($params as $param) {
|
231 |
+
$keyvalue = explode('=', $param);
|
232 |
+
$good_params[$keyvalue[0]] = $keyvalue[1];
|
233 |
+
}
|
234 |
+
|
235 |
+
return $good_params;
|
236 |
+
}
|
237 |
+
|
238 |
+
function set_oauth_time_offset( $offset ) {
|
239 |
+
$this->oauth_time_offset = $offset;
|
240 |
+
}
|
241 |
+
|
242 |
+
function hmac_sha1($key, $data) {
|
243 |
+
if (function_exists('hash_hmac')) {
|
244 |
+
$hash = hash_hmac('sha1', $data, $key, true);
|
245 |
+
|
246 |
+
return $hash;
|
247 |
+
} else {
|
248 |
+
$blocksize = 64;
|
249 |
+
$hashfunc = 'sha1';
|
250 |
+
if (strlen($key) > $blocksize) {
|
251 |
+
$key = pack('H*', $hashfunc($key));
|
252 |
+
}
|
253 |
+
|
254 |
+
$key = str_pad($key, $blocksize, chr(0x00));
|
255 |
+
$ipad = str_repeat(chr(0x36), $blocksize);
|
256 |
+
$opad = str_repeat(chr(0x5c), $blocksize);
|
257 |
+
$hash = pack('H*', $hashfunc(( $key ^ $opad ) . pack('H*', $hashfunc(($key ^ $ipad) . $data))));
|
258 |
+
|
259 |
+
return $hash;
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
function do_oauth($url, $params, $token_secret = '') {
|
264 |
+
$sig_string = $this->create_signature_base_string(false, $url, $params);
|
265 |
+
|
266 |
+
//$hash = hash_hmac( 'sha1', $sig_string, TOP_OAUTH_CONSUMER_SECRET . '&' . $token_secret, true );
|
267 |
+
$hash = $this->hmac_sha1($this->oauth_consumer_secret . '&' . $token_secret, $sig_string);
|
268 |
+
|
269 |
+
$sig = base64_encode($hash);
|
270 |
+
|
271 |
+
$params['oauth_signature'] = $sig;
|
272 |
+
|
273 |
+
$header = "OAuth ";
|
274 |
+
$all_params = array();
|
275 |
+
$other_params = array();
|
276 |
+
foreach ($params as $key => $value) {
|
277 |
+
if (strpos($key, 'oauth_') !== false) {
|
278 |
+
$all_params[] = $key . '="' . $this->encode($value) . '"';
|
279 |
+
} else {
|
280 |
+
$other_params[$key] = $value;
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
$header .= implode($all_params, ", ");
|
285 |
+
|
286 |
+
return $this->do_request($url, $header, $other_params);
|
287 |
+
}
|
288 |
+
|
289 |
+
function get_request_token() {
|
290 |
+
$params = array();
|
291 |
+
|
292 |
+
$admin_url = get_option('top_opt_admin_url');
|
293 |
+
if (!isset($admin_url)) {
|
294 |
+
$admin_url = top_currentPageURL();
|
295 |
+
}
|
296 |
+
|
297 |
+
TOP_DEBUG( 'In function get_request_token' );
|
298 |
+
$params['oauth_consumer_key'] = TOP_OAUTH_CONSUMER_KEY;
|
299 |
+
//$params['oauth_callback'] = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '&TOP_oauth=1';
|
300 |
+
$params['oauth_callback'] = htmlentities($admin_url . '&TOP_oauth=1');
|
301 |
+
|
302 |
+
$params['oauth_signature_method'] = 'HMAC-SHA1';
|
303 |
+
$params['oauth_timestamp'] = time();
|
304 |
+
$params['oauth_nonce'] = $this->get_nonce();
|
305 |
+
$params['oauth_version'] = '1.0';
|
306 |
+
|
307 |
+
if ( top_is_debug_enabled() ) {
|
308 |
+
TOP_DEBUG( '..params are ' . print_r( $params, true ) );
|
309 |
+
}
|
310 |
+
|
311 |
+
$result = $this->do_oauth(TOP_OAUTH_REQUEST_URL, $params);
|
312 |
+
|
313 |
+
if ($result) {
|
314 |
+
$new_params = $this->parse_params($result);
|
315 |
+
return $new_params;
|
316 |
+
}
|
317 |
+
}
|
318 |
+
|
319 |
+
function get_access_token($token, $token_secret, $verifier) {
|
320 |
+
$params = array();
|
321 |
+
|
322 |
+
TOP_DEBUG( 'In function get_access_token' );
|
323 |
+
|
324 |
+
$params['oauth_consumer_key'] = $this->oauth_consumer_key;
|
325 |
+
$params['oauth_signature_method'] = 'HMAC-SHA1';
|
326 |
+
$params['oauth_timestamp'] = time() + $this->oauth_time_offset;
|
327 |
+
$params['oauth_nonce'] = $this->get_nonce();
|
328 |
+
$params['oauth_version'] = '1.0';
|
329 |
+
$params['oauth_token'] = $token;
|
330 |
+
$params['oauth_verifier'] = $verifier;
|
331 |
+
|
332 |
+
if ( top_is_debug_enabled() ) {
|
333 |
+
TOP_DEBUG( '..params are ' . print_r( $params, true ) );
|
334 |
+
}
|
335 |
+
|
336 |
+
$result = $this->do_oauth(TOP_OAUTH_ACCESS_URL, $params, $token_secret);
|
337 |
+
if ($result) {
|
338 |
+
$new_params = $this->parse_params($result);
|
339 |
+
return $new_params;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
function update_status($token, $token_secret, $status) {
|
344 |
+
$params = array();
|
345 |
+
|
346 |
+
$params['oauth_consumer_key'] =$this->oauth_consumer_key;
|
347 |
+
$params['oauth_signature_method'] = 'HMAC-SHA1';
|
348 |
+
$params['oauth_timestamp'] = time() + $this->oauth_time_offset;
|
349 |
+
$params['oauth_nonce'] = $this->get_nonce();
|
350 |
+
$params['oauth_version'] = '1.0';
|
351 |
+
$params['oauth_token'] = $token;
|
352 |
+
$params['status'] = $status;
|
353 |
+
|
354 |
+
if ( top_is_debug_enabled() ) {
|
355 |
+
TOP_DEBUG( '..params are ' . print_r( $params, true ) );
|
356 |
+
}
|
357 |
+
|
358 |
+
$url = 'http://api.twitter.com/1/statuses/update.xml';
|
359 |
+
|
360 |
+
$result = $this->do_oauth($url, $params, $token_secret);
|
361 |
+
if ($result) {
|
362 |
+
$new_params = TOP_parsexml($result);
|
363 |
+
return true;
|
364 |
+
} else {
|
365 |
+
return false;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
|
369 |
+
function was_duplicate_tweet() {
|
370 |
+
return $this->duplicate_tweet;
|
371 |
+
}
|
372 |
+
|
373 |
+
function get_auth_url($token) {
|
374 |
+
return TOP_OAUTH_AUTHORIZE_URL . '?oauth_token=' . $token;
|
375 |
+
}
|
376 |
+
|
377 |
+
function get_user_info($user_id) {
|
378 |
+
$url = 'http://api.twitter.com/1/users/show.xml?id=' . $user_id;
|
379 |
+
|
380 |
+
$result = $this->do_get_request($url);
|
381 |
+
if ($result) {
|
382 |
+
$new_params = TOP_parsexml($result);
|
383 |
+
return $new_params;
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
?>
|
css/tweet-old-post.css
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.wrap h2 {
|
2 |
+
margin-top: 32px;
|
3 |
+
}
|
4 |
+
#top_opt .options {
|
5 |
+
overflow: hidden;
|
6 |
+
border: none;
|
7 |
+
}
|
8 |
+
#top_opt .option {
|
9 |
+
overflow: hidden;
|
10 |
+
border-bottom: dashed 1px #ccc;
|
11 |
+
padding-bottom: 9px;
|
12 |
+
padding-top: 9px;
|
13 |
+
}
|
14 |
+
#top_opt .option label {
|
15 |
+
display: block;
|
16 |
+
float: left;
|
17 |
+
width: 200px;
|
18 |
+
margin-right: 24px;
|
19 |
+
text-align: right;
|
20 |
+
}
|
21 |
+
#top_opt .option span {
|
22 |
+
display: block;
|
23 |
+
float: left;
|
24 |
+
margin-left: 230px;
|
25 |
+
margin-top: 6px;
|
26 |
+
clear: left;
|
27 |
+
}
|
28 |
+
|
29 |
+
#top_opt p.submit {
|
30 |
+
overflow: hidden;
|
31 |
+
}
|
32 |
+
#top_opt .option span {
|
33 |
+
color: #666;
|
34 |
+
display: block;
|
35 |
+
}
|
36 |
+
|
37 |
+
#top_opt .category label
|
38 |
+
{
|
39 |
+
float:left;
|
40 |
+
text-align:left;
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
#top_opt .category .catlabel
|
45 |
+
{
|
46 |
+
text-align:right;
|
47 |
+
}
|
48 |
+
|
49 |
+
#profile-box
|
50 |
+
{
|
51 |
+
overflow:hidden;
|
52 |
+
padding-left: 15px;
|
53 |
+
}
|
54 |
+
#profile-box .avatar
|
55 |
+
{
|
56 |
+
float:left;
|
57 |
+
margin-right: 10px;
|
58 |
+
border-style: none;
|
59 |
+
}
|
60 |
+
|
61 |
+
#profile-box p {
|
62 |
+
margin-left: 58px;
|
63 |
+
}
|
64 |
+
|
65 |
+
#profile-box h4,
|
66 |
+
#profile-box h5 {
|
67 |
+
font-size: 13px;
|
68 |
+
text-shadow: #fff 0 -1px 1px;
|
69 |
+
margin: 0px;
|
70 |
+
padding-bottom: 2px;
|
71 |
+
}
|
72 |
+
|
73 |
+
#profile-box h5 {
|
74 |
+
font-size: 11px;
|
75 |
+
font-weight: normal;
|
76 |
+
}
|
images/twitter.png
ADDED
Binary file
|
log.txt
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
1328977340 Signature base string is: POST&http%3A%2F%2Fapi.twitter.com%2F1%2Fstatuses%2Fupdate.xml&oauth_consumer_key%3DofaYongByVpa3NDEbXa2g%26oauth_nonce%3Dec9d7bcfaf6e0f68917055d7281808d3%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1328977340%26oauth_token%3D91804964-eAZvUDZD3qvtfa82ByNzjcPx6LqDrYeFa0P1YSSpa%26oauth_version%3D1.0%26status%3DAccess%2520Master%2520Page%2520Controls%2520from%2520Content%2520Pages%2520without%2520using%2520FindControl%2520%2520
|
2 |
+
1328977340 Doing POST request, OAUTH header is OAuth oauth_consumer_key="ofaYongByVpa3NDEbXa2g", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1328977340", oauth_nonce="ec9d7bcfaf6e0f68917055d7281808d3", oauth_version="1.0", oauth_token="91804964-eAZvUDZD3qvtfa82ByNzjcPx6LqDrYeFa0P1YSSpa", oauth_signature="nsgWtgDzbDRX3jr%2FT8QPKdy%2FpQM%3D"
|
3 |
+
1328977340 ..using CURL transport
|
4 |
+
1328977340 ..POST parameters are Array
|
5 |
+
(
|
6 |
+
[0] => status=Access+Master+Page+Controls+from+Content+Pages+without+using+FindControl++
|
7 |
+
)
|
8 |
+
|
9 |
+
1328977340 ..CURLOPT_FOLLOWLOCATION is ON
|
10 |
+
1328977341 ..CURL returned a status code of 200
|
readme.txt
ADDED
@@ -0,0 +1,621 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ay Matharu
|
3 |
+
Tags: Tweet old post, Tweets, Promote old post by tweeting about them, Twitter, Auto Tweet, Hashtags, Twitter Hashtags, Tweet Posts, Tweet, Post Tweets, Wordpress Twitter Plugin, Twitter Plugin, Tweet Selected Posts
|
4 |
+
Requires at least: 2.7
|
5 |
+
Tested up to: 3.3.1
|
6 |
+
Stable tag: trunk
|
7 |
+
|
8 |
+
|
9 |
+
Plugin to tweet about your old posts to get more hits for them and keep them alive.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Tweet Old Posts is a plugin designed to tweet your older posts to get more traffic.
|
14 |
+
|
15 |
+
Tweet Old Posts randomly picks your older post based on the interval specified by you. The primary function of this plugin is to promote older blog posts by tweeting about them and getting more traffic.
|
16 |
+
|
17 |
+
For updates follow http://twitter.com/matharuajay
|
18 |
+
|
19 |
+
**Fortcoming**
|
20 |
+
|
21 |
+
- Sleep time
|
22 |
+
- Post priority
|
23 |
+
- Additional text based on categories
|
24 |
+
- Post for Facebook and Google+
|
25 |
+
- Option to set number of tweets to post at a time
|
26 |
+
|
27 |
+
|
28 |
+
**Pro Version (will be released soon)**
|
29 |
+
- Change via Tweet Old Post to your specified name
|
30 |
+
- Multiple Twitter accounts
|
31 |
+
|
32 |
+
|
33 |
+
**Let me know if you have any more ideas**
|
34 |
+
|
35 |
+
**New in v3.3.1**
|
36 |
+
|
37 |
+
- Changed logic for posting data to twitter.
|
38 |
+
- Resolved bit.ly issue.
|
39 |
+
|
40 |
+
|
41 |
+
**New in v3.3.0**
|
42 |
+
|
43 |
+
- Attempt to fix logs out issue (Tweet Old Post pushes out when any action is performed).
|
44 |
+
|
45 |
+
|
46 |
+
**New in v3.2.9**
|
47 |
+
|
48 |
+
- Option to reset setting. When something goes wrong, please reset the settings and setup again.
|
49 |
+
- For people still facing issues of conflict with Google Analytics Plugin, this version should work.
|
50 |
+
- Minor bug fixes.
|
51 |
+
|
52 |
+
|
53 |
+
**New in v3.2.8**
|
54 |
+
|
55 |
+
- Resolved conflict with Google Analytics Plugin.
|
56 |
+
- Changed the log file location to root of plugin folder.
|
57 |
+
- Maintained Tweet Cycle. Repeat only when all post have been tweeted.
|
58 |
+
- Made other optimizations and resolved some minor bugs.
|
59 |
+
|
60 |
+
|
61 |
+
**New in v3.2.7**
|
62 |
+
|
63 |
+
- Added logging for people who cant make it work can enable and check the log, or mail me the log file.
|
64 |
+
- Brought back the exclude post option.
|
65 |
+
- Made other optimizations and resolved some minor bugs.
|
66 |
+
- Check http://www.ajaymatharu.com/tweet-old-post-update-3-2-7/ for more detailed explanation.
|
67 |
+
|
68 |
+
|
69 |
+
**New in v3.2.6**
|
70 |
+
|
71 |
+
- removed exclude post due to security threat. Will work on it and bring it up back.
|
72 |
+
|
73 |
+
|
74 |
+
**New in v3.2.5**
|
75 |
+
|
76 |
+
- Resolved hashtag not posting issue.
|
77 |
+
- other bug fixes.
|
78 |
+
|
79 |
+
|
80 |
+
**New in v3.2.4**
|
81 |
+
|
82 |
+
- Bug fixes
|
83 |
+
|
84 |
+
|
85 |
+
**New in v3.2.3**
|
86 |
+
|
87 |
+
- Bug fixes
|
88 |
+
|
89 |
+
|
90 |
+
**New in v3.2.2**
|
91 |
+
|
92 |
+
- Resolved bit.ly issue
|
93 |
+
- new option for hashtags
|
94 |
+
- other bug fixes
|
95 |
+
|
96 |
+
|
97 |
+
**New in v3.2.1**
|
98 |
+
|
99 |
+
- Bug fixes
|
100 |
+
|
101 |
+
|
102 |
+
**New in v3.2**
|
103 |
+
|
104 |
+
- Bug fixes
|
105 |
+
- Option to choose to include link in post
|
106 |
+
- option to post only title or body or both title and body
|
107 |
+
- option to set additional text either at beginning or end of tweet
|
108 |
+
- option to pick hashtags from custom field
|
109 |
+
|
110 |
+
|
111 |
+
**New in v3.1.2**
|
112 |
+
|
113 |
+
- Resolved tweets not getting posted when categories are excluded.
|
114 |
+
- If you are not able to authorise your twitter account set you blog URL in Administration → Settings → General.
|
115 |
+
|
116 |
+
|
117 |
+
|
118 |
+
**New in v3.1.1**
|
119 |
+
|
120 |
+
- Resolved tweets not getting posted issue. Sorry guys :(
|
121 |
+
|
122 |
+
|
123 |
+
|
124 |
+
**New in v3.1**
|
125 |
+
|
126 |
+
- Resolved issue of plugin flooding twitter account with tweets.
|
127 |
+
- added provision to exclude some post from selected categories
|
128 |
+
|
129 |
+
|
130 |
+
|
131 |
+
**New in v3.0**
|
132 |
+
|
133 |
+
- added OAuth authentication
|
134 |
+
- user defined intervals
|
135 |
+
- may not work under php 4 requires php 5
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
**New in v2.0**
|
140 |
+
|
141 |
+
- added provision to select if you want to shorten the URL or not.
|
142 |
+
- Cleaned other options.
|
143 |
+
|
144 |
+
|
145 |
+
|
146 |
+
**New in v1.9**
|
147 |
+
|
148 |
+
- Removed PHP 4 support as it was creating problem for lot of people
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
**New in v1.8**
|
153 |
+
|
154 |
+
- Bug Fixes
|
155 |
+
- Provision to fetch tweet url from custom field
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
**New in v1.7**
|
160 |
+
|
161 |
+
- Removed api option from 1click.at not needed api key
|
162 |
+
|
163 |
+
|
164 |
+
|
165 |
+
**New in v1.6**
|
166 |
+
|
167 |
+
- Made the plugin PHP 4 compatible. Guys try it out and please let me know if that worked.
|
168 |
+
- Better error prompting. If your tweets are not appearing on twitter. Try "Tweet Now" button you'll see if there is any problem in tweeting.
|
169 |
+
- Added 1click.at shortning service you need to get the api key from http://theeasyapi.com/ you need to add your machine IP address in the server of http://theeasyapi.com/ for this api key to work.
|
170 |
+
|
171 |
+
|
172 |
+
|
173 |
+
**New in v1.5**
|
174 |
+
|
175 |
+
- Maximum age of post to be eligible for tweet - allows you to set Maximum age of the post to be eligible for tweet
|
176 |
+
- Added one more shortner service was looking for j.mp but they dont have the api yet.
|
177 |
+
|
178 |
+
|
179 |
+
|
180 |
+
**New in v1.4**
|
181 |
+
|
182 |
+
- Hashtags - allows you to set default hashtags for your tweets
|
183 |
+
|
184 |
+
|
185 |
+
|
186 |
+
**New in v1.3**
|
187 |
+
|
188 |
+
- URL Shortener Service - allows you to select which URL shortener service you want to use.
|
189 |
+
|
190 |
+
|
191 |
+
|
192 |
+
**New in v1.2**
|
193 |
+
|
194 |
+
- Tweet Prefix - Allows you to set prefix to the tweets.
|
195 |
+
- Add Data - Allows you to add post data to the tweets
|
196 |
+
- Tweet now - Button that will tweet at that moment without wanting you to wait for scheduled tweet
|
197 |
+
|
198 |
+
|
199 |
+
|
200 |
+
**v1.1**
|
201 |
+
|
202 |
+
- Twitter Username & Password - Using this twitter account credentials plugin will tweet.
|
203 |
+
- Minimum interval between tweets - allows you to determine how often the plugin will automatically choose and tweet a blog post for you.
|
204 |
+
- Randomness interval - This is a contributing factor in minimum interval so that posts are randomly chosen and tweeted from your blog.
|
205 |
+
- Minimum age of post to be eligible for tweet - This allows you to set how old your post should be in order to be eligible for the tweet.
|
206 |
+
- Categories to omit from tweets - This will protect posts from the selected categories from being tweeted.
|
207 |
+
|
208 |
+
== Installation ==
|
209 |
+
|
210 |
+
Following are the steps to install the Tweet Old Post plugin
|
211 |
+
|
212 |
+
1. Download the latest version of the Tweet Old Posts Plugin to your computer from here.
|
213 |
+
2. With an FTP program, access your site�s server.
|
214 |
+
3. Upload (copy) the Plugin file(s) or folder to the /wp-content/plugins folder.
|
215 |
+
4. In your WordPress Administration Panels, click on Plugins from the menu.
|
216 |
+
5. You should see Tweet Old Posts Plugin listed. If not, with your FTP program, check the folder to see if it is installed. If it isn�t, upload the file(s) again. If it is, delete the files and upload them again.
|
217 |
+
6. To turn the Tweet Old Posts Plugin on, click Activate.
|
218 |
+
7. Check your Administration Panels or WordPress blog to see if the Plugin is working.
|
219 |
+
8. You can change the plugin options from Tweet Old Posts under settings menu.
|
220 |
+
|
221 |
+
Alternatively you can also follow the following steps to install the Tweet Old Post plugin
|
222 |
+
|
223 |
+
1. In your WordPress Administration Panels, click on Add New option under Plugins from the menu.
|
224 |
+
2. Click on upload at the top.
|
225 |
+
3. Browse the location and select the Tweet Old Post Plugin and click install now.
|
226 |
+
4. To turn the Tweet Old Posts Plugin on, click Activate.
|
227 |
+
5. Check your Administration Panels or WordPress blog to see if the Plugin is working.
|
228 |
+
6. You can change the plugin options from Tweet Old Posts under settings menu.
|
229 |
+
|
230 |
+
== Frequently Asked Questions ==
|
231 |
+
|
232 |
+
If you have any questions please mail me at,
|
233 |
+
ajay@ajaymatharu.com or matharuajay@yahoo.co.in
|
234 |
+
|
235 |
+
**Too many redirects while trying to authorize**
|
236 |
+
|
237 |
+
- Make sure "Tweet Old Post Admin URL (Current URL)" is showing your current URL.
|
238 |
+
- Click on "Update Tweet Old Post Options".
|
239 |
+
- Try to authorize again.
|
240 |
+
|
241 |
+
|
242 |
+
**Tweet Old post does not posts any tweets?**
|
243 |
+
|
244 |
+
- If its not tweeting any tweets try playing around with the options. Try setting maxtweetage to none and try again.
|
245 |
+
- Try removing categories from excluded option. Some of them have posted issues of tweet not getting post when categories are selected in exclued category section.
|
246 |
+
|
247 |
+
|
248 |
+
**Tweet old post giving SimpleXmlElement error?**
|
249 |
+
|
250 |
+
- If it is giving SimpleXmlElement error, check with your hosting provider on which version of PHP are they supporting.
|
251 |
+
Tweet Old Post supports PHP 5 onwards. It will give SimpleXmlElement error if your hosting provider supports PHP 4
|
252 |
+
or PHP less than 5
|
253 |
+
|
254 |
+
|
255 |
+
**Tweets not getting posted?**
|
256 |
+
|
257 |
+
- If your tweets are not getting posted, try deauthorizing and again authorizing your twitter account with
|
258 |
+
plugin.
|
259 |
+
|
260 |
+
|
261 |
+
**Plugin flooded your tweeter account with tweets?**
|
262 |
+
|
263 |
+
- please check your setting increase the minimum interval between tweets. If your plugin is not updated please update your plugin to latest version.
|
264 |
+
|
265 |
+
|
266 |
+
**Not able to authorize your twitter account with Tweet Old Post**
|
267 |
+
|
268 |
+
- If you are not able to authorise your twitter account set you blog URL in Administration → Settings → General.
|
269 |
+
|
270 |
+
**Any more questions or doubts?**
|
271 |
+
|
272 |
+
- DM me on http://twitter.com/matharuajay or mail me at ajay(at)ajaymatharu(dot)com
|
273 |
+
|
274 |
+
|
275 |
+
== Screenshots ==
|
276 |
+
|
277 |
+
for screenshots you can check out
|
278 |
+
|
279 |
+
http://www.ajaymatharu.com/wordpress-plugin-tweet-old-posts/
|
280 |
+
|
281 |
+
== Changelog ==
|
282 |
+
|
283 |
+
|
284 |
+
**New in v3.3.1**
|
285 |
+
|
286 |
+
- Changed logic for posting data to twitter.
|
287 |
+
- Resolved bit.ly issue.
|
288 |
+
|
289 |
+
|
290 |
+
**New in v3.3.0**
|
291 |
+
|
292 |
+
- Attempt to fix logs out issue (Tweet Old Post pushes out when any action is performed).
|
293 |
+
|
294 |
+
|
295 |
+
**New in v3.2.9**
|
296 |
+
|
297 |
+
- Option to reset setting. When something goes wrong, please reset the settings and setup again.
|
298 |
+
- For people still facing issues of conflict with Google Analytics Plugin, this version should work.
|
299 |
+
- Minor bug fixes.
|
300 |
+
|
301 |
+
|
302 |
+
|
303 |
+
**New in v3.2.8**
|
304 |
+
|
305 |
+
- Resolved conflict with Google Analytics Plugin.
|
306 |
+
- Changed the log file location to root of plugin folder.
|
307 |
+
- Maintained Tweet Cycle. Repeat only when all post have been tweeted.
|
308 |
+
- Made other optimizations and resolved some minor bugs.
|
309 |
+
|
310 |
+
|
311 |
+
|
312 |
+
**New in v3.2.7**
|
313 |
+
|
314 |
+
- Added logging for people who cant make it work can enable and check the log, or mail me the log file.
|
315 |
+
- Brought back the exclude post option.
|
316 |
+
- Made other optimizations and resolved some minor bugs.
|
317 |
+
- Check http://www.ajaymatharu.com/tweet-old-post-update-3-2-7/ for more detailed explanation.
|
318 |
+
|
319 |
+
|
320 |
+
|
321 |
+
**New in v3.2.6**
|
322 |
+
|
323 |
+
- removed exclude post due to security threat. Will work on it and bring it up back.
|
324 |
+
|
325 |
+
|
326 |
+
|
327 |
+
**New in v3.2.5**
|
328 |
+
|
329 |
+
- Resolved hashtag not posting issue.
|
330 |
+
- other bug fixes.
|
331 |
+
|
332 |
+
|
333 |
+
|
334 |
+
**New in v3.2.4**
|
335 |
+
|
336 |
+
- Bug fixes
|
337 |
+
|
338 |
+
|
339 |
+
|
340 |
+
**New in v3.2.3**
|
341 |
+
|
342 |
+
- Bug fixes
|
343 |
+
|
344 |
+
|
345 |
+
|
346 |
+
**New in v3.2.2**
|
347 |
+
|
348 |
+
- Resolved bit.ly issue
|
349 |
+
- new option for hashtags
|
350 |
+
- other bug fixes
|
351 |
+
|
352 |
+
|
353 |
+
|
354 |
+
**New in v3.2.1**
|
355 |
+
|
356 |
+
- Bug fixes
|
357 |
+
|
358 |
+
|
359 |
+
|
360 |
+
**New in v3.2**
|
361 |
+
|
362 |
+
- Bug fixes
|
363 |
+
- Option to choose to include link in post
|
364 |
+
- option to post only title or body or both title and body
|
365 |
+
- option to set additional text either at beginning or end of tweet
|
366 |
+
- option to pick hashtags from custom field
|
367 |
+
|
368 |
+
|
369 |
+
|
370 |
+
**New in v3.1.2**
|
371 |
+
|
372 |
+
- Resolved tweets not getting posted when categories are excluded.
|
373 |
+
- If you are not able to authorise your twitter account set you blog URL in Administration → Settings → General.
|
374 |
+
|
375 |
+
|
376 |
+
|
377 |
+
**New in v3.1**
|
378 |
+
|
379 |
+
- Resolved issue of plugin flooding twitter account with tweets.
|
380 |
+
- added provision to exclude some post from selected categories
|
381 |
+
|
382 |
+
|
383 |
+
|
384 |
+
**New in v3.0**
|
385 |
+
|
386 |
+
- added OAuth authentication
|
387 |
+
- user defined intervals
|
388 |
+
- may not work under php 4 requires php 5
|
389 |
+
|
390 |
+
|
391 |
+
|
392 |
+
**New in v2.0**
|
393 |
+
|
394 |
+
- added provision to select if you want to shorten the URL or not.
|
395 |
+
- Cleaned other options.
|
396 |
+
|
397 |
+
|
398 |
+
|
399 |
+
**New in v1.9**
|
400 |
+
|
401 |
+
- Removed PHP 4 support as it was creating problem for lot of people
|
402 |
+
|
403 |
+
|
404 |
+
|
405 |
+
**New in v1.8**
|
406 |
+
|
407 |
+
- Bug Fixes
|
408 |
+
- Provision to fetch tweet url from custom field
|
409 |
+
|
410 |
+
|
411 |
+
|
412 |
+
**New in v1.7**
|
413 |
+
|
414 |
+
- Removed api option from 1click.at not needed api key
|
415 |
+
|
416 |
+
|
417 |
+
|
418 |
+
**New in v1.6**
|
419 |
+
|
420 |
+
- Made the plugin PHP 4 compatible. Guys try it out and please let me know if that worked.
|
421 |
+
- Better error prompting. If your tweets are not appearing on twitter. Try "Tweet Now" button you'll see if there is any problem in tweeting.
|
422 |
+
- Added 1click.at shortning service you need to get the api key from http://theeasyapi.com/ you need to add your machine IP address in the server of http://theeasyapi.com/ for this api key to work.
|
423 |
+
|
424 |
+
|
425 |
+
|
426 |
+
**New in v1.5**
|
427 |
+
|
428 |
+
- Maximum age of post to be eligible for tweet - allows you to set Maximum age of the post to be eligible for tweet
|
429 |
+
- Added one more shortner service was looking for j.mp but they dont have the api yet.
|
430 |
+
|
431 |
+
|
432 |
+
|
433 |
+
**New in v1.4**
|
434 |
+
|
435 |
+
- Hashtags - allows you to set default hashtags for your tweets
|
436 |
+
|
437 |
+
|
438 |
+
|
439 |
+
**New in v1.3**
|
440 |
+
|
441 |
+
- URL Shortener Service - allows you to select which URL shortener service you want to use.
|
442 |
+
|
443 |
+
|
444 |
+
|
445 |
+
**New in v1.2**
|
446 |
+
|
447 |
+
- Tweet Prefix - Allows you to set prefix to the tweets.
|
448 |
+
- Add Data - Allows you to add post data to the tweets
|
449 |
+
- Tweet now - Button that will tweet at that moment without wanting you to wait for scheduled tweet
|
450 |
+
|
451 |
+
|
452 |
+
|
453 |
+
**v1.1**
|
454 |
+
|
455 |
+
- Twitter Username & Password - Using this twitter account credentials plugin will tweet.
|
456 |
+
- Minimum interval between tweets - allows you to determine how often the plugin will automatically choose and tweet a blog post for you.
|
457 |
+
- Randomness interval - This is a contributing factor in minimum interval so that posts are randomly chosen and tweeted from your blog.
|
458 |
+
- Minimum age of post to be eligible for tweet - This allows you to set how old your post should be in order to be eligible for the tweet.
|
459 |
+
- Categories to omit from tweets - This will protect posts from the selected categories from being tweeted.
|
460 |
+
|
461 |
+
|
462 |
+
== Other Notes ==
|
463 |
+
|
464 |
+
Some of the options you can configure for the Tweet Old Posts plugins are,
|
465 |
+
|
466 |
+
|
467 |
+
**New in v3.3.1**
|
468 |
+
|
469 |
+
- Changed logic for posting data to twitter.
|
470 |
+
- Resolved bit.ly issue.
|
471 |
+
|
472 |
+
|
473 |
+
**New in v3.3.0**
|
474 |
+
|
475 |
+
- Attempt to fix logs out issue (Tweet Old Post pushes out when any action is performed).
|
476 |
+
|
477 |
+
|
478 |
+
**New in v3.2.9**
|
479 |
+
|
480 |
+
- Option to reset setting. When something goes wrong, please reset the settings and setup again.
|
481 |
+
- For people still facing issues of conflict with Google Analytics Plugin, this version should work.
|
482 |
+
- Minor bug fixes.
|
483 |
+
|
484 |
+
|
485 |
+
**New in v3.2.8**
|
486 |
+
|
487 |
+
- Resolved conflict with Google Analytics Plugin.
|
488 |
+
- Changed the log file location to root of plugin folder.
|
489 |
+
- Maintained Tweet Cycle. Repeat only when all post have been tweeted.
|
490 |
+
- Made other optimizations and resolved some minor bugs.
|
491 |
+
|
492 |
+
|
493 |
+
**New in v3.2.7**
|
494 |
+
|
495 |
+
- Added logging for people who cant make it work can enable and check the log, or mail me the log file.
|
496 |
+
- Brought back the exclude post option.
|
497 |
+
- Made other optimizations and resolved some minor bugs.
|
498 |
+
- Check http://www.ajaymatharu.com/tweet-old-post-update-3-2-7/ for more detailed explanation.
|
499 |
+
|
500 |
+
|
501 |
+
**New in v3.2.6**
|
502 |
+
|
503 |
+
- removed exclude post due to security threat. Will work on it and bring it up back.
|
504 |
+
|
505 |
+
|
506 |
+
**New in v3.2.5**
|
507 |
+
|
508 |
+
- Resolved hashtag not posting issue.
|
509 |
+
- other bug fixes.
|
510 |
+
|
511 |
+
|
512 |
+
**New in v3.2.4**
|
513 |
+
|
514 |
+
- Bug fixes
|
515 |
+
|
516 |
+
|
517 |
+
**New in v3.2.3**
|
518 |
+
|
519 |
+
- Bug fixes
|
520 |
+
|
521 |
+
|
522 |
+
**New in v3.2.2**
|
523 |
+
|
524 |
+
- Resolved bit.ly issue
|
525 |
+
- new option for hashtags
|
526 |
+
- other bug fixes
|
527 |
+
|
528 |
+
|
529 |
+
**New in v3.2.1**
|
530 |
+
|
531 |
+
- Bug fixes
|
532 |
+
|
533 |
+
|
534 |
+
**New in v3.2**
|
535 |
+
|
536 |
+
- Bug fixes
|
537 |
+
- Option to choose to include link in post
|
538 |
+
- option to post only title or body or both title and body
|
539 |
+
- option to set additional text either at beginning or end of tweet
|
540 |
+
- option to pick hashtags from custom field
|
541 |
+
|
542 |
+
|
543 |
+
**New in v3.1.2**
|
544 |
+
|
545 |
+
- Resolved tweets not getting posted when categories are excluded.
|
546 |
+
- If you are not able to authorise your twitter account set you blog URL in Administration → Settings → General.
|
547 |
+
|
548 |
+
|
549 |
+
**New in v3.1**
|
550 |
+
|
551 |
+
- Resolved issue of plugin flooding twitter account with tweets.
|
552 |
+
- added provision to exclude some post from selected categories
|
553 |
+
|
554 |
+
|
555 |
+
**New in v3.0**
|
556 |
+
|
557 |
+
- added OAuth authentication
|
558 |
+
- user defined intervals
|
559 |
+
- may not work under php 4 requires php 5
|
560 |
+
|
561 |
+
|
562 |
+
**New in v2.0**
|
563 |
+
|
564 |
+
- added provision to select if you want to shorten the URL or not.
|
565 |
+
- Cleaned other options.
|
566 |
+
|
567 |
+
|
568 |
+
**New in v1.9**
|
569 |
+
|
570 |
+
- Removed PHP 4 support as it was creating problem for lot of people
|
571 |
+
|
572 |
+
|
573 |
+
**New in v1.8**
|
574 |
+
|
575 |
+
- Bug Fixes
|
576 |
+
- Provision to fetch tweet url from custom field
|
577 |
+
|
578 |
+
|
579 |
+
**New in v1.7**
|
580 |
+
|
581 |
+
- Removed api option from 1click.at not needed api key
|
582 |
+
|
583 |
+
|
584 |
+
**New in v1.6**
|
585 |
+
|
586 |
+
- Made the plugin PHP 4 compatible. Guys try it out and please let me know if that worked.
|
587 |
+
- Better error prompting. If your tweets are not appearing on twitter. Try "Tweet Now" button you'll see if there is any problem in tweeting.
|
588 |
+
- Added 1click.at shortning service you need to get the api key from http://theeasyapi.com/ you need to add your machine IP address in the server of http://theeasyapi.com/ for this api key to work.
|
589 |
+
|
590 |
+
|
591 |
+
**New in v1.5**
|
592 |
+
|
593 |
+
- Maximum age of post to be eligible for tweet - allows you to set Maximum age of the post to be eligible for tweet
|
594 |
+
- Added one more shortner service was looking for j.mp but they dont have the api yet.
|
595 |
+
|
596 |
+
|
597 |
+
**New in v1.4**
|
598 |
+
|
599 |
+
- Hashtags - allows you to set default hashtags for your tweets
|
600 |
+
|
601 |
+
|
602 |
+
**New in v1.3**
|
603 |
+
|
604 |
+
- URL Shortener Service - allows you to select which URL shortener service you want to use.
|
605 |
+
|
606 |
+
|
607 |
+
**New in v1.2**
|
608 |
+
|
609 |
+
- Tweet Prefix - Allows you to set prefix to the tweets.
|
610 |
+
- Add Data - Allows you to add post data to the tweets
|
611 |
+
- Tweet now - Button that will tweet at that moment without wanting you to wait for scheduled tweet
|
612 |
+
|
613 |
+
|
614 |
+
**v1.1**
|
615 |
+
|
616 |
+
- Twitter Username & Password - Using this twitter account credentials plugin will tweet.
|
617 |
+
- Minimum interval between tweets - allows you to determine how often the plugin will automatically choose and tweet a blog post for you.
|
618 |
+
- Randomness interval - This is a contributing factor in minimum interval so that posts are randomly chosen and tweeted from your blog.
|
619 |
+
- Minimum age of post to be eligible for tweet - This allows you to set how old your post should be in order to be eligible for the tweet.
|
620 |
+
- Categories to omit from tweets - This will protect posts from the selected categories from being tweeted.
|
621 |
+
|
top-admin.php
ADDED
@@ -0,0 +1,842 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('tweet-old-post.php');
|
4 |
+
require_once('top-core.php');
|
5 |
+
require_once( 'Include/top-oauth.php' );
|
6 |
+
require_once('xml.php');
|
7 |
+
require_once( 'Include/top-debug.php' );
|
8 |
+
function top_admin() {
|
9 |
+
//check permission
|
10 |
+
if (current_user_can('manage_options'))
|
11 |
+
{
|
12 |
+
$message = null;
|
13 |
+
$message_updated = __("Tweet Old Post Options Updated.", 'TweetOldPost');
|
14 |
+
$response = null;
|
15 |
+
$save = true;
|
16 |
+
$settings = top_get_settings();
|
17 |
+
|
18 |
+
//on authorize
|
19 |
+
if (isset($_GET['TOP_oauth'])) {
|
20 |
+
global $top_oauth;
|
21 |
+
|
22 |
+
$result = $top_oauth->get_access_token($settings['oauth_request_token'], $settings['oauth_request_token_secret'], $_GET['oauth_verifier']);
|
23 |
+
|
24 |
+
if ($result) {
|
25 |
+
$settings['oauth_access_token'] = $result['oauth_token'];
|
26 |
+
$settings['oauth_access_token_secret'] = $result['oauth_token_secret'];
|
27 |
+
$settings['user_id'] = $result['user_id'];
|
28 |
+
|
29 |
+
$result = $top_oauth->get_user_info($result['user_id']);
|
30 |
+
if ($result) {
|
31 |
+
$settings['profile_image_url'] = $result['user']['profile_image_url'];
|
32 |
+
$settings['screen_name'] = $result['user']['screen_name'];
|
33 |
+
if (isset($result['user']['location'])) {
|
34 |
+
$settings['location'] = $result['user']['location'];
|
35 |
+
} else {
|
36 |
+
$settings['location'] = false;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
top_save_settings($settings);
|
41 |
+
echo '<script language="javascript">window.open ("' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=TweetOldPost","_self")</script>';
|
42 |
+
die;
|
43 |
+
}
|
44 |
+
}
|
45 |
+
//on deauthorize
|
46 |
+
else if (isset($_GET['top']) && $_GET['top'] == 'deauthorize') {
|
47 |
+
$settings = top_get_settings();
|
48 |
+
$settings['oauth_access_token'] = '';
|
49 |
+
$settings['oauth_access_token_secret'] = '';
|
50 |
+
$settings['user_id'] = '';
|
51 |
+
$settings['tweet_queue'] = array();
|
52 |
+
|
53 |
+
top_save_settings($settings);
|
54 |
+
echo '<script language="javascript">window.open ("' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=TweetOldPost","_self")</script>';
|
55 |
+
die;
|
56 |
+
}
|
57 |
+
else if (isset($_GET['top']) && $_GET['top'] == 'reset') {
|
58 |
+
print('
|
59 |
+
<div id="message" class="updated fade">
|
60 |
+
<p>' . __("All settings have been reset. Kindly update the settings for Tweet Old Post to start tweeting again.", 'TweetOldPost') . '</p>
|
61 |
+
</div>');
|
62 |
+
}
|
63 |
+
//check if username and key provided if bitly selected
|
64 |
+
if (isset($_POST['top_opt_url_shortener'])) {
|
65 |
+
if ($_POST['top_opt_url_shortener'] == "bit.ly") {
|
66 |
+
|
67 |
+
//check bitly username
|
68 |
+
if (!isset($_POST['top_opt_bitly_user'])) {
|
69 |
+
print('
|
70 |
+
<div id="message" class="updated fade">
|
71 |
+
<p>' . __('Please enter bit.ly username.', 'TweetOldPost') . '</p>
|
72 |
+
</div>');
|
73 |
+
$save = false;
|
74 |
+
}
|
75 |
+
//check bitly key
|
76 |
+
elseif (!isset($_POST['top_opt_bitly_key'])) {
|
77 |
+
print('
|
78 |
+
<div id="message" class="updated fade">
|
79 |
+
<p>' . __('Please enter bit.ly API Key.', 'TweetOldPost') . '</p>
|
80 |
+
</div>');
|
81 |
+
$save = false;
|
82 |
+
}
|
83 |
+
//if both the good to save
|
84 |
+
else {
|
85 |
+
$save = true;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
//if submit and if bitly selected its fields are filled then save
|
91 |
+
if (isset($_POST['submit']) && $save) {
|
92 |
+
$message = $message_updated;
|
93 |
+
|
94 |
+
//TOP admin URL (current url)
|
95 |
+
if (isset($_POST['top_opt_admin_url'])) {
|
96 |
+
update_option('top_opt_admin_url', $_POST['top_opt_admin_url']);
|
97 |
+
}
|
98 |
+
|
99 |
+
//what to tweet
|
100 |
+
if (isset($_POST['top_opt_tweet_type'])) {
|
101 |
+
update_option('top_opt_tweet_type', $_POST['top_opt_tweet_type']);
|
102 |
+
}
|
103 |
+
|
104 |
+
//additional data
|
105 |
+
if (isset($_POST['top_opt_add_text'])) {
|
106 |
+
update_option('top_opt_add_text', $_POST['top_opt_add_text']);
|
107 |
+
}
|
108 |
+
|
109 |
+
//place of additional data
|
110 |
+
if (isset($_POST['top_opt_add_text_at'])) {
|
111 |
+
update_option('top_opt_add_text_at', $_POST['top_opt_add_text_at']);
|
112 |
+
}
|
113 |
+
|
114 |
+
//include link
|
115 |
+
if (isset($_POST['top_opt_include_link'])) {
|
116 |
+
update_option('top_opt_include_link', $_POST['top_opt_include_link']);
|
117 |
+
}
|
118 |
+
|
119 |
+
//fetch url from custom field?
|
120 |
+
if (isset($_POST['top_opt_custom_url_option'])) {
|
121 |
+
update_option('top_opt_custom_url_option', true);
|
122 |
+
} else {
|
123 |
+
|
124 |
+
update_option('top_opt_custom_url_option', false);
|
125 |
+
}
|
126 |
+
|
127 |
+
//custom field to fetch URL from
|
128 |
+
if (isset($_POST['top_opt_custom_url_field'])) {
|
129 |
+
update_option('top_opt_custom_url_field', $_POST['top_opt_custom_url_field']);
|
130 |
+
} else {
|
131 |
+
|
132 |
+
update_option('top_opt_custom_url_field', '');
|
133 |
+
}
|
134 |
+
|
135 |
+
//use URL shortner?
|
136 |
+
if (isset($_POST['top_opt_use_url_shortner'])) {
|
137 |
+
update_option('top_opt_use_url_shortner', true);
|
138 |
+
} else {
|
139 |
+
|
140 |
+
update_option('top_opt_use_url_shortner', false);
|
141 |
+
}
|
142 |
+
|
143 |
+
//url shortener to use
|
144 |
+
if (isset($_POST['top_opt_url_shortener'])) {
|
145 |
+
update_option('top_opt_url_shortener', $_POST['top_opt_url_shortener']);
|
146 |
+
if ($_POST['top_opt_url_shortener'] == "bit.ly") {
|
147 |
+
if (isset($_POST['top_opt_bitly_user'])) {
|
148 |
+
update_option('top_opt_bitly_user', $_POST['top_opt_bitly_user']);
|
149 |
+
}
|
150 |
+
if (isset($_POST['top_opt_bitly_key'])) {
|
151 |
+
update_option('top_opt_bitly_key', $_POST['top_opt_bitly_key']);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
//hashtags option
|
157 |
+
if (isset($_POST['top_opt_custom_hashtag_option'])) {
|
158 |
+
update_option('top_opt_custom_hashtag_option', $_POST['top_opt_custom_hashtag_option']);
|
159 |
+
} else {
|
160 |
+
update_option('top_opt_custom_hashtag_option', "nohashtag");
|
161 |
+
}
|
162 |
+
|
163 |
+
//use inline hashtags
|
164 |
+
if (isset($_POST['top_opt_use_inline_hashtags'])) {
|
165 |
+
update_option('top_opt_use_inline_hashtags', true);
|
166 |
+
} else {
|
167 |
+
update_option('top_opt_use_inline_hashtags', false);
|
168 |
+
}
|
169 |
+
|
170 |
+
//hashtag length
|
171 |
+
if (isset($_POST['top_opt_hashtag_length'])) {
|
172 |
+
update_option('top_opt_hashtag_length', $_POST['top_opt_hashtag_length']);
|
173 |
+
} else {
|
174 |
+
update_option('top_opt_hashtag_length', 0);
|
175 |
+
}
|
176 |
+
|
177 |
+
//custom field name to fetch hashtag from
|
178 |
+
if (isset($_POST['top_opt_custom_hashtag_field'])) {
|
179 |
+
update_option('top_opt_custom_hashtag_field', $_POST['top_opt_custom_hashtag_field']);
|
180 |
+
} else {
|
181 |
+
update_option('top_opt_custom_hashtag_field', '');
|
182 |
+
}
|
183 |
+
|
184 |
+
//default hashtags for tweets
|
185 |
+
if (isset($_POST['top_opt_hashtags'])) {
|
186 |
+
update_option('top_opt_hashtags', $_POST['top_opt_hashtags']);
|
187 |
+
} else {
|
188 |
+
update_option('top_opt_hashtags', '');
|
189 |
+
}
|
190 |
+
|
191 |
+
//tweet interval
|
192 |
+
if (isset($_POST['top_opt_interval'])) {
|
193 |
+
if (is_numeric($_POST['top_opt_interval']) && $_POST['top_opt_interval'] > 0) {
|
194 |
+
update_option('top_opt_interval', $_POST['top_opt_interval']);
|
195 |
+
} else {
|
196 |
+
update_option('top_opt_interval', "4");
|
197 |
+
}
|
198 |
+
}
|
199 |
+
|
200 |
+
//random interval
|
201 |
+
if (isset($_POST['top_opt_interval_slop'])) {
|
202 |
+
if (is_numeric($_POST['top_opt_interval_slop']) && $_POST['top_opt_interval_slop'] > 0) {
|
203 |
+
update_option('top_opt_interval_slop', $_POST['top_opt_interval_slop']);
|
204 |
+
} else {
|
205 |
+
update_option('top_opt_interval_slop', "4");
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
//minimum post age to tweet
|
210 |
+
if (isset($_POST['top_opt_age_limit'])) {
|
211 |
+
if (is_numeric($_POST['top_opt_age_limit']) && $_POST['top_opt_age_limit'] >= 0) {
|
212 |
+
update_option('top_opt_age_limit', $_POST['top_opt_age_limit']);
|
213 |
+
} else {
|
214 |
+
update_option('top_opt_age_limit', "30");
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
//maximum post age to tweet
|
219 |
+
if (isset($_POST['top_opt_max_age_limit'])) {
|
220 |
+
if (is_numeric($_POST['top_opt_max_age_limit']) && $_POST['top_opt_max_age_limit'] > 0) {
|
221 |
+
update_option('top_opt_max_age_limit', $_POST['top_opt_max_age_limit']);
|
222 |
+
} else {
|
223 |
+
update_option('top_opt_max_age_limit', "0");
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
//option to enable log
|
228 |
+
if ( isset($_POST['top_enable_log'])) {
|
229 |
+
update_option('top_enable_log', true);
|
230 |
+
global $top_debug;
|
231 |
+
$top_debug->enable( true );
|
232 |
+
|
233 |
+
}
|
234 |
+
else{
|
235 |
+
update_option('top_enable_log', false);
|
236 |
+
global $top_debug;
|
237 |
+
$top_debug->enable( false );
|
238 |
+
}
|
239 |
+
|
240 |
+
//categories to omit from tweet
|
241 |
+
if (isset($_POST['post_category'])) {
|
242 |
+
update_option('top_opt_omit_cats', implode(',', $_POST['post_category']));
|
243 |
+
} else {
|
244 |
+
update_option('top_opt_omit_cats', '');
|
245 |
+
}
|
246 |
+
|
247 |
+
//successful update message
|
248 |
+
print('
|
249 |
+
<div id="message" class="updated fade">
|
250 |
+
<p>' . __('Tweet Old Post Options Updated.', 'TweetOldPost') . '</p>
|
251 |
+
</div>');
|
252 |
+
}
|
253 |
+
//tweet now clicked
|
254 |
+
elseif (isset($_POST['tweet'])) {
|
255 |
+
$tweet_msg = top_opt_tweet_old_post();
|
256 |
+
print('
|
257 |
+
<div id="message" class="updated fade">
|
258 |
+
<p>' . __($tweet_msg, 'TweetOldPost') . '</p>
|
259 |
+
</div>');
|
260 |
+
}
|
261 |
+
elseif (isset($_POST['reset'])) {
|
262 |
+
top_reset_settings();
|
263 |
+
echo '<script language="javascript">window.open ("' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=TweetOldPost&top=reset","_self")</script>';
|
264 |
+
die;
|
265 |
+
}
|
266 |
+
|
267 |
+
|
268 |
+
//set up data into fields from db
|
269 |
+
|
270 |
+
//what to tweet?
|
271 |
+
$admin_url = get_option('top_opt_admin_url');
|
272 |
+
if (!isset($admin_url)) {
|
273 |
+
$admin_url = "";
|
274 |
+
}
|
275 |
+
|
276 |
+
//what to tweet?
|
277 |
+
$tweet_type = get_option('top_opt_tweet_type');
|
278 |
+
if (!isset($tweet_type)) {
|
279 |
+
$tweet_type = "title";
|
280 |
+
}
|
281 |
+
|
282 |
+
//additional text
|
283 |
+
$additional_text = get_option('top_opt_add_text');
|
284 |
+
if (!isset($additional_text)) {
|
285 |
+
$additional_text = "";
|
286 |
+
}
|
287 |
+
|
288 |
+
//position of additional text
|
289 |
+
$additional_text_at = get_option('top_opt_add_text_at');
|
290 |
+
if (!isset($additional_text_at)) {
|
291 |
+
$additional_text_at = "beginning";
|
292 |
+
}
|
293 |
+
|
294 |
+
//include link in tweet
|
295 |
+
$include_link = get_option('top_opt_include_link');
|
296 |
+
if (!isset($include_link)) {
|
297 |
+
$include_link = "no";
|
298 |
+
}
|
299 |
+
|
300 |
+
//use custom field to fetch url
|
301 |
+
$custom_url_option = get_option('top_opt_custom_url_option');
|
302 |
+
if (!isset($custom_url_option)) {
|
303 |
+
$custom_url_option = "";
|
304 |
+
} elseif ($custom_url_option)
|
305 |
+
$custom_url_option = "checked";
|
306 |
+
else
|
307 |
+
$custom_url_option="";
|
308 |
+
|
309 |
+
//custom field name for url
|
310 |
+
$custom_url_field = get_option('top_opt_custom_url_field');
|
311 |
+
if (!isset($custom_url_field)) {
|
312 |
+
$custom_url_field = "";
|
313 |
+
}
|
314 |
+
|
315 |
+
//use url shortner?
|
316 |
+
$use_url_shortner = get_option('top_opt_use_url_shortner');
|
317 |
+
if (!isset($use_url_shortner)) {
|
318 |
+
$use_url_shortner = "";
|
319 |
+
} elseif ($use_url_shortner)
|
320 |
+
$use_url_shortner = "checked";
|
321 |
+
else
|
322 |
+
$use_url_shortner="";
|
323 |
+
|
324 |
+
//url shortner
|
325 |
+
$url_shortener = get_option('top_opt_url_shortener');
|
326 |
+
if (!isset($url_shortener)) {
|
327 |
+
$url_shortener = top_opt_URL_SHORTENER;
|
328 |
+
}
|
329 |
+
|
330 |
+
//bitly key
|
331 |
+
$bitly_api = get_option('top_opt_bitly_key');
|
332 |
+
if (!isset($bitly_api)) {
|
333 |
+
$bitly_api = "";
|
334 |
+
}
|
335 |
+
|
336 |
+
//bitly username
|
337 |
+
$bitly_username = get_option('top_opt_bitly_user');
|
338 |
+
if (!isset($bitly_username)) {
|
339 |
+
$bitly_username = "";
|
340 |
+
}
|
341 |
+
|
342 |
+
//hashtag option
|
343 |
+
$custom_hashtag_option = get_option('top_opt_custom_hashtag_option');
|
344 |
+
if (!isset($custom_hashtag_option)) {
|
345 |
+
$custom_hashtag_option = "nohashtag";
|
346 |
+
}
|
347 |
+
|
348 |
+
//use inline hashtag
|
349 |
+
$use_inline_hashtags = get_option('top_opt_use_inline_hashtags');
|
350 |
+
if (!isset($use_inline_hashtags)) {
|
351 |
+
$use_inline_hashtags = "";
|
352 |
+
} elseif ($use_inline_hashtags)
|
353 |
+
$use_inline_hashtags = "checked";
|
354 |
+
else
|
355 |
+
$use_inline_hashtags="";
|
356 |
+
|
357 |
+
//hashtag length
|
358 |
+
$hashtag_length = get_option('top_opt_hashtag_length');
|
359 |
+
if (!isset($hashtag_length)) {
|
360 |
+
$hashtag_length = "20";
|
361 |
+
}
|
362 |
+
|
363 |
+
//custom field
|
364 |
+
$custom_hashtag_field = get_option('top_opt_custom_hashtag_field');
|
365 |
+
if (!isset($custom_hashtag_field)) {
|
366 |
+
$custom_hashtag_field = "";
|
367 |
+
}
|
368 |
+
|
369 |
+
//default hashtag
|
370 |
+
$twitter_hashtags = get_option('top_opt_hashtags');
|
371 |
+
if (!isset($twitter_hashtags)) {
|
372 |
+
$twitter_hashtags = top_opt_HASHTAGS;
|
373 |
+
}
|
374 |
+
|
375 |
+
//interval
|
376 |
+
$interval = get_option('top_opt_interval');
|
377 |
+
if (!(isset($interval) && is_numeric($interval))) {
|
378 |
+
$interval = top_opt_INTERVAL;
|
379 |
+
}
|
380 |
+
|
381 |
+
//random interval
|
382 |
+
$slop = get_option('top_opt_interval_slop');
|
383 |
+
if (!(isset($slop) && is_numeric($slop))) {
|
384 |
+
$slop = top_opt_INTERVAL_SLOP;
|
385 |
+
}
|
386 |
+
|
387 |
+
//min age limit
|
388 |
+
$ageLimit = get_option('top_opt_age_limit');
|
389 |
+
if (!(isset($ageLimit) && is_numeric($ageLimit))) {
|
390 |
+
$ageLimit = top_opt_AGE_LIMIT;
|
391 |
+
}
|
392 |
+
|
393 |
+
//max age limit
|
394 |
+
$maxAgeLimit = get_option('top_opt_max_age_limit');
|
395 |
+
if (!(isset($maxAgeLimit) && is_numeric($maxAgeLimit))) {
|
396 |
+
$maxAgeLimit = top_opt_MAX_AGE_LIMIT;
|
397 |
+
}
|
398 |
+
|
399 |
+
|
400 |
+
//check enable log
|
401 |
+
$top_enable_log = get_option('top_enable_log');
|
402 |
+
if (!isset($top_enable_log)) {
|
403 |
+
$top_enable_log = "";
|
404 |
+
} elseif ($top_enable_log)
|
405 |
+
$top_enable_log = "checked";
|
406 |
+
else
|
407 |
+
$top_enable_log="";
|
408 |
+
|
409 |
+
//set omitted categories
|
410 |
+
$omitCats = get_option('top_opt_omit_cats');
|
411 |
+
if (!isset($omitCats)) {
|
412 |
+
$omitCats = top_opt_OMIT_CATS;
|
413 |
+
}
|
414 |
+
|
415 |
+
$x = WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
|
416 |
+
|
417 |
+
print('
|
418 |
+
<div class="wrap">
|
419 |
+
<h2>' . __('Tweet old post by - ', 'TweetOldPost') . ' <a href="http://www.ajaymatharu.com">Ajay Matharu</a></h2>
|
420 |
+
<form id="top_opt" name="top_TweetOldPost" action="" method="post">
|
421 |
+
<input type="hidden" name="top_opt_action" value="top_opt_update_settings" />
|
422 |
+
<fieldset class="options">
|
423 |
+
<div class="option">
|
424 |
+
<label for="top_opt_twitter_username">' . __('Account Login', 'TweetOldPost') . ':</label>
|
425 |
+
|
426 |
+
<div id="profile-box">');
|
427 |
+
if (!$settings["oauth_access_token"]) {
|
428 |
+
|
429 |
+
echo '<a href="' . top_get_auth_url() . '"><img src="' . $x . 'images/twitter.png" /></a>';
|
430 |
+
} else {
|
431 |
+
echo '<img class="avatar" src="' . $settings["profile_image_url"] . '" alt="" />
|
432 |
+
<h4>' . $settings["screen_name"] . '</h4>';
|
433 |
+
if ($settings["location"]) {
|
434 |
+
echo '<h5>' . $settings["location"] . '</h5>';
|
435 |
+
}
|
436 |
+
echo '<p>
|
437 |
+
|
438 |
+
Your account has been authorized. <a href="' . $_SERVER["REQUEST_URI"] . '&top=deauthorize" onclick=\'return confirm("Are you sure you want to deauthorize your Twitter account?");\'>Click to deauthorize</a>.<br />
|
439 |
+
|
440 |
+
</p>
|
441 |
+
|
442 |
+
<div class="retweet-clear"></div>
|
443 |
+
';
|
444 |
+
}
|
445 |
+
print('</div>
|
446 |
+
</div>
|
447 |
+
<div class="option">
|
448 |
+
<b> Note: </b>If you are not able to authorize? or Wordpress logs you out on any button click,<br/>
|
449 |
+
|
450 |
+
- If current URL is not showing your current page URL, copy paste the current page URL in Current URL field and press update settings button to update the settings. Then retry to authorize.<br/>
|
451 |
+
|
452 |
+
- If current URL is showing your current page URL, press update settings button to update the settings. Then retry to authorize.
|
453 |
+
|
454 |
+
|
455 |
+
</div>
|
456 |
+
<div class="option">
|
457 |
+
<label for="top_opt_admin_url">' . __('Tweet Old Post Admin URL <br/> (Current URL)', 'TweetOldPost') . ':</label>
|
458 |
+
<input type="text" style="width:500px" id="top_opt_admin_url" value="' . $admin_url . '" name="top_opt_admin_url" /><br/><b>(Note: If this does not show your current URL in this textbox, copy paste the current URL in this textbox)</b>
|
459 |
+
</div>
|
460 |
+
<div class="option">
|
461 |
+
<label for="top_opt_tweet_type">' . __('Tweet Content', 'TweetOldPost') . ':</label>
|
462 |
+
<select id="top_opt_tweet_type" name="top_opt_tweet_type" style="width:150px">
|
463 |
+
<option value="title" ' . top_opt_optionselected("title", $tweet_type) . '>' . __(' Title Only ', 'TweetOldPost') . ' </option>
|
464 |
+
<option value="body" ' . top_opt_optionselected("body", $tweet_type) . '>' . __(' Body Only ', 'TweetOldPost') . ' </option>
|
465 |
+
<option value="titlenbody" ' . top_opt_optionselected("titlenbody", $tweet_type) . '>' . __(' Title & Body ', 'TweetOldPost') . ' </option>
|
466 |
+
</select>
|
467 |
+
|
468 |
+
</div>
|
469 |
+
|
470 |
+
|
471 |
+
<div class="option">
|
472 |
+
<label for="top_opt_add_text">' . __('Additional Text', 'TweetOldPost') . ':</label>
|
473 |
+
<input type="text" size="25" name="top_opt_add_text" id="top_opt_add_text" value="' . $additional_text . '" autocomplete="off" />
|
474 |
+
</div>
|
475 |
+
<div class="option">
|
476 |
+
<label for="top_opt_add_text_at">' . __('Additional Text At', 'TweetOldPost') . ':</label>
|
477 |
+
<select id="top_opt_add_text_at" name="top_opt_add_text_at" style="width:150px">
|
478 |
+
<option value="beginning" ' . top_opt_optionselected("beginning", $additional_text_at) . '>' . __(' Beginning of tweet ', 'TweetOldPost') . '</option>
|
479 |
+
<option value="end" ' . top_opt_optionselected("end", $additional_text_at) . '>' . __(' End of tweet ', 'TweetOldPost') . '</option>
|
480 |
+
</select>
|
481 |
+
</div>
|
482 |
+
|
483 |
+
<div class="option">
|
484 |
+
<label for="top_opt_include_link">' . __('Include Link', 'TweetOldPost') . ':</label>
|
485 |
+
<select id="top_opt_include_link" name="top_opt_include_link" style="width:150px" onchange="javascript:showURLOptions()">
|
486 |
+
<option value="false" ' . top_opt_optionselected("false", $include_link) . '>' . __(' No ', 'TweetOldPost') . '</option>
|
487 |
+
<option value="true" ' . top_opt_optionselected("true", $include_link) . '>' . __(' Yes ', 'TweetOldPost') . '</option>
|
488 |
+
</select>
|
489 |
+
</div>
|
490 |
+
|
491 |
+
<div id="urloptions" style="display:none">
|
492 |
+
|
493 |
+
<div class="option">
|
494 |
+
<label for="top_opt_custom_url_option">' . __('Fetch URL from custom field', 'TweetOldPost') . ':</label>
|
495 |
+
<input onchange="return showCustomField();" type="checkbox" name="top_opt_custom_url_option" ' . $custom_url_option . ' id="top_opt_custom_url_option" />
|
496 |
+
<b>If checked URL will be fetched from custom field.</b>
|
497 |
+
</div>
|
498 |
+
|
499 |
+
|
500 |
+
|
501 |
+
<div id="customurl" style="display:none;">
|
502 |
+
<div class="option">
|
503 |
+
<label for="top_opt_custom_url_field">' . __('Custom field name to fetch URL to be tweeted with post', 'TweetOldPost') . ':</label>
|
504 |
+
<input type="text" size="25" name="top_opt_custom_url_field" id="top_opt_custom_url_field" value="' . $custom_url_field . '" autocomplete="off" />
|
505 |
+
<b>If set this will fetch the URL from specified custom field</b>
|
506 |
+
</div>
|
507 |
+
|
508 |
+
</div>
|
509 |
+
|
510 |
+
<div class="option">
|
511 |
+
<label for="top_opt_use_url_shortner">' . __('Use URL shortner?', 'TweetOldPost') . ':</label>
|
512 |
+
<input onchange="return showshortener()" type="checkbox" name="top_opt_use_url_shortner" id="top_opt_use_url_shortner" ' . $use_url_shortner . ' />
|
513 |
+
|
514 |
+
</div>
|
515 |
+
|
516 |
+
<div id="urlshortener">
|
517 |
+
<div class="option">
|
518 |
+
<label for="top_opt_url_shortener">' . __('URL Shortener Service', 'TweetOldPost') . ':</label>
|
519 |
+
<select name="top_opt_url_shortener" id="top_opt_url_shortener" onchange="javascript:showURLAPI()" style="width:100px;">
|
520 |
+
<option value="is.gd" ' . top_opt_optionselected('is.gd', $url_shortener) . '>' . __('is.gd', 'TweetOldPost') . '</option>
|
521 |
+
<option value="su.pr" ' . top_opt_optionselected('su.pr', $url_shortener) . '>' . __('su.pr', 'TweetOldPost') . '</option>
|
522 |
+
<option value="bit.ly" ' . top_opt_optionselected('bit.ly', $url_shortener) . '>' . __('bit.ly', 'TweetOldPost') . '</option>
|
523 |
+
<option value="tr.im" ' . top_opt_optionselected('tr.im', $url_shortener) . '>' . __('tr.im', 'TweetOldPost') . '</option>
|
524 |
+
<option value="3.ly" ' . top_opt_optionselected('3.ly', $url_shortener) . '>' . __('3.ly', 'TweetOldPost') . '</option>
|
525 |
+
<option value="u.nu" ' . top_opt_optionselected('u.nu', $url_shortener) . '>' . __('u.nu', 'TweetOldPost') . '</option>
|
526 |
+
<option value="1click.at" ' . top_opt_optionselected('1click.at', $url_shortener) . '>' . __('1click.at', 'TweetOldPost') . '</option>
|
527 |
+
<option value="tinyurl" ' . top_opt_optionselected('tinyurl', $url_shortener) . '>' . __('tinyurl', 'TweetOldPost') . '</option>
|
528 |
+
</select>
|
529 |
+
</div>
|
530 |
+
<div id="showDetail" style="display:none">
|
531 |
+
<div class="option">
|
532 |
+
<label for="top_opt_bitly_user">' . __('bit.ly Username', 'TweetOldPost') . ':</label>
|
533 |
+
<input type="text" size="25" name="top_opt_bitly_user" id="top_opt_bitly_user" value="' . $bitly_username . '" autocomplete="off" />
|
534 |
+
</div>
|
535 |
+
|
536 |
+
<div class="option">
|
537 |
+
<label for="top_opt_bitly_key">' . __('bit.ly API Key', 'TweetOldPost') . ':</label>
|
538 |
+
<input type="text" size="25" name="top_opt_bitly_key" id="top_opt_bitly_key" value="' . $bitly_api . '" autocomplete="off" />
|
539 |
+
</div>
|
540 |
+
</div>
|
541 |
+
</div>
|
542 |
+
</div>
|
543 |
+
|
544 |
+
|
545 |
+
<div class="option">
|
546 |
+
<label for="top_opt_custom_hashtag_option">' . __('Hashtags', 'TweetOldPost') . ':</label>
|
547 |
+
<select name="top_opt_custom_hashtag_option" id="top_opt_custom_hashtag_option" onchange="javascript:return showHashtagCustomField()" style="width:250px;">
|
548 |
+
<option value="nohashtag" ' . top_opt_optionselected('nohashtag', $custom_hashtag_option) . '>' . __('Don`t add any hashtags', 'TweetOldPost') . '</option>
|
549 |
+
<option value="common" ' . top_opt_optionselected('common', $custom_hashtag_option) . '>' . __('Common hashtag for all tweets', 'TweetOldPost') . '</option>
|
550 |
+
<option value="categories" ' . top_opt_optionselected('categories', $custom_hashtag_option) . '>' . __('Create hashtags from categories', 'TweetOldPost') . '</option>
|
551 |
+
<option value="tags" ' . top_opt_optionselected('tags', $custom_hashtag_option) . '>' . __('Create hashtags from tags', 'TweetOldPost') . '</option>
|
552 |
+
<option value="custom" ' . top_opt_optionselected('custom', $custom_hashtag_option) . '>' . __('Get hashtags from custom fields', 'TweetOldPost') . '</option>
|
553 |
+
|
554 |
+
</select>
|
555 |
+
|
556 |
+
|
557 |
+
</div>
|
558 |
+
<div id="inlinehashtag" style="display:none;">
|
559 |
+
<div class="option">
|
560 |
+
<label for="top_opt_use_inline_hashtags">' . __('Use inline hashtags: ', 'TweetOldPost') . '</label>
|
561 |
+
<input type="checkbox" name="top_opt_use_inline_hashtags" id="top_opt_use_inline_hashtags" ' . $use_inline_hashtags . ' />
|
562 |
+
|
563 |
+
</div>
|
564 |
+
|
565 |
+
<div class="option">
|
566 |
+
<label for="top_opt_hashtag_length">' . __('Maximum Hashtag length: ', 'TweetOldPost') . '</label>
|
567 |
+
<input type="text" size="25" name="top_opt_hashtag_length" id="top_opt_hashtag_length" value="' . $hashtag_length . '" />
|
568 |
+
<b>Set this to 0 to include all hashtags</b>
|
569 |
+
</div>
|
570 |
+
</div>
|
571 |
+
<div id="customhashtag" style="display:none;">
|
572 |
+
<div class="option">
|
573 |
+
<label for="top_opt_custom_hashtag_field">' . __('Custom field name', 'TweetOldPost') . ':</label>
|
574 |
+
<input type="text" size="25" name="top_opt_custom_hashtag_field" id="top_opt_custom_hashtag_field" value="' . $custom_hashtag_field . '" autocomplete="off" />
|
575 |
+
<b>fetch hashtags from this custom field</b>
|
576 |
+
</div>
|
577 |
+
|
578 |
+
</div>
|
579 |
+
<div id="commonhashtag" style="display:none;">
|
580 |
+
<div class="option">
|
581 |
+
<label for="top_opt_hashtags">' . __('Common #hashtags for your tweets', 'TweetOldPost') . ':</label>
|
582 |
+
<input type="text" size="25" name="top_opt_hashtags" id="top_opt_hashtags" value="' . $twitter_hashtags . '" autocomplete="off" />
|
583 |
+
<b>Include #, like #thoughts</b>
|
584 |
+
</div>
|
585 |
+
</div>
|
586 |
+
<div class="option">
|
587 |
+
<label for="top_opt_interval">' . __('Minimum interval between tweets: ', 'TweetOldPost') . '</label>
|
588 |
+
<input type="text" id="top_opt_interval" maxlength="5" value="' . $interval . '" name="top_opt_interval" /> Hour / Hours <b>(Note: If set to 0 it will take default as 4 hours)</b>
|
589 |
+
|
590 |
+
</div>
|
591 |
+
<div class="option">
|
592 |
+
<label for="top_opt_interval_slop">' . __('Random Interval (added to minimum interval): ', 'TweetOldPost') . '</label>
|
593 |
+
<input type="text" id="top_opt_interval_slop" maxlength="5" value="' . $slop . '" name="top_opt_interval_slop" /> Hour / Hours <b>(Note: If set to 0 it will take default as 4 hours)</b>
|
594 |
+
|
595 |
+
</div>
|
596 |
+
<div class="option">
|
597 |
+
<label for="top_opt_age_limit">' . __('Minimum age of post to be eligible for tweet: ', 'TweetOldPost') . '</label>
|
598 |
+
<input type="text" id="top_opt_age_limit" maxlength="5" value="' . $ageLimit . '" name="top_opt_age_limit" /> Day / Days
|
599 |
+
<b> (enter 0 for today)</b>
|
600 |
+
|
601 |
+
</div>
|
602 |
+
|
603 |
+
<div class="option">
|
604 |
+
<label for="top_opt_max_age_limit">' . __('Maximum age of post to be eligible for tweet: ', 'TweetOldPost') . '</label>
|
605 |
+
<input type="text" id="top_opt_max_age_limit" maxlength="5" value="' . $maxAgeLimit . '" name="top_opt_max_age_limit" /> Day / Days
|
606 |
+
<b>(If you dont want to use this option enter 0 or leave blank)</b><br/>
|
607 |
+
<b>Post older than specified days will not be tweeted.</b>
|
608 |
+
</div>
|
609 |
+
|
610 |
+
|
611 |
+
|
612 |
+
|
613 |
+
|
614 |
+
|
615 |
+
<div class="option">
|
616 |
+
<label for="top_enable_log">' . __('Enable Log: ', 'TweetOldPost') . '</label>
|
617 |
+
<input type="checkbox" name="top_enable_log" id="top_enable_log" ' . $top_enable_log . ' />
|
618 |
+
<b>saves log in log folder</b>
|
619 |
+
|
620 |
+
</div>
|
621 |
+
|
622 |
+
|
623 |
+
<div class="option category">
|
624 |
+
<div style="float:left">
|
625 |
+
<label class="catlabel">' . __('Categories to Omit from tweets: ', 'TweetOldPost') . '</label> </div>
|
626 |
+
<div style="float:left">
|
627 |
+
<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
|
628 |
+
');
|
629 |
+
wp_category_checklist(0, 0, explode(',', $omitCats));
|
630 |
+
print(' </ul>
|
631 |
+
<div style="clear:both;padding-top:20px;">
|
632 |
+
<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=ExcludePosts">Exclude specific posts</a> from selected categories.
|
633 |
+
</div>
|
634 |
+
|
635 |
+
|
636 |
+
</div>
|
637 |
+
|
638 |
+
</div>
|
639 |
+
</fieldset>
|
640 |
+
|
641 |
+
|
642 |
+
|
643 |
+
<h3>Note: Please click update to then click tweet now to reflect the changes.</h3>
|
644 |
+
<p class="submit"><input type="submit" name="submit" onclick="javascript:return validate()" value="' . __('Update Tweet Old Post Options', 'TweetOldPost') . '" />
|
645 |
+
<input type="submit" name="tweet" value="' . __('Tweet Now', 'TweetOldPost') . '" />
|
646 |
+
<input type="submit" onclick=\'return confirm("This will reset all the setting, including your account, omitted categories and excluded posts. Are you sure you want to reset all the settings?");\' name="reset" value="' . __('Reset Settings', 'TweetOldPost') . '" />
|
647 |
+
</p>
|
648 |
+
|
649 |
+
</form><script language="javascript" type="text/javascript">
|
650 |
+
function showURLAPI()
|
651 |
+
{
|
652 |
+
var urlShortener=document.getElementById("top_opt_url_shortener").value;
|
653 |
+
if(urlShortener=="bit.ly")
|
654 |
+
{
|
655 |
+
document.getElementById("showDetail").style.display="block";
|
656 |
+
|
657 |
+
}
|
658 |
+
else
|
659 |
+
{
|
660 |
+
document.getElementById("showDetail").style.display="none";
|
661 |
+
|
662 |
+
}
|
663 |
+
|
664 |
+
}
|
665 |
+
|
666 |
+
function validate()
|
667 |
+
{
|
668 |
+
|
669 |
+
if(document.getElementById("showDetail").style.display=="block" && document.getElementById("top_opt_url_shortener").value=="bit.ly")
|
670 |
+
{
|
671 |
+
if(trim(document.getElementById("top_opt_bitly_user").value)=="")
|
672 |
+
{
|
673 |
+
alert("Please enter bit.ly username.");
|
674 |
+
document.getElementById("top_opt_bitly_user").focus();
|
675 |
+
return false;
|
676 |
+
}
|
677 |
+
|
678 |
+
if(trim(document.getElementById("top_opt_bitly_key").value)=="")
|
679 |
+
{
|
680 |
+
alert("Please enter bit.ly API key.");
|
681 |
+
document.getElementById("top_opt_bitly_key").focus();
|
682 |
+
return false;
|
683 |
+
}
|
684 |
+
}
|
685 |
+
if(trim(document.getElementById("top_opt_interval").value) != "" && !isNumber(trim(document.getElementById("top_opt_interval").value)))
|
686 |
+
{
|
687 |
+
alert("Enter only numeric in Minimum interval between tweet");
|
688 |
+
document.getElementById("top_opt_interval").focus();
|
689 |
+
return false;
|
690 |
+
}
|
691 |
+
if(trim(document.getElementById("top_opt_interval_slop").value) != "" && !isNumber(trim(document.getElementById("top_opt_interval_slop").value)))
|
692 |
+
{
|
693 |
+
alert("Enter only numeric in Random interval");
|
694 |
+
document.getElementById("top_opt_interval_slop").focus();
|
695 |
+
return false;
|
696 |
+
}
|
697 |
+
if(trim(document.getElementById("top_opt_age_limit").value) != "" && !isNumber(trim(document.getElementById("top_opt_age_limit").value)))
|
698 |
+
{
|
699 |
+
alert("Enter only numeric in Minimum age of post");
|
700 |
+
document.getElementById("top_opt_age_limit").focus();
|
701 |
+
return false;
|
702 |
+
}
|
703 |
+
if(trim(document.getElementById("top_opt_max_age_limit").value) != "" && !isNumber(trim(document.getElementById("top_opt_max_age_limit").value)))
|
704 |
+
{
|
705 |
+
alert("Enter only numeric in Maximum age of post");
|
706 |
+
document.getElementById("top_opt_max_age_limit").focus();
|
707 |
+
return false;
|
708 |
+
}
|
709 |
+
if(trim(document.getElementById("top_opt_max_age_limit").value) != "" && trim(document.getElementById("top_opt_max_age_limit").value) != 0)
|
710 |
+
{
|
711 |
+
if(eval(document.getElementById("top_opt_age_limit").value) > eval(document.getElementById("top_opt_max_age_limit").value))
|
712 |
+
{
|
713 |
+
alert("Post max age limit cannot be less than Post min age iimit");
|
714 |
+
document.getElementById("top_opt_age_limit").focus();
|
715 |
+
return false;
|
716 |
+
}
|
717 |
+
}
|
718 |
+
}
|
719 |
+
|
720 |
+
function trim(stringToTrim) {
|
721 |
+
return stringToTrim.replace(/^\s+|\s+$/g,"");
|
722 |
+
}
|
723 |
+
|
724 |
+
function showCustomField()
|
725 |
+
{
|
726 |
+
if(document.getElementById("top_opt_custom_url_option").checked)
|
727 |
+
{
|
728 |
+
document.getElementById("customurl").style.display="block";
|
729 |
+
}
|
730 |
+
else
|
731 |
+
{
|
732 |
+
document.getElementById("customurl").style.display="none";
|
733 |
+
}
|
734 |
+
}
|
735 |
+
|
736 |
+
function showHashtagCustomField()
|
737 |
+
{
|
738 |
+
if(document.getElementById("top_opt_custom_hashtag_option").value=="custom")
|
739 |
+
{
|
740 |
+
document.getElementById("customhashtag").style.display="block";
|
741 |
+
document.getElementById("commonhashtag").style.display="none";
|
742 |
+
document.getElementById("inlinehashtag").style.display="block";
|
743 |
+
}
|
744 |
+
else if(document.getElementById("top_opt_custom_hashtag_option").value=="common")
|
745 |
+
{
|
746 |
+
document.getElementById("customhashtag").style.display="none";
|
747 |
+
document.getElementById("commonhashtag").style.display="block";
|
748 |
+
document.getElementById("inlinehashtag").style.display="block";
|
749 |
+
}
|
750 |
+
else if(document.getElementById("top_opt_custom_hashtag_option").value=="nohashtag")
|
751 |
+
{
|
752 |
+
document.getElementById("customhashtag").style.display="none";
|
753 |
+
document.getElementById("commonhashtag").style.display="none";
|
754 |
+
document.getElementById("inlinehashtag").style.display="none";
|
755 |
+
}
|
756 |
+
else
|
757 |
+
{
|
758 |
+
document.getElementById("inlinehashtag").style.display="block";
|
759 |
+
document.getElementById("customhashtag").style.display="none";
|
760 |
+
document.getElementById("commonhashtag").style.display="none";
|
761 |
+
}
|
762 |
+
}
|
763 |
+
|
764 |
+
function showURLOptions()
|
765 |
+
{
|
766 |
+
if(document.getElementById("top_opt_include_link").value=="true")
|
767 |
+
{
|
768 |
+
document.getElementById("urloptions").style.display="block";
|
769 |
+
}
|
770 |
+
else
|
771 |
+
{
|
772 |
+
document.getElementById("urloptions").style.display="none";
|
773 |
+
}
|
774 |
+
}
|
775 |
+
|
776 |
+
function isNumber(val)
|
777 |
+
{
|
778 |
+
if(isNaN(val)){
|
779 |
+
return false;
|
780 |
+
}
|
781 |
+
else{
|
782 |
+
return true;
|
783 |
+
}
|
784 |
+
}
|
785 |
+
|
786 |
+
function showshortener()
|
787 |
+
{
|
788 |
+
|
789 |
+
|
790 |
+
if((document.getElementById("top_opt_use_url_shortner").checked))
|
791 |
+
{
|
792 |
+
document.getElementById("urlshortener").style.display="block";
|
793 |
+
}
|
794 |
+
else
|
795 |
+
{
|
796 |
+
document.getElementById("urlshortener").style.display="none";
|
797 |
+
}
|
798 |
+
}
|
799 |
+
function setFormAction()
|
800 |
+
{
|
801 |
+
if(document.getElementById("top_opt_admin_url").value == "")
|
802 |
+
{
|
803 |
+
document.getElementById("top_opt_admin_url").value=location.href;
|
804 |
+
document.getElementById("top_opt").action=location.href;
|
805 |
+
}
|
806 |
+
else
|
807 |
+
{
|
808 |
+
document.getElementById("top_opt").action=document.getElementById("top_opt_admin_url").value;
|
809 |
+
}
|
810 |
+
}
|
811 |
+
|
812 |
+
setFormAction();
|
813 |
+
showURLAPI();
|
814 |
+
showshortener();
|
815 |
+
showCustomField();
|
816 |
+
showHashtagCustomField();
|
817 |
+
showURLOptions();
|
818 |
+
|
819 |
+
</script>');
|
820 |
+
} else {
|
821 |
+
print('
|
822 |
+
<div id="message" class="updated fade">
|
823 |
+
<p>' . __('You do not have enough permission to set the option. Please contact your admin.', 'TweetOldPost') . '</p>
|
824 |
+
</div>');
|
825 |
+
}
|
826 |
+
}
|
827 |
+
|
828 |
+
function top_opt_optionselected($opValue, $value) {
|
829 |
+
if ($opValue == $value) {
|
830 |
+
return 'selected="selected"';
|
831 |
+
}
|
832 |
+
return '';
|
833 |
+
}
|
834 |
+
|
835 |
+
function top_opt_head_admin() {
|
836 |
+
$home = get_settings('siteurl');
|
837 |
+
$base = '/' . end(explode('/', str_replace(array('\\', '/top-admin.php'), array('/', ''), __FILE__)));
|
838 |
+
$stylesheet = $home . '/wp-content/plugins' . $base . '/css/tweet-old-post.css';
|
839 |
+
echo('<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />');
|
840 |
+
}
|
841 |
+
|
842 |
+
?>
|
top-core.php
ADDED
@@ -0,0 +1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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once( 'Include/top-oauth.php' );
|
4 |
+
global $top_oauth;
|
5 |
+
$top_oauth = new TOPOAuth;
|
6 |
+
|
7 |
+
function top_tweet_old_post() {
|
8 |
+
//check last tweet time against set interval and span
|
9 |
+
if (top_opt_update_time()) {
|
10 |
+
update_option('top_opt_last_update', time());
|
11 |
+
top_opt_tweet_old_post();
|
12 |
+
}
|
13 |
+
}
|
14 |
+
|
15 |
+
function top_currentPageURL() {
|
16 |
+
|
17 |
+
if(!isset($_SERVER['REQUEST_URI'])){
|
18 |
+
$serverrequri = $_SERVER['PHP_SELF'];
|
19 |
+
}else{
|
20 |
+
$serverrequri = $_SERVER['REQUEST_URI'];
|
21 |
+
}
|
22 |
+
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
|
23 |
+
$protocol = top_strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
|
24 |
+
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
|
25 |
+
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$serverrequri;
|
26 |
+
|
27 |
+
|
28 |
+
}
|
29 |
+
|
30 |
+
function top_strleft($s1, $s2) {
|
31 |
+
return substr($s1, 0, strpos($s1, $s2));
|
32 |
+
}
|
33 |
+
|
34 |
+
//get random post and tweet
|
35 |
+
function top_opt_tweet_old_post() {
|
36 |
+
return top_generate_query();
|
37 |
+
}
|
38 |
+
|
39 |
+
function top_generate_query($can_requery = true)
|
40 |
+
{
|
41 |
+
global $wpdb;
|
42 |
+
$rtrn_msg="";
|
43 |
+
$omitCats = get_option('top_opt_omit_cats');
|
44 |
+
$maxAgeLimit = get_option('top_opt_max_age_limit');
|
45 |
+
$ageLimit = get_option('top_opt_age_limit');
|
46 |
+
$exposts = get_option('top_opt_excluded_post');
|
47 |
+
$exposts = preg_replace('/,,+/', ',', $exposts);
|
48 |
+
|
49 |
+
$top_opt_tweeted_posts = array();
|
50 |
+
$top_opt_tweeted_posts = get_option('top_opt_tweeted_posts');
|
51 |
+
|
52 |
+
if(!$top_opt_tweeted_posts)
|
53 |
+
$top_opt_tweeted_posts = array();
|
54 |
+
|
55 |
+
if($top_opt_tweeted_posts != null)
|
56 |
+
$already_tweeted = implode(",", $top_opt_tweeted_posts);
|
57 |
+
else
|
58 |
+
$already_tweeted="";
|
59 |
+
|
60 |
+
if (substr($exposts, 0, 1) == ",") {
|
61 |
+
$exposts = substr($exposts, 1, strlen($exposts));
|
62 |
+
}
|
63 |
+
if (substr($exposts, -1, 1) == ",") {
|
64 |
+
$exposts = substr($exposts, 0, strlen($exposts) - 1);
|
65 |
+
}
|
66 |
+
|
67 |
+
if (!(isset($ageLimit) && is_numeric($ageLimit))) {
|
68 |
+
$ageLimit = top_opt_AGE_LIMIT;
|
69 |
+
}
|
70 |
+
|
71 |
+
if (!(isset($maxAgeLimit) && is_numeric($maxAgeLimit))) {
|
72 |
+
$maxAgeLimit = top_opt_MAX_AGE_LIMIT;
|
73 |
+
}
|
74 |
+
if (!isset($omitCats)) {
|
75 |
+
$omitCats = top_opt_OMIT_CATS;
|
76 |
+
}
|
77 |
+
|
78 |
+
$sql = "SELECT ID
|
79 |
+
FROM $wpdb->posts
|
80 |
+
WHERE post_type = 'post'
|
81 |
+
AND post_status = 'publish' ";
|
82 |
+
|
83 |
+
if(is_numeric($ageLimit))
|
84 |
+
{
|
85 |
+
if($ageLimit > 0)
|
86 |
+
$sql = $sql . " AND post_date <= curdate( ) - INTERVAL " . $ageLimit . " day";
|
87 |
+
}
|
88 |
+
|
89 |
+
if ($maxAgeLimit != 0) {
|
90 |
+
$sql = $sql . " AND post_date >= curdate( ) - INTERVAL " . $maxAgeLimit . " day";
|
91 |
+
}
|
92 |
+
|
93 |
+
if (isset($exposts)) {
|
94 |
+
if (trim($exposts) != '') {
|
95 |
+
$sql = $sql . " AND ID Not IN (" . $exposts . ") ";
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
if (isset($already_tweeted)) {
|
100 |
+
if(trim($already_tweeted) !="")
|
101 |
+
{
|
102 |
+
$sql = $sql . " AND ID Not IN (" . $already_tweeted . ") ";
|
103 |
+
}
|
104 |
+
}
|
105 |
+
if ($omitCats != '') {
|
106 |
+
$sql = $sql . " AND NOT (ID IN (SELECT tr.object_id FROM " . $wpdb->prefix . "term_relationships AS tr INNER JOIN " . $wpdb->prefix . "term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN (" . $omitCats . ")))";
|
107 |
+
}
|
108 |
+
$sql = $sql . "
|
109 |
+
ORDER BY RAND()
|
110 |
+
LIMIT 1 ";
|
111 |
+
|
112 |
+
$oldest_post = $wpdb->get_var($sql);
|
113 |
+
|
114 |
+
if($oldest_post == null)
|
115 |
+
{
|
116 |
+
if($can_requery)
|
117 |
+
{
|
118 |
+
$top_opt_tweeted_posts=array();
|
119 |
+
update_option('top_opt_tweeted_posts', $top_opt_tweeted_posts);
|
120 |
+
return top_generate_query(false);
|
121 |
+
}
|
122 |
+
else
|
123 |
+
{
|
124 |
+
return "No post found to tweet. Please check your settings and try again.";
|
125 |
+
}
|
126 |
+
}
|
127 |
+
if (isset($oldest_post)) {
|
128 |
+
array_push($top_opt_tweeted_posts, $oldest_post);
|
129 |
+
update_option('top_opt_tweeted_posts', $top_opt_tweeted_posts);
|
130 |
+
return top_opt_tweet_post($oldest_post);
|
131 |
+
}
|
132 |
+
return $rtrn_msg;
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
//tweet for the passed random post
|
137 |
+
function top_opt_tweet_post($oldest_post) {
|
138 |
+
global $wpdb;
|
139 |
+
$post = get_post($oldest_post);
|
140 |
+
$content = "";
|
141 |
+
$to_short_url = true;
|
142 |
+
$shorturl = "";
|
143 |
+
$tweet_type = get_option('top_opt_tweet_type');
|
144 |
+
$additional_text = get_option('top_opt_add_text');
|
145 |
+
$additional_text_at = get_option('top_opt_add_text_at');
|
146 |
+
$include_link = get_option('top_opt_include_link');
|
147 |
+
$custom_hashtag_option = get_option('top_opt_custom_hashtag_option');
|
148 |
+
$custom_hashtag_field = get_option('top_opt_custom_hashtag_field');
|
149 |
+
$twitter_hashtags = get_option('top_opt_hashtags');
|
150 |
+
$url_shortener = get_option('top_opt_url_shortener');
|
151 |
+
$custom_url_option = get_option('top_opt_custom_url_option');
|
152 |
+
$to_short_url = get_option('top_opt_use_url_shortner');
|
153 |
+
$use_inline_hashtags = get_option('top_opt_use_inline_hashtags');
|
154 |
+
$hashtag_length = get_option('top_opt_hashtag_length');
|
155 |
+
|
156 |
+
if ($include_link != "false") {
|
157 |
+
$permalink = get_permalink($oldest_post);
|
158 |
+
|
159 |
+
if ($custom_url_option) {
|
160 |
+
$custom_url_field = get_option('top_opt_custom_url_field');
|
161 |
+
if (trim($custom_url_field) != "") {
|
162 |
+
$permalink = trim(get_post_meta($post->ID, $custom_url_field, true));
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
if ($to_short_url) {
|
167 |
+
|
168 |
+
if ($url_shortener == "bit.ly") {
|
169 |
+
$bitly_key = get_option('top_opt_bitly_key');
|
170 |
+
$bitly_user = get_option('top_opt_bitly_user');
|
171 |
+
$shorturl = shorten_url($permalink, $url_shortener, $bitly_key, $bitly_user);
|
172 |
+
} else {
|
173 |
+
$shorturl = shorten_url($permalink, $url_shortener);
|
174 |
+
}
|
175 |
+
} else {
|
176 |
+
$shorturl = $permalink;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
if ($tweet_type == "title" || $tweet_type == "titlenbody") {
|
181 |
+
$title = stripslashes($post->post_title);
|
182 |
+
$title = strip_tags($title);
|
183 |
+
$title = preg_replace('/\s\s+/', ' ', $title);
|
184 |
+
} else {
|
185 |
+
$title = "";
|
186 |
+
}
|
187 |
+
|
188 |
+
if ($tweet_type == "body" || $tweet_type == "titlenbody") {
|
189 |
+
$body = stripslashes($post->post_content);
|
190 |
+
$body = strip_tags($body);
|
191 |
+
$body = preg_replace('/\s\s+/', ' ', $body);
|
192 |
+
} else {
|
193 |
+
$body = "";
|
194 |
+
}
|
195 |
+
|
196 |
+
if ($tweet_type == "titlenbody") {
|
197 |
+
if ($title == null) {
|
198 |
+
$content = $body;
|
199 |
+
} elseif ($body == null) {
|
200 |
+
$content = $title;
|
201 |
+
} else {
|
202 |
+
$content = $title . " - " . $body;
|
203 |
+
}
|
204 |
+
} elseif ($tweet_type == "title") {
|
205 |
+
$content = $title;
|
206 |
+
} elseif ($tweet_type == "body") {
|
207 |
+
$content = $body;
|
208 |
+
}
|
209 |
+
|
210 |
+
if ($additional_text != "") {
|
211 |
+
if ($additional_text_at == "end") {
|
212 |
+
$content = $content . ". " . $additional_text;
|
213 |
+
} elseif ($additional_text_at == "beginning") {
|
214 |
+
$content = $additional_text . ": " . $content;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
$hashtags = "";
|
219 |
+
$newcontent = "";
|
220 |
+
if ($custom_hashtag_option != "nohashtag") {
|
221 |
+
|
222 |
+
if ($custom_hashtag_option == "common") {
|
223 |
+
//common hashtag
|
224 |
+
$hashtags = $twitter_hashtags;
|
225 |
+
}
|
226 |
+
//post custom field hashtag
|
227 |
+
elseif ($custom_hashtag_option == "custom") {
|
228 |
+
if (trim($custom_hashtag_field) != "") {
|
229 |
+
$hashtags = trim(get_post_meta($post->ID, $custom_hashtag_field, true));
|
230 |
+
}
|
231 |
+
} elseif ($custom_hashtag_option == "categories") {
|
232 |
+
$post_categories = get_the_category($post->ID);
|
233 |
+
if ($post_categories) {
|
234 |
+
foreach ($post_categories as $category) {
|
235 |
+
$tagname = str_replace(".", "", str_replace(" ", "_", $category->cat_name));
|
236 |
+
if ($use_inline_hashtags) {
|
237 |
+
if (strrpos($content, $tagname) === false) {
|
238 |
+
$hashtags = $hashtags . "#" . $tagname . " ";
|
239 |
+
} else {
|
240 |
+
$newcontent = preg_replace('/\b' . $tagname . '\b/i', "#" . $tagname, $content, 1);
|
241 |
+
}
|
242 |
+
} else {
|
243 |
+
$hashtags = $hashtags . "#" . $tagname . " ";
|
244 |
+
}
|
245 |
+
}
|
246 |
+
}
|
247 |
+
} elseif ($custom_hashtag_option == "tags") {
|
248 |
+
$post_tags = get_the_tags($post->ID);
|
249 |
+
if ($post_tags) {
|
250 |
+
foreach ($post_tags as $tag) {
|
251 |
+
$tagname = str_replace(".", "", str_replace(" ", "_", $tag->name));
|
252 |
+
if ($use_inline_hashtags) {
|
253 |
+
if (strrpos($content, $tagname) === false) {
|
254 |
+
$hashtags = $hashtags . "#" . $tagname . " ";
|
255 |
+
} else {
|
256 |
+
$newcontent = preg_replace('/\b' . $tagname . '\b/i', "#" . $tagname, $content, 1);
|
257 |
+
}
|
258 |
+
} else {
|
259 |
+
$hashtags = $hashtags . "#" . $tagname . " ";
|
260 |
+
}
|
261 |
+
}
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
if ($newcontent != "")
|
266 |
+
$content = $newcontent;
|
267 |
+
}
|
268 |
+
|
269 |
+
|
270 |
+
|
271 |
+
if ($include_link != "false") {
|
272 |
+
if (!is_numeric($shorturl) && (strncmp($shorturl, "http", strlen("http")) == 0)) {
|
273 |
+
|
274 |
+
} else {
|
275 |
+
return "OOPS!!! problem with your URL shortning service. Some signs of error " . $shorturl . ".";
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
$message = set_tweet_length($content, $shorturl, $hashtags, $hashtag_length);
|
280 |
+
$status = urlencode(stripslashes(urldecode($message)));
|
281 |
+
if ($status) {
|
282 |
+
$poststatus = top_update_status($message);
|
283 |
+
if ($poststatus == true)
|
284 |
+
return "Whoopie!!! Tweet Posted Successfully";
|
285 |
+
else
|
286 |
+
return "OOPS!!! there seems to be some problem while tweeting. Please try again.";
|
287 |
+
}
|
288 |
+
return "OOPS!!! there seems to be some problem while tweeting. Try again. If problem is persistent mail the problem at ajay@ajaymatharu.com";
|
289 |
+
}
|
290 |
+
|
291 |
+
//send request to passed url and return the response
|
292 |
+
function send_request($url, $method='GET', $data='', $auth_user='', $auth_pass='') {
|
293 |
+
$ch = curl_init($url);
|
294 |
+
if (strtoupper($method) == "POST") {
|
295 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
296 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
297 |
+
}
|
298 |
+
if (ini_get('open_basedir') == '' && ini_get('safe_mode') == 'Off') {
|
299 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
300 |
+
}
|
301 |
+
curl_setopt($ch, CURLOPT_HEADER, 0);
|
302 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
303 |
+
if ($auth_user != '' && $auth_pass != '') {
|
304 |
+
curl_setopt($ch, CURLOPT_USERPWD, "{$auth_user}:{$auth_pass}");
|
305 |
+
}
|
306 |
+
$response = curl_exec($ch);
|
307 |
+
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
308 |
+
curl_close($ch);
|
309 |
+
if ($httpcode != 200) {
|
310 |
+
return $httpcode;
|
311 |
+
}
|
312 |
+
|
313 |
+
return $response;
|
314 |
+
}
|
315 |
+
|
316 |
+
|
317 |
+
/* returns a result form url */
|
318 |
+
function top_curl_get_result($url) {
|
319 |
+
$ch = curl_init();
|
320 |
+
$timeout = 5;
|
321 |
+
curl_setopt($ch,CURLOPT_URL,$url);
|
322 |
+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
|
323 |
+
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
|
324 |
+
$data = curl_exec($ch);
|
325 |
+
curl_close($ch);
|
326 |
+
return $data;
|
327 |
+
}
|
328 |
+
|
329 |
+
function top_get_bitly_short_url($url,$login,$appkey,$format='txt') {
|
330 |
+
$connectURL = 'http://api.bit.ly/v3/shorten?login='.$login.'&apiKey='.$appkey.'&uri='.urlencode($url).'&format='.$format;
|
331 |
+
return top_curl_get_result($connectURL);
|
332 |
+
}
|
333 |
+
|
334 |
+
//Shorten long URLs with is.gd or bit.ly.
|
335 |
+
function shorten_url($the_url, $shortener='is.gd', $api_key='', $user='') {
|
336 |
+
|
337 |
+
if (($shortener == "bit.ly") && isset($api_key) && isset($user)) {
|
338 |
+
$response = top_get_bitly_short_url($the_url, $user, $api_key);
|
339 |
+
} elseif ($shortener == "su.pr") {
|
340 |
+
$url = "http://su.pr/api/simpleshorten?url={$the_url}";
|
341 |
+
$response = send_request($url, 'GET');
|
342 |
+
} elseif ($shortener == "tr.im") {
|
343 |
+
$url = "http://api.tr.im/api/trim_simple?url={$the_url}";
|
344 |
+
$response = send_request($url, 'GET');
|
345 |
+
} elseif ($shortener == "3.ly") {
|
346 |
+
$url = "http://3.ly/?api=em5893833&u={$the_url}";
|
347 |
+
$response = send_request($url, 'GET');
|
348 |
+
} elseif ($shortener == "tinyurl") {
|
349 |
+
$url = "http://tinyurl.com/api-create.php?url={$the_url}";
|
350 |
+
$response = send_request($url, 'GET');
|
351 |
+
} elseif ($shortener == "u.nu") {
|
352 |
+
$url = "http://u.nu/unu-api-simple?url={$the_url}";
|
353 |
+
$response = send_request($url, 'GET');
|
354 |
+
} elseif ($shortener == "1click.at") {
|
355 |
+
$url = "http://1click.at/api.php?action=shorturl&url={$the_url}&format=simple";
|
356 |
+
$response = send_request($url, 'GET');
|
357 |
+
} else {
|
358 |
+
$url = "http://is.gd/api.php?longurl={$the_url}";
|
359 |
+
$response = send_request($url, 'GET');
|
360 |
+
}
|
361 |
+
|
362 |
+
return $response;
|
363 |
+
}
|
364 |
+
|
365 |
+
//Shrink a tweet and accompanying URL down to 140 chars.
|
366 |
+
function set_tweet_length($message, $url, $twitter_hashtags="", $hashtag_length=0) {
|
367 |
+
|
368 |
+
$tags = $twitter_hashtags;
|
369 |
+
$message_length = strlen($message);
|
370 |
+
$url_length = strlen($url);
|
371 |
+
//$cur_length = strlen($tags);
|
372 |
+
if ($hashtag_length == 0)
|
373 |
+
$hashtag_length = strlen($tags);
|
374 |
+
|
375 |
+
if ($twitter_hashtags != "") {
|
376 |
+
if (strlen($tags) > $hashtag_length) {
|
377 |
+
$tags = substr($tags, 0, $hashtag_length);
|
378 |
+
$tags = substr($tags, 0, strrpos($tags, ' '));
|
379 |
+
}
|
380 |
+
$hashtag_length = strlen($tags);
|
381 |
+
}
|
382 |
+
|
383 |
+
if ($message_length + $url_length + $hashtag_length > 140) {
|
384 |
+
|
385 |
+
|
386 |
+
$shorten_message_to = 140 - $url_length - $hashtag_length;
|
387 |
+
$shorten_message_to = $shorten_message_to - 4;
|
388 |
+
//$message = $message." ";
|
389 |
+
if (strlen($message) > $shorten_message_to) {
|
390 |
+
$message = substr($message, 0, $shorten_message_to);
|
391 |
+
$message = substr($message, 0, strrpos($message, ' '));
|
392 |
+
}
|
393 |
+
$message = $message . "...";
|
394 |
+
}
|
395 |
+
return $message . " " . $url . " " . $tags;
|
396 |
+
}
|
397 |
+
|
398 |
+
//check time and update the last tweet time
|
399 |
+
function top_opt_update_time() {
|
400 |
+
|
401 |
+
|
402 |
+
return top_to_update();
|
403 |
+
|
404 |
+
}
|
405 |
+
|
406 |
+
function top_to_update() {
|
407 |
+
$last = get_option('top_opt_last_update');
|
408 |
+
$interval = get_option('top_opt_interval');
|
409 |
+
$slop = get_option('top_opt_interval_slop');
|
410 |
+
|
411 |
+
if (!(isset($interval))) {
|
412 |
+
$interval = top_opt_INTERVAL;
|
413 |
+
}
|
414 |
+
else if(!(is_numeric($interval)))
|
415 |
+
{
|
416 |
+
$interval = top_opt_INTERVAL;
|
417 |
+
}
|
418 |
+
|
419 |
+
|
420 |
+
if (!(isset($slop))) {
|
421 |
+
$slop = top_opt_INTERVAL_SLOP;
|
422 |
+
}
|
423 |
+
else if(!(is_numeric($slop)))
|
424 |
+
{
|
425 |
+
$slop = top_opt_INTERVAL_SLOP;
|
426 |
+
}
|
427 |
+
|
428 |
+
|
429 |
+
|
430 |
+
$interval = $interval * 60 * 60;
|
431 |
+
$slop = $slop * 60 * 60;
|
432 |
+
if (false === $last) {
|
433 |
+
$ret = 1;
|
434 |
+
} else if (is_numeric($last)) {
|
435 |
+
$ret = ( (time() - $last) > ($interval + rand(0, $slop)));
|
436 |
+
}
|
437 |
+
|
438 |
+
|
439 |
+
return $ret;
|
440 |
+
}
|
441 |
+
|
442 |
+
function top_get_auth_url() {
|
443 |
+
global $top_oauth;
|
444 |
+
$settings = top_get_settings();
|
445 |
+
|
446 |
+
$token = $top_oauth->get_request_token();
|
447 |
+
if ($token) {
|
448 |
+
$settings['oauth_request_token'] = $token['oauth_token'];
|
449 |
+
$settings['oauth_request_token_secret'] = $token['oauth_token_secret'];
|
450 |
+
|
451 |
+
top_save_settings($settings);
|
452 |
+
|
453 |
+
return $top_oauth->get_auth_url($token['oauth_token']);
|
454 |
+
}
|
455 |
+
}
|
456 |
+
|
457 |
+
function top_update_status($new_status) {
|
458 |
+
global $top_oauth;
|
459 |
+
$settings = top_get_settings();
|
460 |
+
|
461 |
+
if (isset($settings['oauth_access_token']) && isset($settings['oauth_access_token_secret'])) {
|
462 |
+
return $top_oauth->update_status($settings['oauth_access_token'], $settings['oauth_access_token_secret'], $new_status);
|
463 |
+
}
|
464 |
+
|
465 |
+
return false;
|
466 |
+
}
|
467 |
+
|
468 |
+
function top_has_tokens() {
|
469 |
+
$settings = top_get_settings();
|
470 |
+
|
471 |
+
return ( $settings['oauth_access_token'] && $settings['oauth_access_token_secret'] );
|
472 |
+
}
|
473 |
+
|
474 |
+
function top_is_valid() {
|
475 |
+
return twit_has_tokens();
|
476 |
+
}
|
477 |
+
|
478 |
+
function top_do_tweet($post_id) {
|
479 |
+
$settings = top_get_settings();
|
480 |
+
|
481 |
+
$message = top_get_message($post_id);
|
482 |
+
|
483 |
+
// If we have a valid message, Tweet it
|
484 |
+
// this will fail if the Tiny URL service is done
|
485 |
+
if ($message) {
|
486 |
+
// If we successfully posted this to Twitter, then we can remove it from the queue eventually
|
487 |
+
if (twit_update_status($message)) {
|
488 |
+
return true;
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
return false;
|
493 |
+
}
|
494 |
+
|
495 |
+
function top_get_settings() {
|
496 |
+
global $top_defaults;
|
497 |
+
|
498 |
+
$settings = $top_defaults;
|
499 |
+
|
500 |
+
$wordpress_settings = get_option('top_settings');
|
501 |
+
if ($wordpress_settings) {
|
502 |
+
foreach ($wordpress_settings as $key => $value) {
|
503 |
+
$settings[$key] = $value;
|
504 |
+
}
|
505 |
+
}
|
506 |
+
|
507 |
+
return $settings;
|
508 |
+
}
|
509 |
+
|
510 |
+
function top_save_settings($settings) {
|
511 |
+
update_option('top_settings', $settings);
|
512 |
+
}
|
513 |
+
|
514 |
+
function top_reset_settings()
|
515 |
+
{
|
516 |
+
delete_option('top_settings');
|
517 |
+
update_option('top_enable_log','');
|
518 |
+
update_option('top_opt_add_text','');
|
519 |
+
update_option('top_opt_add_text_at','beginning');
|
520 |
+
update_option('top_opt_age_limit',30);
|
521 |
+
update_option('top_opt_bitly_key','');
|
522 |
+
update_option('top_opt_bitly_user','');
|
523 |
+
update_option('top_opt_custom_hashtag_field','');
|
524 |
+
update_option('top_opt_custom_hashtag_option','nohashtag');
|
525 |
+
update_option('top_opt_custom_url_field','');
|
526 |
+
update_option('top_opt_custom_url_option','');
|
527 |
+
update_option('top_opt_excluded_post','');
|
528 |
+
update_option('top_opt_hashtags','');
|
529 |
+
update_option('top_opt_hashtag_length','20');
|
530 |
+
update_option('top_opt_include_link','no');
|
531 |
+
update_option('top_opt_interval',4);
|
532 |
+
update_option('top_opt_interval_slop',4);
|
533 |
+
delete_option('top_opt_last_update');
|
534 |
+
update_option('top_opt_max_age_limit',60);
|
535 |
+
update_option('top_opt_omit_cats','');
|
536 |
+
update_option('top_opt_tweet_type','title');
|
537 |
+
delete_option('top_opt_tweeted_posts');
|
538 |
+
update_option('top_opt_url_shortener','is.gd');
|
539 |
+
update_option('top_opt_use_inline_hashtags','');
|
540 |
+
update_option('top_opt_use_url_shortner','');
|
541 |
+
}
|
542 |
+
|
543 |
+
?>
|
top-excludepost.php
ADDED
@@ -0,0 +1,343 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once('tweet-old-post.php');
|
4 |
+
require_once('top-core.php');
|
5 |
+
require_once( 'Include/top-oauth.php' );
|
6 |
+
require_once('xml.php');
|
7 |
+
|
8 |
+
if (!function_exists ("mysql_real_escape_string"))
|
9 |
+
{
|
10 |
+
function mysql_real_escape_string ($str)
|
11 |
+
{
|
12 |
+
return mysql_escape_string ($str);
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
function top_exclude() {
|
17 |
+
$message = null;
|
18 |
+
$message_updated = __("Tweet Old Post Options Updated.", 'TweetOldPost');
|
19 |
+
$response = null;
|
20 |
+
$records_per_page = 20;
|
21 |
+
$omit_cat=get_option('top_opt_omit_cats');
|
22 |
+
$update_text = "Exclude Selected";
|
23 |
+
$search_term="";
|
24 |
+
$ex_filter="all";
|
25 |
+
$cat_filter=0;
|
26 |
+
|
27 |
+
global $wpdb;
|
28 |
+
|
29 |
+
if ((!isset($_GET["paged"])) && (!isset($_POST["delids"]))) {
|
30 |
+
$exposts = get_option('top_opt_excluded_post');
|
31 |
+
} else {
|
32 |
+
$exposts = $_POST["delids"];
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
$exposts = preg_replace('/,,+/', ',', $exposts);
|
38 |
+
if (substr($exposts, 0, 1) == ",") {
|
39 |
+
$exposts = substr($exposts, 1, strlen($exposts));
|
40 |
+
}
|
41 |
+
if (substr($exposts, -1, 1) == ",") {
|
42 |
+
$exposts = substr($exposts, 0, strlen($exposts) - 1);
|
43 |
+
}
|
44 |
+
$excluded_posts = explode(",", $exposts);
|
45 |
+
|
46 |
+
|
47 |
+
if (!isset($_GET['paged']))
|
48 |
+
$_GET['paged'] = 1;
|
49 |
+
|
50 |
+
if (isset($_POST["excludeall"])) {
|
51 |
+
if (substr($_POST["delids"], 0, -1) == "") {
|
52 |
+
print('
|
53 |
+
<div id="message" style="margin-top:30px" class="updated fade">
|
54 |
+
<p>' . __('No post selected please select a post to be excluded.', 'TweetOldPost') . '</p>
|
55 |
+
</div>');
|
56 |
+
} else {
|
57 |
+
|
58 |
+
update_option('top_opt_excluded_post',$exposts);
|
59 |
+
print('
|
60 |
+
<div id="message" style="margin-top:30px" class="updated fade">
|
61 |
+
<p>' . __('Posts excluded successfully.', 'TweetOldPost') . '</p>
|
62 |
+
</div>');
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
print('
|
67 |
+
<div id="help" style="overflow: hidden;padding-left:15px; font-size: 14px; margin-top: 25px; background-color: rgb(239, 239, 239);">
|
68 |
+
<p>' . __('This page shows all the post from your <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=TweetOldPost">selected categories</a>.<br /> All the post excluded will not be tweeted even if the category is selected.', 'TweetOldPost') . '</p>
|
69 |
+
</div>');
|
70 |
+
|
71 |
+
print('
|
72 |
+
<div id="help" style="overflow: hidden;padding-left:15px; font-size: 14px; margin-top: 25px;margin-bottom:25px; background-color: rgb(239, 239, 239);">
|
73 |
+
<p>' . __('You have selected following POST IDs to be excluded from tweeting: <span id="excludeList" style="font-weight:bold;font-style:italic;"></span>.<br /> <strong>Note:</strong> If you have made any change and dint hit "Exclude Selected" button changes will not be saved. Please hit "Exclude Selected" button after making any changes.', 'TweetOldPost') . '</p>
|
74 |
+
</div>');
|
75 |
+
|
76 |
+
$sql = "SELECT p.ID,p.post_title,p.post_date,u.user_nicename,p.guid FROM $wpdb->posts p join $wpdb->users u on p.post_author=u.ID WHERE post_type = 'post'
|
77 |
+
AND post_status = 'publish'";
|
78 |
+
|
79 |
+
|
80 |
+
if(isset($_POST["setFilter"]))
|
81 |
+
{
|
82 |
+
if($_POST["cat"] != 0)
|
83 |
+
{
|
84 |
+
|
85 |
+
$cat_filter = $_POST["cat"];
|
86 |
+
$cat_filter = mysql_real_escape_string($cat_filter);
|
87 |
+
$sql = $sql . " and p.ID IN ( SELECT tr.object_id FROM ".$wpdb->prefix."term_relationships AS tr INNER JOIN ".$wpdb->prefix."term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id=" . $cat_filter . ")";
|
88 |
+
|
89 |
+
}
|
90 |
+
else
|
91 |
+
{
|
92 |
+
$sql = $sql . " and p.ID NOT IN ( SELECT tr.object_id FROM ".$wpdb->prefix."term_relationships AS tr INNER JOIN ".$wpdb->prefix."term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN (" . $omit_cat . "))";
|
93 |
+
$cat_filter = 0;
|
94 |
+
}
|
95 |
+
|
96 |
+
if($_POST["selFilter"] == "excluded")
|
97 |
+
{
|
98 |
+
$sql = $sql . " and p.ID IN (".$exposts.")";
|
99 |
+
$update_text = "Update";
|
100 |
+
$ex_filter = "excluded";
|
101 |
+
}
|
102 |
+
|
103 |
+
}
|
104 |
+
else
|
105 |
+
{
|
106 |
+
if($omit_cat !='')
|
107 |
+
{
|
108 |
+
$sql = $sql . " and p.ID NOT IN ( SELECT tr.object_id FROM ".$wpdb->prefix."term_relationships AS tr INNER JOIN ".$wpdb->prefix."term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy = 'category' AND tt.term_id IN (" . $omit_cat . "))";
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
if(isset($_POST["s"]))
|
113 |
+
{
|
114 |
+
if(trim( $_POST["s"]) != "")
|
115 |
+
{
|
116 |
+
$_s = $_POST["s"];
|
117 |
+
$_s = mysql_real_escape_string($_s);
|
118 |
+
$sql = $sql . " and post_title like '%" . trim( $_s) . "%'";
|
119 |
+
$search_term = trim( $_s);
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
$sql = $sql . " order by post_date desc";
|
124 |
+
$posts = $wpdb->get_results($sql);
|
125 |
+
|
126 |
+
$from = $_GET["paged"] * $records_per_page - $records_per_page;
|
127 |
+
$to = min($_GET['paged'] * $records_per_page, count($posts));
|
128 |
+
$post_count =count($posts);
|
129 |
+
|
130 |
+
$ex = 0;
|
131 |
+
for ($j = 0; $j < $post_count; $j++) {
|
132 |
+
if (in_array($posts[$j]->ID, $excluded_posts)) {
|
133 |
+
$excludeList[$ex] = $posts[$j]->ID;
|
134 |
+
$ex = $ex + 1;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
if($excludeList.length >0)
|
138 |
+
{
|
139 |
+
$exposts = implode(",",$excludeList);
|
140 |
+
}
|
141 |
+
print('<form id="top_TweetOldPost" name="top_TweetOldPost" action="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=ExcludePosts" method="post"><input type="hidden" name="delids" id="delids" value="' . $exposts . '" /><input type="submit" id="pageit" name="pageit" style="display:none" value="" /> ');
|
142 |
+
print('<div class="tablenav"><div class="alignleft actions">');
|
143 |
+
print('<input type="submit" class="button-secondary" name="excludeall" value="' . __($update_text, 'TweetOldPost') . '" />');
|
144 |
+
print('<select name="selFilter" id="selFilter" style="width:100px"><option value="all" '.top_opt_optionselected("all",$ex_filter).'> All </option><option value="excluded" '.top_opt_optionselected("excluded",$ex_filter).'> Excluded </option></select>');
|
145 |
+
$dropdown_options = array('show_option_all' => __('Selected Categories'),'exclude' =>$omit_cat,'selected' =>$cat_filter);
|
146 |
+
wp_dropdown_categories($dropdown_options);
|
147 |
+
print('<input type="submit" class="button-secondary" name="setFilter" value="' . __('Filter', 'TweetOldPost') . '" />');
|
148 |
+
print('<p class="search-box" style="margin:0px">
|
149 |
+
<input type="text" id="post-search-input" name="s" value="'.$search_term.'" />
|
150 |
+
<input type="submit" value="Search Posts" name="search" class="button" />
|
151 |
+
</p>');
|
152 |
+
print('</div>');
|
153 |
+
if (count($posts) > 0) {
|
154 |
+
$page_links = paginate_links(array(
|
155 |
+
'base' => add_query_arg('paged', '%#%'),
|
156 |
+
'format' => '',
|
157 |
+
'prev_text' => __('«'),
|
158 |
+
'next_text' => __('»'),
|
159 |
+
'total' => ceil(count($posts) / $records_per_page),
|
160 |
+
'current' => $_GET['paged']
|
161 |
+
));
|
162 |
+
|
163 |
+
if ($page_links) {
|
164 |
+
|
165 |
+
print('<div class="tablenav-pages">');
|
166 |
+
$page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s',
|
167 |
+
number_format_i18n(( $_GET['paged'] - 1 ) * $records_per_page + 1),
|
168 |
+
number_format_i18n(min($_GET['paged'] * $records_per_page, count($posts))),
|
169 |
+
number_format_i18n(count($posts)),
|
170 |
+
$page_links
|
171 |
+
);
|
172 |
+
echo $page_links_text;
|
173 |
+
print('</div>');
|
174 |
+
}
|
175 |
+
print('</div>');//tablenav div
|
176 |
+
|
177 |
+
print(' <div class="wrap">
|
178 |
+
<table class="widefat fixed">
|
179 |
+
<thead>
|
180 |
+
<tr>
|
181 |
+
<th class="manage-column column-cb check-column"><input name="headchkbx" onchange="javascript:checkedAll();" type="checkbox" value="checkall"/></th>
|
182 |
+
<th>No.</th>
|
183 |
+
<th>Id</th>
|
184 |
+
<th>Post Title</th>
|
185 |
+
<th>Author</th>
|
186 |
+
<th>Post Date</th>
|
187 |
+
<th>Categories</th>
|
188 |
+
</tr>
|
189 |
+
</thead>
|
190 |
+
<tbody>
|
191 |
+
');
|
192 |
+
|
193 |
+
|
194 |
+
|
195 |
+
|
196 |
+
for ($i = $from; $i < $to; $i++) {
|
197 |
+
$categories = get_the_category($posts[$i]->ID);
|
198 |
+
if (!empty($categories)) {
|
199 |
+
$out = array();
|
200 |
+
foreach ($categories as $c)
|
201 |
+
$out[] = "<a href='edit.php?post_type={$post->post_type}&category_name={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
|
202 |
+
$cats = join(', ', $out);
|
203 |
+
} else {
|
204 |
+
$cats = 'Uncategorized';
|
205 |
+
}
|
206 |
+
|
207 |
+
if (in_array($posts[$i]->ID, $excluded_posts)) {
|
208 |
+
$checked = "Checked";
|
209 |
+
$bgcolor="#FFCC99";
|
210 |
+
} else {
|
211 |
+
$checked = "";
|
212 |
+
$bgcolor="#FFF";
|
213 |
+
}
|
214 |
+
|
215 |
+
print('
|
216 |
+
|
217 |
+
<tr style="background-color:'.$bgcolor.';">
|
218 |
+
<th class="check-column">
|
219 |
+
<input type="checkbox" name="chkbx" id="del' . $posts[$i]->ID . '" onchange="javascript:managedelid(this,\'' . $posts[$i]->ID . '\');" value="' . $posts[$i]->ID . '" ' . $checked . '/>
|
220 |
+
</th>
|
221 |
+
<td>
|
222 |
+
' . ($i + 1) . '
|
223 |
+
</td>
|
224 |
+
<td>
|
225 |
+
' . $posts[$i]->ID . '
|
226 |
+
</td>
|
227 |
+
<td>
|
228 |
+
<a href=' . $posts[$i]->guid . ' target="_blank">' . $posts[$i]->post_title . '</a>
|
229 |
+
</td>
|
230 |
+
<td>
|
231 |
+
' . $posts[$i]->user_nicename . '
|
232 |
+
</td>
|
233 |
+
<td>
|
234 |
+
' . $posts[$i]->post_date . '
|
235 |
+
</td>
|
236 |
+
<td>
|
237 |
+
' . $cats . '
|
238 |
+
</td>
|
239 |
+
</tr>
|
240 |
+
|
241 |
+
');
|
242 |
+
}
|
243 |
+
print('
|
244 |
+
</tbody>
|
245 |
+
</table>
|
246 |
+
</div>
|
247 |
+
');
|
248 |
+
|
249 |
+
print('<div class="tablenav"><div class="alignleft actions"><input type="submit" class="button-secondary" name="excludeall" value="' . __($update_text, 'TweetOldPost') . '" /></div>');
|
250 |
+
|
251 |
+
if ($page_links) {
|
252 |
+
|
253 |
+
print('<div class="tablenav-pages">');
|
254 |
+
$page_links_text = sprintf('<span class="displaying-num">' . __('Displaying %s–%s of %s') . '</span>%s',
|
255 |
+
number_format_i18n(( $_GET['paged'] - 1 ) * $records_per_page + 1),
|
256 |
+
number_format_i18n(min($_GET['paged'] * $records_per_page, count($posts))),
|
257 |
+
number_format_i18n(count($posts)),
|
258 |
+
$page_links
|
259 |
+
);
|
260 |
+
echo $page_links_text;
|
261 |
+
print('</div>');
|
262 |
+
}
|
263 |
+
print('</div>');
|
264 |
+
|
265 |
+
|
266 |
+
|
267 |
+
print('
|
268 |
+
<script language="javascript">
|
269 |
+
|
270 |
+
|
271 |
+
jQuery(function() {
|
272 |
+
jQuery(".page-numbers").click(function(e){
|
273 |
+
jQuery("#top_TweetOldPost").attr("action",jQuery(this).attr("href"));
|
274 |
+
e.preventDefault();
|
275 |
+
jQuery("#pageit").click();
|
276 |
+
});// page number click end
|
277 |
+
});//jquery document.ready end
|
278 |
+
|
279 |
+
function setExcludeList(exlist)
|
280 |
+
{
|
281 |
+
jQuery("#excludeList").html("\"" + exlist + "\"");
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
function managedelid(ctrl,id)
|
286 |
+
{
|
287 |
+
|
288 |
+
var delids = document.getElementById("delids").value;
|
289 |
+
if(ctrl.checked)
|
290 |
+
{
|
291 |
+
delids=addId(delids,id);
|
292 |
+
}
|
293 |
+
else
|
294 |
+
{
|
295 |
+
delids=removeId(delids,id);
|
296 |
+
}
|
297 |
+
document.getElementById("delids").value=delids;
|
298 |
+
setExcludeList(delids);
|
299 |
+
}
|
300 |
+
|
301 |
+
function removeId(list, value) {
|
302 |
+
list = list.split(",");
|
303 |
+
if(list.indexOf(value) != -1)
|
304 |
+
list.splice(list.indexOf(value), 1);
|
305 |
+
return list.join(",");
|
306 |
+
}
|
307 |
+
|
308 |
+
|
309 |
+
function addId(list,value)
|
310 |
+
{
|
311 |
+
list = list.split(",");
|
312 |
+
if(list.indexOf(value) == -1)
|
313 |
+
list.push(value);
|
314 |
+
return list.join(",");
|
315 |
+
}
|
316 |
+
|
317 |
+
function checkedAll() {
|
318 |
+
var ischecked=document.top_TweetOldPost.headchkbx.checked;
|
319 |
+
var delids="";
|
320 |
+
for (var i = 0; i < document.top_TweetOldPost.chkbx.length; i++) {
|
321 |
+
document.top_TweetOldPost.chkbx[i].checked = ischecked;
|
322 |
+
if(ischecked)
|
323 |
+
delids=delids+document.top_TweetOldPost.chkbx[i].value+",";
|
324 |
+
}
|
325 |
+
document.getElementById("delids").value=delids;
|
326 |
+
}
|
327 |
+
|
328 |
+
setExcludeList("' . $exposts . '");
|
329 |
+
|
330 |
+
</script>
|
331 |
+
');
|
332 |
+
}
|
333 |
+
else
|
334 |
+
{
|
335 |
+
print('</div>');//tablenav div
|
336 |
+
print('
|
337 |
+
<div id="message" style="margin-top:30px" class="updated fade">
|
338 |
+
<p>' . __('No Posts found. Review your search or filter criteria/term.', 'TweetOldPost') . '</p>
|
339 |
+
</div>');
|
340 |
+
}
|
341 |
+
print('</form>');
|
342 |
+
}
|
343 |
+
?>
|
tweet-old-post.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
# /*
|
3 |
+
# Plugin Name: Tweet old post
|
4 |
+
# Plugin URI: http://www.ajaymatharu.com/wordpress-plugin-tweet-old-posts/
|
5 |
+
# Description: This plugin helps you to keeps your old posts alive by tweeting about them and driving more traffic to them from twitter.
|
6 |
+
# Author: Ajay Matharu
|
7 |
+
# Version: 3.3.1
|
8 |
+
# Author URI: http://www.ajaymatharu.com
|
9 |
+
# */
|
10 |
+
|
11 |
+
|
12 |
+
require_once('top-admin.php');
|
13 |
+
require_once('top-core.php');
|
14 |
+
require_once('top-excludepost.php');
|
15 |
+
|
16 |
+
define ('top_opt_1_HOUR', 60*60);
|
17 |
+
define ('top_opt_2_HOURS', 2*top_opt_1_HOUR);
|
18 |
+
define ('top_opt_4_HOURS', 4*top_opt_1_HOUR);
|
19 |
+
define ('top_opt_8_HOURS', 8*top_opt_1_HOUR);
|
20 |
+
define ('top_opt_6_HOURS', 6*top_opt_1_HOUR);
|
21 |
+
define ('top_opt_12_HOURS', 12*top_opt_1_HOUR);
|
22 |
+
define ('top_opt_24_HOURS', 24*top_opt_1_HOUR);
|
23 |
+
define ('top_opt_48_HOURS', 48*top_opt_1_HOUR);
|
24 |
+
define ('top_opt_72_HOURS', 72*top_opt_1_HOUR);
|
25 |
+
define ('top_opt_168_HOURS', 168*top_opt_1_HOUR);
|
26 |
+
define ('top_opt_INTERVAL', 4);
|
27 |
+
define ('top_opt_INTERVAL_SLOP', 4);
|
28 |
+
define ('top_opt_AGE_LIMIT', 30); // 120 days
|
29 |
+
define ('top_opt_MAX_AGE_LIMIT', 60); // 120 days
|
30 |
+
define ('top_opt_OMIT_CATS', "");
|
31 |
+
define('top_opt_TWEET_PREFIX',"");
|
32 |
+
define('top_opt_ADD_DATA',"false");
|
33 |
+
define('top_opt_URL_SHORTENER',"is.gd");
|
34 |
+
define('top_opt_HASHTAGS',"");
|
35 |
+
|
36 |
+
global $top_db_version;
|
37 |
+
$top_db_version = "1.0";
|
38 |
+
|
39 |
+
function top_admin_actions() {
|
40 |
+
add_menu_page("Tweet Old Post", "Tweet Old Post", 1, "TweetOldPost", "top_admin");
|
41 |
+
add_submenu_page("TweetOldPost", __('Exclude Posts','TweetOldPost'), __('Exclude Posts','TweetOldPost'), 1, __('ExcludePosts','TweetOldPost'), 'top_exclude');
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
add_action('admin_menu', 'top_admin_actions');
|
46 |
+
add_action('admin_head', 'top_opt_head_admin');
|
47 |
+
add_action('init','top_tweet_old_post');
|
48 |
+
add_action('admin_init','top_authorize',1);
|
49 |
+
|
50 |
+
function top_authorize()
|
51 |
+
{
|
52 |
+
|
53 |
+
|
54 |
+
if ( isset( $_REQUEST['oauth_token'] ) ) {
|
55 |
+
$auth_url= str_replace('oauth_token', 'oauth_token1', top_currentPageURL());
|
56 |
+
echo '<script language="javascript">window.open ("'.$auth_url.'","_self"
|
57 |
+
|
58 |
+
)</script>';
|
59 |
+
die;
|
60 |
+
}
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
add_filter('plugin_action_links', 'top_plugin_action_links', 10, 2);
|
65 |
+
|
66 |
+
function top_plugin_action_links($links, $file) {
|
67 |
+
static $this_plugin;
|
68 |
+
|
69 |
+
if (!$this_plugin) {
|
70 |
+
$this_plugin = plugin_basename(__FILE__);
|
71 |
+
}
|
72 |
+
|
73 |
+
if ($file == $this_plugin) {
|
74 |
+
// The "page" query string value must be equal to the slug
|
75 |
+
// of the Settings admin page we defined earlier, which in
|
76 |
+
// this case equals "myplugin-settings".
|
77 |
+
$settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=TweetOldPost">Settings</a>';
|
78 |
+
array_unshift($links, $settings_link);
|
79 |
+
}
|
80 |
+
|
81 |
+
return $links;
|
82 |
+
}
|
83 |
+
|
84 |
+
?>
|
xml.php
ADDED
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
function TOP_parsexml( $xml, $get_attributes = 1, $priority = 'tag' )
|
4 |
+
{
|
5 |
+
$parser = xml_parser_create('');
|
6 |
+
xml_parser_set_option( $parser, XML_OPTION_TARGET_ENCODING, "UTF-8" );
|
7 |
+
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 );
|
8 |
+
xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
|
9 |
+
xml_parse_into_struct( $parser, trim($xml), $xml_values );
|
10 |
+
xml_parser_free($parser);
|
11 |
+
|
12 |
+
if (!$xml_values)
|
13 |
+
return;
|
14 |
+
|
15 |
+
$xml_array = array ();
|
16 |
+
$parents = array ();
|
17 |
+
$opened_tags = array ();
|
18 |
+
$arr = array ();
|
19 |
+
$current = & $xml_array;
|
20 |
+
$repeated_tag_index = array ();
|
21 |
+
|
22 |
+
foreach ($xml_values as $data) {
|
23 |
+
unset ($attributes, $value);
|
24 |
+
extract($data);
|
25 |
+
$result = array ();
|
26 |
+
$attributes_data = array ();
|
27 |
+
if (isset ($value))
|
28 |
+
{
|
29 |
+
if ($priority == 'tag')
|
30 |
+
$result = $value;
|
31 |
+
else
|
32 |
+
$result['value'] = $value;
|
33 |
+
}
|
34 |
+
if (isset ($attributes) and $get_attributes)
|
35 |
+
{
|
36 |
+
foreach ($attributes as $attr => $val)
|
37 |
+
{
|
38 |
+
if ($priority == 'tag')
|
39 |
+
$attributes_data[$attr] = $val;
|
40 |
+
else
|
41 |
+
$result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
|
42 |
+
}
|
43 |
+
}
|
44 |
+
if ($type == "open")
|
45 |
+
{
|
46 |
+
$parent[$level -1] = & $current;
|
47 |
+
if (!is_array($current) or (!in_array($tag, array_keys($current))))
|
48 |
+
{
|
49 |
+
$current[$tag] = $result;
|
50 |
+
if ($attributes_data)
|
51 |
+
$current[$tag . '_attr'] = $attributes_data;
|
52 |
+
$repeated_tag_index[$tag . '_' . $level] = 1;
|
53 |
+
$current = & $current[$tag];
|
54 |
+
}
|
55 |
+
else
|
56 |
+
{
|
57 |
+
if (isset ($current[$tag][0]))
|
58 |
+
{
|
59 |
+
$current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
|
60 |
+
$repeated_tag_index[$tag . '_' . $level]++;
|
61 |
+
}
|
62 |
+
else
|
63 |
+
{
|
64 |
+
$current[$tag] = array (
|
65 |
+
$current[$tag],
|
66 |
+
$result
|
67 |
+
);
|
68 |
+
$repeated_tag_index[$tag . '_' . $level] = 2;
|
69 |
+
if (isset ($current[$tag . '_attr']))
|
70 |
+
{
|
71 |
+
$current[$tag]['0_attr'] = $current[$tag . '_attr'];
|
72 |
+
unset ($current[$tag . '_attr']);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
$last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
|
76 |
+
$current = & $current[$tag][$last_item_index];
|
77 |
+
}
|
78 |
+
}
|
79 |
+
elseif ($type == "complete")
|
80 |
+
{
|
81 |
+
if (!isset ($current[$tag]))
|
82 |
+
{
|
83 |
+
$current[$tag] = $result;
|
84 |
+
$repeated_tag_index[$tag . '_' . $level] = 1;
|
85 |
+
if ($priority == 'tag' and $attributes_data)
|
86 |
+
$current[$tag . '_attr'] = $attributes_data;
|
87 |
+
}
|
88 |
+
else
|
89 |
+
{
|
90 |
+
if (isset ($current[$tag][0]) and is_array($current[$tag]))
|
91 |
+
{
|
92 |
+
$current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
|
93 |
+
if ($priority == 'tag' and $get_attributes and $attributes_data)
|
94 |
+
{
|
95 |
+
$current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
|
96 |
+
}
|
97 |
+
$repeated_tag_index[$tag . '_' . $level]++;
|
98 |
+
}
|
99 |
+
else
|
100 |
+
{
|
101 |
+
$current[$tag] = array (
|
102 |
+
$current[$tag],
|
103 |
+
$result
|
104 |
+
);
|
105 |
+
$repeated_tag_index[$tag . '_' . $level] = 1;
|
106 |
+
if ($priority == 'tag' and $get_attributes)
|
107 |
+
{
|
108 |
+
if (isset ($current[$tag . '_attr']))
|
109 |
+
{
|
110 |
+
$current[$tag]['0_attr'] = $current[$tag . '_attr'];
|
111 |
+
unset ($current[$tag . '_attr']);
|
112 |
+
}
|
113 |
+
if ($attributes_data)
|
114 |
+
{
|
115 |
+
$current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
$repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
elseif ($type == 'close')
|
123 |
+
{
|
124 |
+
$current = & $parent[$level -1];
|
125 |
+
}
|
126 |
+
}
|
127 |
+
return $xml_array;
|
128 |
+
}
|
129 |
+
|
130 |
+
?>
|