芝麻web文件管理V1.00
编辑当前文件:/www/wwwroot/shphe-en.com/wp-content/plugins/easyiit_autopost_v2/easyiit_autopost.php
parent == 490){ $categorys[] = $val; } } ?>
发布设置
标题随机前缀:
name;?>
term_id;echo $post_setting[$str_title_pre]?></textarea>
标题随机后缀:
</textarea>
随机关键字标签:
name;?>
term_id;echo $post_setting[$str_tag]?></textarea>
发布类别:
Featured
最大发布数量:
parent == 490){ $categorys[] = $val; } } $featured_category = get_category_by_slug("featured"); if(!$featured_category){ wp_create_category("featured"); $featured_category = get_category_by_slug("featured"); } $featured_count = count(query_posts(array('cat'=>$featured_category->term_id, 'post_type' => 'post','posts_per_page'=>-1))); $max_post_num = $post_setting['max_num']?$post_setting['max_num']:1200; if(time()<($last_post_time+$post_setting['post_rate'])){ echo -1;exit; } if($featured_count >= $max_post_num){ $home_url = home_url('/'); $home_url_ar = explode('/',$home_url); //file_get_contents('http://www.quanqiusou.cn/extend_api/saas/spider.php?t=4&w='.$home_url_ar[2]); $every_num = 1; }else{ $every_num = 100; } for($i=0;$i<$every_num;$i++){ foreach($categorys as $vv){ $ar_tt[$vv] = count(explode("\n",$post_setting['tags_'.$vv])); } $cur_catid = get_rand($ar_tt); $str_title_pre = 'title_pre_'.$cur_catid; $str_title_suffix = 'title_suffix'; $str_tags = 'tags_'.$cur_catid; if($post_setting[$str_title_pre]==''||$post_setting[$str_title_suffix]==''||$post_setting[$str_tags]==''){ echo -2;exit; } $cat_taxonomy = $wpdb->get_row("SELECT * FROM wp_term_taxonomy where `term_id`=".$cur_catid." AND `taxonomy` = 'category'"); $randposts = $wpdb->get_row("SELECT * FROM wp_term_relationships WHERE term_taxonomy_id=".$cat_taxonomy->term_taxonomy_id." ORDER BY RAND() LIMIT 1"); $post = query_posts(array('p' => $randposts->object_id)); if(!$post[0]->post_title){ $randposts = $wpdb->get_row("SELECT * FROM wp_term_relationships WHERE term_taxonomy_id=".$cat_taxonomy->term_taxonomy_id." ORDER BY RAND() LIMIT 1"); $post = query_posts(array('p' => $randposts->object_id)); } $product_gallery = get_post_meta($post[0]->ID,"product_gallery"); $title_pre_arr = explode("\n",$post_setting[$str_title_pre]); $tags_arr = explode("\n",$post_setting[$str_tags]); $title_pre = $title_pre_arr[array_rand($title_pre_arr)]; $title_suffix = $post_setting[$str_title_suffix]; shuffle($tags_arr); $tags = array_slice($tags_arr,0,10); //print_r($tags);exit; if($post[0]->post_title){ $new_post = array( 'post_title' => str_replace("/n",'',$title_pre)." ".$post[0]->post_title." ".str_replace("/n",'',$title_suffix), 'post_content' => $post[0]->post_content, 'post_status' => 'publish', 'post_author' => 1, 'post_date' => '2016-01-08 00:00:00', 'post_date_gmt' => '2016-01-08 00:00:00', 'post_category' => array($featured_category->cat_ID) ); $post_id = wp_insert_post( $new_post ); update_post_meta($post_id, "product_gallery", $product_gallery[0]); wp_set_post_tags($post_id,$tags); if($post_id){ update_option("_last_post_time",time()); echo $post_id.'-'; } } } echo "success\n"; exit(); } //概率算法 function get_rand($proArr) { $result = ''; $proSum = array_sum($proArr); foreach ($proArr as $key => $proCur) { $randNum = mt_rand(1, $proSum); if ($randNum <= $proCur) { $result = $key; break; } else { $proSum -= $proCur; } } unset ($proArr); return $result; } /*function easyiit_autopost_add_scripts() { wp_enqueue_script( 'autopost-script', '/wp-content/plugins/easyiit_autopost/js/autopost.js', array( 'jquery' ), '20161212', true ); } add_action( 'wp_enqueue_scripts', 'easyiit_autopost_add_scripts' ); add_action( 'admin_enqueue_scripts', 'easyiit_autopost_add_scripts' );*/