The Twitter Stream twitter stream options page function.




  1. if ( !function_exists( 'twitter_stream_options_page' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'twitter-stream/twitter-stream.php'; 
  5. // NOTICE! Understand what this does before running. 
  6. $result = twitter_stream_options_page(); 

Defined (1)

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

  1. function twitter_stream_options_page() { 
  2. ?> 
  3. <div class="wrap"> 
  4. <h2><?php _e( 'Twitter Stream Authorize Page', 'twit_sream' ); ?></h2> 
  5. Created by <strong>Paul Robinson</strong>. 
  6. <small style="margin-bottom: 25px; display: block;">Confused? Unsure what to do? Check the <a href="">documentation</a></small> 
  7. <?php 
  8. if(isset($_GET['wptwit-page']) && $_GET['wptwit-page'] == 'cachedeleted') { 
  9. ?> 
  10. <div id="message" class="updated fade"> 
  11. <p><strong> 
  12. <?php _e('Cache Deleted!', 'twit_stream' ); ?> 
  13. </strong></p> 
  14. </div> 
  15. <?php 
  16. } elseif(isset($_GET['wptwit-page']) && $_GET['wptwit-page'] == 'cachefailed') { 
  17. ?> 
  18. <div id="message" class="error fade"> 
  19. <p><strong> 
  20. <?php _e('Cache Deletion Failed!', 'twit_stream' ); ?> 
  21. </strong></p> 
  22. </div> 
  23. <?php 
  24. ?> 
  25. <div style="width: 500px; margin-top:10px;"> 
  26. <div style="border: 1px solid rgb(221, 221, 221); padding: 10px; float: left; background-color: white; margin-right: 15px;"> 
  27. <div style="width: 350px; height: 130px; float:left;"> 
  28. <h3>Donate</h3> 
  29. <p>If you like this plugin and have found it to be useful, please help me keep this plugin free by clicking the <a href="" target="_blank"><strong>donate</strong></a> button, or you can send me a gift from my <a href="" target="_blank"><strong>Amazon wishlist</strong></a>. Thank you.</p> 
  30. </div> 
  31. <div style="width:100px; float:left; margin:15px 0 0 10px;"> 
  32. <a target="_blank" title="Donate" href=""><img src="<?php echo WP_PLUGIN_URL; ?>/twitter-stream/donate-paypal.jpg" alt="Donate with Paypal"> </a> 
  33. <a target="_blank" title="Amazon Wish List" href=""> 
  34. <img src="<?php echo WP_PLUGIN_URL; ?>/twitter-stream/amazon-wishlist.jpg" alt="My Amazon Wish List"> </a> 
  35. </div> 
  36. <div style="clear:both;"></div> 
  37. </div> 
  38. </div> 
  39. <div style="clear: both;"></div> 
  40. <?php 
  41. //Have we already been authorized? 
  42. $token = get_option('twitter_stream_token'); 
  43. if(!defined('CONSUMER_KEY') && !defined('CONSUMER_SECRET')) { 
  44. ?> 
  45. <h3>Create A Twitter App</h3> 
  46. <p>To sign into Twitter via Twitter Stream you will need to register for a Twitter App. The process is fairly quick and can be done by clicking the 'Get your consumer keys' button below (opens in new window/tab), <strong>please read the instructions below first</strong>. Due to how finnicky oAuth can be, any tiny mistakes can and will cause a lot of heartache.</p> 
  47. <div style="margin: 15px 0 15px 0;"><a href="" target="_blank"><img src="<?php echo WP_PLUGIN_URL; ?>/twitter-stream/twitter-oauth-button.png" alt="Get your consumer keys"/></a></div> 
  48. <p>In the fields you are given you will need to enter the following information. <strong>Important:</strong> You must enter the callback URL, failing to do so will result in anerrorin the next step.</p> 
  49. <ul> 
  50. <li><strong>Name & Description:</strong> Any name to identify your blog (e.g. <?php echo bloginfo('name'); ?> Stream), it cannot contain the word 'Twitter'. The description is also required, just enter something that will remind you what you created the app for, must be 10 characters or more.</li> 
  51. <li><strong>Website:</strong> Generally the URL to the home page of your blog. Again required, and must be related to your website.</li> 
  52. <li><strong>Callback URL:</strong> Enter the following: <strong>http://<?php echo $_SERVER['HTTP_HOST'] . preg_replace('/&wptwit-page=[^&]*/', '', $_SERVER['REQUEST_URI']) . '&wptwit-page=callback'; ?></strong></li> 
  53. </ul> 
  54. <p>Once you have completed the registration click on the <strong>Keys and Access Tokens</strong> tab. The two key's you need are the <strong>Consumer Key (API Key)</strong> and the <strong>Consumer Secret (API Secret)</strong>. Please enter them in the boxes below & hit save.</p> 
  55. <p><strong>N.B:</strong> Apps are automatically set for Read/Write access. If you wish you can switch this to Read Only as Twitter Stream does not need write access to your Twitter account.</p> 
  56. <h3>Enter Key Information</h3> 
  57. <form action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>" method="post"> 
  58. <label for="consumerkey" style="font-weight:bold;display:block;width:150px;">Consumer Key (API Key):</label> <input type="text" value="" id="consumerkey" name="consumerkey" /> 
  59. <label for="consumersecret" style="font-weight:bold;display:block;width:150px;margin-top:5px;">Consumer Secret (API Secret):</label> <input type="text" value="" id="consumersecret" name="consumersecret" /> 
  60. <input type="submit" value="Save" style="display:block;margin-top:10px;" /> 
  61. </form> 
  62. <?php 
  63. } elseif(!is_array($token) && !isset($token['oauth_token'])) { 
  64. ?> 
  65. <h3>Sign In With Twitter</h3> 
  66. <p>Now you have registered a Twitter App and the keys have been saved, we can sign you into Twitter & finally get Twitter Stream up and running. To sign in simply click the 'sign in with Twitter' button below, check the details on the page that follows match that of the Twitter App you created, and finally press the 'allow' button.</p> 
  67. <div style="margin: 15px 0 15px 0;"><a href="<?php echo preg_replace('/&wptwit-page=[^&]*/', '', $_SERVER['REQUEST_URI']) . '&wptwit-page=redirect'; ?>"><img src="<?php echo WP_PLUGIN_URL; ?>/twitter-stream/darker.png" alt="Sign in with Twitter"/></a></div> 
  68. <h3>I'm Getting A 401 Error! What Do I Do?</h3> 
  69. <p>Here are a few common issues that cause this error. Please make sure one of these is not the issue. If you are still having trouble please get in touch via <a href=""></a>.</p> 
  70. <ul> 
  71. <li>Whitespace in the Keys. This is less of a problem now as Twitter Stream tries to strip any whitespace from the keys, but it can still happen in some cases.</li> 
  72. <li>No Callback URL set on the app. This happens quite a lot. It is very, very important to set the callback URL when creating your app with Twitter. Twitter Stream will generally fail with a 401errorif you do not enter it.</li> 
  73. <li>Wrong Keys. I know it sounds like "Is it switched on?", but sometimes the wrong keys have been used. Please make sure to enter the <strong>API Key</strong> & <strong>API Secret</strong> from below the Application Settings header found on the API Keys tab of your Twitter application page.</li> 
  74. </ul> 
  75. <p>As mentioned, if none of those help please don't hesitate to get in touch & I'll try to help as soon as I am able.</p> 
  76. <h3>What If I Made A Mistake Entering The Keys?</h3> 
  77. <p>If you made a mistake entering the keys please click <a href="<?php echo preg_replace('/&wptwit-page=[^&]*/', '', $_SERVER['REQUEST_URI']) . '&wptwit-page=deletekeys'; ?>" style="color: #aa0000;">delete</a> to remove them.</p> 
  78. <?php 
  79. } else { 
  80. ?> 
  81. <h3>Twitter Stream Authorized!</h3> 
  82. <p>If you ever wish to revoke Twitter Stream's access to your twitter account just go to <a href="">Twitter's</a> Development website, login, then hover over your username (top right) and hit <strong>My Applications</strong>. Find the name of the application you created when authorizing Twitter Stream and click it. Next press the 'Delete' button at the bottom of the page. Remember that doing this will obviously stop Twitter Stream from working. Once you've done that, click <a href="<?php echo preg_replace('/&wptwit-page=[^&]*/', '', $_SERVER['REQUEST_URI']) . '&wptwit-page=deletekeys'; ?>" style="color: #aa0000;">here</a> to revoke your keys from the WordPress database as they are no longer needed.</p> 
  83. <h3>What Do I Do Now?</h3> 
  84. <p>The easiest way to use Twitter Stream is to add it via the widgets. Just go to the widgets page and add the Twitter Stream widget to one of your widget areas. The alternative is to use the function by including <code><php twitter_stream(); ?></code> in your template somewhere. You can customize it using the parameters shown <a href="">here</a>. 
  85. <h3>I Need To Change My Keys!</h3> 
  86. <p>If you ever need to change your consumer keys for whatever reason click <a href="<?php echo preg_replace('/&wptwit-page=[^&]*/', '', $_SERVER['REQUEST_URI']) . '&wptwit-page=deletekeys'; ?>" style="color: #aa0000;">delete</a> to remove them.</p> 
  87. <?php 
  88. ?> 
  89. <h3>How Do I delete The Cache?</h3> 
  90. <p>Use the small button below to delete the cache. Use this if there is anerrormessage displaying instead of your Tweets or if you have changed your widget/template function settings.</p> 
  91. <a href="<?php echo preg_replace('/&wptwit-page=[^&]*/', '', $_SERVER['REQUEST_URI']) . '&wptwit-page=deletecache'; ?>" style="display:block;width:95px;text-decoration:none;border:line-height:15px;margin:1px;padding:3px;font-size:11px;-moz-border-radius:4px 4px 4px 4px;-webkit-border-radius:4px 4px 4px 4px;border-radius:4px 4px 4px 4px;border-style:solid;border-width:1px;background-color:#fff0f5;border-color:#BBBBBB;color:#464646;text-align:center;">Delete Cache?</a> 
  92. <p><small>Huge thanks to <a href="">Abraham Williams</a> for creating TwitterOAuth which is used to connect Twitter Stream to Twitter via oAuth.</small></p> 
  93. </div> 
  94. <?php