/* --------------------------------------------------------- * PART 2 — PlayArcade Game Engine (게임 포스트 자동화) * --------------------------------------------------------- */ /* --------------------------------------------------------- * 1) 게임 자동 카테고리 분류 (안정화 버전) * --------------------------------------------------------- */ add_action('save_post', function($post_id){ if (wp_is_post_revision($post_id)) return; if (get_post_type($post_id) !== 'post') return; // 자동포스팅 엔진이 이미 카테고리를 지정한 경우 건너뛰기 $current = wp_get_post_categories($post_id); if (!empty($current)) return; $title = strtolower(get_the_title($post_id)); $rules = [ 'Action' => ['action', 'hero', 'combat'], 'Adventure' => ['adventure', 'quest', 'story'], 'Arcade' => ['arcade', 'classic', 'retro'], 'Board Game' => ['board', 'chess', 'checkers'], 'Casino' => ['casino', 'poker', 'blackjack', 'slots'], 'Customize' => ['dress', 'makeup', 'style'], 'Defense' => ['defense', 'tower', 'protect'], 'Dress-Up' => ['dress', 'fashion', 'outfit'], 'Driving' => ['car', 'drive', 'race', 'drift'], 'Education' => ['learn', 'math', 'quiz'], 'Fighting' => ['fight', 'warrior', 'battle'], 'Game News' => ['news', 'update', 'release'], 'Jigsaw' => ['jigsaw', 'piece'], 'Multiplayer' => ['io', 'multiplayer', 'online'], 'Puzzles' => ['puzzle', 'match', 'brain', 'logic'], 'Rhythm' => ['music', 'rhythm', 'beat'], 'Shooting' => ['shoot', 'gun', 'sniper', 'fps'], 'Sports' => ['sport', 'soccer', 'football', 'basketball'], 'Strategy' => ['strategy', 'tactics', 'build'] ]; foreach ($rules as $cat => $keywords) { foreach ($keywords as $word) { if (strpos($title, $word) !== false) { $cat_id = get_cat_ID($cat); if ($cat_id > 0) { wp_set_post_categories($post_id, [$cat_id]); return; } } } } }, 40); /* --------------------------------------------------------- * 2) 자동 썸네일 (default-thumb.jpg) 안정화 버전 * --------------------------------------------------------- */ add_action('save_post', function($post_id){ if (wp_is_post_revision($post_id)) return; if (get_post_type($post_id) !== 'post') return; if (has_post_thumbnail($post_id)) return; $image_url = "https://playarcade.net/wp-content/uploads/default-thumb.jpg"; // 외부 이미지 다운로드 $image_id = media_sideload_image($image_url, $post_id, null, 'id'); if (!is_wp_error($image_id) && $image_id) { set_post_thumbnail($post_id, $image_id); } }, 50); /* --------------------------------------------------------- * 3) Related Games (중복 제거 + 최적화 버전) * --------------------------------------------------------- */ add_filter('the_content', function($content){ if (!is_single() || get_post_type() !== 'post') return $content; $cats = wp_get_post_categories(get_the_ID()); $q = new WP_Query([ 'category__in' => $cats, 'post__not_in' => [get_the_ID()], 'posts_per_page' => 6, 'orderby' => 'rand' ]); if (!$q->have_posts()) return $content; $html = '
Learn the controls, objectives, and strategies to master {$title}. Improve your score by practicing timing and movement.
"; $extra .= "Explore more games like {$title} on PlayArcade.
"; remove_action('publish_post', __FUNCTION__, 10); wp_update_post([ 'ID' => $post_id, 'post_content' => $content . $extra ]); add_action('publish_post', __FUNCTION__, 10, 2); }, 10, 2); ?> /* --------------------------------------------------------- * PART 3 — PlayArcade Auto Posting Engine (Guides + Top10) * --------------------------------------------------------- */ /* --------------------------------------------------------- * 0) 크론 스케줄 중복 방지 * --------------------------------------------------------- */ add_action('init', function(){ if (!wp_next_scheduled('playarcade_daily_ai_guide')) { wp_schedule_event(time(), 'daily', 'playarcade_daily_ai_guide'); } if (!wp_next_scheduled('playarcade_daily_top10')) { wp_schedule_event(time(), 'daily', 'playarcade_daily_top10'); } }); /* --------------------------------------------------------- * 1) 하루 1개 가이드 자동 생성 * --------------------------------------------------------- */ add_action('playarcade_daily_ai_guide', function(){ $games = get_posts([ 'post_type' => 'post', 'numberposts' => 1, 'orderby' => 'rand', 'post_status' => 'publish', 'suppress_filters' => false, ]); if (empty($games)) return; $game = $games[0]; $game_title = $game->post_title; $game_link = get_permalink($game->ID); $guide_title = "How to Play {$game_title} – Tips & Tricks"; // 중복 생성 방지 if (get_page_by_title($guide_title, OBJECT, 'post')) return; // Guides 카테고리 강제 적용 $guides = get_term_by('slug', 'guides', 'category'); $guides_cat = $guides ? $guides->term_id : 0; $content = "This is a gameplay guide for {$game_title} on PlayArcade.
"; $content .= "Improve your score by learning the mechanics, timing, and strategy.
"; $content .= "Play here: {$game_title}
"; $content .= "More games at PlayArcade.
"; wp_insert_post([ 'post_title' => $guide_title, 'post_content' => $content, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => [$guides_cat], 'post_author' => 1 ]); }); /* --------------------------------------------------------- * 2) 하루 1개 Top10 자동 생성 (고급 버전 통합) * --------------------------------------------------------- */ add_action('playarcade_daily_top10', function(){ $keywords = [ "arcade games", "retro arcade games", "action games", "fighting games", "adventure games", "puzzle games", "brain games", "jigsaw games", "racing games", "car games", "shooting games", "fps browser games", "sports games", "strategy games", "io games", "best io games", "unblocked games", "games to play at school", "flash games alternative" ]; $patterns = [ "Top 10 %s", "Best Free %s", "Best %s 2026", "Games Like %s" ]; $mapping = [ "arcade games" => "Arcade", "retro arcade games" => "Arcade", "action games" => "Action", "fighting games" => "Fighting", "adventure games" => "Adventure", "puzzle games" => "Puzzles", "brain games" => "Puzzles", "jigsaw games" => "Jigsaw", "racing games" => "Driving", "car games" => "Driving", "shooting games" => "Shooting", "fps browser games" => "Shooting", "sports games" => "Sports", "strategy games" => "Strategy", "io games" => "Multiplayer", "best io games" => "Multiplayer", "unblocked games" => null, "games to play at school" => null, "flash games alternative" => "Arcade" ]; $keyword = $keywords[array_rand($keywords)]; $pattern = $patterns[array_rand($patterns)]; $title = sprintf($pattern, ucwords($keyword)); // 중복 생성 방지 if (get_page_by_title($title, OBJECT, 'post')) return; // 카테고리 매핑 $cat_name = $mapping[$keyword]; if ($cat_name) { $cat_id = get_cat_ID($cat_name); $games = get_posts([ 'post_type' => 'post', 'numberposts' => 10, 'orderby' => 'rand', 'category' => $cat_id, 'post_status' => 'publish', 'suppress_filters' => false, ]); } else { $games = get_posts([ 'post_type' => 'post', 'numberposts' => 10, 'orderby' => 'rand', 'post_status' => 'publish', 'suppress_filters' => false, ]); } if (empty($games)) return; /* 고급 Top10 본문 생성 (BLOCK C 통합) */ $content = "Here are the best {$keyword} you can play right now on PlayArcade.
"; $content .= "These games were selected based on popularity, gameplay quality, and user ratings.
"; $content .= "Are these games free? Yes, all games listed are free to play.
"; $content .= "Do I need to download anything? No, all games run directly in your browser.
"; // Guides 카테고리 강제 적용 $guides = get_term_by('slug', 'guides', 'category'); $guides_cat = $guides ? $guides->term_id : 0; wp_insert_post([ 'post_title' => $title, 'post_content' => $content, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => [$guides_cat], 'post_author' => 1 ]); }); ?>