Plugin Directory

Changeset 381088


Ignore:
Timestamp:
05/05/2011 04:29:42 AM (15 years ago)
Author:
cooiky
Message:
 
Location:
qqpress/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • qqpress/trunk/qqpress.php

    r371888 r381088  
    44Author:  cooiky
    55Author URI: http://www.hencuo.com/
    6 Plugin URI: http://www.hencuo.com/qqpress
     6Plugin URI: http://app.hencuo.com/qqpress
    77Description: 新文章发布时,将文章标题和URL发布到你的腾讯微博。
    8 Version: 1.0
     8Version: 1.1
    99*/
    1010
    1111$qq_consumer_key = '4dd4655596bb4b828cda01d6fc8de0d1';
    1212$qq_consumer_secret = '5d1c003f3f281827c2b4f8d859e1469e';
    13 $table_name = "qqpress";
    1413
    1514register_activation_hook(__FILE__, 'qqpress_install');
     
    2019add_action('admin_menu', 'qc_options_add_page');
    2120add_action('wp_insert_post', 'qqpress_run');
    22 add_option('qqpress_message', '新日志:[title] [permalink]', '', 'yes');
     21add_option('qqpress_message', '新日志:[title] [link]', '', 'yes');
    2322
    2423function qc_init() {
     
    4039//创建日志同步状态表
    4140function qqpress_install() {
    42     global $wpdb, $table_name;
     41    global $wpdb;
     42    $table_name = "qqpress";
    4343   
    4444    qqpress_db_drop_table(); //删除旧的日志同步状态表
     
    5757
    5858        dbDelta($sql);
    59 
    60         add_option("qqpress_db_version", "1.0");
    61     }
     59    }
     60
     61    add_option("qqpress_db_version", "1.0");
    6262   
    6363    //初始化日志同步状态表
     
    7575    //删除 wp_options 表中的对应记录
    7676    delete_option('qqpress_message');
     77    delete_option('qqpress_db_version');
    7778    delete_option('qq_oauth_token');
    7879    delete_option('qq_oauth_token_secret');
     
    8283//如果已经存在日志同步状态表qqpress,则删除
    8384function 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 ) {
    8789        $sql = "DROP TABLE " . $table_name;
    8890
    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    }
    9598}
    9699
    97100//新增或更新日志的同步状态
    98101function qqpress_db_update_post($postID, $status) {
    99     global $wpdb, $table_name;
     102    global $wpdb;
     103    $table_name = "qqpress";
    100104   
    101105    qqpress_db_delete_post($postID); //如果同步状态表中已经存在该日志,删除
     
    108112//判断该日志是否已经同步
    109113function qqpress_was_qqed($postID) {
    110     global $wpdb, $table_name;
     114    global $wpdb;
     115    $table_name = "qqpress";
    111116
    112117    $query = "SELECT id, status from " . $table_name . " WHERE id = " . $wpdb->escape($postID);
     
    117122//删除同步状态表中的该日志记录
    118123function qqpress_db_delete_post($postID) {
    119     global $wpdb, $table_name;
     124    global $wpdb;
     125    $table_name = "qqpress";
    120126
    121127    $query = "DELETE FROM " . $table_name . " WHERE id like " . $wpdb->escape($postID);
    122128
    123     return $wpdb->query( $query );
     129    return $wpdb->query($query);
    124130}
    125131
    126132//将最新文章同步到腾讯微博,并更新该日志的同步状态为已同步
    127133function qqpress_process_posts() {
    128     global $wpdb, $table_name;
     134    global $wpdb;
     135    $table_name = "qqpress";
    129136
    130137    $query = "SELECT * FROM " . $table_name;
     
    186193        <h2>腾讯微博同步</h2>
    187194        <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>
    189196        </div>
    190197<?php
     
    220227//自定义内容
    221228function qqpress_options_page() {
    222     global $wpdb, $table_name;
     229    global $wpdb;
     230    $table_name = "qqpress";
    223231
    224232    $message = get_option('qqpress_message');
     
    241249    <ul>
    242250        <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>
    245253    </ul>
    246254    </p>
  • qqpress/trunk/readme.txt

    r371888 r381088  
    55Requires at least: 3.0
    66Tested up to: 3.1.1
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88
    99支持将新日志标题和链接同步到腾讯微博。
     
    3030
    3131== Changelog ==
     32= 1.1 =
     33* 2011/05/05
     34* 修正插件激活时无法创建数据库表的bug
    3235
    3336= 1.0 =
Note: See TracChangeset for help on using the changeset viewer.