WordPress 采集文章后,定时发布-昊天SEO

/**

* 定时发布 插件

*/

 

if(!function_exists(‘add_action’)){

    header(‘Status 403 Forbidden’);

    header(‘HTTP/1.0 403 Forbidden’);

    header(‘HTTP/1.1 403 Forbidden’);

    exit();}

/**

* 定义发布时间间隔 单位分钟

* WPMS_DELAY

*/

define(‘WPMS_DELAY’,1);

 

define(‘WPMS_OPTION’,‘wp_missed_schedule’);

 

function wpms_replace(){

    delete_option(WPMS_OPTION);

register_deactivation_hook(__FILE__,‘wpms_replace’);

function wpms_init(){

    remove_action(‘publish_future_post’,‘check_and_publish_future_post’);

    $last=get_option(WPMS_OPTION,false);

    if(($last!==false)&&($last>(time()-(WPMS_DELAY*60))))return;

    update_option(WPMS_OPTION,time());

    global$wpdb;

    /**

     * 获取需要发布的文章,从draft到publish状态

     */

 

    $scheduledIDs=$wpdb>get_col(“SELECT`ID`FROM`{$wpdb->posts}`”.“WHERE(“.“((`post_date`>0)&&(`post_date`<=CURRENT_TIMESTAMP()))OR”.“((`post_date_gmt`>0)&&(`post_date_gmt`<=UTC_TIMESTAMP()))”.“)AND`post_status`=’draft’LIMIT 0,1”);

 

    if(!count($scheduledIDs))return;

    foreach($scheduledIDs as$scheduledID){if(!$scheduledID)continue;

        wp_publish_post($scheduledID);}

add_action(‘init’,‘wpms_init’,0);

 

此文由“快兔兔AI采集器”自动生成,目的为演示采集器效果,若侵权请及时联系删除。

原文链接:https://www.168seo.cn/seo/24667.html

更多内容