// 从文本域解析图片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 = '

'; $content_len = mb_strlen( $content ); $mid_pos = (int)( $content_len / 2 ); $new_content = mb_substr( $content, 0, $mid_pos ) . $img_tag . mb_substr( $content, $mid_pos ); $updated = wp_update_post( array( 'ID' => $post_id, 'post_content' => $new_content ), true ); if ( is_wp_error( $updated ) ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => '新增图片失败:' . $updated->get_error_message(), 'image_count' => 0, 'broken_count' => 0, 'replaced_count' => 1, 'old_urls' => array(), 'new_urls' => array( $new_img_url ), 'run_source' => $source ) ); return; } clean_post_cache( $post_id ); $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'add_image', 'reason' => '文章无图片,已在内容中间插入图片', 'image_count' => 1, 'broken_count' => 0, 'replaced_count' => 1, 'old_urls' => array(), 'new_urls' => array( $new_img_url ), 'run_source' => $source ) ); return; } // 检测失效图片(原有逻辑不变) $broken_urls = array(); $reasons = array(); foreach ( $images as $url ) { $check = $this->is_image_url_valid( $url ); if ( ! $check['valid'] ) { $broken_urls[] = $url; $reasons[] = $url . ' => ' . $check['reason']; } } $broken_urls = array_values( array_unique( $broken_urls ) ); if ( empty( $broken_urls ) ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'no_need', 'reason' => '所有图片均可正常访问', 'image_count' => count( $images ), 'broken_count' => 0, 'replaced_count' => 0, 'old_urls' => array(), 'new_urls' => array(), 'run_source' => $source ) ); return; } // 替换失效图片(核心修改部分) $new_content = $content; $replace_map = array(); $replaced_count = 0; $failed_reason = ''; // 获取与失效图片数量匹配的随机备用图 $rand_imgs = $this->get_random_img_urls( count( $broken_urls ) ); if ( empty( $rand_imgs ) ) { $failed_reason = '未配置可用图片地址,无法替换'; } else { // 为每个失效URL分配不同的备用图 foreach ( $broken_urls as $index => $bad_url ) { $new_img = $rand_imgs[ $index ]; if ( false !== strpos( $new_content, $bad_url ) ) { $new_content = str_replace( $bad_url, $new_img, $new_content ); $replace_map[ $bad_url ] = $new_img; $replaced_count++; } } } if ( $failed_reason ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => $failed_reason . ';失效明细:' . implode( ';', $reasons ), 'image_count' => count( $images ), 'broken_count' => count( $broken_urls ), 'replaced_count' => $replaced_count, 'old_urls' => $broken_urls, 'new_urls' => $replace_map, 'run_source' => $source ) ); return; } if ( $new_content === $content || $replaced_count <= 0 ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => '检测到失效图片,但未能完成替换;失效明细:' . implode( ';', $reasons ), 'image_count' => count( $images ), 'broken_count' => count( $broken_urls ), 'replaced_count' => 0, 'old_urls' => $broken_urls, 'new_urls' => $replace_map, 'run_source' => $source ) ); return; } $updated = wp_update_post( array( 'ID' => $post_id, 'post_content' => $new_content ), true ); if ( is_wp_error( $updated ) ) { $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'failed', 'reason' => '文章更新失败:' . $updated->get_error_message(), 'image_count' => count( $images ), 'broken_count' => count( $broken_urls ), 'replaced_count' => 0, 'old_urls' => $broken_urls, 'new_urls' => $replace_map, 'run_source' => $source ) ); return; } clean_post_cache( $post_id ); $this->insert_log( array( 'post_id' => $post_id, 'post_title' => get_the_title( $post_id ), 'status' => 'success', 'reason' => '已替换失效图片;失效明细:' . implode( ';', $reasons ), 'image_count' => count( $images ), 'broken_count' => count( $broken_urls ), 'replaced_count' => $replaced_count, 'old_urls' => $broken_urls, 'new_urls' => $replace_map, 'run_source' => $source ) ); } 明星信息-番剧百科-第358页
好东西要分享

明星信息

第358页

天衣蜜(天衣みつ)材料

天衣蜜(天衣みつ)材料 天衣蜜,日文名:天衣みつ、あまい みつ,英文名:Mitsu Amai,日月日死亡于日/眧缃东京都,是日/眧缃AWV女牲,天衣蜜是一位正在00日月以作 品文章“天上驻车场 [牲欲束缚パーキングエリア]”正在成人制片公司...

天野美优(天野美優)材料

天野美优(天野美优)材料 天野美优,日文名:天野美优、あまのみゆ,英文名:Amano Miyu,年0月日死亡于日/眧缃东京都,是日/眧缃AWV女牲,0年0月日入行,从属于えむっ娘ラボ公司,喜好看电影。 天野美优(天野美优)材料 中文名:天野...

天音亚莉西(天音ありす)材料

天音亚莉西(天音ありす)材料 天音亚莉西,日文名:天音ありす、あまねありす,英文名:没有详,年0月日死亡于日/眧缃东京都,是日/眧缃AWV女牲,0日月日入行,从属于OPPAI公司,喜好剑道。 天音亚莉西(天音ありす)材料 中文名:天音亚莉西...

夸父简介

夸父简介 夸父,中国古代神话传闻人士,听说正在黄帝时代,南方大荒中,有座名叫成都载天的大山,寓居着大神后土的子嗣,称夸父族。由于他们长的个个身体高,力量大,因为别称侏儒族。他们凭仗该署环境,专喜替人仗义执言。夸父族的人协助蚩尤群落抗衡黄帝群...

奥田咲材料

奥田咲材料 奥田咲,日文名:奥田咲、おくださき,英文名:Okuda Saki,年0月日死亡于日/眧缃千叶县,是日/眧缃AWV女牲,0年0月0日入行,从属于Of如果从发布“限跌令”的城市来看,也可以发现,“限跌令”并非普遍现象,它只发生在库存...

奥菜莉乃材料

奥菜莉乃材料 奥菜莉乃,日文名:おきなりの,英文名:Okina Rino,日月日死亡于日/眧缃东京都,是日/眧缃AWV女牲,0年0月0日入行,从属于S NO. STYLE片商,喜好搞笑、听演唱会、芭蕾。 奥菜莉乃材料 中文名:奥菜莉乃 日文...

如月カレン(如月没有幸)材料

如月カレン(如月没有幸)材料 如月没有幸,日文名:如月カレン,英文名:Karen Kisaragi,日月日死亡于日/眧缃东京都,是日/眧缃AWV女牲。如月カレン(如月没有幸)正在00年以专属女牲的身份正在KMP(KM-Produce)这家公...

如月由奈(如月ユナ)材料

如月由奈(如月ユナ)材料 如月由奈,日文名:如月ユナ、きさらぎゆな,英文名:Kisaragi Yuna,年0月日死亡于日/眧缃东京都,是日/眧缃AWV女牲,0年0月日入行,从属于Prestige片商,喜好美甲、网球、操持、英语。 如月由奈(...

如月芽衣(如月めい)全副番号大全及图片封面

如月芽衣(如月めい)全副番号大全及图片封面 二零一五年如月芽衣(如月めい)全副作品文章番号 肉/蘾锴担保の生保レディ ヤ?リ?ま?く?り 时间 ZENI-00 / 二零一五–0 超?女体観察 名 AGEMIX- / 二零 一五&...

如月芽衣(如月めい)材料

如月芽衣(如月めい)材料 如月芽衣,日文名:如月めい、きさらぎめい,英文名:没有详,0年0月0日死亡于日/眧缃东京都,是日/眧缃AWV女牲,0年0月日入行,从属于キャンディ片商,喜好漫步。 如月芽衣(如月めい)材料 中文名:如月芽衣 日文名...

妃乃光(妃乃ひかり)简介

妃乃光(妃乃ひかり)简介 妃乃光,日文名:妃乃ひかり,日月日死亡于日/眧缃神奈川县,日/眧缃AWV女牲,以饱满身体着称。妃乃光(妃乃ひかり)入行公司为水晶映像,为正在Moodyz旗下的AWV女牲。00日月,从水晶映像(クリスタル映像)入行,...

妃悠爱(妃悠愛)全副番号大全及图片封面

妃悠爱(妃悠爱)全副番号大全及图片封面 00年妃悠爱(妃悠爱)全副作品文章番号 耻辱の肉/蘾锴介护 妃悠爱 RKI-00 / 00– 妃悠爱 DRS-0 / 00– 偌妻の疼き 妃悠爱 HAWVD- / 00R...

妃悠爱(妃悠愛)材料

妃悠爱(妃悠爱)材料 妃悠爱,日文名:妃悠爱、きさきゆあ,英文名:Kisakiyu Ai,0日月0日死亡于日/眧缃东京都,是日/眧缃AWV女牲,00年0月0日入行,从属于WANZ片商,喜好篮球、购物。 妃悠爱(妃悠爱)材料 中文名:妃悠爱 ...

妃月留衣(妃月るい)全副番号大全及图片封面

妃月留衣(妃月るい)全副番号大全及图片封面 二零一六年妃月留衣(妃月る い)全副作品文章番号 自イキを缲り返すオナニーみたいなわがままグラインド骑佄?妃月るい SNIS-0 / 二零一六– おしっこ弛禁 扭/莬鷟?大洪流スペシャ...

妃月留衣(妃月るい)材料

妃月留衣(妃月るい)材料 妃月留衣,日文名:妃月るい、ひづきるい,英文名:Hiduki Rui,年0月日死“我在上海做金融工作,身边有同事和朋友把孩子送到收费昂贵的国际学校,孩子们觉得有车有房、吃大餐是天经地义的事。但城市的繁华不能蒙住我们...