Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 137 lines (120 sloc) 5.455 kB
4f9b238 @zachgraves initial commit
zachgraves authored
1 <?php
e54b9da @zachgraves added license headers
zachgraves authored
2 /**
3 * Yahoo! Updates Wordpress Plugin
4 *
5 * Find documentation and support on Yahoo! Developer Network: http://developer.yahoo.com
6 *
7 * Hosted on GitHub: http://github.com/yahoo/yos-updates-wordpress/tree/master
8 *
9 * @package yos-updates-wordpress
10 * @subpackage yahoo
11 *
2428313 @zachgraves updated authors
zachgraves authored
12 * @author Ryan Kennedy
13 * @author Lawrence Morrisroe <lem@yahoo-inc.com>,
6304536 @zachgraves fixed my email address in the comments, also updated the ico warning
zachgraves authored
14 * @author Zach Graves <zachg@yahoo-inc.com>
e54b9da @zachgraves added license headers
zachgraves authored
15 * @copyright Copyrights for code authored by Yahoo! Inc. is licensed under the following terms:
16 * @license BSD Open Source License
17 *
18 * Permission is hereby granted, free of charge, to any person obtaining a copy
19 * of this software and associated documentation files (the "Software"), to deal
20 * in the Software without restriction, including without limitation the rights
21 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 * copies of the Software, and to permit persons to whom the Software is
23 * furnished to do so, subject to the following conditions:
24 *
25 * The above copyright notice and this permission notice shall be included in
26 * all copies or substantial portions of the Software.
27 *
28 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 * THE SOFTWARE.
35 **/
4f9b238 @zachgraves initial commit
zachgraves authored
36 /*
a7ca63a @zachgraves fixed plugin desc
zachgraves authored
37 Plugin Name: Yahoo! Updates for WordPress
38 Plugin URI: http://developer.yahoo.com/social/
4c4c27c @zachgraves more wp specific config changes
zachgraves authored
39 Description: Posts a Yahoo! Update to your connections when you publish a new blog post.
1ba96f4 @zachgraves updated wordpress readme
zachgraves authored
40 Version: 1.0
a7ca63a @zachgraves fixed plugin desc
zachgraves authored
41 Author: Yahoo! Inc.
42 Author URI: http://www.yahoo.com/
4f9b238 @zachgraves initial commit
zachgraves authored
43 */
44 ?>
45 <?php
9e4d21d @zachgraves soft tabs
zachgraves authored
46
3ea505c @zachgraves CCK API support
zachgraves authored
47 define("YUPDATES_WIDGET_ENABLED", true);
48
49 define("PLUGIN_OPTIONS_URI","options-general.php?page=yupdates_plugin_options");
50 define("USER_MENU_URI","users.php?page=yupdates_menu");
51
52 require_once("lib/OAuth/OAuth.php");
53 require_once("lib/Yahoo/YahooOAuthApplication.class.php");
6fe832f @zachgraves alter bit.ly shorten YQL query to use standalone class, rather than g…
zachgraves authored
54 require_once("lib/Yahoo/YahooYQLQuery.class.php");
3ea505c @zachgraves CCK API support
zachgraves authored
55
56 // require_once("yupdates_application.php");
57 require_once("yupdates_sessionstore.php");
58 require_once("yupdates_utils.php");
59 require_once("yupdates_menu.php");
60 require_once("yupdates_options.php");
61 require_once("yupdates_hooks.php");
62 require_once("yupdates_db.php");
63
64 if(YUPDATES_WIDGET_ENABLED) {
65 require_once("yupdates_widgets.php");
66 }
67
68 add_action("admin_menu", "yupdates_plugin_menu");
69 add_action("init", "yupdates_auth_init");
70 add_action("publish_post", "yupdates_publish_post");
71 // add_action("delete_post", "yupdates_delete_post");
72 // add_action("edit_post", "yupdates_edit_post");
73
74 function yupdates_plugin_menu() {
75 add_submenu_page("users.php", "Yahoo! Updates Page", "Yahoo! Updates Authorization", 0, "yupdates_menu", "yupdates_menu");
76 add_options_page("Yahoo! Updates Plugin Options", "Yahoo! Updates Plugin", 8, "yupdates_plugin_options", "yupdates_plugin_options");
77 }
78
79 function yupdates_auth_init() {
9e4d21d @zachgraves soft tabs
zachgraves authored
80 $session = yupdates_get_session();
81
82 // handle directions from auth flow
83 if(array_key_exists("yupdates_clearauthorization", $_REQUEST)) {
84 yupdates_clear_session();
85 } else if(array_key_exists("auth_popup", $_REQUEST)) {
86 yupdates_close_popup();
87 }
b423d30 @zachgraves cleanup
zachgraves authored
88
9e4d21d @zachgraves soft tabs
zachgraves authored
89 // show warnings
b423d30 @zachgraves cleanup
zachgraves authored
90
9e4d21d @zachgraves soft tabs
zachgraves authored
91 if($session->hasSession == false) {
92 if($session->store->hasRequestToken()) {
93 $request_token = $session->store->fetchRequestToken();
94 if($request_token && is_null($request_token->key) && !is_null($request_token->oauth_problem)) {
95 add_action("admin_notices", "yupdates_requestTokenProblem_warning");
96 } else if(stripos($_SERVER["REQUEST_URI"], USER_MENU_URI) === FALSE) {
97 add_action("admin_notices", "yupdates_authorization_warning");
98 }
b423d30 @zachgraves cleanup
zachgraves authored
99 } else if(yupdatesdb_hasApplicationInfo() && stripos($_SERVER["REQUEST_URI"], USER_MENU_URI) === FALSE ) {
9e4d21d @zachgraves soft tabs
zachgraves authored
100 add_action("admin_notices", "yupdates_authorization_warning");
b423d30 @zachgraves cleanup
zachgraves authored
101 }
9e4d21d @zachgraves soft tabs
zachgraves authored
102 }
103
104 if(!yupdatesdb_hasApplicationInfo() && stripos($_SERVER["REQUEST_URI"], PLUGIN_OPTIONS_URI) === FALSE) {
105 add_action("admin_notices", "yupdates_appinfo_warning");
106 }
3ea505c @zachgraves CCK API support
zachgraves authored
107 }
108
109 function yupdates_requestTokenProblem_warning() {
9e4d21d @zachgraves soft tabs
zachgraves authored
110 $session_store = yupdates_get_currentUserSessionStore();
111 $token = $session_store->fetchRequestToken();
112 $oauth_problem = !is_null($token->oauth_problem) ? $token->oauth_problem : "Unknown Error";
113
114 echo <<<HTML
c51abce @zachgraves adding better error handling for oauth problems
zachgraves authored
115 <div id="yupdates-authorization-warning" class="updated fade">
3ea505c @zachgraves CCK API support
zachgraves authored
116 <p><strong>Yahoo! Updates - OAuth Error: Request token $oauth_problem. <a href="options-general.php?page=yupdates_plugin_options#settings">Re-configure the plugin.</a></strong></p>
c51abce @zachgraves adding better error handling for oauth problems
zachgraves authored
117 </div>
31c43b5 @zachgraves minor optimizations
zachgraves authored
118 HTML;
3ea505c @zachgraves CCK API support
zachgraves authored
119 }
120
121 function yupdates_appinfo_warning() {
9e4d21d @zachgraves soft tabs
zachgraves authored
122 echo <<<HTML
c51abce @zachgraves adding better error handling for oauth problems
zachgraves authored
123 <div id="yupdates-appinfo-warning" class="updated fade">
3ea505c @zachgraves CCK API support
zachgraves authored
124 <p><strong>You haven't configured the Yahoo! Updates Plugin yet. <a href="options-general.php?page=yupdates_plugin_options">Configure the plugin.</a></strong></p>
c51abce @zachgraves adding better error handling for oauth problems
zachgraves authored
125 </div>
4f9b238 @zachgraves initial commit
zachgraves authored
126 HTML;
3ea505c @zachgraves CCK API support
zachgraves authored
127 }
128
129 function yupdates_authorization_warning() {
9e4d21d @zachgraves soft tabs
zachgraves authored
130 echo <<<HTML
c51abce @zachgraves adding better error handling for oauth problems
zachgraves authored
131 <div id="yupdates-authorization-warning" class="updated fade">
3ea505c @zachgraves CCK API support
zachgraves authored
132 <p><strong>You haven't authorized the Yahoo! Updates Plugin yet. <a href="users.php?page=yupdates_menu">Authorize the plugin now.</a></strong></p>
c51abce @zachgraves adding better error handling for oauth problems
zachgraves authored
133 </div>
134 HTML;
3ea505c @zachgraves CCK API support
zachgraves authored
135 }
4f9b238 @zachgraves initial commit
zachgraves authored
136 ?>
Something went wrong with that request. Please try again.