Plugin Directory

Changeset 483775


Ignore:
Timestamp:
01/03/2012 08:30:36 AM (14 years ago)
Author:
runsheng2005
Message:

增加了独立博客文章设定界面

Location:
wp2baiduzone/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp2baiduzone/trunk/php/baiduzone.php

    r401318 r483775  
    11<?php
    2 /*  Copyright 2011  Carey Zhou (email : [email protected])
     2/* 
     3   Copyright 2011  Carey Zhou (email : [email protected])
     4   
    35   This program is free software; you can redistribute it and/or modify
    46   it under the terms of the GNU General Public License as published by
    57   the Free Software Foundation; either version 2 of the License, or
    68   (at your option) any later version.
     9   
    710   This program is distributed in the hope that it will be useful,
    811   but WITHOUT ANY WARRANTY; without even the implied warranty of
    912   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1013   GNU General Public License for more details.
     14   
    1115   You should have received a copy of the GNU General Public License
    1216   along with this program; if not, write to the Free Software
  • wp2baiduzone/trunk/php/iconv.php

    r401318 r483775  
    11<?php
    22/*  Copyright 2011  Carey Zhou (email : [email protected])
     3
    34   This program is free software; you can redistribute it and/or modify
    45   it under the terms of the GNU General Public License as published by
    56   the Free Software Foundation; either version 2 of the License, or
    67   (at your option) any later version.
     8   
    79   This program is distributed in the hope that it will be useful,
    810   but WITHOUT ANY WARRANTY; without even the implied warranty of
    911   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1012   GNU General Public License for more details.
     13   
    1114   You should have received a copy of the GNU General Public License
    1215   along with this program; if not, write to the Free Software
  • wp2baiduzone/trunk/readme.txt

    r401318 r483775  
    22
    33Contributors: Carey Zhou
    4 Donate link: http://zhourunsheng.com/
     4Donate link: http://blog.zhourunsheng.com/
    55Tags: baidu, wp2baiduzone,百度空间,文章同步
    66Requires at least: 2.7
    7 Tested up to: 3.1.3
    8 Stable tag: 1.0
     7Tested up to: 3.3
     8Stable tag: 1.1
    99
    1010== Description ==
    1111
    1212同步发布 WordPress 博文到 百度空间.
     13
     14Version 1.1 支持功能
     15
     161. 支持独立博客文章的设定同步,即发布博文的时候可进行同步选项的单独设定。
    1317
    1418Version 1.0 支持功能
     
    37411. 软件配置界面 Screenshots.png
    3842
     432. 独立博客文章配置界面 Screenshots1.png
     44
    3945
    4046== Frequently Asked Questions ==
     
    4349== Changelog ==
    4450
     51= 1.1 =
     52* 加入独立博文配置页面
     53
    4554= 1.0 =
    4655* 初级版本
     
    4857== Upgrade Notice ==
    4958
     59= 1.1 =
     60* 加入独立博文配置页面
     61
    5062= 1.0 =
    5163* 初级版本
  • wp2baiduzone/trunk/wp2baiduzone.php

    r401318 r483775  
    55Version:     1.0
    66Author:      Carey Zhou
    7 Author URI:  http://www.zhourunsheng.com
     7Author URI:  http://blog.zhourunsheng.com
    88Description: 同步发表 WordPress 博客日志到 百度空间
    99*/
    1010
    1111/*  Copyright 2011  Carey Zhou (email : [email protected])
     12
    1213   This program is free software; you can redistribute it and/or modify
    1314   it under the terms of the GNU General Public License as published by
    1415   the Free Software Foundation; either version 2 of the License, or
    1516   (at your option) any later version.
     17   
    1618   This program is distributed in the hope that it will be useful,
    1719   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1820   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1921   GNU General Public License for more details.
     22   
    2023   You should have received a copy of the GNU General Public License
    2124   along with this program; if not, write to the Free Software
     
    4346    register_setting( 'WP2BaiduZone-Settings', 'wp2baiduzone_sharenotallow' );
    4447    register_setting( 'WP2BaiduZone-Settings', 'wp2baiduzone_isaddlink' );
     48        register_setting( 'WP2BaiduZone-Settings', 'wp2baiduzone_issync' );
    4549}
    4650
     
    147151function publish_article_to_baiduzone($post_ID)
    148152{
    149     $post = get_post($post_ID);
     153    if (get_option('wp2baiduzone_issync') != 'yes') { //该文章不同步
     154        return $post_ID;
     155    }
     156   
     157    $post = get_post($post_ID);
    150158   
    151159    //new article
    152     if($post->post_type == "post" && ($post->post_date == $post->post_modified))
     160    if(($post->post_type == "post") && ($post->post_date == $post->post_modified))
    153161    {
    154162        //get title
     
    175183        }
    176184        //<pre> content </pre>
    177         $content = "<pre>" . $content . "</pre>";
     185        //$content = "<pre>" . $content . "</pre>";
    178186       
    179187        $blogpower = get_option('wp2baiduzone_blogpower');
     
    224232}
    225233?>
     234<?php
     235add_action('add_meta_boxes', 'wp2bz_add_custom_box');
     236
     237function wp2bz_add_custom_box(){
     238    add_meta_box( 'wp2bz-meta_box','百度空间博文同步','wp2bz_box_set_sync', 'post', 'side', 'high');
     239}
     240
     241function wp2bz_box_set_sync(){
     242    global $post;
     243   
     244    $username = get_option('wp2baiduzone_user');
     245    $password = get_option('wp2baiduzone_password');
     246    if(strlen($username) < 3 || strlen($password) < 3) {
     247         echo '<div class="misc-pub-section" style="line-height:18px;">';
     248         echo '<b>配置信息: </b><br/>';
     249         echo '您还未配置百度空间的帐号信息,如果要同步文章,请首先到 <a href="'.site_url('/wp-admin/options-general.php?page=wp2baiduzone').'">wp2baiduzone</a> 进行配置。';
     250         echo '</div>';
     251         return false;
     252    } else {
     253        echo '<div class="misc-pub-section" style="line-height:18px;">';
     254        echo '<b>配置信息: </b><br/>';
     255        echo '您百度空间的同步帐号为 <b>'.$username.'</b>';
     256        echo '</div>';
     257    }
     258   
     259    $synced = get_option( 'wp2baiduzone_issync', 'yes');
     260    $post_status = get_post_status($post->ID);
     261    switch($post_status){
     262        case 'publish':
     263                $status_info='这篇文章已经发布,默认不会同步。';$synced='no';
     264                break;
     265        case 'private':
     266                $status_info='这篇文章是私密文章,默认不会同步。';$synced='no';
     267                break;
     268        case 'future':
     269                $status_info='这篇文章是定时发布,将在设定的时间同步。';
     270                break;
     271        case 'auto-draft':
     272                $status_info='这篇文章是您新建的,点击“发布”将会同步到您的百度空间。';$synced='yes';
     273                break;
     274        case 'draft':
     275                $status_info='这篇文章是您之前保存的草稿,点击“发布”将会同步到您的百度空间。';
     276                break;
     277        case 'pending':
     278                $status_info='这篇文章等待复审,通过后将会根据选择情况进行同步';
     279                break;
     280        default:
     281               $synced='yes';
     282               break;
     283    }
     284   
     285    if($status_info) {
     286       echo '<div class="misc-pub-section" style="line-height:18px;"><b>温馨提示: </b><br/>'.$status_info.'</div>';
     287    }
     288   
     289    echo '<div class="misc-pub-section" style="background:#EAF2FA;line-height:18px;">';
     290    echo '<b>同步到百度空间: </b><br/>';
     291   
     292    echo '<input type="radio" name="wp2baiduzone_issync" value="no"';
     293    if($synced == 'no') {
     294       echo ' checked="checked"';
     295    }
     296    echo '/><label>不同步</label> <br/>';
     297   
     298    echo '<input type="radio" name="wp2baiduzone_issync" value="yes"';
     299    if($synced == 'yes') {
     300       echo ' checked="checked"';
     301    }
     302    echo '/><label>同步</label> <br/>';
     303    echo '</div>';
     304    echo '<div class="clear"></div>';
     305}
     306
     307/* Use the save_post action to do something with the data entered */
     308add_action('save_post', 'wp2bz_save_custom_box_data');
     309
     310/* When the post is saved, saves our custom data */
     311function wp2bz_save_custom_box_data( $post_id ) {
     312    if (isset($_POST['wp2baiduzone_issync'])) {
     313        update_option( 'wp2baiduzone_issync', $_POST['wp2baiduzone_issync'] );
     314    }
     315}
     316
     317?>
Note: See TracChangeset for help on using the changeset viewer.