Changeset 381088
- Timestamp:
- 05/05/2011 04:29:42 AM (15 years ago)
- Location:
- qqpress/trunk
- Files:
-
- 2 edited
-
qqpress.php (modified) (11 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
qqpress/trunk/qqpress.php
r371888 r381088 4 4 Author: cooiky 5 5 Author URI: http://www.hencuo.com/ 6 Plugin URI: http:// www.hencuo.com/qqpress6 Plugin URI: http://app.hencuo.com/qqpress 7 7 Description: 新文章发布时,将文章标题和URL发布到你的腾讯微博。 8 Version: 1. 08 Version: 1.1 9 9 */ 10 10 11 11 $qq_consumer_key = '4dd4655596bb4b828cda01d6fc8de0d1'; 12 12 $qq_consumer_secret = '5d1c003f3f281827c2b4f8d859e1469e'; 13 $table_name = "qqpress";14 13 15 14 register_activation_hook(__FILE__, 'qqpress_install'); … … 20 19 add_action('admin_menu', 'qc_options_add_page'); 21 20 add_action('wp_insert_post', 'qqpress_run'); 22 add_option('qqpress_message', '新日志:[title] [ permalink]', '', 'yes');21 add_option('qqpress_message', '新日志:[title] [link]', '', 'yes'); 23 22 24 23 function qc_init() { … … 40 39 //创建日志同步状态表 41 40 function qqpress_install() { 42 global $wpdb, $table_name; 41 global $wpdb; 42 $table_name = "qqpress"; 43 43 44 44 qqpress_db_drop_table(); //删除旧的日志同步状态表 … … 57 57 58 58 dbDelta($sql); 59 60 add_option("qqpress_db_version", "1.0"); 61 }59 } 60 61 add_option("qqpress_db_version", "1.0"); 62 62 63 63 //初始化日志同步状态表 … … 75 75 //删除 wp_options 表中的对应记录 76 76 delete_option('qqpress_message'); 77 delete_option('qqpress_db_version'); 77 78 delete_option('qq_oauth_token'); 78 79 delete_option('qq_oauth_token_secret'); … … 82 83 //如果已经存在日志同步状态表qqpress,则删除 83 84 function qqpress_db_drop_table() { 84 global $wpdb, $table_name; 85 86 if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ) 85 global $wpdb; 86 $table_name = "qqpress"; 87 88 if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ) { 87 89 $sql = "DROP TABLE " . $table_name; 88 90 89 if (version_compare($wp_version, '2.3', '>=')) 90 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 91 else 92 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 93 94 dbDelta($sql); 91 if (version_compare($wp_version, '2.3', '>=')) 92 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 93 else 94 require_once(ABSPATH . 'wp-admin/upgrade-functions.php'); 95 96 dbDelta($sql); 97 } 95 98 } 96 99 97 100 //新增或更新日志的同步状态 98 101 function qqpress_db_update_post($postID, $status) { 99 global $wpdb, $table_name; 102 global $wpdb; 103 $table_name = "qqpress"; 100 104 101 105 qqpress_db_delete_post($postID); //如果同步状态表中已经存在该日志,删除 … … 108 112 //判断该日志是否已经同步 109 113 function qqpress_was_qqed($postID) { 110 global $wpdb, $table_name; 114 global $wpdb; 115 $table_name = "qqpress"; 111 116 112 117 $query = "SELECT id, status from " . $table_name . " WHERE id = " . $wpdb->escape($postID); … … 117 122 //删除同步状态表中的该日志记录 118 123 function qqpress_db_delete_post($postID) { 119 global $wpdb, $table_name; 124 global $wpdb; 125 $table_name = "qqpress"; 120 126 121 127 $query = "DELETE FROM " . $table_name . " WHERE id like " . $wpdb->escape($postID); 122 128 123 return $wpdb->query( $query);129 return $wpdb->query($query); 124 130 } 125 131 126 132 //将最新文章同步到腾讯微博,并更新该日志的同步状态为已同步 127 133 function qqpress_process_posts() { 128 global $wpdb, $table_name; 134 global $wpdb; 135 $table_name = "qqpress"; 129 136 130 137 $query = "SELECT * FROM " . $table_name; … … 186 193 <h2>腾讯微博同步</h2> 187 194 <div id="message" class="updated fade"><p>授权成功</p></div> 188 <p>取消授权请访问: http://open.t.qq.com/apps/appslist.php</p>195 <p>取消授权请访问:<a href="http://open.t.qq.com/apps/appslist.php" target="_blank">http://open.t.qq.com/apps/appslist.php</a></p> 189 196 </div> 190 197 <?php … … 220 227 //自定义内容 221 228 function qqpress_options_page() { 222 global $wpdb, $table_name; 229 global $wpdb; 230 $table_name = "qqpress"; 223 231 224 232 $message = get_option('qqpress_message'); … … 241 249 <ul> 242 250 <li><strong>[title]</strong>:日志标题</li> 243 <li><strong>[permalink]</strong>:自定义的日志永久链接<em>( http://www.hencuo.com/archives/119)</em></li>244 <li><strong>[link]</strong>:默认的日志链接<em>( http://www.hencuo.com/index.php?p=119)</em></li>251 <li><strong>[permalink]</strong>:自定义的日志永久链接<em>(<a href="http://www.hencuo.com/archives/119" target="_blank">http://www.hencuo.com/archives/119</a>)</em></li> 252 <li><strong>[link]</strong>:默认的日志链接<em>(<a href="http://www.hencuo.com/index.php?p=119" target="_blank">http://www.hencuo.com/index.php?p=119</a>)</em></li> 245 253 </ul> 246 254 </p> -
qqpress/trunk/readme.txt
r371888 r381088 5 5 Requires at least: 3.0 6 6 Tested up to: 3.1.1 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 9 9 支持将新日志标题和链接同步到腾讯微博。 … … 30 30 31 31 == Changelog == 32 = 1.1 = 33 * 2011/05/05 34 * 修正插件激活时无法创建数据库表的bug 32 35 33 36 = 1.0 =
Note: See TracChangeset
for help on using the changeset viewer.