// 从文本域解析图片URL,返回指定数量的不同随机图片URL private function get_random_img_urls( $count = 1 ) { $raw = get_option( self::OPTION_IMG_URLS, '' ); if ( empty( $raw ) ) return array(); $lines = explode( "\n", $raw ); $urls = array(); foreach ( $lines as $line ) { $url = trim( $line ); if ( ! empty( $url ) ) { $urls[] = $url; } } if ( empty( $urls ) ) return array(); // 打乱数组顺序,保证随机性 shuffle( $urls ); // 如果需要的数量大于可用数量,循环补充 $result = array(); $urlCount = count( $urls ); for ( $i = 0; $i < $count; $i++ ) { $result[] = $urls[ $i % $urlCount ]; } return $result; } // 单张随机图兼容方法(保留原有调用) private function get_random_img_url() { $urls = $this->get_random_img_urls( 1 ); return $urls ? $urls[0] : ''; } private function process_post( $post_id, $source ) { $post = get_post( $post_id ); if ( ! $post || 'publish' !== $post->post_status ) return; $content = (string)$post->post_content; $images = $this->extract_image_urls( $content ); // 文章无图片 → 中间插入图片(原有逻辑不变) if ( empty( $images ) ) { $new_img_url = $this->get_random_img_url(); if ( empty( $new_img_url ) ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => '未配置可用图片地址,无法新增图片', 'image_count' => 0, 'broken_count' => 0, 'replaced_count' => 0, 'old_urls' => array(), 'new_urls' => array(), 'run_source' => $source ) ); return; } $img_tag = '
\u5742\u53e3\u7f8e\u7a57\u4e43(\u5742\u53e3\u307f\u307b\u306e)\u6750\u6599<\/p>\n
\u5742\u53e3\u7f8e\u7a57\u4e43\uff0c\u65e5\u6587\u540d\uff1a\u65e5\u6587\u540d\uff1a\u5742\u53e3\u307f\u307b\u306e\u3001\u3055\u304b\u3050\u3061\u307f\u307b\u306e\uff0c\u82f1\u6587\u540d\uff1aMihono Sak\u786e\u5b9e\uff0c\u6211\u5df2\u7ecf\u7ad9\u5728\u4e86\u9752\u4e91\u8857\u56db\u53f7\u95e8\u53e3\u3002\u6211\u672c\u6765\u53ea\u662f\u4e00\u4e2a\u8def\u8fc7\u8005\uff0c\u7136\u800c\uff0c\u5f53\u6211\u7684\u76ee\u5149\u900f\u8fc7\u73bb\u7483\u5f80\u91cc\u770b\u65f6\uff0c\u6211\u53d1\u73b0\u4e86\u8fd9\u662f\u4e00\u5bb6\u7259\u79d1\u8bca\u6240\u3002\u90a3\u662f\u6211\u642c\u8fc1\u5230\u65b0\u5b85\u65f6\uff0c\u7b2c\u4e00\u6b21\u7259\u9f88\u75db\uff0c\u6211\u4fbf\u63a8\u5f00\u95e8\u8d70\u8fdb\u4e86\u8bca\u6240\u3002\u738b\u533b\u751f\u8d70\u4e86\u4e0a\u6765\uff0c\u8bf4\u8bf7\u6211\u7a0d\u7b49\u51e0\u5206\u949f\uff0c\u56e0\u4e3a\u8bca\u6240\u521a\u5f00\u95e8\uff0c\u5f85\u5979\u4eec\u51c6\u5907\u4e00\u4e0b\u5c31\u4e3a\u6211\u770b\u7259\u3002aguchi\uff0c\u5e740\u67080\u65e5\u6b7b\u4ea1\u4e8e\u65e5<\/p>\n
\/\u7727\u7f03\u4e1c\u4eac\u90fd\uff0c\u662f\u65e5\/\u7727\u7f03AWV\u5973\u7272\uff0c0\u5e740\u67080\u65e5\u5165\u884c\uff0c\u4ece\u5c5e\u4e8eBe-Side Promotion\u516c\u53f8\uff0c\u559c\u597d\u770b\u52a8\u753b\u7247\u3001cosplay\u3002<\/p>\n \u5742\u53e3\u7f8e\u7a57\u4e43(\u5742\u53e3\u307f\u307b\u306e)\u6750\u6599<\/p>\n \u4e2d\u6587\u540d\uff1a\u5742\u53e3\u7f8e\u7a57\u4e43<\/p>\n \u65e5\u6587\u540d\uff1a\u5742\u53e3\u307f\u307b\u306e\u3001\u3055\u304b\u3050\u3061\u307f\u307b\u306e<\/p>\n \u82f1\u6587\u540d\uff1aMihono Sakaguchi<\/p>\n \u56fd\u522b\uff1a\u5973<\/p>\n \u4eba\u79cd\uff1a\u5927\u548c\u4eba\u79cd<\/p>\n \u515a\u7c4d\uff1a\u65e5\/\u7727\u7f03<\/p>\n \u51fa\u534e\u8bde\u671f\uff1a\u5e740\u67080\u65e5<\/p>\n \u6b7b\u4ea1\u5730\uff1a\u65e5\/\u7727\u7f03\u4e1c<\/p>\n
<\/a><\/p>\n