tweet_afo_settings

The Recent Tweet Widget AFO tweet afo settings class.

Defined (1)

The class is defined in the following location(s).

/settings.php  
  1. class tweet_afo_settings { 
  2.  
  3. static $title = 'Recent Tweet Widget AFO Settings'; 
  4.  
  5. public function __construct() { 
  6. $this->load_settings(); 
  7.  
  8. public function tweet_widget_afo_options () { 
  9. global $wpdb; 
  10.  
  11. $afo_twitteruser = get_option('afo_twitteruser'); 
  12. $afo_notweets = get_option('afo_notweets'); 
  13. $afo_consumerkey = get_option('afo_consumerkey'); 
  14. $afo_consumersecret = get_option('afo_consumersecret'); 
  15. $afo_accesstoken = get_option('afo_accesstoken'); 
  16. $afo_accesstokensecret = get_option('afo_accesstokensecret'); 
  17. $this->twitter_feed_pro_add(); 
  18. $this->help_support(); 
  19. ?> 
  20. <form name="f" method="post" action=""> 
  21. <input type="hidden" name="option" value="tweet_widget_afo_save_settings" /> 
  22. <?php wp_nonce_field( 'tweet_widget_afo_save_action', 'tweet_widget_afo_save_action_field' ); ?> 
  23. <table width="100%" border="0" style="width:98%; background-color:#fff; border:1px solid #ccc; margin:2px 0px; padding:10px;"> 
  24. <?php if(isset($GLOBALS['msg'])) { ?> 
  25. <tr> 
  26. <td width="45%" colspan="2"><div class="afo_error"><?php echo $GLOBALS['msg'];?></div></td> 
  27. </tr> 
  28. <?php } ?> 
  29. <tr> 
  30. <td width="45%" colspan="2"><h1><?php echo self::$title;?></h1></td> 
  31. </tr> 
  32. <tr> 
  33. <td><strong>Twitter Username: <font color="red">(required)</font></strong></td> 
  34. <td><input type="text" name="afo_twitteruser" value="<?php echo $afo_twitteruser;?>" /></td> 
  35. </tr> 
  36. <tr> 
  37. <td><strong>No of Tweets: </strong></td> 
  38. <td><input type="text" name="afo_notweets" value="<?php echo $afo_notweets;?>" /> Default is 5</td> 
  39. </tr> 
  40. <tr> 
  41. <td><strong>Consumer Key: <font color="red">(required)</font></strong></td> 
  42. <td><input type="text" name="afo_consumerkey" value="<?php echo $afo_consumerkey;?>" /></td> 
  43. </tr> 
  44. <tr> 
  45. <td><strong>Consumer Secret: <font color="red">(required)</font></strong></td> 
  46. <td><input type="text" name="afo_consumersecret" value="<?php echo $afo_consumersecret;?>" /></td> 
  47. </tr> 
  48. <tr> 
  49. <td><strong>Access Token: <font color="red">(required)</font></strong></td> 
  50. <td><input type="text" name="afo_accesstoken" value="<?php echo $afo_accesstoken;?>" /></td> 
  51. </tr> 
  52. <tr> 
  53. <td><strong>Access Token Secret: <font color="red">(required)</font></strong></td> 
  54. <td><input type="text" name="afo_accesstokensecret" value="<?php echo $afo_accesstokensecret;?>" /></td> 
  55. </tr> 
  56. <tr> 
  57. <td> </td> 
  58. <td><input type="submit" name="submit" value="Save" class="button button-primary button-large" /></td> 
  59. </tr> 
  60. <tr> 
  61. <td> </td> 
  62. <td> </td> 
  63. </tr> 
  64. <tr> 
  65. <td colspan="2">You need to create a new twitter app and enter all the required data mentioned in the form. <br /> 
  66. Please log in to <a href="https://apps.twitter.com/" target="_blank">https://apps.twitter.com/</a> with your twitter account <strong>Username</strong> and <strong>Password</strong>. And click on the <strong>Create new app</strong> button.<br /> 
  67. A new window will open. Enter all the relevant data, and follow the instructions. Your new app will be created.<br /> 
  68. Now on the <strong>API Keys</strong> tab you will get all the data required for the plugin to work. 
  69. </td> 
  70. </tr> 
  71. </table> 
  72. </form> 
  73. <?php  
  74. $this->donate(); 
  75.  
  76. public function help_support() { ?> 
  77. <table width="98%" border="0" style="background-color:#FFFFFF; border:1px solid #CCCCCC; padding:0px 0px 0px 10px; margin:2px 0px;"> 
  78. <tr> 
  79. <td align="right"><a href="http://www.aviplugins.com/support.php" target="_blank">Help and Support</a> <a href="http://www.aviplugins.com/rss/news.xml" target="_blank"><img src="<?php echo plugin_dir_url( __FILE__ ) . '/images/rss.png';?>" style="vertical-align: middle;" alt="RSS"></a></td> 
  80. </tr> 
  81. </table> 
  82. <?php 
  83.  
  84. private function donate() { ?> 
  85. <table width="98%" border="0" style="background-color:#FFF; border:1px solid #ccc; margin:2px 0px; padding-right:10px;"> 
  86. <tr> 
  87. <td align="right"><a href="http://www.aviplugins.com/donate/" target="_blank">Donate</a> <img src="<?php echo plugin_dir_url( __FILE__ ) . '/images/paypal.png';?>" style="vertical-align: middle;" alt="PayPal"></td> 
  88. </tr> 
  89. </table> 
  90. <?php 
  91.  
  92. private function twitter_feed_pro_add() { ?> 
  93. <table width="98%" border="0" style="background-color:#FFFFD2; border:1px solid #E6DB55; padding:0px 0px 0px 10px; margin:2px 0px;"> 
  94. <tr> 
  95. <td><p>The PRO version <strong>Twitter Feed PRO</strong> supports Twitter feeds from multiple accounts. There is option to customize the look of the twitter feed widget. Select background color, link color, link hover color, link hover style etc. You can get it <a href="http://aviplugins.com/twitter-feed-pro/" target="_blank">here</a> in <strong>USD 2.00</strong> </p></td> 
  96. </tr> 
  97. </table> 
  98. <?php } 
  99.  
  100. public function tween_widget_afo_menu () { 
  101. add_options_page( 'Recent Tweet Widget', 'Tweet Widget Settings', 'activate_plugins', 'tween_widget_afo_menu', array( $this, 'tweet_widget_afo_options') ); 
  102.  
  103. public function tweet_widget_afo_save_settings() { 
  104. if(isset($_POST['option']) and sanitize_text_field($_POST['option']) == "tweet_widget_afo_save_settings") { 
  105.  
  106. if ( ! isset( $_POST['tweet_widget_afo_save_action_field'] ) || ! wp_verify_nonce( $_POST['tweet_widget_afo_save_action_field'], 'tweet_widget_afo_save_action' ) ) { 
  107. wp_die( 'Sorry, your nonce did not verify.'); 
  108. }  
  109.  
  110. update_option( 'afo_twitteruser', sanitize_text_field($_POST['afo_twitteruser']) ); 
  111. update_option( 'afo_notweets', sanitize_text_field($_POST['afo_notweets']) ); 
  112. update_option( 'afo_consumerkey', sanitize_text_field($_POST['afo_consumerkey']) ); 
  113. update_option( 'afo_consumersecret', sanitize_text_field($_POST['afo_consumersecret']) ); 
  114. update_option( 'afo_accesstoken', sanitize_text_field($_POST['afo_accesstoken']) ); 
  115. update_option( 'afo_accesstokensecret', sanitize_text_field($_POST['afo_accesstokensecret']) ); 
  116. $GLOBALS['msg'] = 'Settings saved successfully.'; 
  117.  
  118. public function load_settings() { 
  119. add_action( 'admin_menu' , array( $this, 'tween_widget_afo_menu' ) ); 
  120. add_action( 'admin_init', array( $this, 'tweet_widget_afo_save_settings' ) ); 
  121. add_action( 'admin_enqueue_scripts', array( $this, 'register_plugin_styles') ); 
  122.  
  123. public function register_plugin_styles() { 
  124. wp_enqueue_style( 'style_tweet_widget', plugins_url( 'twitter-feed-afo/style_tweet_widget.css' ) ); 
  125.