好吧,我最近购买了一个名为WPArcade的wordpress插件,但是,我遇到了一些问题。特别是,我不能让我的游戏像他们想要的那样进食。当我尝试从Kongregate输入游戏时,它显示找到0个游戏,但同时也显示以下错误:
警告:第113行为C:\Program Files (x86)\Ampps\www\wp\wp-content\plugins\wparcade-plugin\feeds\kongregate\kongregate.php中的foreach()提供的参数无效
我在一个本地服务器上测试这个站点,这就是为什么它在C驱动器中。
Kongregates提要:http://www.kongregate.com/games_for_your_site.xml
插件中的每个发布者都会发生这种情况,除了一个不会抛出警告的发布者。
第113到155行: Kongregate
$xml = simplexml_load_string($get_kongregate_feed);
foreach($xml->game as $game) {
$id = intval($game->id);
$name = mysql_real_escape_string($game->title);
$check_id = $wpdb->get_var("SELECT id FROM ".$wpdb->prefix."wparcade_kongregate_games WHERE id = '$id'");
$count = mysql_result(mysql_query("SELECT COUNT(*) as newgames FROM ".$wpdb->prefix."wparcade_kongregate_games WHERE id = '$check_id'"),0);
if($count !== '1') {
$name = mysql_real_escape_string($game->title);
$slug = mysql_real_escape_string($game->title);
$slug = wparcade_stringforslug($slug);
$category = mysql_real_escape_string($game->category);
$category = wparcade_strstr_before($category, " & ");
if(!$category) $category = mysql_real_escape_string($game->category);
$categories = mysql_real_escape_string($game->category);
$categories = str_replace(' & ', ', ', $categories);
if(!$categories) $categories = mysql_real_escape_string($game->category);
$description = mysql_real_escape_string($game->description);
$instructions = mysql_real_escape_string($game->instructions);
$thumbnail_url = mysql_real_escape_string($game->thumbnail);
$swf_url = mysql_real_escape_string($game->flash_file);
$width = $game->width;
$height = $game->height;
$tags = strtolower($categories);
$author = mysql_real_escape_string($game->developer_name);
$wparcade_kongregate_feed_game_status = $options['kongregate_feed_game_status'];
$status = $wparcade_kongregate_feed_game_status;
$feedsinglecat_id = $options['kongregate_feed_single_cat'];
$feedcategory = get_cat_name($feedsinglecat_id);
if($feedsinglecat_id !== 'none') {
$categories = $feedcategory;
$category = $feedcategory;
}
$sql = "INSERT INTO ".$wpdb->prefix."wparcade_kongregate_games (id, name, slug, description, thumbnail_url, swf_url, width, height, author, categories, category, tags, instructions, status) VALUES ('$id', '$name', '$slug', '$description', '$thumbnail_url', '$swf_url', '$width', '$height', '$author', '$categories', '$category', '$tags', '$instructions', '$status')";
$list .= '<li class="wparcade_new_games""><strong>'.$name.'</strong></li>';
$wpdb->query($sql);
$inserted++;
} else {
$list .= '<li class="wparcade_old_games"><strong>'.$name.'</strong></li>';
}
}以防万一,这是来自唯一有效的提要的代码:
$xml = simplexml_load_string($get_scirra_feed);
foreach($xml->game as $game) {
$id = intval($game->gameid);
$name = mysql_real_escape_string($game->name);
$count = mysql_result(mysql_query("SELECT COUNT(*) as newgames FROM ".$wpdb->prefix."wparcade_scirra_games WHERE id = '$id'"),0);
$category = mysql_real_escape_string($game->category);
$slug = mysql_real_escape_string($game->name);
$slug = wparcade_stringforslug($slug);
$check_for = $wpdb->get_var("SELECT name FROM ".$wpdb->prefix."wparcade_scirra_games WHERE slug = '$slug'");
if($count !== '1' && $category !== 'Example' && !$check_for) {
$name = mysql_real_escape_string($game->name);
$slug = mysql_real_escape_string($game->name);
$slug = wparcade_stringforslug($slug);
$category = mysql_real_escape_string($game->category);
$category = str_replace('Shooter', 'Shooting', $category);
$category = str_replace('Defence', 'Defense', $category);
$category = str_replace('Puzzle', 'Puzzles', $category);
$category = str_replace('Rotary', 'Arcade, Rotary', $category);
$categories = $category;
$description = strip_tags(mysql_real_escape_string($game->description));
$instructions = strip_tags(mysql_real_escape_string($game->instructions));
$thumbnail_url = $game->images->small;
$thumbnail_large_url = $game->images->medium;
$screen1_url = $game->images->big;
$embed_url = mysql_real_escape_string($game->embedurl);
$embed_url = str_replace('http://', '//', $embed_url);
$embed_url = str_replace('//', 'http://', $embed_url);
$width = $game->width;
$height = $game->height;
$tags = strtolower($categories);
$author = mysql_real_escape_string($game->author->username);
$wparcade_scirra_feed_game_status = $options['scirra_feed_game_status'];
$status = $wparcade_scirra_feed_game_status;
$feedsinglecat_id = $options['scirra_feed_single_cat'];
$feedcategory = get_cat_name($feedsinglecat_id);
if($feedsinglecat_id !== 'none') {
$categories = $feedcategory;
$category = $feedcategory;
}
$sql = "INSERT INTO ".$wpdb->prefix."wparcade_scirra_games (id, name, slug, description, thumbnail_url, thumbnail_large_url, screen1_url, embed_url, width, height, author, categories, category, tags, instructions, status) VALUES ('$id', '$name', '$slug', '$description','$thumbnail_url', '$thumbnail_large_url', '$screen1_url', '$embed_url', '$width', '$height', '$author', '$categories', '$category', '$tags', '$instructions', '$status')";
$list .= '<li class="wparcade_new_games""><strong>'.$name.'</strong></li>';
$wpdb->query($sql);
$inserted++;
} else {
$list .= '<li class="wparcade_old_games"><strong>'.$name.'</strong></li>';
}
}提前感谢您的帮助。
另外,我在插件的支持网站上询问过了,但几乎已经过了一个星期了,没有得到任何答复。
发布于 2015-04-05 06:46:56
这里的问题是,对于Kongregate,$xml->游戏不是一个可迭代的对象(像数组一样)。最简单的调试方法是在第113行,尝试插入如下内容:
print_r($xml->game);
//or
print_r($xml);让数据可见性了解哪些是工作的,哪些是不工作的,这可能会帮助您更好地理解为什么不工作。祝好运!
https://stackoverflow.com/questions/29452179
复制相似问题