Advertisement
wrdprskn

Parse

May 29th, 2015
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.20 KB | None | 0 0
  1. <?php
  2. require_once('tweetily.php');
  3. require_once('top-core.php');
  4. require_once( 'Include/top-oauth.php' );
  5. require_once('xml.php');
  6. require_once( 'Include/top-debug.php' );
  7.  
  8.  
  9. function top_admin() {
  10. //check permission
  11. if (current_user_can('manage_options'))
  12. {
  13. $message = null;
  14. $message_updated = __("Tweetily options have been updated!", 'Tweetily');
  15. $response = null;
  16. $save = true;
  17. $settings = top_get_settings();
  18.  
  19. //on authorize
  20. if (isset($_GET['TOP_oauth'])) {
  21. global $top_oauth;
  22.  
  23. $result = $top_oauth->get_access_token($settings['oauth_request_token'], $settings['oauth_request_token_secret'], $_GET['oauth_verifier']);
  24.  
  25. if ($result) {
  26. $settings['oauth_access_token'] = $result['oauth_token'];
  27. $settings['oauth_access_token_secret'] = $result['oauth_token_secret'];
  28. $settings['user_id'] = $result['user_id'];
  29.  
  30. $result = $top_oauth->get_user_info($result['user_id']);
  31. if ($result) {
  32. $settings['profile_image_url'] = $result['user']['profile_image_url'];
  33. $settings['screen_name'] = $result['user']['screen_name'];
  34. if (isset($result['user']['location'])) {
  35. $settings['location'] = $result['user']['location'];
  36. } else {
  37. $settings['location'] = false;
  38. }
  39. }
  40.  
  41. top_save_settings($settings);
  42. echo '<script language="javascript">window.open ("' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=Tweetily","_self")</script>';
  43. die;
  44. }
  45. }
  46. //on deauthorize
  47. else if (isset($_GET['top']) && $_GET['top'] == 'deauthorize') {
  48. $settings = top_get_settings();
  49. $settings['oauth_access_token'] = '';
  50. $settings['oauth_access_token_secret'] = '';
  51. $settings['user_id'] = '';
  52. $settings['tweet_queue'] = array();
  53.  
  54. top_save_settings($settings);
  55. echo '<script language="javascript">window.open ("' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=Tweetily","_self")</script>';
  56. die;
  57. }
  58. else if (isset($_GET['top']) && $_GET['top'] == 'reset') {
  59. print('
  60. <div id="message" class="updated fade">
  61. <p>' . __("All settings have been reset. Please update the settings for Tweetily to start tweeting again.", 'Tweetily') . '</p>
  62. </div>');
  63. }
  64. //check if username and key provided if bitly selected
  65. if (isset($_POST['top_opt_url_shortener'])) {
  66. if ($_POST['top_opt_url_shortener'] == "bit.ly") {
  67.  
  68. //check bitly username
  69. if (!isset($_POST['top_opt_bitly_user'])) {
  70. print('
  71. <div id="message" class="updated fade">
  72. <p>' . __('Please enter bit.ly username.', 'Tweetily') . '</p>
  73. </div>');
  74. $save = false;
  75. }
  76. //check bitly key
  77. elseif (!isset($_POST['top_opt_bitly_key'])) {
  78. print('
  79. <div id="message" class="updated fade">
  80. <p>' . __('Please enter bit.ly API Key.', 'Tweetily') . '</p>
  81. </div>');
  82. $save = false;
  83. }
  84. //if both the good to save
  85. else {
  86. $save = true;
  87. }
  88. }
  89. }
  90.  
  91.  
  92. if(get_option('next_tweet_time')=='0'){
  93. $next_tweet_time = time()+ get_option('top_opt_interval') * 60 * 60;
  94. update_option('next_tweet_time', $next_tweet_time);
  95. }
  96. //if submit and if bitly selected its fields are filled then save
  97. if (isset($_POST['submit']) && $save) {
  98. $message = $message_updated;
  99.  
  100. //
  101. if (isset($_POST['as_number_tweet'])) {
  102. if($_POST['as_number_tweet']>0 && $_POST['as_number_tweet']<=10){
  103. update_option('as_number_tweet', $_POST['as_number_tweet']);
  104. }elseif($_POST['as_number_tweet']>10){
  105. update_option('as_number_tweet', 10);
  106. }else{
  107. update_option('as_number_tweet', 1);
  108. }
  109. }
  110. if (isset($_POST['as_post_type'])) {
  111. update_option('as_post_type', $_POST['as_post_type']);
  112. }
  113.  
  114.  
  115. //TOP admin URL (current url)
  116. if (isset($_POST['top_opt_admin_url'])) {
  117. update_option('top_opt_admin_url', $_POST['top_opt_admin_url']);
  118. }
  119.  
  120. //what to tweet
  121. if (isset($_POST['top_opt_tweet_type'])) {
  122. update_option('top_opt_tweet_type', $_POST['top_opt_tweet_type']);
  123. }
  124.  
  125. //additional data
  126. if (isset($_POST['top_opt_add_text'])) {
  127. update_option('top_opt_add_text', $_POST['top_opt_add_text']);
  128. }
  129.  
  130. //place of additional data
  131. if (isset($_POST['top_opt_add_text_at'])) {
  132. update_option('top_opt_add_text_at', $_POST['top_opt_add_text_at']);
  133. }
  134.  
  135. //include link
  136. if (isset($_POST['top_opt_include_link'])) {
  137. update_option('top_opt_include_link', $_POST['top_opt_include_link']);
  138. }
  139.  
  140. //fetch url from custom field?
  141. if (isset($_POST['top_opt_custom_url_option'])) {
  142. update_option('top_opt_custom_url_option', true);
  143. } else {
  144.  
  145. update_option('top_opt_custom_url_option', false);
  146. }
  147.  
  148. //custom field to fetch URL from
  149. if (isset($_POST['top_opt_custom_url_field'])) {
  150. update_option('top_opt_custom_url_field', $_POST['top_opt_custom_url_field']);
  151. } else {
  152.  
  153. update_option('top_opt_custom_url_field', '');
  154. }
  155.  
  156. //use URL shortner?
  157. if (isset($_POST['top_opt_use_url_shortner'])) {
  158. update_option('top_opt_use_url_shortner', true);
  159. } else {
  160.  
  161. update_option('top_opt_use_url_shortner', false);
  162. }
  163.  
  164. //url shortener to use
  165. if (isset($_POST['top_opt_url_shortener'])) {
  166. update_option('top_opt_url_shortener', $_POST['top_opt_url_shortener']);
  167. if ($_POST['top_opt_url_shortener'] == "bit.ly") {
  168. if (isset($_POST['top_opt_bitly_user'])) {
  169. update_option('top_opt_bitly_user', $_POST['top_opt_bitly_user']);
  170. }
  171. if (isset($_POST['top_opt_bitly_key'])) {
  172. update_option('top_opt_bitly_key', $_POST['top_opt_bitly_key']);
  173. }
  174. }
  175. }
  176.  
  177. //hashtags option
  178. if (isset($_POST['top_opt_custom_hashtag_option'])) {
  179. update_option('top_opt_custom_hashtag_option', $_POST['top_opt_custom_hashtag_option']);
  180. } else {
  181. update_option('top_opt_custom_hashtag_option', "nohashtag");
  182. }
  183.  
  184. //use inline hashtags
  185. if (isset($_POST['top_opt_use_inline_hashtags'])) {
  186. update_option('top_opt_use_inline_hashtags', true);
  187. } else {
  188. update_option('top_opt_use_inline_hashtags', false);
  189. }
  190.  
  191. //hashtag length
  192. if (isset($_POST['top_opt_hashtag_length'])) {
  193. update_option('top_opt_hashtag_length', $_POST['top_opt_hashtag_length']);
  194. } else {
  195. update_option('top_opt_hashtag_length', 0);
  196. }
  197.  
  198. //custom field name to fetch hashtag from
  199. if (isset($_POST['top_opt_custom_hashtag_field'])) {
  200. update_option('top_opt_custom_hashtag_field', $_POST['top_opt_custom_hashtag_field']);
  201. } else {
  202. update_option('top_opt_custom_hashtag_field', '');
  203. }
  204.  
  205. //default hashtags for tweets
  206. if (isset($_POST['top_opt_hashtags'])) {
  207. update_option('top_opt_hashtags', $_POST['top_opt_hashtags']);
  208. } else {
  209. update_option('top_opt_hashtags', '');
  210. }
  211.  
  212. //tweet interval
  213. if (isset($_POST['top_opt_interval'])) {
  214. if (is_numeric($_POST['top_opt_interval']) && $_POST['top_opt_interval'] > 0) {
  215. update_option('top_opt_interval', $_POST['top_opt_interval']);
  216. } else {
  217. update_option('top_opt_interval', "4");
  218. }
  219. }
  220.  
  221. $next_tweet_time = time()+ get_option('top_opt_interval') * 60 * 60;
  222. update_option('next_tweet_time', $next_tweet_time);
  223.  
  224. //random interval
  225. if (isset($_POST['top_opt_interval_slop'])) {
  226. if (is_numeric($_POST['top_opt_interval_slop']) && $_POST['top_opt_interval_slop'] > 0) {
  227. update_option('top_opt_interval_slop', $_POST['top_opt_interval_slop']);
  228. } else {
  229. update_option('top_opt_interval_slop', "4");
  230. }
  231. }
  232.  
  233. //minimum post age to tweet
  234. if (isset($_POST['top_opt_age_limit'])) {
  235. if (is_numeric($_POST['top_opt_age_limit']) && $_POST['top_opt_age_limit'] >= 0) {
  236. update_option('top_opt_age_limit', $_POST['top_opt_age_limit']);
  237. } else {
  238. update_option('top_opt_age_limit', "30");
  239. }
  240. }
  241.  
  242. //maximum post age to tweet
  243. if (isset($_POST['top_opt_max_age_limit'])) {
  244. if (is_numeric($_POST['top_opt_max_age_limit']) && $_POST['top_opt_max_age_limit'] > 0) {
  245. update_option('top_opt_max_age_limit', $_POST['top_opt_max_age_limit']);
  246. } else {
  247. update_option('top_opt_max_age_limit', "0");
  248. }
  249. }
  250. //option as_number_tweet
  251.  
  252.  
  253.  
  254. //option to enable log
  255. if ( isset($_POST['top_enable_log'])) {
  256. update_option('top_enable_log', true);
  257. global $top_debug;
  258. $top_debug->enable( true );
  259.  
  260. }
  261. else{
  262. update_option('top_enable_log', false);
  263. global $top_debug;
  264. $top_debug->enable( false );
  265. }
  266.  
  267. //categories to omit from tweet
  268. if (isset($_POST['post_category'])) {
  269. update_option('top_opt_omit_cats', implode(',', $_POST['post_category']));
  270. } else {
  271. update_option('top_opt_omit_cats', '');
  272. }
  273.  
  274. //successful update message
  275. print('
  276. <div id="message" class="updated fade">
  277. <p>' . __('Tweetily Options Updated.', 'Tweetily') . '</p>
  278. </div>');
  279. }
  280. //tweet now clicked
  281. elseif (isset($_POST['tweet'])) {
  282. update_option('top_opt_last_update',time());
  283. $tweet_msg = top_opt_tweet_old_post();
  284. print('
  285. <div id="message" class="updated fade">
  286. <p>' . __($tweet_msg, 'Tweetily') . '</p>
  287. </div>');
  288. }
  289. elseif (isset($_POST['reset'])) {
  290. top_reset_settings();
  291. echo '<script language="javascript">window.open ("' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=Tweetily&top=reset","_self")</script>';
  292. die;
  293. }
  294.  
  295.  
  296. //set up data into fields from db
  297. global $wpdb;
  298.  
  299. $admin_url = site_url('/wp-admin/admin.php?page=Tweetily');
  300.  
  301. //Current URL - updated querie for those with caching plugins
  302. //$admin_url = $wpdb->get_var("select option_value from wp_options where option_name = 'top_opt_admin_url';");
  303. //$admin_url = get_option('top_opt_admin_url');
  304.  
  305. if (!isset($admin_url)) {
  306. $admin_url = top_currentPageURL();
  307. update_option('top_opt_admin_url', $admin_url);
  308. }
  309.  
  310. //what to tweet?
  311. $tweet_type = get_option('top_opt_tweet_type');
  312. if (!isset($tweet_type)) {
  313. $tweet_type = "title";
  314. }
  315.  
  316. //additional text
  317. $additional_text = get_option('top_opt_add_text');
  318. if (!isset($additional_text)) {
  319. $additional_text = "";
  320. }
  321.  
  322. //position of additional text
  323. $additional_text_at = get_option('top_opt_add_text_at');
  324. if (!isset($additional_text_at)) {
  325. $additional_text_at = "beginning";
  326. }
  327.  
  328. //include link in tweet
  329. $include_link = get_option('top_opt_include_link');
  330. if (!isset($include_link)) {
  331. $include_link = "no";
  332. }
  333.  
  334. //use custom field to fetch url
  335. $custom_url_option = get_option('top_opt_custom_url_option');
  336. if (!isset($custom_url_option)) {
  337. $custom_url_option = "";
  338. } elseif ($custom_url_option)
  339. $custom_url_option = "checked";
  340. else
  341. $custom_url_option="";
  342.  
  343. //custom field name for url
  344. $custom_url_field = get_option('top_opt_custom_url_field');
  345. if (!isset($custom_url_field)) {
  346. $custom_url_field = "";
  347. }
  348.  
  349. //use url shortner?
  350. $use_url_shortner = get_option('top_opt_use_url_shortner');
  351. if (!isset($use_url_shortner)) {
  352. $use_url_shortner = "";
  353. } elseif ($use_url_shortner)
  354. $use_url_shortner = "checked";
  355. else
  356. $use_url_shortner="";
  357.  
  358. //url shortner
  359. $url_shortener = get_option('top_opt_url_shortener');
  360. if (!isset($url_shortener)) {
  361. $url_shortener = top_opt_URL_SHORTENER;
  362. }
  363.  
  364. //bitly key
  365. $bitly_api = get_option('top_opt_bitly_key');
  366. if (!isset($bitly_api)) {
  367. $bitly_api = "";
  368. }
  369.  
  370. //bitly username
  371. $bitly_username = get_option('top_opt_bitly_user');
  372. if (!isset($bitly_username)) {
  373. $bitly_username = "";
  374. }
  375.  
  376. //hashtag option
  377. $custom_hashtag_option = get_option('top_opt_custom_hashtag_option');
  378. if (!isset($custom_hashtag_option)) {
  379. $custom_hashtag_option = "nohashtag";
  380. }
  381.  
  382. //use inline hashtag
  383. $use_inline_hashtags = get_option('top_opt_use_inline_hashtags');
  384. if (!isset($use_inline_hashtags)) {
  385. $use_inline_hashtags = "";
  386. } elseif ($use_inline_hashtags)
  387. $use_inline_hashtags = "checked";
  388. else
  389. $use_inline_hashtags="";
  390.  
  391. //hashtag length
  392. $hashtag_length = get_option('top_opt_hashtag_length');
  393. if (!isset($hashtag_length)) {
  394. $hashtag_length = "20";
  395. }
  396.  
  397. //custom field
  398. $custom_hashtag_field = get_option('top_opt_custom_hashtag_field');
  399. if (!isset($custom_hashtag_field)) {
  400. $custom_hashtag_field = "";
  401. }
  402.  
  403. //default hashtag
  404. $twitter_hashtags = get_option('top_opt_hashtags');
  405. if (!isset($twitter_hashtags)) {
  406. $twitter_hashtags = top_opt_HASHTAGS;
  407. }
  408.  
  409. //interval
  410. $interval = get_option('top_opt_interval');
  411. if (!(isset($interval) && is_numeric($interval))) {
  412. $interval = top_opt_INTERVAL;
  413. }
  414.  
  415. //random interval
  416. $slop = get_option('top_opt_interval_slop');
  417. if (!(isset($slop) && is_numeric($slop))) {
  418. $slop = top_opt_INTERVAL_SLOP;
  419. }
  420.  
  421. //min age limit
  422. $ageLimit = get_option('top_opt_age_limit');
  423. if (!(isset($ageLimit) && is_numeric($ageLimit))) {
  424. $ageLimit = top_opt_AGE_LIMIT;
  425. }
  426.  
  427. //max age limit
  428. $maxAgeLimit = get_option('top_opt_max_age_limit');
  429. if (!(isset($maxAgeLimit) && is_numeric($maxAgeLimit))) {
  430. $maxAgeLimit = top_opt_MAX_AGE_LIMIT;
  431. }
  432.  
  433.  
  434. //check enable log
  435. $top_enable_log = get_option('top_enable_log');
  436. if (!isset($top_enable_log)) {
  437. $top_enable_log = "";
  438. } elseif ($top_enable_log)
  439. $top_enable_log = "checked";
  440. else
  441. $top_enable_log="";
  442.  
  443. //set omitted categories
  444. $omitCats = get_option('top_opt_omit_cats');
  445. if (!isset($omitCats)) {
  446. $omitCats = top_opt_OMIT_CATS;
  447. }
  448.  
  449. $x = WP_PLUGIN_URL . '/' . str_replace(basename(__FILE__), "", plugin_basename(__FILE__));
  450.  
  451. print('
  452. <div class="wrap">
  453. <h2>' . __('Tweetily - Tweet WP Posts Automatically by - ', 'Tweetily') . ' <a href="http://thecustomerservicemanager.com">Flavio Martins</a></h2>
  454. <h3>If you like this plugin, follow <a href="http://www.twitter.com/flavmartins">@flavmartins</a> on Twitter to help keep this plugin free...FOREVER!</h3>
  455.  
  456. <a href="https://twitter.com/flavmartins" class="twitter-follow-button" data-show-count="true" data-size="large">Follow @flavmartins</a>
  457. <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  458. <br /><br />
  459.  
  460. <form id="top_opt" name="top_TweetOldPost" action="" method="post">
  461. <input type="hidden" name="top_opt_action" value="top_opt_update_settings" />
  462. <fieldset class="options">
  463. <div class="option">
  464. <label for="top_opt_twitter_username">' . __('', 'Tweetily') . '</label>
  465.  
  466.  
  467. <div id="profile-box">');
  468. if (!$settings["oauth_access_token"]) {
  469.  
  470. echo '<a href="' . top_get_auth_url() . '" class="auth-twitter">Sign in with Twitter</a>';
  471. } else {
  472. echo '<img class="avatar" src="' . $settings["profile_image_url"] . '" alt="" />
  473. <h4>' . $settings["screen_name"] . '</h4>';
  474. if ($settings["location"]) {
  475. echo '<h5>' . $settings["location"] . '</h5>';
  476. }
  477. echo '<p>
  478.  
  479. You\'re Connected! <a href="' . $_SERVER["REQUEST_URI"] . '&top=deauthorize" onclick=\'return confirm("Are you sure you want to deauthorize your Twitter account?");\'>Click here to deauthorize</a>.<br />
  480.  
  481. </p>
  482.  
  483. <div class="retweet-clear"></div>
  484. ';
  485. }
  486. $as_number_tweet = get_option('as_number_tweet');
  487. $as_post_type = get_option('as_post_type');
  488.  
  489.  
  490. print('</div>
  491. </div>
  492.  
  493. <div class="countdown_opt" style="width:100%;height:auto;overflow: hidden;float:none;border-bottom: dashed 1px #ccc;"><br />
  494. <label style="margin-left:40px;"><strong>Next Tweet coming in:</strong></label>
  495. <div id="defaultCountdown" style="width:20%;margin-left:15%;margin-bottom:40px;"></div>
  496. </div>
  497.  
  498. <div class="option" >
  499. <label for="top_opt_tweet_type" >' . __('Tweet Content:<br /><span class="desc">What do you want to share?<span>', 'Tweetily') . '</label>
  500. <select id="top_opt_tweet_type" name="top_opt_tweet_type" style="width:150px">
  501. <option value="title" ' . top_opt_optionselected("title", $tweet_type) . '>' . __(' Post Title Only ', 'Tweetily') . ' </option>
  502. <option value="body" ' . top_opt_optionselected("body", $tweet_type) . '>' . __(' Post Body Only ', 'Tweetily') . ' </option>
  503. <option value="titlenbody" ' . top_opt_optionselected("titlenbody", $tweet_type) . '>' . __(' Both Title & Body ', 'Tweetily') . ' </option>
  504. </select>
  505.  
  506. </div>
  507.  
  508.  
  509. <div class="option" >
  510. <label for="top_opt_add_text">' . __('Additional Text:<br /><span class="desc">Text added to your auto posts.<span>', 'Tweetily') . '</label>
  511. <input type="text" size="25" name="top_opt_add_text" id="top_opt_add_text" value="' . $additional_text . '" autocomplete="off" />
  512. </div>
  513. <div class="option" >
  514. <label for="top_opt_add_text_at">' . __('Additional Text Location:<br /><span class="desc">Where you want the added text.<span>', 'Tweetily') . ':</label>
  515. <select id="top_opt_add_text_at" name="top_opt_add_text_at" style="width:175px">
  516. <option value="beginning" ' . top_opt_optionselected("beginning", $additional_text_at) . '>' . __(' Beginning of the tweet ', 'Tweetily') . '</option>
  517. <option value="end" ' . top_opt_optionselected("end", $additional_text_at) . '>' . __(' End of the tweet ', 'Tweetily') . '</option>
  518. </select>
  519. </div>
  520.  
  521. <div class="option">
  522. <label for="top_opt_include_link">' . __('Include Link:<br /><span class="desc">Include a link to your post?<span>', 'Tweetily') . '</label>
  523. <select id="top_opt_include_link" name="top_opt_include_link" style="width:150px" onchange="javascript:showURLOptions()">
  524. <option value="false" ' . top_opt_optionselected("false", $include_link) . '>' . __(' No ', 'Tweetily') . '</option>
  525. <option value="true" ' . top_opt_optionselected("true", $include_link) . '>' . __(' Yes ', 'Tweetily') . '</option>
  526. </select>
  527. </div>
  528.  
  529. <div id="urloptions" style="display:none">
  530.  
  531.  
  532.  
  533. <div class="option">
  534. <label for="top_opt_use_url_shortner">' . __('Use URL shortner?:<br /><span class="desc">Shorten the link to your post.<span>', 'Tweetily') . '</label>
  535. <input onchange="return showshortener()" type="checkbox" name="top_opt_use_url_shortner" id="top_opt_use_url_shortner" ' . $use_url_shortner . ' />
  536.  
  537. </div>
  538.  
  539. <div id="urlshortener">
  540. <div class="option">
  541. <label for="top_opt_url_shortener">' . __('URL Shortener Service', 'Tweetily') . ':</label>
  542. <select name="top_opt_url_shortener" id="top_opt_url_shortener" onchange="javascript:showURLAPI()" style="width:100px;">
  543. <option value="is.gd" ' . top_opt_optionselected('is.gd', $url_shortener) . '>' . __('is.gd', 'Tweetily') . '</option>
  544. <option value="su.pr" ' . top_opt_optionselected('su.pr', $url_shortener) . '>' . __('su.pr', 'Tweetily') . '</option>
  545. <option value="bit.ly" ' . top_opt_optionselected('bit.ly', $url_shortener) . '>' . __('bit.ly', 'Tweetily') . '</option>
  546. <option value="tr.im" ' . top_opt_optionselected('tr.im', $url_shortener) . '>' . __('tr.im', 'Tweetily') . '</option>
  547. <option value="3.ly" ' . top_opt_optionselected('3.ly', $url_shortener) . '>' . __('3.ly', 'Tweetily') . '</option>
  548. <option value="u.nu" ' . top_opt_optionselected('u.nu', $url_shortener) . '>' . __('u.nu', 'Tweetily') . '</option>
  549. <option value="1click.at" ' . top_opt_optionselected('1click.at', $url_shortener) . '>' . __('1click.at', 'Tweetily') . '</option>
  550. <option value="tinyurl" ' . top_opt_optionselected('tinyurl', $url_shortener) . '>' . __('tinyurl', 'Tweetily') . '</option>
  551. </select>
  552. </div>
  553. <div id="showDetail" style="display:none">
  554. <div class="option">
  555. <label for="top_opt_bitly_user">' . __('bit.ly Username', 'Tweetily') . ':</label>
  556. <input type="text" size="25" name="top_opt_bitly_user" id="top_opt_bitly_user" value="' . $bitly_username . '" autocomplete="off" />
  557. </div>
  558.  
  559. <div class="option">
  560. <label for="top_opt_bitly_key">' . __('bit.ly API Key', 'Tweetily') . ':</label>
  561. <input type="text" size="25" name="top_opt_bitly_key" id="top_opt_bitly_key" value="' . $bitly_api . '" autocomplete="off" />
  562. </div>
  563. </div>
  564. </div>
  565. </div>
  566.  
  567.  
  568. <div class="option" >
  569. <label for="top_opt_custom_hashtag_option">' . __('#Hashtags:<br /><span class="desc">Include #hashtags in your auto posts.<span>', 'Tweetily') . '</label>
  570. <select name="top_opt_custom_hashtag_option" id="top_opt_custom_hashtag_option" onchange="javascript:return showHashtagCustomField()" style="width:275px;">
  571. <option value="nohashtag" ' . top_opt_optionselected('nohashtag', $custom_hashtag_option) . '>' . __('No. Don\'t add any hashtags', 'Tweetily') . '</option>
  572. <option value="common" ' . top_opt_optionselected('common', $custom_hashtag_option) . '>' . __('Yes. Use common hashtags for all tweets', 'Tweetily') . '</option>
  573. <option value="categories" ' . top_opt_optionselected('categories', $custom_hashtag_option) . '>' . __('Yes, Use hashtags from post categories', 'Tweetily') . '</option>
  574. <option value="tags" ' . top_opt_optionselected('tags', $custom_hashtag_option) . '>' . __('Yes. Use create hashtags from post tags', 'Tweetily') . '</option>
  575.  
  576.  
  577. </select>
  578.  
  579.  
  580. </div>
  581. <div id="inlinehashtag" style="display:none;">
  582. <div class="option">
  583. <label for="top_opt_use_inline_hashtags">' . __('Use inline hashtags: ', 'Tweetily') . '</label>
  584. <input type="checkbox" name="top_opt_use_inline_hashtags" id="top_opt_use_inline_hashtags" ' . $use_inline_hashtags . ' />
  585.  
  586. </div>
  587.  
  588. <div class="option">
  589. <label for="top_opt_hashtag_length">' . __('Maximum characters for hashtags: ', 'Tweetily') . '</label>
  590. <input type="text" size="25" name="top_opt_hashtag_length" id="top_opt_hashtag_length" value="' . $hashtag_length . '" />
  591. <strong>(If 0, all hashtags will be included.)</strong>
  592. </div>
  593. </div>
  594. <div id="customhashtag" style="display:none;">
  595. <div class="option">
  596. <label for="top_opt_custom_hashtag_field">' . __('Custom field name', 'Tweetily') . ':</label>
  597. <input type="text" size="25" name="top_opt_custom_hashtag_field" id="top_opt_custom_hashtag_field" value="' . $custom_hashtag_field . '" autocomplete="off" />
  598. <strong>Get hashtags from this custom field</strong>
  599. </div>
  600.  
  601. </div>
  602. <div id="commonhashtag" style="display:none;">
  603. <div class="option">
  604. <label for="top_opt_hashtags">' . __('Common #hashtags for your tweets', 'Tweetily') . ':</label>
  605. <input type="text" size="25" name="top_opt_hashtags" id="top_opt_hashtags" value="' . $twitter_hashtags . '" autocomplete="off" />
  606. <strong>Include #. (e.g. #marketing, #blogging, #custserv)</strong>
  607. </div>
  608. </div>
  609. <div class="option" >
  610. <label for="top_opt_interval">' . __('Time between tweets: <br /><span class="desc">Minimum time between your tweets?<span>', 'Tweetily') . '</label>
  611. <input type="text" id="top_opt_interval" maxlength="5" value="' . $interval . '" name="top_opt_interval" /> Hour / Hours <strong>(If 0, it will default to 4 hours.)</strong>
  612.  
  613. </div>
  614. <div class="option" >
  615. <label for="top_opt_interval_slop">' . __('Random Time Added: <br /><span class="desc">Random time added to make your post normal.<span>', 'Tweetily') . '</label>
  616. <input type="text" id="top_opt_interval_slop" maxlength="5" value="' . $slop . '" name="top_opt_interval_slop" /> Hour / Hours <strong>(If 0, it will default to 4 hours.)</strong>
  617.  
  618. </div>
  619. <div class="option" >
  620. <label for="top_opt_age_limit">' . __('Minimum age of post: <br /><span class="desc">Include post in tweets if at least this age.<span>', 'Tweetily') . '</label>
  621. <input type="text" id="top_opt_age_limit" maxlength="5" value="' . $ageLimit . '" name="top_opt_age_limit" /> Day / Days
  622. <strong>(If 0, it will include today.)</strong>
  623.  
  624. </div>
  625.  
  626. <div class="option" >
  627. <label for="top_opt_max_age_limit">' . __('Maximum age of post: <br /><span class="desc">Don\'t include posts older than this.<span>', 'Tweetily') . '</label>
  628. <input type="text" id="top_opt_max_age_limit" maxlength="5" value="' . $maxAgeLimit . '" name="top_opt_max_age_limit" /> Day / Days
  629. <strong>(If 0, all posts will be included.)</strong>
  630. </div>
  631.  
  632. <div class="option" >
  633. <label for="top_enable_log">' . __('Enable Logging: ', 'Tweetily') . '</label>
  634. <input type="checkbox" name="top_enable_log" id="top_enable_log" ' . $top_enable_log . ' />
  635. <strong>Yes, save a log of actions in log file.</strong>
  636.  
  637. </div>
  638. <div class="option">
  639. <label class="ttip">Number of Tweets: <span class="desc">Number of tweets to share each time.<span></label>
  640. <input type="text" value="'.$as_number_tweet.'" name="as_number_tweet"/>
  641. </div>
  642.  
  643. <div class="option">
  644. <label class="ttip">Select post type: <span class="desc">What type of items do you want to share?<span></label>
  645.  
  646.  
  647. <select name="as_post_type">
  648. <option value="post">Only Posts</option>
  649. <option value="page">Only Pages</option>
  650. <option value="all">Both Posts & Pages</option>
  651. </select> Currently sharing:&nbsp;'.$as_post_type.'
  652. </div>
  653.  
  654. <div class="option category">
  655. <div style="float:left">
  656. <label class="catlabel">' . __('Exclude Categories: <span class="desc">Check categories not to share.<span>', 'Tweetily') . '</label> </div>
  657. <div style="float:left">
  658. <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
  659. ');
  660. wp_category_checklist(0, 0, explode(',', $omitCats));
  661. print(' </ul>
  662. <div style="clear:both;padding-top:20px;">
  663. <a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=ExcludePosts">Exclude specific posts</a> from selected categories.
  664. </div>
  665.  
  666.  
  667. </div>
  668.  
  669. </div>
  670. </fieldset>
  671.  
  672. <div class="option">
  673. <label for="top_opt_admin_url">' . __('Your Tweetily Plugin Admin URL', 'Tweetily') . ':</label>
  674. <input type="text" style="width:500px" id="top_opt_admin_url" value="' . $admin_url . '" name="top_opt_admin_url" /><br /><strong>(Note: If this does not show your current URL in this textbox, paste the current URL in this textbox, then click "Update Options".)</strong>
  675. </div>
  676.  
  677.  
  678. <p class="submit"><input type="submit" name="submit" onclick="javascript:return validate()" value="' . __('Update Tweetily Options', 'Tweetily') . '" />
  679. <input type="submit" name="tweet" value="' . __('Tweet Now!', 'Tweetily') . '" />
  680. <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', 'Tweetily') . '" /><br /><br /><strong>Note: Please remember to click "Update Settings" after making any changes.</strong>
  681. </p>
  682.  
  683. </form><script language="javascript" type="text/javascript">
  684. function showURLAPI()
  685. {
  686. var urlShortener=document.getElementById("top_opt_url_shortener").value;
  687. if(urlShortener=="bit.ly")
  688. {
  689. document.getElementById("showDetail").style.display="block";
  690.  
  691. }
  692. else
  693. {
  694. document.getElementById("showDetail").style.display="none";
  695.  
  696. }
  697.  
  698. }
  699.  
  700. function validate()
  701. {
  702.  
  703. if(document.getElementById("showDetail").style.display=="block" && document.getElementById("top_opt_url_shortener").value=="bit.ly")
  704. {
  705. if(trim(document.getElementById("top_opt_bitly_user").value)=="")
  706. {
  707. alert("Please enter bit.ly username.");
  708. document.getElementById("top_opt_bitly_user").focus();
  709. return false;
  710. }
  711.  
  712. if(trim(document.getElementById("top_opt_bitly_key").value)=="")
  713. {
  714. alert("Please enter bit.ly API key.");
  715. document.getElementById("top_opt_bitly_key").focus();
  716. return false;
  717. }
  718. }
  719. if(trim(document.getElementById("top_opt_interval").value) != "" && !isNumber(trim(document.getElementById("top_opt_interval").value)))
  720. {
  721. alert("Enter only numeric in Minimum interval between tweet");
  722. document.getElementById("top_opt_interval").focus();
  723. return false;
  724. }
  725. if(trim(document.getElementById("top_opt_interval_slop").value) != "" && !isNumber(trim(document.getElementById("top_opt_interval_slop").value)))
  726. {
  727. alert("Enter only numeric in Random interval");
  728. document.getElementById("top_opt_interval_slop").focus();
  729. return false;
  730. }
  731. if(trim(document.getElementById("top_opt_age_limit").value) != "" && !isNumber(trim(document.getElementById("top_opt_age_limit").value)))
  732. {
  733. alert("Enter only numeric in Minimum age of post");
  734. document.getElementById("top_opt_age_limit").focus();
  735. return false;
  736. }
  737. if(trim(document.getElementById("top_opt_max_age_limit").value) != "" && !isNumber(trim(document.getElementById("top_opt_max_age_limit").value)))
  738. {
  739. alert("Enter only numeric in Maximum age of post");
  740. document.getElementById("top_opt_max_age_limit").focus();
  741. return false;
  742. }
  743. if(trim(document.getElementById("top_opt_max_age_limit").value) != "" && trim(document.getElementById("top_opt_max_age_limit").value) != 0)
  744. {
  745. if(eval(document.getElementById("top_opt_age_limit").value) > eval(document.getElementById("top_opt_max_age_limit").value))
  746. {
  747. alert("Post max age limit cannot be less than Post min age iimit");
  748. document.getElementById("top_opt_age_limit").focus();
  749. return false;
  750. }
  751. }
  752. }
  753.  
  754. function trim(stringToTrim) {
  755. return stringToTrim.replace(/^\s+|\s+$/g,"");
  756. }
  757.  
  758. function showCustomField()
  759. {
  760. if(document.getElementById("top_opt_custom_url_option").checked)
  761. {
  762. document.getElementById("customurl").style.display="block";
  763. }
  764. else
  765. {
  766. document.getElementById("customurl").style.display="none";
  767. }
  768. }
  769.  
  770. function showHashtagCustomField()
  771. {
  772. if(document.getElementById("top_opt_custom_hashtag_option").value=="custom")
  773. {
  774. document.getElementById("customhashtag").style.display="block";
  775. document.getElementById("commonhashtag").style.display="none";
  776. document.getElementById("inlinehashtag").style.display="block";
  777. }
  778. else if(document.getElementById("top_opt_custom_hashtag_option").value=="common")
  779. {
  780. document.getElementById("customhashtag").style.display="none";
  781. document.getElementById("commonhashtag").style.display="block";
  782. document.getElementById("inlinehashtag").style.display="block";
  783. }
  784. else if(document.getElementById("top_opt_custom_hashtag_option").value=="nohashtag")
  785. {
  786. document.getElementById("customhashtag").style.display="none";
  787. document.getElementById("commonhashtag").style.display="none";
  788. document.getElementById("inlinehashtag").style.display="none";
  789. }
  790. else
  791. {
  792. document.getElementById("inlinehashtag").style.display="block";
  793. document.getElementById("customhashtag").style.display="none";
  794. document.getElementById("commonhashtag").style.display="none";
  795. }
  796. }
  797.  
  798. function showURLOptions()
  799. {
  800. if(document.getElementById("top_opt_include_link").value=="true")
  801. {
  802. document.getElementById("urloptions").style.display="block";
  803. }
  804. else
  805. {
  806. document.getElementById("urloptions").style.display="none";
  807. }
  808. }
  809.  
  810. function isNumber(val)
  811. {
  812. if(isNaN(val)){
  813. return false;
  814. }
  815. else{
  816. return true;
  817. }
  818. }
  819.  
  820. function showshortener()
  821. {
  822.  
  823.  
  824. if((document.getElementById("top_opt_use_url_shortner").checked))
  825. {
  826. document.getElementById("urlshortener").style.display="block";
  827. }
  828. else
  829. {
  830. document.getElementById("urlshortener").style.display="none";
  831. }
  832. }
  833. function setFormAction()
  834. {
  835. if(document.getElementById("top_opt_admin_url").value == "")
  836. {
  837. document.getElementById("top_opt_admin_url").value=location.href;
  838. document.getElementById("top_opt").action=location.href;
  839. }
  840. else
  841. {
  842. document.getElementById("top_opt").action=document.getElementById("top_opt_admin_url").value;
  843. }
  844. }
  845.  
  846. setFormAction();
  847. showURLAPI();
  848. showshortener();
  849. showCustomField();
  850. showHashtagCustomField();
  851. showURLOptions();
  852.  
  853. </script>');
  854.  
  855.  
  856. echo "<script type='text/javascript' src='".plugins_url('countdown/jquery-1.7.1.min.js', __FILE__)."'></script>";
  857.  
  858. echo "<script type='text/javascript' src='".plugins_url('countdown/jquery.countdown.pack.js', __FILE__)."'></script>";
  859.  
  860. $next_tweet_time = get_option('next_tweet_time') ;
  861. echo "<script type='text/javascript'>
  862. $(function () {
  863. var untilDay = new Date($next_tweet_time * 1000);
  864. $('#defaultCountdown').countdown({until: untilDay , format: 'HMS'});
  865. });
  866. </script>";
  867.  
  868. } else {
  869. print('
  870. <div id="message" class="updated fade">
  871. <p>' . __('Oh no! Permission error, please contact your Web site administrator.', 'Tweetily') . '</p>
  872. </div>');
  873. }
  874. }
  875.  
  876. function top_opt_optionselected($opValue, $value) {
  877. if ($opValue == $value) {
  878. return 'selected="selected"';
  879. }
  880. return '';
  881. }
  882.  
  883. function top_opt_head_admin() {
  884. $home = get_settings('siteurl');
  885. $base = '/' . end(explode('/', str_replace(array('\\', '/top-admin.php'), array('/', ''), __FILE__)));
  886. $stylesheet = $home . '/wp-content/plugins' . $base . '/css/tweet-old-post.css';
  887. echo('<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />');
  888. }
  889.  
  890. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement