Permalink
Browse files

fixed issues for request token on first setup

  • Loading branch information...
1 parent a3f7553 commit dd0088e40c216891100fca9e24a6b9027ee79344 @zagraves zagraves committed Oct 22, 2009
Showing with 70 additions and 50 deletions.
  1. +8 −5 yupdates.php
  2. +1 −1 yupdates_hooks.php
  3. +56 −39 yupdates_options.php
  4. +5 −5 yupdates_widgets.php
View
@@ -63,9 +63,9 @@
add_action("admin_menu", "yupdates_plugin_menu");
add_action("init", "yupdates_auth_init");
- add_action("delete_post", "yupdates_delete_post");
- add_action("edit_post", "yupdates_edit_post");
add_action("publish_post", "yupdates_publish_post");
+ // add_action("delete_post", "yupdates_delete_post");
+ // add_action("edit_post", "yupdates_edit_post");
?>
<?php
function yupdates_plugin_menu() {
@@ -93,11 +93,13 @@ function yupdates_auth_init() {
$request_token = $session->store->fetchRequestToken();
if(is_null($request_token->key) && !is_null($request_token->oauth_problem)) {
add_action("admin_notices", "yupdates_requestTokenProblem_warning");
+ } else if(stripos($_SERVER["REQUEST_URI"], USER_MENU_URI) === FALSE) {
+ add_action("admin_notices", "yupdates_authorization_warning");
}
- } else if($session->store->hasAccessToken()) {
-
} else if(yupdatesdb_hasApplicationInfo() && stripos($_SERVER["REQUEST_URI"], USER_MENU_URI) === FALSE ) {
add_action("admin_notices", "yupdates_authorization_warning");
+ } else if($session->store->hasAccessToken()) {
+ // do nothing, we're all set.
}
}
@@ -111,7 +113,8 @@ function yupdates_auth_init() {
function yupdates_requestTokenProblem_warning() {
$session_store = yupdates_get_currentUserSessionStore();
$token = $session_store->fetchRequestToken();
- $oauth_problem = $token->oauth_problem;
+ $oauth_problem = !is_null($token->oauth_problem) ? $token->oauth_problem : "Unknown Error";
+
echo <<<HTML
<div id="yupdates-authorization-warning" class="updated fade">
<p><strong>OAuth Error: Request token $oauth_problem. <a href="options-general.php?page=yupdates_plugin_options#settings">Re-configure the plugin.</a></strong></p>
View
@@ -43,7 +43,7 @@ function yupdates_edit_post($postid) {
function yupdates_publish_post($postid) {
$session = yupdates_get_session();
- if($session->hasSession) {
+ if($session->hasSession) {
$post = get_post($postid);
$title_template = get_option("yupdates_title_template");
View
@@ -35,6 +35,17 @@
* THE SOFTWARE.
**/
+// Pre-2.6 compatibility
+if ( ! defined( 'WP_CONTENT_URL' ) )
+ define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
+if ( ! defined( 'WP_CONTENT_DIR' ) )
+ define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
+if ( ! defined( 'WP_PLUGIN_URL' ) )
+ define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
+if ( ! defined( 'WP_PLUGIN_DIR' ) )
+ define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
+
+
function yupdates_plugin_options() {
$ck = get_option('yupdates_consumer_key');
$cks = get_option('yupdates_consumer_secret');
@@ -53,7 +64,7 @@ function yupdates_plugin_options() {
</style>
<script type="text/javascript">
<!--
-function switchMenu(obj) {
+function switchDisplay(obj) {
var el = document.getElementById(obj);
el.style.display = (el.style.display != "none") ? 'none' : '';
}
@@ -64,14 +75,15 @@ function switchMenu(obj) {
<a name="settings"></a>
<form method="post" action="options.php">
- <?php
- if(function_exists("wp_nonce_field")) {
- wp_nonce_field('update-options');
- }
- ?>
+<?php
+ if(function_exists("wp_nonce_field")) {
+ wp_nonce_field('update-options');
+ }
+?>
<h3 class="authTitle">Yahoo! API Access Settings</h3>
-Enter your API Key, Shared Secret, and App ID from the Yahoo! Developer Network. (These are needed so your WordPress blog can read and write data on your behalf without revealing your Yahoo! ID and password).
+Enter your API Key, Shared Secret, and App ID from the Yahoo! Developer Network. (These are needed so your WordPress blog can read
+and write data on your behalf without revealing your Yahoo! ID and password).
<table class="form-table">
<tr valign="top">
<th scope="row">Yahoo! API Key</th>
@@ -87,46 +99,51 @@ function switchMenu(obj) {
</tr>
</table>
-<p><em>Don't know what these are, or how to get them?</em> <a onclick="switchMenu('ydnhelp');" title="Switch the Menu">Show/hide instructions for how to get a Yahoo! API key.</a> (It's quick and free.)</p>
+ <p><em>Don't know what these are, or how to get them?</em> <a onclick="switchDisplay('ydnhelp');" title="Switch the Menu">S
+ how/hide instructions for how to get a Yahoo! API key.</a> (It's quick and free.)</p>
-<div id="ydnhelp" style="display:none; border: 1px solid #cccccc; margin: 10px; padding: 20px;">
+ <div id="ydnhelp" style="display:none; border: 1px solid #cccccc; margin: 10px; padding: 20px;">
<h4 class="authTitle">How to get a Yahoo! API Key</h4>
<ol>
- <li><p>Go to the <a href="https://developer.apps.yahoo.com/dashboard/createKey.html" target="_new">
- Yahoo! Developer Network</a> to register for an API key, and complete
- the form with the following information:</p>
- <ol>
- <li type="a"><strong>Application Name:</strong> Enter "<?php bloginfo('name'); ?>"</li>
- <li type="a"><strong>Kind of Application:</strong> Choose "Web-based"</li>
- <li type="a"><strong>Description:</strong> Describe your site here.</li>
- <li type="a"><strong>Application URL:</strong> Enter "<?php bloginfo('url'); ?>"</li>
- <li type="a"><strong>Favicon URL:</strong> Provide the URL to a GIF, JPG or PNG image (note: ICO is <em>not</em> supported) to serve as the favicon for your blog, if you have one. This will be used if you generate a Yahoo! Update with each blog post.<br />(e.g. <img src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/yupdates-wordpress/images/favicon.png" width="16" height="16" align="bottom" /> John posted "My First iPhone Experiences" from his blog: Mac User Fans. )</li>
- <li type="a"><strong>Application Domain:</strong> Enter "<?php echo sprintf("http://%s", $_SERVER['HTTP_HOST']) ?>"</li>
- </ol>
- </li>
-
- <li><p class="authStep"><strong>Choose access to private user data.</strong></p>
- <p><img src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/yupdates-wordpress/images/auth_step2_scopes.png"></p></li>
-
- <li><p class="authStep"><strong>Choose Read/Write access to Yahoo! Updates.</strong></td>
- <p><img src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/yupdates-wordpress/images/auth_step3_read-write.png"></p></li>
-
- <li><p class="authStep"><strong>Agree to the Yahoo! Terms of Use, and click the "Get API Key" button.</strong></p>
- <p><img src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/yupdates-wordpress/images/auth_step4_apikey.png"></p></li>
-
- <li><p class="authStep"><strong>If you haven't done so previously, verify
- ownership of your domain with Yahoo! by creating a file with the specified
- name and uploading that to the root directory of your domain.</strong></p></li>
-
- <li><p class="authStep"><strong>Once you've successfully created your API
- key, copy your API key information from the success screen (sample below) to the Yahoo! API Access Settings below:</strong></p>
- <p><img src="<?php echo get_option('siteurl'); ?>/wp-content/plugins/yupdates-wordpress/images/auth_step6_success.png" width="562" height="233"></p></li>
+ <li><p>Go to the <a href="https://developer.apps.yahoo.com/dashboard/createKey.html" target="_new">
+ Yahoo! Developer Network</a> to register for an API key, and complete
+ the form with the following information:</p>
+ <ol>
+ <li type="a"><strong>Application Name:</strong> Enter "<?php bloginfo('name'); ?>"</li>
+ <li type="a"><strong>Kind of Application:</strong> Choose "Web-based"</li>
+ <li type="a"><strong>Description:</strong> Describe your site here.</li>
+ <li type="a"><strong>Application URL:</strong> Enter "<?php bloginfo('url'); ?>"</li>
+ <li type="a"><strong>Favicon URL:</strong> Provide the URL to a GIF, JPG or PNG image (note: ICO is <em>not</em> supported)
+ to serve as the favicon for your blog, if you have one. This will be used if you
+ generate a Yahoo! Update with each blog post.
+ <br />
+ (e.g. <img src="<?php echo WP_CONTENT_URL; ?>/plugins/yupdates-wordpress/images/favicon.png" width="16" height="16" align="bottom" /> John posted "My First iPhone Experiences" from his blog: Mac User Fans. )
+ </li>
+ <li type="a"><strong>Application Domain:</strong> Enter "<?php echo sprintf("http://%s", $_SERVER['HTTP_HOST']) ?>"</li>
+ </ol>
+ </li>
+ <li><p class="authStep"><strong>Choose access to private user data.</strong></p>
+ <p><img src="<?php echo WP_CONTENT_URL; ?>/plugins/yupdates-wordpress/images/auth_step2_scopes.png"></p>
+ </li>
+ <li><p class="authStep"><strong>Choose Read/Write access to Yahoo! Updates.</strong></td>
+ <p><img src="<?php echo WP_CONTENT_URL; ?>/plugins/yupdates-wordpress/images/auth_step3_read-write.png"></p>
+ </li>
+ <li><p class="authStep"><strong>Agree to the Yahoo! Terms of Use, and click the "Get API Key" button.</strong></p>
+ <p><img src="<?php echo WP_CONTENT_URL; ?>/plugins/yupdates-wordpress/images/auth_step4_apikey.png"></p>
+ </li>
+ <li><p class="authStep"><strong>If you haven't done so previously, verify
+ ownership of your domain with Yahoo! by creating a file with the specified
+ name and uploading that to the root directory of your domain.</strong></p>
+ </li>
+ <li><p class="authStep"><strong>Once you've successfully created your API
+ key, copy your API key information from the success screen (sample below) to the Yahoo! API Access Settings below:</strong></p>
+ <p><img src="<?php echo WP_CONTENT_URL; ?>/plugins/yupdates-wordpress/images/auth_step6_success.png" width="562" height="233"></p>
+ </li>
</ol>
</div>
-
<hr noshade="noshade" />
<h3 class="authTitle">Yahoo! Updates Settings</h3>
<table class="form-table">
View
@@ -106,11 +106,11 @@ function yupdates_yahoo_updates_widget_control() {
$count = $newCount;
}
}
-?>
- <p><label for="yupdates-widget-count">Number of Updates to Display:
- <input type="text" id="yupdates-widget-count" name="yupdateswidgetcount" size="2" value="<?php echo $count; ?>"></label></p>
- <input type="hidden" name="yupdateswidgetsubmit" value="1">
-<?php
+ echo <<<HTML
+ <p><label for="yupdates-widget-count">Number of Updates to Display:
+ <input type="text" id="yupdates-widget-count" name="yupdateswidgetcount" size="2" value="$count"></label></p>
+ <input type="hidden" name="yupdateswidgetsubmit" value="1">
+HTML;
}
if(YUPDATES_WIDGET_ENABLED) {

0 comments on commit dd0088e

Please sign in to comment.