'', 'minrate' => '3', 'countrycode' => 'us', 'scrollspeed' => '7000' ), $atts ); if (empty($attributes['appid']) || is_numeric($attributes['appid']) == false) { return "There is an error with the 'appid' attribute of your App Reviews shortcode"; } $json = file_get_contents('https://itunes.apple.com/'. $attributes['countrycode'] .'/rss/customerreviews/page=1/id=' . $attributes['appid'] . '/sortBy=mostRecent/json'); $reviews = json_decode($json, true); if (isset($reviews['feed']['entry'])) { $names = array(); $count = -1; $addedcount = 0; foreach($reviews['feed']['entry'] as $item) { if ($count > -1) { $names[$addedcount] = '
' . $item['author']['name']['label'] . ' said:
' . $item['title']['label'] . '
"' . $item['content']['label'] . '"'; $addedcount = $addedcount + 1; } $count = $count + 1; } $js_array = json_encode($names); $arr1 = str_split($attributes['appid']); $idText = ''; foreach ($arr1 as $num) { $idText = $idText . toAlpha($num); } echo ''; $output = '
'; $output = $output . ''; $output = $output .'
'; return $output; } else { return "There was a problem downloading app reviews from the Apple app store."; } } function toAlpha($data){ $alphabet = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); $alpha_flip = array_flip($alphabet); if($data <= 25){ return $alphabet[$data]; } elseif($data > 25){ $dividend = ($data + 1); $alpha = ''; $modulo; while ($dividend > 0){ $modulo = ($dividend - 1) % 26; $alpha = $alphabet[$modulo] . $alpha; $dividend = floor((($dividend - $modulo) / 26)); } return $alpha; } } add_shortcode('appreviews', 'appreviews_setup'); ?>