itemID = $data['itemID']; $this->itemType = $data['itemType']; } function get_excerpt() { if( strlen($this->itemID) < 25 ) { return "Valid ID"; } else { return "ID too long"; } } function the_excerpt( ) { return $this->get_excerpt();; } function the_title( $title ) { echo $title; } } function appStore_add_scripts() { if(appStore_setting('enable_lightbox') == "yes") wp_enqueue_script('lightbox', plugins_url('js_functions/lightbox/js/lightbox-2.6.min.js',ASA_MAIN_FILE), null, null, true); wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core');//enables UI wp_enqueue_script('jquery-ui-accordion'); } function appStore_add_stylesheets() { wp_register_style('appStore-styles', plugins_url( 'css/appStore-styles.css', ASA_MAIN_FILE )); wp_enqueue_style( 'appStore-styles'); wp_register_style('appStore-jquery-accordian', 'http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css'); wp_enqueue_style( 'appStore-jquery-accordian'); wp_register_style('appStore-googlefont', 'http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600'); wp_enqueue_style( 'appStore-googlefont'); if(appStore_setting('enable_lightbox') == "yes") { wp_register_style('lightbox-styles', plugins_url( 'js_functions/lightbox/css/lightbox.css', ASA_MAIN_FILE )); wp_enqueue_style( 'lightbox-styles'); } } function appStore_addLinkToFooter () { if (appStore_setting('displayLinkToFooter') != "no") { echo '

'.__("Assisted by",'appStoreAssistant').' App Store Assistant

'; } } function appStore_icon_in_rss($originalContent) { global $post; $postContent = $post->post_content; $postURL = $post->guid; $pattern = get_shortcode_regex(); preg_match('/'.$pattern.'/s', $post->post_content, $matches); $firstShortcode = $matches[2]; $atts = shortcode_parse_atts( $matches[3] ); if ($firstShortcode == "asa_item" || $firstShortcode == "ios_app" || $firstShortcode == "mac_app" || $firstShortcode == "itunes_store") { $id = $atts['id']; if(!empty($atts['link'])) { $pattern = '(id[0-9]+)'; preg_match($pattern, $atts['link'], $matches, PREG_OFFSET_CAPTURE, 3); $appIDs[] = substr($matches[0][0], 2); $id = $appIDs[0]; } if($id == "" || !is_numeric($id)) return; $app = appStore_get_data($id); $appIcon_url = $app->imageRSS_cached; $smallDescription = appStore_shortenDescription($app->description,"rss"); $fullDescription = $app->description; } elseif($firstShortcode == "amazon_item") { $asin = $atts['asin']; if($asin == "")return; $amazonProduct = appStore_get_amazonData($asin); $appIcon_url = $amazonProduct['imageRSS']; $smallDescription = appStore_shortenDescription($amazonProduct['Description'],"rss"); $fullDescription = $amazonProduct['Description']; } if(appStore_setting('rss_showIcon') == "yes") { $content .= 'Icon2'; } $content .= $originalContent; if(appStore_setting('rss_showShortDescription') == "yes") { $content .= " ".$smallDescription; $content .= '… '.__('Read more','appStoreAssistant').''; } else { $content .= " ".$fullDescription; } //$content .= "[".appStore_setting('rss_showIcon')."][".appStore_setting('rss_showShortDescription')."]"; return $content; } function appStore_admin_bar_render() { // Is the user sufficiently leveled, or has the bar been disabled? if (!is_super_admin() || !is_admin_bar_showing() ) return; // Good to go, lets do this! add_action('admin_bar_menu', 'appStore_admin_bar_links', 500); //add_action('admin_bar_menu', 'appStore_remove_default_links', 500); } function appStore_admin_bar_links() { global $wp_admin_bar; // Links to add, in the form: 'Label' => 'URL' $links = array( 'Search iTunes & App Stores to create new Post' => site_url().'/wp-admin/admin.php?page=appStore_IDsearch', 'Clear the Cache' => site_url()."/wp-admin/admin.php?page=appStore_sm_utilities&tab=clearcache", 'Clear the Cache for a single item' => site_url().'/wp-admin/admin.php?page=appStore_sm_utilities&tab=defaultTab', 'Help with Shortcodes' => site_url().'/wp-admin/admin.php?page=appStore_sm_help&tab=shortcodes' ); // Add the Parent link. $wp_admin_bar->add_menu( array( 'title' => '+ New ASA Post', 'id' => 'asa_newapppost', 'href' => site_url().'/wp-admin/admin.php?page=appStore_IDsearch', 'parent' => false )); //Add the submenu links. foreach ($links as $label => $url) { $wp_admin_bar->add_menu( array( 'title' => $label, 'id' => 'asa_newapppost_'.substr($url,-8), 'href' => $url, 'parent' => 'asa_newapppost' //'meta' => array('target' => '_blank') // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' ); )); } } function asa_load_translation_file() { // relative path to WP_PLUGIN_DIR where the translation files will sit: $plugin_path = dirname( plugin_basename( __FILE__ ) ) . '/languages/'; load_plugin_textdomain( 'appStoreAssistant', false, $plugin_path ); } function appStore_get_the_post_thumbnail( $post_id = null, $size = 'post-thumbnail', $attr = '' ) { $post_id = ( null === $post_id ) ? get_the_ID() : $post_id; $post_thumbnail_id = get_post_thumbnail_id( $post_id ); $size = apply_filters( 'post_thumbnail_size', $size ); if ( $post_thumbnail_id ) { do_action( 'begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters if ( in_the_loop() ) update_post_thumbnail_cache(); $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr ); do_action( 'end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); } else { $html = ''; } $errorImage = plugins_url( 'images/CautionIcon.png' , ASA_MAIN_FILE ); $html = 'FAKE THUMBNAIL 1'; //$html = ""; return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr ); } function appStore_post_thumbnail_html( $html) { // was appStore_post_thumbnail_html( $html, $post_id, $post_thumbnail_id, $size, $attr ) $errorImage = plugins_url( 'images/CautionIcon.png' , ASA_MAIN_FILE ); $html = 'FAKE THUMBNAIL 2'; return $html; /* echo "------------------------[BREAK POINT]------------------------------"; if (appStore_setting('excerpt_generator')=="asa") { $appIconDesc = appStore_get_icon_desc(); $html = ''; $html .= '<# some text #>'; $html .= ''; return $html; } else { $post_id = ( null === $post_id ) ? get_the_ID() : $post_id; $post_thumbnail_id = get_post_thumbnail_id( $post_id ); $size = apply_filters( 'post_thumbnail_size', $size ); if ( $post_thumbnail_id ) { do_action( 'begin_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); // for "Just In Time" filtering of all of wp_get_attachment_image()'s filters if ( in_the_loop() ) update_post_thumbnail_cache(); $html = wp_get_attachment_image( $post_thumbnail_id, $size, false, $attr ); do_action( 'end_fetch_post_thumbnail_html', $post_id, $post_thumbnail_id, $size ); } else { $html = ''; } return apply_filters( 'post_thumbnail_html', $html, $post_id, $post_thumbnail_id, $size, $attr ); } */ } function appStore_get_icon_desc($shortcodeData) { $shortcode = (isset($shortcodeData['shortcode']) ? $shortcodeData['shortcode'] : 'none'); switch ($shortcode) { case "asa_item": $id = $shortcodeData['atts']['id']; if(!empty($shortcodeData['atts']['link'])) { $pattern = '(id[0-9]+)'; preg_match($pattern, $shortcodeData['atts']['link'], $matches, PREG_OFFSET_CAPTURE, 3); $appIDs[] = substr($matches[0][0], 2); $id = $appIDs[0]; } if($id == "" || !is_numeric($id))return; $app = appStore_get_data($id); $appFullDescription = (isset($app->description) ? $app->description : ''); $appIcon_url = $app->artworkUrl60; break; case "ios_app": $id = $shortcodeData['atts']['id']; if(!empty($shortcodeData['atts']['link'])) { $pattern = '(id[0-9]+)'; preg_match($pattern, $shortcodeData['atts']['link'], $matches, PREG_OFFSET_CAPTURE, 3); $appIDs[] = substr($matches[0][0], 2); $id = $appIDs[0]; } if($id == "" || !is_numeric($id))return; $app = appStore_get_data($id); $appFullDescription = $app->description; $appIcon_url = $app->artworkUrl60; break; case "amazon_item": $asin = $shortcodeData['atts']['asin']; if($asin == "")return; $amazonProduct = appStore_get_amazonData($asin); $appFullDescription = (isset($amazonProduct['Description']) ? $amazonProduct['Description'] : ''); $appIcon_url = $amazonProduct['SmallImage']; break; case "mac_app": $id = $shortcodeData['atts']['id']; if(!empty($shortcodeData['atts']['link'])) { $pattern = '(id[0-9]+)'; preg_match($pattern, $shortcodeData['atts']['link'], $matches, PREG_OFFSET_CAPTURE, 3); $appIDs[] = substr($matches[0][0], 2); $id = $appIDs[0]; } if($id == "" || !is_numeric($id))return; $app = appStore_get_data($id); $appFullDescription = $app->description; $appIcon_url = $app->artworkUrl60; break; case "itunes_store": $id = $shortcodeData['atts']['id']; if($id == "" || !is_numeric($id))return; $iTunesItem = appStore_get_data($id); $appFullDescription = $iTunesItem->longDescription; $appIcon_url = $iTunesItem->artworkUrl60; break; case "asa_item": $appFullDescription = __('A List of items','appStoreAssistant'); $appIcon_url = plugins_url( 'images/MusicList.png', ASA_MAIN_FILE ); break; case "iTunes_list": $appFullDescription = __('A List of music from iTunes','appStoreAssistant'); $appIcon_url = plugins_url( 'images/MusicList.png', ASA_MAIN_FILE ); break; case "ios_app_list": $appFullDescription = __('A List of Apps','appStoreAssistant'); $appIcon_url = plugins_url( 'images/Apps.jpg', ASA_MAIN_FILE ); break; case "none": $appFullDescription = ''; $appIcon_url = plugins_url( 'images/Apps.jpg', ASA_MAIN_FILE ); break; } $appData['appFullDescription'] = $appFullDescription; $appData['appIcon_url'] = $appIcon_url; return $appData; } function appStore_excerpt_filter($text, $excerpt="") { global $post,$post_id; $originalPost = $post; $postContent = substr($post->post_content,1, 400); $originalExcerpt = esc_attr( get_post_field( 'post_excerpt', $post_id ) ); $postTitle = esc_attr( get_post_field( 'post_title', $post_id ) ); $shortcodeData = getShortcodeDataFromPost(); // Create More Info text if (appStore_setting('displayexcerptreadmore')=="yes") { $readMoreText = appStore_setting('excerpt_moreinfo_text'); $readMoreLink = ' '; $readMoreLink .= $readMoreText; $readMoreLink .= ''; if (appStore_setting('excerpt_moreinfo_link') == "button") { $readMoreLink = ''; // '
 
'; $readMoreLink .= '
'; $readMoreLink .= ''; $readMoreLink .= $readMoreText.'
'; } } else { $readMoreLink = ""; } $appIconDesc = appStore_get_icon_desc($shortcodeData); if(appStore_setting('displayexcerptthumbnail')=="yes") { $displayIcon = ''; $displayIcon .= ''.$postTitle.''; $displayIcon .= ''; } else { $displayIcon =""; } if(strlen($originalExcerpt) > 20 ) { $appShortDescription = $displayIcon.$originalExcerpt." ".$readMoreLink; } else { //Get the App Data $appShortDescription = $displayIcon; $appShortDescription .= nl2br(wp_trim_words($appIconDesc['appFullDescription'],appStore_setting('excerpt_max_chars'))); $appShortDescription .= $readMoreLink; } return $appShortDescription; } function getShortcodeDataFromPost(){ global $post; $shortcodeData = ''; $postContent = substr($post->post_content,1, 400); $shortcodes = array("asa_item","amazon_item","ios_app", "itunes_store","ibooks_store","mac_app"); foreach ($shortcodes as $shortcode) { if (stristr($postContent, $shortcode) !== FALSE) { $shortcodeData['shortcode'] = $shortcode; } } // Get Attributes $data = preg_match_all('/([a-zA-Z_]+)=\"([^\"]*?)\"/', $postContent, $matches); foreach ($matches[1] as $shortcodeKey=>$shortcode) { $shortcodeData['atts'][$shortcode] = $matches[2][$shortcodeKey]; } /* example array: [shortcode] => ios_app [atts] => Array ( [id] => 411784735 [more_info_text] => More Info Text from Oscars post!!!... ) */ return $shortcodeData; } // +++++ Add ios_app button to TinyMCE function add_asa_mce_button() { if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) return; if ( get_user_option('rich_editing') == 'true') { add_filter('mce_external_plugins', 'add_asa_mce_tinymce_plugin'); add_filter('mce_buttons', 'register_asa_mce_button'); } } function register_asa_mce_button($buttons) { array_push($buttons, "|", "asa_app", "itunes_store", "asaf_atomfeed","asa_amazon"); return $buttons; } function add_asa_mce_tinymce_plugin($plugin_array) { $plugin_array['asa_mce'] = plugins_url( 'js_functions/mce.plugin.js', ASA_MAIN_FILE ); return $plugin_array; } function appStore_refresh_mce($ver) { $ver += 3; return $ver; } // ----- End of Add ASA buttons to TinyMCE function appStore_css_hook() { $emptyStar = plugins_url( 'images/rating/star-rating-'.appStore_setting('empty_star_color').'.png', ASA_MAIN_FILE ); $fullStar = plugins_url( 'images/rating/star-rating-'.appStore_setting('full_star_color').'.png', ASA_MAIN_FILE ); ?> ''), $atts ) ); //Don't do anything if the ID is blank or non-numeric if($id == "" || !is_numeric($id)) return; $appStore_options_data = appStore_get_data($id); $output = '
'; $output .= "RAW DATA FOR $id
"; $link = ASA_APPSTORE_URL . $id; $output .= "Using Link $link
"; $output .= '
';
	$output .= print_r($appStore_options_data,true);
	$output .= '
'; $output .= '
'; return $output; } function appStore_handler_item ( $atts,$content=null, $code="" ) { // Get App ID and more_info_text from shortcode extract( shortcode_atts( array( 'id' => '', 'link' => '', 'more_info_text' => 'continued...' ), $atts ) ); if(!empty($link)) { $pattern = '(id[0-9]+)'; preg_match($pattern, $link, $matches, PREG_OFFSET_CAPTURE, 3); $appIDs[] = substr($matches[0][0], 2); $id = $appIDs[0]; } //Don't do anything if the ID is blank or non-numeric if($id == "" || !is_numeric($id))return; //Get the App Data $app = appStore_get_data($id); if($app) { return appStore_renderItem($app,$more_info_text,"SingleApp",$code); } else { return __("This item is no longer available.",'appStoreAssistant')." (id:$id)"; //wp_die('No valid data for app id: ' . $id); } } function appStore_handler_itemLink( $atts,$content=null, $code="") { // Get item ID and more_info_text from shortcode extract( shortcode_atts( array( 'id' => '', 'text' => '' ), $atts ) ); //Don't do anything if the ID is blank or non-numeric if($id == "" || !is_numeric($id))return; //Get the App Data $item = appStore_get_data($id); if($item) { switch ($item->wrapperType) { case "collection": $itemName = $item->collectionName; $itemURL = getAffiliateURL($item->collectionViewUrl); break; case "track": $itemName = $item->trackName; $itemURL = getAffiliateURL($item->trackViewUrl); break; case "audiobook": $itemName = $item->collectionName; $itemURL = getAffiliateURL($item->collectionViewUrl); break; case "software": $itemName = $item->trackName; $itemURL = getAffiliateURL($item->trackViewUrl); break; } if ($text == '') $text = $itemName; $itemURL_Display = ''; return $itemURL_Display; } else { return "Error Processing App ID: $id"; //wp_die('No valid data for app id: ' . $id); } } function appStore_handler_app_element($atts,$content=null, $code="",$platform="ios_app") { $mode = "SingleApp"; // Get App ID and more_info_text from shortcode extract( shortcode_atts( array( 'id' => '', 'elements' => '' ), $atts ) ); $elements = preg_replace("/[^a-zA-Z,]+/", "", $elements); //Don't do anything if the ID is blank or non-numeric if($id == "" || !is_numeric($id))return; //Get the App Data $app = appStore_get_data($id); $app->TheAppPrice = appStore_format_price($app->price); $app->appURL = getAffiliateURL($app->trackViewUrl); if(appStore_setting('smaller_buy_button_iOS') == "yes" && wp_is_mobile()) { $app->buttonText = $app->TheAppPrice." "; } else { $app->buttonText = $app->TheAppPrice." - ".__("View in App Store",'appStoreAssistant')." "; } $app->mode = $mode; if($app->kind == 'mac-software') $platform = 'mac_app'; $app->platform = $platform; $element = ""; $appElements_available = explode(",","appName,appIcon,appDescription,appBadge,appDetails,appGCIcon,appScreenshots,appDeviceList,appBuyButton,appRating,appPrice,appBadgeSm,appReleaseNotes,appVersion"); if($app) { $appElements = explode(",", $elements); $appElements = array_filter($appElements, 'strlen'); foreach($appElements as $appElement) { if (in_array($appElement, $appElements_available)) { $displayFunction = "displayAppStore_".$appElement; $element .= " ".$displayFunction($app,true)." "; } else { $element = "

Invalid Element attribute: $appElement

"; } } return $element; } else { return "Error Processing App ID: $id"; //wp_die('No valid data for app id: ' . $id); } } function appStore_handler_list($atts, $content = null, $code="") { // Get ATOM URL and more_info_text from shortcode extract( shortcode_atts( array( 'ids' => '', 'debug' => 'false', 'more_info_text' => 'open in The Store...' ), $atts ) ); if(empty($ids)) { _e("Missing list of IDs.",'appStoreAssistant'); return; } //echo "[$debug]"; //if($debug=="true") echo "[$appID][".print_r($app)."]"; $appIDs = explode(",",$ids); $AppListing = ""; //Pair down array to number of apps preference array_splice($appIDs, appStore_setting('qty_of_apps')); //Load App data foreach($appIDs as $appID) { if($appID == "" || !is_numeric($appID)) return; $app = appStore_get_data($appID); if($app) { $AppListing .= appStore_renderItem($app,$more_info_text,"ListOfApps"); } else { $AppListing .= ""; //wp_die('No valid data for app id: ' . $id); } } return $AppListing; } function appStore_handler_feed($atts, $content = null, $code="") { $mode = ""; // Get ATOM URL and more_info_text from shortcode extract( shortcode_atts( array( 'atomurl' => '', 'debug' => 'false', 'more_info_text' => __('open in The App Store...','appStoreAssistant') ), $atts ) ); if(empty($atomurl)) { _e( 'Missing atomurl in tag. Replace id with atomurl.','appStoreAssistant'); return; } $mode = strtolower($mode); if ($mode == "itunes") { $platform = "itunes"; } else { $platform = $mode.'_app'; } $originalatomurl = $atomurl; if(substr($atomurl,-7,7) == "rss.xml" || substr($atomurl,-8,8) == "rss.xml/") { if(substr($atomurl,-8,8) == "rss.xml/") $atomurl = substr($atomurl,0,-1); } else { $last = $atomurl[strlen($atomurl)-1]; if($last != "/" && substr($atomurl,-3) != "xml") $AddSlash = "/"; if (substr($atomurl,-4) != "/xml") $atomurl .= "/xml"; } // Should not end in / Good: https://itunes.apple.com/us/rss/toppaidmacapps/limit=25/xml // Should not end in / Good: https://itunes.apple.com/WebObjects/MZStore.woa/wpa/MRSS/newreleases/sf=143441/limit=10/rss.xml $overridecache = false; //DEBUG //Check to see if feed is available cached $appStore_feedID = "appStore_rssfeed_".hash('md2', $atomurl); $appStore_feedOptions = get_option($appStore_feedID, ''); if($appStore_feedOptions == '' || $appStore_feedOptions['next_check'] < time() || $overridecache) { $STAT = "REBUILT CACHE"; // Get Array of AppIDs for ATOM Feed $appIDs = appStore_getIDs_from_feed($atomurl); $appStore_feedOptions = array('next_check' => time() + appStore_setting('cache_time_select_box'), 'feedURL' => $atomurl, 'appIDs' => $appIDs); update_option($appStore_feedID, $appStore_feedOptions); } else { $STAT = "From CACHE"; $appIDs = $appStore_feedOptions['appIDs']; } if(is_array($appIDs)) { //Pair down array to number of apps preference array_splice($appIDs, appStore_setting('qty_of_apps')); //Load App data $appListDisplay = ''; $appPositionNumber = 1; foreach($appIDs as $appID) { //$appListDisplay .= "
<<<<<<<[$appID]>>>>>>>
"; if($appID == "" || !is_numeric($appID)) return "This list is currently empty."; $app = appStore_get_data($appID); $app->PositionNumber = $appPositionNumber; $appPositionNumber ++; if($app) { $appListDisplay .= appStore_renderItem($app,$more_info_text,"ListOfApps").'
'; } else { $appListDisplay .= "Error Processing Item ID: $appID"; } } } else { $appListDisplay = "Sorry, no data for $atomurl [$originalatomurl]. Please check and make sure the URL is correct. For additional URLs, please visit the
iTunes RSS Generator. This may be a temporary issue."; } return $appListDisplay; } function appStore_getBadge ($store,$style="Normal") { // Create Badge img Tag $addCountryCode = false; if(appStore_setting('store_badge_language')) { $countryCode = appStore_setting('store_badge_language'); } else { $countryCode = "US-UK"; } $SizeMultiplier = appStore_setting('appStore_store_badge_size'); $badgeImage = 'images/Badges/'; switch ($store) { case "iTunes": $SizeMultiplier = appStore_setting('iTunes_store_badge_size'); if($style == "Music") { $badgeImage .= "Listen_on_Apple_Music_Badge_"; } else { $badgeImage .= "Get_it_on_iTunes_Badge_"; } $badgeImage .= $countryCode; $badgeImage .= ".svg"; $BadgeWidth = intval(110 * $SizeMultiplier); $BadgeHeight = intval(40 * $SizeMultiplier); break; case "iBooks": $SizeMultiplier = appStore_setting('iBooks_store_badge_size'); $badgeImage .= "Get_it_on_iBooks_Badge_"; $badgeImage .= $countryCode; $badgeImage .= ".svg"; $BadgeWidth = intval(110 * $SizeMultiplier); $BadgeHeight = intval(40 * $SizeMultiplier); break; case "App Store": $SizeMultiplier = appStore_setting('appStore_store_badge_size'); $badgeImage .= "Download_on_the_App_Store_Badge_"; $badgeImage .= $countryCode; $badgeImage .= "_135x40.svg"; $BadgeWidth = intval(135 * $SizeMultiplier); $BadgeHeight = intval(40 * $SizeMultiplier); break; case "Amazon": $SizeMultiplier = appStore_setting('amazon_badge_size'); $badgeImage .= "Get_it_on-Amazon.svg"; $BadgeWidth = intval(215 * $SizeMultiplier); $BadgeHeight = intval(74 * $SizeMultiplier); break; default: $badgeImage .= "Missing_Badge.svg"; $BadgeWidth = intval(135 * $SizeMultiplier); $BadgeHeight = intval(40 * $SizeMultiplier); } $BadgeSize = 'width = "'.$BadgeWidth.' height="'.$BadgeHeight.'"'; $badgeImgTag = ''.$store.''; return $badgeImgTag; } function appStore_renderItem($itemInfo,$more_info_text="View in Store...",$mode="SingleApp") { $itemType = ''; if (isset($itemInfo->wrapperType)) $itemType .= $itemInfo->wrapperType."_"; if (isset($itemInfo->kind)) $itemType .= $itemInfo->kind."_"; if (isset($itemInfo->collectionType)) $itemType .= $itemInfo->collectionType; $trackListing = ""; //echo "
<<<<<<<++[".$itemType."]++>>>>>>>
"; //Debug //echo '---------------'.print_r($itemInfo,true).'---------------';//Debug switch ($itemType) { case "software_mac-software_": $itemOutput = __("Mac Software",'appStoreAssistant'); $platform = 'mac_app'; $itemStore = "AppStore"; break; case "software_software_": $itemOutput = __("iOS Software",'appStoreAssistant'); $platform = 'ios_app'; $itemStore = "AppStore"; break; case "software_software_Album": $itemOutput = __("iOS Software",'appStoreAssistant'); $platform = 'ios_app'; $itemStore = "AppStore"; break; case "track_music-video_": $itemOutput = __("Music Video",'appStoreAssistant'); $itemStore = "iTunes"; $itemTemplate = "iTunesMain"; $unformattedPrice = $itemInfo->trackPrice; $iTunesID = $itemInfo->trackId; $iTunesName = $itemInfo->trackName; if(isset($itemInfo->collectionName)) $fromAlbum = $itemInfo->collectionName; $isExplicit = $itemInfo->trackExplicitness; $trackTime = $itemInfo->trackTimeMillis; $iTunesKind = $itemInfo->kind; $iTunesURL = $itemInfo->trackViewUrl; $artistType = __("Artist",'appStoreAssistant'); $cavType = __("Explicit",'appStoreAssistant'); $trackType = __("Track Count",'appStoreAssistant'); break; case "track_song_": $itemOutput = __("Song",'appStoreAssistant'); $itemStore = "iTunes"; $itemTemplate = "iTunesMusic"; $unformattedPrice = $itemInfo->trackPrice; $iTunesID = $itemInfo->trackId; $iTunesName = $itemInfo->trackName; $fromAlbum = $itemInfo->collectionName; $isExplicit = $itemInfo->trackExplicitness; $trackTime = $itemInfo->trackTimeMillis; $iTunesKind = $itemInfo->kind; $iTunesURL = $itemInfo->trackViewUrl; $artistType = __("Artist",'appStoreAssistant'); $cavType = __("Explicit",'appStoreAssistant'); $trackType = __("Track Count",'appStoreAssistant'); break; case "ebook_": $itemOutput = __("eBook",'appStoreAssistant'); $itemStore = "iBooks"; $itemTemplate = "iBooksMain"; $unformattedPrice = $itemInfo->price; $iTunesID = $itemInfo->trackId; $iBooksName = $itemInfo->trackName; $iTunesKind = $itemInfo->kind; $isExplicit = ''; $iBooksURL = $itemInfo->trackViewUrl; $artistType = __("Author",'appStoreAssistant'); $cavType = __("Explicit",'appStoreAssistant'); $trackType = __("Track Count",'appStoreAssistant'); $description = $itemInfo->description; break; case "_ebook_": $itemOutput = __("eBook",'appStoreAssistant'); $itemStore = "iBooks"; $itemTemplate = "iBooksMain"; $unformattedPrice = $itemInfo->price; $iTunesID = $itemInfo->trackId; $iTunesName = $itemInfo->trackName; $iTunesKind = $itemInfo->kind; $isExplicit = ''; $iBooksURL = $itemInfo->trackViewUrl; $artistType = __("Author",'appStoreAssistant'); $description = $itemInfo->description; break; case "collection_Album": $itemOutput = __("Music Album",'appStoreAssistant'); $itemStore = "iTunes"; $itemTemplate = "iTunesMusic"; $unformattedPrice = $itemInfo->collectionPrice; if(isset($itemInfo->collectionID)) $iTunesID = $itemInfo->collectionID; if(isset($itemInfo->collectionId)) $iTunesID = $itemInfo->collectionId; if(isset($itemInfo->trackListing)) $trackListing = $itemInfo->trackListing; $iTunesName = $itemInfo->collectionName; $isExplicit = $itemInfo->collectionExplicitness; $trackCount = $itemInfo->trackCount; $iTunesKind = $itemInfo->collectionType; $iTunesCopyright = $itemInfo->copyright; $iTunesURL = $itemInfo->collectionViewUrl; $artistType = __("Artist",'appStoreAssistant'); $cavType = __("Explicit",'appStoreAssistant'); $trackType = __("Track Count",'appStoreAssistant'); break; case "track_feature-movie_": $itemOutput = __("Movie",'appStoreAssistant'); $itemStore = "iTunes"; $itemTemplate = "iTunesMain"; $unformattedPrice = $itemInfo->trackPrice; $iTunesID = $itemInfo->trackId; $iTunesName = $itemInfo->trackName; if(isset($itemInfo->collectionName)) $fromAlbum = $itemInfo->collectionName; $isExplicit = $itemInfo->trackExplicitness; $trackTime = $itemInfo->trackTimeMillis; $iTunesKind = $itemInfo->kind; $iTunesURL = $itemInfo->trackViewUrl; $artistType = __("Director",'appStoreAssistant'); $cavType = __("Rated",'appStoreAssistant'); $trackType = __("Track Count",'appStoreAssistant'); $description = $itemInfo->longDescription; break; case "track_tv-episode_": $itemOutput = __("TV Episode",'appStoreAssistant'); $itemStore = "iTunes"; $itemTemplate = "iTunesMain"; $unformattedPrice = $itemInfo->trackPrice; $iTunesID = $itemInfo->trackId; $iTunesName = $itemInfo->artistName.": ".$itemInfo->trackName; $fromAlbum = $itemInfo->collectionName; $isExplicit = $itemInfo->trackExplicitness; $trackTime = $itemInfo->trackTimeMillis; $iTunesKind = $itemInfo->kind; $iTunesURL = $itemInfo->trackViewUrl; $artistType = __("Series",'appStoreAssistant'); $cavType = __("Rated",'appStoreAssistant'); $description = $itemInfo->longDescription; break; case "collection_TV Season": $itemOutput = __("TV Season",'appStoreAssistant'); $itemStore = "iTunes"; $itemTemplate = "iTunesMain"; $unformattedPrice = $itemInfo->collectionPrice; if(isset($itemInfo->collectionID)) $iTunesID = $itemInfo->collectionID; if(isset($itemInfo->collectionId)) $iTunesID = $itemInfo->collectionId; $iTunesName = $itemInfo->collectionName; $isExplicit = $itemInfo->collectionExplicitness; $trackCount = $itemInfo->trackCount; $iTunesKind = $itemInfo->collectionType; $iTunesURL = $itemInfo->collectionViewUrl; $iTunesCopyright = $itemInfo->copyright; $trackType = __("Episodes",'appStoreAssistant'); $artistType = __("Series",'appStoreAssistant'); $cavType = __("Rated",'appStoreAssistant'); $trackType = __("Track Count",'appStoreAssistant'); $description = $itemInfo->longDescription; break; case "audiobook_": $itemOutput = __("AudioBook",'appStoreAssistant'); $itemStore = "iTunes"; $itemTemplate = "iTunesMain"; $unformattedPrice = $itemInfo->collectionPrice; $iTunesID = $itemInfo->collectionId; $iTunesName = $itemInfo->collectionName; $isExplicit = $itemInfo->collectionExplicitness; $iTunesURL = $itemInfo->collectionViewUrl; $iTunesCopyright = $itemInfo->copyright; $description = $itemInfo->description; $artistType = __("Author",'appStoreAssistant'); break; case "track_podcast_": $itemOutput = __("Podcast",'appStoreAssistant'); $itemStore = "iTunes"; $itemTemplate = "iTunesMain"; $unformattedPrice = $itemInfo->trackPrice; $iTunesID = $itemInfo->trackId; $iTunesName = $itemInfo->trackName; $fromAlbum = $itemInfo->collectionName; $isExplicit = $itemInfo->trackExplicitness; if(isset($itemInfo->trackTimeMillis)) $trackTime = $itemInfo->trackTimeMillis; $iTunesKind = $itemInfo->kind; $iTunesURL = $itemInfo->trackViewUrl; $artistType = __("Produced by",'appStoreAssistant'); break; default: $itemOutput = __("Unknown Item Type!!",'appStoreAssistant')." - $itemType"; $itemStore = "Unknown"; $itemTemplate = "iTunesMain"; } switch ($itemStore) { case "iTunes": if (isset($itemInfo->primaryGenreName)) { $iTunesCategory = $itemInfo->primaryGenreName; } else if (isset($itemInfo->genres)) { $iTunesCategory = implode(", ", $itemInfo->genres); } $artistName = $itemInfo->artistName; if(isset($itemInfo->releaseDate)) $releaseDate = date( 'F j, Y', strtotime($itemInfo->releaseDate)); if(isset($itemInfo->contentAdvisoryRating)) $contentAdvisoryRating = $itemInfo->contentAdvisoryRating; $itemOutput = ""; $itemOutput = ""; // iTunes Artwork if(appStore_setting('cache_images_locally') == '1') { $artwork_url = $itemInfo->imagePosts_cached; if(wp_is_mobile()) $artwork_url = $itemInfo->imageiOS_cached; } else { $artwork_url = $itemInfo->imagePosts; if(wp_is_mobile()) $artwork_url = $itemInfo->imageiOS; } $iTunesURL = getAffiliateURL($iTunesURL); if(appStore_setting('smaller_buy_button_iOS') == "yes" && wp_is_mobile()) { $buttonText = appStore_format_price($unformattedPrice)." "; } else { $buttonText = appStore_format_price($unformattedPrice); //$buttonText = appStore_format_price($unformattedPrice)." - ".__("View in iTunes",'appStoreAssistant'); } $itemOutput .= '
'; //$itemOutput .= '
'; $itemOutput .= '
'; $itemOutput .= ''; //$itemOutput .= ''; $itemOutput .= ''; $itemOutput .= '
'; $itemOutput .= ''; $itemOutput .= $buttonText.'
'; $itemOutput .= '
'; $itemOutput .= '
'; if ((appStore_setting('displayitunestitle') == "yes" AND !empty($iTunesName)) OR $mode != "internal") { $itemOutput .= ''; $PositionNumber = 0; if(isset($itemInfo->PositionNumber)) $PositionNumber = $itemInfo->PositionNumber; if ($mode == "ListOfApps" && appStore_setting('displayATOMappPositionNumber') == "yes" && $PositionNumber > 0) { if(appStore_setting('PrePositionNumber') != "EMP") $itemOutput .= appStore_setting('PrePositionNumber'); $itemOutput .= $itemInfo->PositionNumber; if(appStore_setting('PostPositionNumber') != "EMP") $itemOutput .= appStore_setting('PostPositionNumber'); $itemOutput .= $iTunesName; } else { $itemOutput .= $iTunesName; } $itemOutput .= '

'; } if (appStore_setting('displayitunestrackcount') == "yes" AND !empty($trackCount)) { $itemOutput .= ''.$trackType.': '.$trackCount.'
'; } if (appStore_setting('displayitunesartistname') == "yes" AND !empty($artistName)) { $itemOutput .= ''.$artistType.': '.$artistName.'
'; } if (appStore_setting('displayitunesfromalbum') == "yes" AND !empty($fromAlbum)) { $itemOutput .= ''.__("From",'appStoreAssistant').': '.$fromAlbum.'
'; } if (appStore_setting('displayitunesgenre') == "yes" AND !empty($iTunesCategory)) { $itemOutput .= ''.__("Genre",'appStoreAssistant').': '.$iTunesCategory.'
'; } if (appStore_setting('displayadvisoryrating') == "yes" AND !empty($contentAdvisoryRating)) { $itemOutput .= ''.$cavType.': '.$contentAdvisoryRating.'
'; } if (appStore_setting('displayitunesreleasedate') == "yes" AND !empty($releaseDate)) { $itemOutput .= ''.__("Released",'appStoreAssistant').': '.$releaseDate.'
'; } if (true AND !empty($iTunesCopyright)) { $itemOutput .= ''.$iTunesCopyright.'
'; } if (appStore_setting('displayitunesexplicitwarning') == "yes" AND $isExplicit == "explicit") { $itemOutput .= '
Explicit Lyrics
';// 450x268 } if (appStore_setting('displayitunesdescription') == "yes" AND !empty($description)) { $itemOutput .= '
'; $itemOutput .= nl2br($description); $itemOutput .= '
'; } $itemOutput .= '
'; if (appStore_setting('displayitunestracklisting') == "yes" AND is_array($trackListing)) { $itemOutput .= '
 
'; $itemOutput .= '
'; $itemOutput .= ''; foreach ($trackListing['tracks'] as $disc => $tracks) { $itemOutput .= ''; foreach ($tracks as $track) { $itemOutput .= ""; $itemOutput .= ''; $itemOutput .= ''; $itemOutput .= '"; $itemOutput .= '"; if(appStore_setting('displayitunesradiolink') == "yes") $itemOutput .= ''; $itemOutput .= ""; } } $itemOutput .= "
1) $itemOutput .=' (Disc '.$disc.' of '.$trackListing['discCount'].')'; $itemOutput .= '
'; if ($track['number'] < 10 ) $itemOutput .= ' '; $itemOutput .= $track['number'].')'; $itemOutput .= $track['name']; $itemOutput .= ''.$track['trackTime']."'.appStore_format_price($track['trackPrice'],__('Album Only','appStoreAssistant'))."Radio
"; $itemOutput .= '
'; } $itemOutput .= '
'; $itemOutput .= '
'; if($itemTemplate == "iTunesMusic") { $itemOutput .= appStore_getBadge ($itemStore,"Music"); } else { $itemOutput .= appStore_getBadge ($itemStore); } $itemOutput .= ''; $itemOutput .= '
'; $itemOutput .= '
 
'; $itemOutput .= '
'; break; case "iBooks": if (isset($itemInfo->primaryGenreName)) { $iBooksCategory = $itemInfo->primaryGenreName; } else if (isset($itemInfo->genres)) { $iBooksCategory = implode(", ", $itemInfo->genres); } $authorName = $itemInfo->artistName; if(isset($itemInfo->releaseDate)) $releaseDate = date( 'F j, Y', strtotime($itemInfo->releaseDate)); if(isset($itemInfo->contentAdvisoryRating)) $contentAdvisoryRating = $itemInfo->contentAdvisoryRating; $itemOutput = ""; $itemOutput = ""; // iTunes Artwork if(appStore_setting('cache_images_locally') == '1') { $artwork_url = $itemInfo->imagePosts_cached; if(wp_is_mobile()) $artwork_url = $itemInfo->imageiOS_cached; } else { $artwork_url = $itemInfo->imagePosts; if(wp_is_mobile()) $artwork_url = $itemInfo->imageiOS; } $iBooksURL = getAffiliateURL($iBooksURL); if(appStore_setting('smaller_buy_button_iOS') == "yes" && wp_is_mobile()) { $buttonText = appStore_format_price($unformattedPrice)." "; } else { $buttonText = appStore_format_price($unformattedPrice); } $itemOutput .= '
'; $itemOutput .= '
'; $itemOutput .= ''; $itemOutput .= ''; $itemOutput .= '
'; $itemOutput .= ''; $itemOutput .= $buttonText.'
'; $itemOutput .= '
'; $itemOutput .= '
'; if ((appStore_setting('displayiBookstitle') == "yes" AND !empty($iBooksName)) OR $mode != "internal") { $itemOutput .= ''; $PositionNumber = 0; if(isset($itemInfo->PositionNumber)) $PositionNumber = $itemInfo->PositionNumber; if ($mode == "ListOfApps" && appStore_setting('displayATOMappPositionNumber') == "yes" && $PositionNumber > 0) { if(appStore_setting('PrePositionNumber') != "EMP") $itemOutput .= appStore_setting('PrePositionNumber'); $itemOutput .= $itemInfo->PositionNumber; if(appStore_setting('PostPositionNumber') != "EMP") $itemOutput .= appStore_setting('PostPositionNumber'); $itemOutput .= $iBooksName; } else { $itemOutput .= $iBooksName; } $itemOutput .= '

'; } if (appStore_setting('displayiBooksauthorname') == "yes" AND !empty($artistName)) { $itemOutput .= ''.$artistType.': '.$artistName.'
'; } if (appStore_setting('displayiBooksgenre') == "yes" AND !empty($iBooksCategory)) { $itemOutput .= ''.__("Genre",'appStoreAssistant').': '.$iBooksCategory.'
'; } if (appStore_setting('displayadvisoryrating') == "yes" AND !empty($contentAdvisoryRating)) { $itemOutput .= ''.$cavType.': '.$contentAdvisoryRating.'
'; } if (appStore_setting('displayitunesreleasedate') == "yes" AND !empty($releaseDate)) { $itemOutput .= ''.__("Published",'appStoreAssistant').': '.$releaseDate.'
'; } if (appStore_setting('displayibooksexplicitwarning') == "yes" AND $isExplicit == "explicit") { $itemOutput .= '
Explicit Lyrics
';// 450x268 } if (appStore_setting('displayibooksdescription') == "yes" AND !empty($description)) { $itemOutput .= '
'; $itemOutput .= nl2br($description); $itemOutput .= '
'; } $itemOutput .= '
'; $itemOutput .= '
'; $itemOutput .= appStore_getBadge ($itemStore); $itemOutput .= ''; $itemOutput .= '
'; $itemOutput .= '
 
'; $itemOutput .= '
'; break; case "AppStore": $itemInfo->TheAppPrice = appStore_format_price($itemInfo->price); $itemInfo->appURL = getAffiliateURL($itemInfo->trackViewUrl); if(appStore_setting('smaller_buy_button_iOS') == "yes" && wp_is_mobile()) { $itemInfo->buttonText = $itemInfo->TheAppPrice." "; } else { $itemInfo->buttonText = $itemInfo->TheAppPrice." - ".__("View in App Store",'appStoreAssistant')." "; } $itemInfo->more_info_text = $more_info_text; $itemInfo->platform = $platform; $itemInfo->mode = $mode; if(is_single()) $mode .= "_one"; //Get List of Elements and their order switch ($mode) { case "SingleApp_one": $appDetailsOrder = explode(",", appStore_setting('appDetailsOrder')); break; case "SingleApp": $appDetailsOrder = explode(",", appStore_setting('appMPDetailsOrder')); break; case "ListOfApps": $appDetailsOrder = explode(",", appStore_setting('appATOMDetailsOrder')); break; case "ListOfApps_one": $appDetailsOrder = explode(",", appStore_setting('appATOMDetailsOrder')); break; default: $appDetailsOrder = explode(",", appStore_setting('appDetailsOrder')); } $appDetailsOrder = array_filter($appDetailsOrder, 'strlen'); //Create listing for App $itemOutput = '
'; foreach($appDetailsOrder as $appDetailOrder) { $displayFunction = "displayAppStore".substr($appDetailOrder, 14); $itemOutput .= $displayFunction($itemInfo); } $itemOutput .= '

 
'; break; default: $itemOutput = "$itemOutput"; //$itemOutput .= "
".print_r($itemInfo,true)."
"; } return $itemOutput; } function displayAppStore_appName ($app,$elementOnly=false) { if(!empty($app->trackName)) { $trackName = $app->trackName; if($elementOnly) return $trackName; $PositionNumber = 0; if(isset($itemInfo->PositionNumber)) $PositionNumber = $itemInfo->PositionNumber; if ($app->mode == "ListOfApps" && appStore_setting('displayATOMappPositionNumber') == "yes" && $PositionNumber > 0) { $trackName = ""; if(appStore_setting('PrePositionNumber') != "EMP") $trackName .= appStore_setting('PrePositionNumber'); $trackName .= $app->PositionNumber; if(appStore_setting('PostPositionNumber') != "EMP") $trackName .= appStore_setting('PostPositionNumber'); $trackName .= $app->trackName; } switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayapptitle'); } else { $displayMode = appStore_setting('displaympapptitle'); } break; case "ListOfApps": $displayMode = 'HEADLINE'; break; } $element = getDisplayCode ($trackName,"appStore-title",$displayMode,"App Name"); return $element; } } function displayAppStore_appScreenshots($app,$elementOnly=false) { $appIDcode = $app->trackId; switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayscreenshots'); } else { $displayMode = appStore_setting('displaympscreenshots'); } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMscreenshots'); break; } $valid_Screenshots_iPad = false; $valid_Screenshots_iPhone = false; // Get iPhone Screenshots if(appStore_setting('cache_images_locally') == '1') { if (is_array($app->screenshotUrls_cached)){ if(count($app->screenshotUrls_cached) > 0) { $iPhoneScreenShots = $app->screenshotUrls_cached; $valid_Screenshots_iPhone = true; } } } else { if (is_array($app->screenshotUrls)){ if(count($app->screenshotUrls) > 0) { $iPhoneScreenShots = $app->screenshotUrls; $valid_Screenshots_iPhone = true; } } } if($valid_Screenshots_iPhone) { if($app->platform == "mac_app") $title_iPhone = __("Mac Screenshots",'appStoreAssistant'); if($app->platform == "ios_app") $title_iPhone = __("iPhone Screenshots",'appStoreAssistant'); // appStore-screenshots-iphone $elementLoop_iPhone = ' '; } // Get iPad Screenshots if(appStore_setting('cache_images_locally') == '1') { if (isset($app->ipadScreenshotUrls_cached)) { if (is_array($app->ipadScreenshotUrls_cached) AND count($app->ipadScreenshotUrls_cached) > 0) { $iPadScreenShots = $app->ipadScreenshotUrls_cached; $valid_Screenshots_iPad = true; } } } else { if (is_array($app->ipadScreenshotUrls)){ if(count($app->ipadScreenshotUrls) > 0) { $iPadScreenShots = $app->ipadScreenshotUrls; $valid_Screenshots_iPad = true; } } } if($valid_Screenshots_iPad) { $title_iPad = __("iPad Screenshots",'appStoreAssistant'); //appStore-screenshots-iPad $elementLoop_iPad = ' '; } if($valid_Screenshots_iPad || $valid_Screenshots_iPhone) { $element = ""; if ($elementOnly) { if($valid_Screenshots_iPhone) $element .= "

$title_iPhone

".$elementLoop_iPhone; if($valid_Screenshots_iPad) $element .= "

$title_iPad

".$elementLoop_iPad; return $element; } if($valid_Screenshots_iPhone) $element .= getDisplayCode ($elementLoop_iPhone, "appStore-screenshots-iphone", $displayMode,$title_iPhone); if($valid_Screenshots_iPad) $element .= getDisplayCode ($elementLoop_iPad, "appStore-screenshots-ipad", $displayMode,$title_iPad); return $element; } } function displayAppStore_appBadge($app,$elementOnly=false) { switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayappbadge'); } else { $displayMode = appStore_setting('displaympappbadge'); } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMappbadge'); break; } if($elementOnly) $displayMode = "INLINE_NOTITLE"; // Create URL $appLink = ''; $element = getDisplayCode ($element,"appStore-badge",$displayMode,"AppStore Badge"); return $element; } function displayAppStore_appBadgeSm($app,$elementOnly=false) { switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayappbadge'); } else { $displayMode = appStore_setting('displaympappbadge'); } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMappbadge'); break; } if($elementOnly) $displayMode = "INLINE_NOTITLE"; $appLink = ''; $element = $appLink.$badgeImgTag; $element = getDisplayCode ($element,"appStore-badge",$displayMode,"AppStore Badge"); return $element; } function getDisplayCode ($DisplayElement,$cssClass,$displayMode, $SectionTitle="Section") { $baseCSSClass = "accordion-$cssClass"; $displayCode = ""; switch ($displayMode) { case "HIDE": return "\r\r"; break; case "NORM_TITLE": $displayCode = "\r\r"; $displayCode .= '
 
'; $displayCode .= '
'; $displayCode .= '

'.$SectionTitle.':

'; $displayCode .= $DisplayElement; $displayCode .= '
'; break; case "HEADLINE": $displayCode = "\r\r"; $displayCode .= '

'; $displayCode .= $DisplayElement; $displayCode .= '

'; break; case "NORM_NOTITLE": $displayCode = "\r\r"; $displayCode .= '
 
'; $displayCode .= '
'; $displayCode .= $DisplayElement; $displayCode .= '
'; break; case "INLINE_TITLE": $displayCode = "\r\r"; $displayCode .= ''; $displayCode .= ''.$SectionTitle.': '; $displayCode .= $DisplayElement; $displayCode .= ''; break; case "INLINE_NOTITLE": $displayCode = "\r\r"; $displayCode .= ''; $displayCode .= $DisplayElement; $displayCode .= ''; break; case "CLOSED": $cssClass = $cssClass.'-'.rand(); $displayCode = "\r\r"; $displayCode .= "\r"; $displayCode .= '
 
'; $displayCode .= '
'; $displayCode .= '
'; $displayCode .= "

$SectionTitle

"; $displayCode .= '
'; $displayCode .= $DisplayElement; $displayCode .= '
'; break; case "OPEN": $cssClass = $cssClass.'-'.rand(); $displayCode = "\r\r"; $displayCode .= "\r"; $displayCode .= '
 
'; $displayCode .= '
'; $displayCode .= '
'; $displayCode .= "

$SectionTitle

"; $displayCode .= '
'; $displayCode .= $DisplayElement; $displayCode .= '
'; break; default: return "\r\r"; } $displayCode .= "\r\r"; return $displayCode; } function displayAppStore_appDescription($app,$elementOnly=false) { if(empty($app->description)) return ''; $smallDescription = appStore_shortenDescription($app->description); $fullDescription = nl2br($app->description); $element = ""; if($elementOnly) return getDisplayCode ($fullDescription,"appStore-description","INLINE_NOTITLE","Description"); switch (appStore_setting('shortDesc_link')) { case "text": $ReadMore_fullDesc = ' - '.appStore_setting('shortDesc_fullDesc_text').''; $ReadMore_screenshot = ' - '.appStore_setting('shortDesc_screenshot_text').''; break; case "button": $ReadMore_fullDesc = '
'; $ReadMore_fullDesc .= ''; $ReadMore_fullDesc .= appStore_setting('shortDesc_fullDesc_text').'
'; $ReadMore_screenshot = '
'; $ReadMore_screenshot .= ''; $ReadMore_screenshot .= appStore_setting('shortDesc_screenshot_text').'
'; break; case "hide": $ReadMore_fullDesc = ''; $ReadMore_screenshot = ''; break; } switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayappdescription'); if (appStore_setting('use_shortDesc_on_single') == "yes") { $element .= $smallDescription."…"; } else { $element .= $fullDescription; } } else { $displayMode = appStore_setting('displaympappdescription'); if (appStore_setting('use_shortDesc_on_multiple') == "yes") { $element .= $smallDescription; $element .= $ReadMore_fullDesc; } else { $element .= $fullDescription; $element .= $ReadMore_screenshot; } } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMappdescription'); if (appStore_setting('use_shortDesc_on_atomfeed') == "yes") { $element .= nl2br($smallDescription); } else { $element .= nl2br($app->description); } break; } $element = getDisplayCode ($element,"appStore-description",$displayMode,"Description"); return $element; } function displayAppStore_appReleaseNotes($app,$elementOnly=false) { if(empty($app->releaseNotes)) return ''; $releaseNotes = nl2br($app->releaseNotes); $element = ""; switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayappreleasenotes'); } else { $displayMode = appStore_setting('displaympappreleasenotes'); } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMappreleasenotes'); break; } if($elementOnly) $displayMode = "INLINE_NOTITLE"; $element = getDisplayCode ($releaseNotes,"appStore-releasenotes",$displayMode,__('Release Notes','appStoreAssistant')); return $element; } function displayAppStore_appBuyButton($app,$elementOnly=false) { switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayappbuybutton'); } else { $displayMode = appStore_setting('displaympappbuybutton'); } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMappbuybutton'); break; } if($elementOnly) $displayMode = "INLINE_NOTITLE"; $appLink = 'TheAppPrice; $appLink .= ' - '.__("View in App Store",'appStoreAssistant'); $appLink .= ''; $element = getDisplayCode ($appLink,"appStore-purchase-center",$displayMode,"AppStore Buy Button"); return $element; } function displayAppStore_appPrice($app,$elementOnly=false) { $element = $app->TheAppPrice; return $element; } function displayAppStore_appVersion($app,$elementOnly=false) { $element = $app->version; return $element; } function displayAppStore_appDeviceList($app,$elementOnly=false){ switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displaysupporteddevices'); } else { $displayMode = appStore_setting('displaympsupporteddevices'); } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMsupporteddevices'); break; } if($elementOnly) $displayMode = "INLINE_NOTITLE"; $displayType = appStore_setting('displaysupporteddevicesType'); // List all iDevices here $iDevices = array( "all" => array ("name" => "All iOS Devices", "icon" => "all", "releasedate" => "0"), "iPadWifi" => array ("name" => "iPad Wifi", "icon" => "iPadWifi", "releasedate" => "201001"), "iPad2Wifi" => array ("name" => "iPad 2 WiFi", "icon" => "iPad2Wifi", "releasedate" => "201103"), "iPad23G" => array ("name" => "iPad 2 3G", "icon" => "iPad23G", "releasedate" => "201103"), "iPadThirdGen" => array ("name" => "iPad 3", "icon" => "iPadThirdGen", "releasedate" => "201203"), "iPadThirdGen4G" => array ("name" => "iPad 3 4G", "icon" => "iPadThirdGen4G", "releasedate" => "201203"), "iPadFourthGen" => array ("name" => "iPad 4", "icon" => "iPadFourthGen", "releasedate" => "201210"), "iPadFourthGen4G" => array ("name" => "iPad 4 4G", "icon" => "iPadFourthGen4G", "releasedate" => "201210"), "iPadMini" => array ("name" => "iPad mini", "icon" => "iPadMini", "releasedate" => "201210"), "iPadMini4G" => array ("name" => "iPad mini 4G", "icon" => "iPadMini4G", "releasedate" => "201210"), "iPhone-3G" => array ("name" => "iPad 3G", "icon" => "iPhone-3G", "releasedate" => "200806"), "iPhone-3GS" => array ("name" => "iPad 3GS", "icon" => "iPhone-3GS", "releasedate" => "200906"), "iPhone4" => array ("name" => "iPhone 4", "icon" => "iPhone4", "releasedate" => "201006"), "iPhone4S" => array ("name" => "iPhone 4S", "icon" => "iPhone4S", "releasedate" => "201110"), "iPhone5" => array ("name" => "iPhone 5", "icon" => "iPhone5", "releasedate" => "201209"), "iPhone5s" => array ("name" => "iPhone 5s", "icon" => "iPhone5s", "releasedate" => "201309"), "iPhone5c" => array ("name" => "iPhone 5c", "icon" => "iPhone5c", "releasedate" => "201309"), "iPhone6" => array ("name" => "iPhone 6", "icon" => "iPhone6", "releasedate" => "201409"), "iPhone6Plus" => array ("name" => "iPhone 6 Plus", "icon" => "iPhone6Plus", "releasedate" => "201409"), "AppleWatch" => array ("name" => "Apple Watch", "icon" => "AppleWatch", "releasedate" => "201506"), "iPodTouchourthGen" => array ("name" => "iPod Touch 4th Gen", "icon" => "iPodTouchourthGen", "releasedate" => "201009"), "iPodTouchFifthGen" => array ("name" => "iPod Touch 5th Gen", "icon" => "iPodTouchFifthGen", "releasedate" => "201209") ); // print_r($iDevices); if(isset($app->supportedDevices)){ if (is_array($app->supportedDevices)) { $SupportedDevices = $app->supportedDevices; $allDevices = appStore_substr_in_array("all", $SupportedDevices); foreach ($SupportedDevices as $iDevice): if(in_array($iDevice,array_keys($iDevices))) { $iDeviceList[] = $iDevices[$iDevice]; } else { $iDeviceList[] = ["name" => "$iDevice", "icon" => "NewDevice", "releasedate" => "999999"]; } endforeach; } else { $displayMode = "HIDE"; } } switch (appStore_setting('displayappdetailsaslistssort')){ case 'releasedate' : appStore_array_sort_by_column($iDeviceList,'releasedate',SORT_ASC); break; case 'releasedate_reversed' : appStore_array_sort_by_column($iDeviceList,'releasedate',SORT_DESC); break; case 'alphabetically' : appStore_array_sort_by_column($iDeviceList,'name',SORT_ASC); break; case 'alphabetically_reversed' : appStore_array_sort_by_column($iDeviceList,'name',SORT_DESC); break; default: appStore_array_sort_by_column($iDeviceList,'name',SORT_ASC); } $SupportedDevicesElement = ""; switch ($displayType){ case 'List' : $SupportedDevicesElement = implode(", ", $iDeviceList['name']); $SupportedDevicesElement = implode(', ', array_map(function ($entry) { return $entry['name']; }, $iDeviceList)); break; case 'Minimal' : if (appStore_substr_in_array("iPad", $SupportedDevices) || $allDevices) { $SupportedDevicesElement .= '   iPad'; } if (appStore_substr_in_array("iPadMini", $SupportedDevices) || $allDevices) { $SupportedDevicesElement .= '   iPad mini'; } if (appStore_substr_in_array("iPodTouch", $SupportedDevices) || $allDevices) { $SupportedDevicesElement .= '   iPod'; } if (appStore_substr_in_array("iPhone", $SupportedDevices) || $allDevices) { $SupportedDevicesElement .= '   iPhone'; } if (appStore_substr_in_array("AppleWatch", $SupportedDevices) || $allDevices) { $SupportedDevicesElement .= '   AppleWatch'; } break; case 'Normal' : if (appStore_setting('displayappdetailsasliststyle') == "color") { $list_icon_folder = "iDevices"; $list_icon_height = "64"; } else { $list_icon_folder = "iDevicesBW"; $list_icon_height = "82"; } if(isset($iDeviceList)){ if(is_array($iDeviceList)){ foreach ($iDeviceList as $iDevice): $SupportedDevicesElement .= ''.$iDevice['name'].''; endforeach; } } break; } $element = //getDisplayCode($SupportedDevicesElement."
[".print_r($iDeviceList,true)."]-----[".print_r($tmp,true)."]
","appStore-supportedDevices",$displayMode,__('Supported Devices','appStoreAssistant')); //SEALDebug getDisplayCode($SupportedDevicesElement,"appStore-supportedDevices",$displayMode,__('Supported Devices','appStoreAssistant')); return $element; } function appStore_substr_in_array($needle,$haystack){ $found = ARRAY(); // cast to array $needle = (ARRAY) $needle; // map with preg_quote $needle = ARRAY_MAP('preg_quote', $needle); // loop over array to get the search pattern FOREACH ($needle AS $pattern) { IF (COUNT($found = PREG_GREP("/$pattern/", $haystack)) > 0) { RETURN $found; } } // if not found RETURN FALSE; } function displayAppStore_appDetails($app,$elementOnly=false) { $languageCodesISO2A = ["AB" => "Abkhazian", "AA" => "Afar", "AF" => "Afrikaans", "SQ" => "Albanian", "AM" => "Amharic", "AR" => "Arabic", "HY" => "Armenian", "AS" => "Assamese", "AY" => "Aymara", "AZ" => "Azerbaijani", "BA" => "Bashkir", "EU" => "Basque", "BN" => "Bengali", "DZ" => "Bhutani", "BH" => "Bihari", "BI" => "Bislama", "BR" => "Breton", "BG" => "Bulgarian", "MY" => "Burmese", "BE" => "Byelorussian", "KM" => "Cambodian", "CA" => "Catalan", "ZH" => "Chinese", "CO" => "Corsican", "HR" => "Croatian", "CS" => "Czech", "DA" => "Danish", "NL" => "Dutch", "EN" => "English", "EO" => "Esperanto", "ET" => "Estonian", "FO" => "Faeroese", "FJ" => "Fiji", "FI" => "Finnish", "FR" => "French", "FY" => "Frisian", "GD" => "Gaelic (Scots Gaelic)", "GL" => "Galician", "KA" => "Georgian", "DE" => "German", "EL" => "Greek", "KL" => "Greenlandic", "GN" => "Guarani", "GU" => "Gujarati", "HA" => "Hausa", "IW" => "Hebrew", "HI" => "Hindi", "HU" => "Hungarian", "IS" => "Icelandic", "IN" => "Indonesian", "IA" => "Interlingua", "IE" => "Interlingue", "IK" => "Inupiak", "GA" => "Irish", "IT" => "Italian", "JA" => "Japanese", "JW" => "Javanese", "KN" => "Kannada", "KS" => "Kashmiri", "KK" => "Kazakh", "RW" => "Kinyarwanda", "KY" => "Kirghiz", "RN" => "Kirundi", "KO" => "Korean", "KU" => "Kurdish", "LO" => "Laothian", "LA" => "Latin", "LV" => "Latvian, Lettish", "LN" => "Lingala", "LT" => "Lithuanian", "MK" => "Macedonian", "MG" => "Malagasy", "MS" => "Malay", "ML" => "Malayalam", "MT" => "Maltese", "MI" => "Maori", "MR" => "Marathi", "MO" => "Moldavian", "MN" => "Mongolian", "NA" => "Nauru", "NE" => "Nepali", "NO" => "Norwegian", "OC" => "Occitan", "OR" => "Oriya", "OM" => "Oromo, Afan", "PS" => "Pashto, Pushto", "FA" => "Persian", "PL" => "Polish", "PT" => "Portuguese", "PA" => "Punjabi", "QU" => "Quechua", "RM" => "Rhaeto-Romance", "RO" => "Romanian", "RU" => "Russian", "SM" => "Samoan", "SG" => "Sangro", "SA" => "Sanskrit", "SR" => "Serbian", "SH" => "Serbo-Croatian", "ST" => "Sesotho", "TN" => "Setswana", "SN" => "Shona", "SD" => "Sindhi", "SI" => "Singhalese", "SS" => "Siswati", "SK" => "Slovak", "SL" => "Slovenian", "SO" => "Somali", "ES" => "Spanish", "SU" => "Sudanese", "SW" => "Swahili", "SV" => "Swedish", "TL" => "Tagalog", "TG" => "Tajik", "TA" => "Tamil", "TT" => "Tatar", "TE" => "Tegulu", "TH" => "Thai", "BO" => "Tibetan", "TI" => "Tigrinya", "TO" => "Tonga", "TS" => "Tsonga", "TR" => "Turkish", "TK" => "Turkmen", "TW" => "Twi", "UK" => "Ukrainian", "UR" => "Urdu", "UZ" => "Uzbek", "VI" => "Vietnamese", "VO" => "Volapuk", "CY" => "Welsh", "WO" => "Wolof", "XH" => "Xhosa", "JI" => "Yiddish", "YO" => "Yoruba", "ZU" => "Zulu","NB" => "Norwegian Bokmål","ID" => "Indonesian","HE" => "Hebrew"]; switch ($app->mode) { case "SingleApp": if(is_single()) { if (appStore_setting('displayappdetailssection') == "HIDE") return getDisplayCode ("","appStore-appDetails","HIDE","AppStore Details Section"); $displayMode = appStore_setting('displayappdetailssection'); $detailsList['version']['mode'] = appStore_setting('displayversion'); $detailsList['developer']['mode'] = appStore_setting('displaydevelopername'); $detailsList['seller']['mode'] = appStore_setting('displaysellername'); $detailsList['date']['mode'] = appStore_setting('displayreleasedate'); $detailsList['size']['mode'] = appStore_setting('displayfilesize'); $detailsList['price']['mode'] = appStore_setting('displayprice'); $detailsList['minimumOsVersion']['mode'] = appStore_setting('displayminimumOsVersion'); $detailsList['universal']['mode'] = appStore_setting('displayuniversal'); $detailsList['languages']['mode'] = appStore_setting('displaylanguages'); $detailsList['rating']['mode'] = appStore_setting('displayadvisoryrating'); $detailsList['categories']['mode'] = appStore_setting('displaycategories'); } else { if (appStore_setting('displaympappdetailssection') == "HIDE") return getDisplayCode ("","appStore-appDetails","HIDE","AppStore Details Section"); $displayMode = appStore_setting('displaympappdetailssection'); $detailsList['version']['mode'] = appStore_setting('displaympversion'); $detailsList['developer']['mode'] = appStore_setting('displaympdevelopername'); $detailsList['seller']['mode'] = appStore_setting('displaympsellername'); $detailsList['date']['mode'] = appStore_setting('displaympreleasedate'); $detailsList['size']['mode'] = appStore_setting('displaympfilesize'); $detailsList['price']['mode'] = appStore_setting('displaympprice'); $detailsList['minimumOsVersion']['mode'] = appStore_setting('displaympminimumOsVersion'); $detailsList['universal']['mode'] = appStore_setting('displaympuniversal'); $detailsList['languages']['mode'] = appStore_setting('displaymplanguages'); $detailsList['rating']['mode'] = appStore_setting('displaympadvisoryrating'); $detailsList['categories']['mode'] = appStore_setting('displaympcategories'); } break; case "ListOfApps": if (appStore_setting('displayATOMappdetailssection') == "HIDE") return getDisplayCode ("","appStore-appDetails","HIDE","AppStore Details Section"); $displayMode = appStore_setting('displayATOMappdetailssection'); $detailsList['version']['mode'] = appStore_setting('displayATOMversion'); $detailsList['developer']['mode'] = appStore_setting('displayATOMdevelopername'); $detailsList['seller']['mode'] = appStore_setting('displayATOMsellername'); $detailsList['date']['mode'] = appStore_setting('displayATOMreleasedate'); $detailsList['size']['mode'] = appStore_setting('displayATOMfilesize'); $detailsList['price']['mode'] = appStore_setting('displayATOMprice'); $detailsList['minimumOsVersion']['mode'] = appStore_setting('displayATOMminimumOsVersion'); $detailsList['universal']['mode'] = appStore_setting('displayATOMuniversal'); $detailsList['languages']['mode'] = appStore_setting('displayATOMlanguages'); $detailsList['rating']['mode'] = appStore_setting('displayATOMadvisoryrating'); $detailsList['categories']['mode'] = appStore_setting('displayATOMcategories'); break; } $detailsList['version']['title'] = __("Version",'appStoreAssistant'); $detailsList['date']['title'] = __("Released on",'appStoreAssistant'); $detailsList['size']['title'] = __("File Size:",'appStoreAssistant'); $detailsList['price']['title'] = __("Price:",'appStoreAssistant'); $detailsList['rating']['title'] = __("Age Rating:",'appStoreAssistant'); $detailsList['seller']['title'] = __("Sold by",'appStoreAssistant'); $detailsList['developer']['title'] = __("Created by",'appStoreAssistant'); $detailsList['languages']['title'] = __("Languages:",'appStoreAssistant'); $detailsList['minimumOsVersion']['title'] = __("Minimum OS:",'appStoreAssistant'); $detailsList['universal']['title'] = __("Universal Icon",'appStoreAssistant'); if (!empty($app->version)) { $detailsList['version']['value'] = $app->version; } else { $detailsList['version']['mode'] = 'HIDE'; } if (!empty($app->TheAppPrice)) { $detailsList['price']['value'] = $app->TheAppPrice; } else { $detailsList['price']['mode'] = 'HIDE'; } if (!empty($app->minimumOsVersion)) { $detailsList['minimumOsVersion']['value'] = $app->minimumOsVersion; } else { $detailsList['minimumOsVersion']['mode'] = 'HIDE'; } if (($app->artistName == $app->sellerName) AND !empty($app->artistName)) { $detailsList['developer']['title'] = __("Created & Sold by",'appStoreAssistant'); $detailsList['developer']['value'] = $app->artistName; $detailsList['seller']['mode'] = 'HIDE'; } else { if (!empty($app->artistName)) { $detailsList['developer']['title'] = __("Created by",'appStoreAssistant'); $detailsList['developer']['value'] = $app->artistName; } else { $detailsList['developer']['mode'] = 'HIDE'; } if (!empty($app->sellerName)) { $detailsList['seller']['value'] = $app->sellerName; } else { $detailsList['seller']['mode'] = 'HIDE'; } } if (!empty($app->releaseDate)) { $detailsList['date']['value'] = date( 'F j, Y', strtotime($app->releaseDate) ); } else { $detailsList['date']['mode'] = 'HIDE'; } if (!empty($app->fileSizeBytes)) { $detailsList['size']['value'] = size_format($app->fileSizeBytes); } else { $detailsList['size']['mode'] = 'HIDE'; } if(isset($app->features)){ $appFeatures = (array) $app->features; if (in_array("iosUniversal", $appFeatures)) { $detailsList['universal']['value'] = 'universal '.__("This app is designed for both iPhone and iPad",'appStoreAssistant'); } else { $detailsList['universal']['mode'] = 'HIDE'; } } if (!empty($app->contentAdvisoryRating)) { $detailsList['rating']['value'] = $app->contentAdvisoryRating; if(is_array($app->advisories)) { $detailsList['rating']['value'] .= " for the following:"; } } else { $detailsList['rating']['mode'] = 'HIDE'; } if(is_array($app->languageCodesISO2A)) { foreach ($app->languageCodesISO2A as $languageCode): $languages[] = $languageCodesISO2A[$languageCode]; endforeach; sort($languages); $detailsList['languages']['value'] = implode(', ',$languages); } else { $detailsList['languages']['mode'] = 'HIDE'; } $elementCategories = ''; $appCategory = $app->genres; $appCategoryPrime = $app->primaryGenreName; if(is_array($appCategory)) $appCategoryList = implode(', ', $appCategory); $detailsList['categories']['title'] = sprintf( _n('Category', 'Categories:', count($appCategory), 'appStoreAssistant'), count($appCategory) ); if (!empty($appCategory)) { if(count($appCategory) == 1) { $detailsList['categories']['value'] = $appCategory[0]; } elseif (count($appCategory) == 2) { $detailsList['categories']['value'] = $appCategory[0]." & ".$appCategory[1]; } elseif (count($appCategory) > 1) { $detailsList['categories']['value'] = $appCategoryList; } } else { $detailsList['categories']['mode'] = 'HIDE'; } $element = ''; $element = getDisplayCode ($element,"appStore-appDetails",$displayMode,__('App Details','appStoreAssistant')); return $element; } function displayAppStore_appGCIcon($app,$elementOnly=false){ switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displaygamecenterenabled'); } else { $displayMode = appStore_setting('displaympgamecenterenabled'); } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMgamecenterenabled'); break; } if($elementOnly) $displayMode = "INLINE_NOTITLE"; $element = ''; if(isset($app->isGameCenterEnabled)){ if($app->isGameCenterEnabled == 1) { $element .= 'gamecenter'; } } $element = getDisplayCode ($element,"appStore-gamecenter",$displayMode,__('GameCenter Enabled','appStoreAssistant')); return $element; } function displayAppStore_appRating($app,$elementOnly=false) { $element = ''; switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displaystarrating'); } else { $displayMode = appStore_setting('displaympstarrating'); } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMstarrating'); break; } $averageRating = 0; if(isset($app->averageUserRating)) $averageRating = $app->averageUserRating; //App Rating if ($averageRating > 0 && $averageRating <=10) { $appRating = $averageRating * 20; }else { $appRating = false; } if(isset($app->userRatingCount)) $ratingCount = $app->userRatingCount; if (!$appRating) { $element = "Too few ratings for this version."; } else { if(isset($ratingCount)) { $element = ' '; $element .= ' '; $string = sprintf( __('by %d users', 'appStoreAssistant'), $ratingCount ); $element .= ' '.$string.""; } } $element = getDisplayCode($element,"appStore-rating",$displayMode,__('App Store Rating','appStoreAssistant')); return $element; } function displayAppStore_appIcon ($app,$elementOnly=false){ // App Artwork $element = ''; $imgtag_sizeaddon = ''; switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayappicon'); } else { $displayMode = appStore_setting('displaympappicon'); } if(appStore_setting('cache_images_locally') == '1') { $imageTag = $app->imagePosts_cached; } else { $imageTag = $app->imagePosts; $imgtag_sizeaddon = ' width="'.appStore_setting('appicon_size_posts_w').'" height="'.appStore_setting('appicon_size_posts_h').'"'; } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMappicon'); if(appStore_setting('cache_images_locally') == '1') { $imageTag = $app->imageLists_cached; } else { $imageTag = $app->imageLists; $imgtag_sizeaddon = ' width="'.appStore_setting('appicon_size_lists_w').'" height="'.appStore_setting('appicon_size_lists_h').'"'; } break; } if($elementOnly) { $displayMode = "INLINE_NOTITLE"; if(appStore_setting('cache_images_locally') == '1') { $imageTag = $app->imageElements_cached; } else { $imageTag = $app->imageElements; $imgtag_sizeaddon = ' width="'.appStore_setting('appicon_size_element_w').'" height="'.appStore_setting('appicon_size_element_w').'"'; } } if(appStore_setting('cache_images_locally') == '1') { if(wp_is_mobile()) $imageTag = $app->imageiOS_cached; } else { if(wp_is_mobile()) { $imageTag = $app->imageiOS; $imgtag_sizeaddon = ' width="'.appStore_setting('appicon_size_ios_w').'" height="'.appStore_setting('appicon_size_ios_h').'"'; } } $element .= ''; $element .= ''.$app->trackName.''; $element .= ''; $element = getDisplayCode ($element,"appStore-icon",$displayMode,"App Icon"); return $element; } function displayAppStore_appIconBuyButton ($app,$elementOnly=false){ // App Artwork switch ($app->mode) { case "SingleApp": if(is_single()) { $displayMode = appStore_setting('displayappiconbuybutton'); } else { $displayMode = appStore_setting('displaympappiconbuybutton'); } if(appStore_setting('cache_images_locally') == '1') { $imageTag = $app->imagePosts_cached; } else { $imageTag = $app->imagePosts; } break; case "ListOfApps": $displayMode = appStore_setting('displayATOMappiconbuybutton'); if(appStore_setting('cache_images_locally') == '1') { $imageTag = $app->imageLists_cached; } else { $imageTag = $app->imageLists; } break; } if($elementOnly) { $displayMode = "INLINE_NOTITLE"; if(appStore_setting('cache_images_locally') == '1') { $imageTag = $app->imageElements_cached; } else { $imageTag = $app->imageElements; } } if(appStore_setting('cache_images_locally') == '1') { if(wp_is_mobile()) $imageTag = $app->imageiOS_cached; } else { if(wp_is_mobile()) $imageTag = $app->imageiOS; } $element = '
'; $element .= ''; $element .= ''.$app->trackName.''; $element .= ''; $element .= '
'; $element .= ''.$app->TheAppPrice.''; $element .= '
'; $element .= '
 
'; $element = getDisplayCode ($element,"appStore-icon",$displayMode,"App Icon"); return $element; } function getAffiliateURL($itemURL){ switch (appStore_setting('affiliatepartnerid')) { case 2013: $PHGaffiliateID = appStore_setting('PHGaffiliateID'); $phgCampaignvalue = appStore_setting('phgCampaignvalue'); $phgCampaignvalue = substr($phgCampaignvalue,0,45); $AffiliateURL = $itemURL; if (strpos($itemURL, '?') !== false) { $AffiliateURL .= '&at='.$PHGaffiliateID; } else { $AffiliateURL .= '?at='.$PHGaffiliateID; } if (!empty($phgCampaignvalue)) $AffiliateURL .= '&ct='.urlencode($phgCampaignvalue); break; case 2003: $AffiliateURL = "http://clk.tradedoubler.com/click?p=".appStore_setting('tdprogramID')."&a=".appStore_setting('tdwebsiteID')."&url="; if (strpos($itemURL, '?') !== false) { $AffiliateURL .= urlencode($itemURL.'&partnerId=2003'); } else { $AffiliateURL .= urlencode($itemURL.'?partnerId=2003'); } break; default: $phgCampaignvalue = "v".preg_replace("/[^0-9]/",'',plugin_get_version())."_".$_SERVER['SERVER_NAME']; $phgCampaignvalue = preg_replace("/[^A-Za-z0-9_\.]/", '', $phgCampaignvalue); $phgCampaignvalue = substr($phgCampaignvalue,0,42); $AffiliateURL = $itemURL; if (strpos($itemURL, '?') !== false) { $AffiliateURL .= '&at=11l3KC&ct='.$phgCampaignvalue; } else { $AffiliateURL .= '?at=11l3KC&ct='.$phgCampaignvalue; } } return $AffiliateURL; } function appStore_get_data( $id ) { //Check to see if we have a cached version of the JSON. $appStore_options = get_option('appStore_appData_' . $id, ''); if($appStore_options == '' || $appStore_options['next_check'] < time()) { $appStore_options_data = appStore_page_get_json($id); if( isset($appStore_options_data->collectionType)) { if($appStore_options_data->collectionType == "Album") { $trackList_JSON = appStore_page_get_json_tracksList($appStore_options_data->collectionId); //echo '";//Debug $trackList = $trackList_JSON->results; foreach ($trackList as $track) { if ($track->wrapperType == "track") { $trackID = $track->trackNumber; $discNumber = $track->discNumber; $tracksList['discCount'] = $track->discCount; $tracksList['tracks'][$discNumber][$trackID]['name'] = $track->trackName; $tracksList['tracks'][$discNumber][$trackID]['number'] = $track->trackNumber; $tracksList['tracks'][$discNumber][$trackID]['name_censored'] = $track->trackCensoredName; $tracksList['tracks'][$discNumber][$trackID]['trackExplicitness'] = $track->trackExplicitness; $tracksList['tracks'][$discNumber][$trackID]['trackPrice'] = $track->trackPrice; $tracksList['tracks'][$discNumber][$trackID]['trackViewUrl'] = $track->trackViewUrl; $tracksList['tracks'][$discNumber][$trackID]['trackId'] = $track->trackId; $tracksList['tracks'][$discNumber][$trackID]['radioStationUrl'] = $track->radioStationUrl; if(isset($track->trackTimeMillis)){ if($track->trackTimeMillis > 3600000) { $tracksList['tracks'][$discNumber][$trackID]['trackTime'] = strftime('%H:%M:%S', $track->trackTimeMillis/1000); } else { $tracksList['tracks'][$discNumber][$trackID]['trackTime'] = strftime('%M:%S', $track->trackTimeMillis/1000); } } } } //echo '";//Debug $appStore_options_data->trackListing = $tracksList; } } //echo '-----DEBUG1----------'.print_r($appStore_options_data,true).'---------------';//Debug if(!is_array($appStore_options_data) && !is_object($appStore_options_data)) return false; $appStore_options_data = appStore_process_imagedata($appStore_options_data); $appStore_options = array('next_check' => time() + appStore_setting('cache_time_select_box'), 'app_data' => $appStore_options_data); update_option('appStore_appData_' . $id, $appStore_options); } return $appStore_options['app_data']; } function appStore_cache_seconds($seconds) { return appStore_setting('cache_time_select_box'); } function appStore_getIDs_from_feed($atomurl) { /* add_filter( 'wp_feed_cache_transient_lifetime' , 'appStore_cache_seconds' ); $rss = fetch_feed($atomurl); remove_filter( 'wp_feed_cache_transient_lifetime' , 'appStore_cache_seconds' ); if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly // Figure out how many total items there are, but limit it to appStore_setting('qty_of_apps'). $maxitems = $rss->get_item_quantity( appStore_setting('qty_of_apps') ); // Build an array of all the items, starting with element 0 (first element). $rss_items = $rss->get_items( 0, $maxitems ); endif; */ require_once ( ABSPATH . WPINC . '/class-feed.php' ); $feed = new SimplePie(); $feed->set_feed_url($atomurl); $feed->set_cache_duration(appStore_setting('cache_time_select_box')); $feed->set_cache_location(CACHE_DIRECTORY."/"); $feed->get_item_quantity( appStore_setting('qty_of_apps') ); $feed->enable_order_by_date(false); $feed->init(); $feed->handle_content_type(); $max = $feed->get_item_quantity(); for ($x = 0; $x < $max; $x++): $item = $feed->get_item($x); $idLine = $item->get_id(); $appID = ""; if(preg_match("/id([0-9]{6,})\\?i=([0-9]{6,})/u", $idLine)) { preg_match("/\\?i=([0-9]{6,})/u", $idLine,$appID); } else { preg_match("/id([0-9]{6,})/u", $idLine,$appID); } $appIDs[] = $appID[1]; endfor; return $appIDs; } function appStore_page_get_json($id) { if(function_exists('file_get_contents') && ini_get('allow_url_fopen')) $json_data = appStore_page_get_json_via_fopen($id); else if(function_exists('curl_exec')) $json_data = appStore_page_get_json_via_curl($id); else wp_die('

You must have either file_get_contents() or curl_exec() enabled on your web server. Please contact your hosting provider.

'); if($json_data->resultCount == 0) { return null; //wp_die('

Apple returned no app with that app ID.
Please check your app ID.

'); } return $json_data->results[0]; } function appStore_page_get_json_tracksList($id) { if(function_exists('file_get_contents') && ini_get('allow_url_fopen')) $json_data = appStore_page_get_json_via_fopen($id."&entity=song"); else if(function_exists('curl_exec')) $json_data = appStore_page_get_json_via_curl($id."&entity=song"); else wp_die('

You must have either file_get_contents() or curl_exec() enabled on your web server. Please contact your hosting provider.

'); if($json_data->resultCount == 0) { return null; //wp_die('

Apple returned no app with that app ID.
Please check your app ID.

'); } return $json_data; } function appStore_page_get_json_via_fopen($id) { return json_decode(appStore_fopenme(ASA_APPSTORE_URL . $id)); } function appStore_page_get_json_via_curl($id) { return json_decode(appStore_curlme(ASA_APPSTORE_URL . $id)); } function appStore_fopenme ($url) { return @file_get_contents($url); } function appStore_curlme ($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); curl_close($ch); return $output; } function appStore_fopen_or_curl($url) { if(function_exists('file_get_contents') && ini_get('allow_url_fopen')) return appStore_fopenme($url); else if(function_exists('curl_exec')) return appStore_curlme($url); else wp_die('

You must have either file_get_contents() or curl_exec() enabled on your web server. Please contact your hosting provider.

'); } function appStore_getBestIcon($appID) { $filename = false; $topChoice = CACHE_DIRECTORY."AppStore/".$appID."/artworkOriginal_600.png"; $premiumChoice = CACHE_DIRECTORY."AppStore/".$appID."/artworkOriginal_600.jpg"; $firstChoice = CACHE_DIRECTORY."AppStore/".$appID."/artworkOriginal_512.png"; $secondChoice = CACHE_DIRECTORY."AppStore/".$appID."/artworkOriginal_512.jpg"; $thirdChoice = CACHE_DIRECTORY."AppStore/".$appID."/artworkOriginal_100.png"; $fourthChoice = CACHE_DIRECTORY."AppStore/".$appID."/artworkOriginal_100.jpg"; $fifthChoice = CACHE_DIRECTORY."AppStore/".$appID."/artworkOriginal_60.png"; $sixthChoice = CACHE_DIRECTORY."AppStore/".$appID."/artworkOriginal_60.jpg"; $lastChoice = dirname( plugin_basename( __FILE__ ) )."/images/CautionIcon.png"; if (file_exists($topChoice)) { $filename = $topChoice; } elseif (file_exists($premiumChoice)) { $filename = $premiumChoice; } elseif(file_exists($firstChoice)) { $filename = $firstChoice; } elseif(file_exists($secondChoice)) { $filename = $secondChoice; } elseif(file_exists($thirdChoice)) { $filename = $thirdChoice; } elseif(file_exists($fourthChoice)) { $filename = $fourthChoice; } elseif(file_exists($fifthChoice)) { $filename = $fifthChoice; } elseif(file_exists($sixthChoice)) { $filename = $sixthChoice; } elseif(file_exists($lastChoice)) { $filename = $lastChoice; } return $filename; } function appStore_process_imagedata($app) { if(isset($app->trackId)) $appID = $app->trackId; if (isset($app->wrapperType)) { if($app->wrapperType == "audiobook") $appID = $app->collectionId; if($app->wrapperType == "collection") $appID = $app->collectionId; } //Get 600x600 artwork for Albums (Hack discovered by Aslan Guseinov) $get600 = false; if (isset($app->collectionType)) if ($app->collectionType == 'Album' || $app->collectionType == 'TV Season') $get600 = true; if (isset($app->kind)) if ($app->kind == "feature-movie" || $app->kind == "ebook") $get600 = true; if (isset($app->wrapperType)) if ($app->wrapperType == "audiobook") $get600 = true; if(isset($app->artworkUrl100) && $get600) { $app->artworkUrl600 = str_replace("100x100", "600x600", $app->artworkUrl100); } //Save Non-Cached Images incase of problem if(isset($app->screenshotUrls)) $app->screenshotUrls_cached = $app->screenshotUrls; if(isset($app->ipadScreenshotUrls)) $app->ipadScreenshotUrls_cached = $app->ipadScreenshotUrls; //$bestImage = plugins_url( 'images/CautionIcon.png' , ASA_MAIN_FILE ); // Debug if(isset($app->artworkUrl30)) { $app->artworkOriginal_30_cached = $app->artworkUrl30; $bestImage = $app->artworkUrl30; } if(isset($app->artworkUrl60)) { $app->artworkOriginal_60_cached = $app->artworkUrl60; $bestImage = $app->artworkUrl60; } if(isset($app->artworkUrl100)) { $app->artworkOriginal_100_cached = $app->artworkUrl100; $bestImage = $app->artworkUrl100; } if(isset($app->artworkUrl512)) { $app->artworkOriginal_512_cached = $app->artworkUrl512; $bestImage = $app->artworkUrl512; } if(isset($app->artworkUrl600)) { $app->artworkOriginal_600_cached = $app->artworkUrl600; $bestImage = $app->artworkUrl600; } $app->imageFeatured = $bestImage; $app->imageFeatured_cached = $bestImage; $app->imageiOS = $bestImage; $app->imageiOS_cached = $bestImage; $app->imageWidget = $bestImage; $app->imageWidget_cached = $bestImage; $app->imageRSS = $bestImage; $app->imageRSS_cached = $bestImage; $app->imageLists = $bestImage; $app->imageLists_cached = $bestImage; $app->imagePosts = $bestImage; $app->imagePosts_cached = $bestImage; $app->imageElements = $bestImage; $app->imageElements_cached = $bestImage; if(!is_writeable(CACHE_DIRECTORY)) { //Uploads dir isn't writeable. bummer. appStore_set_setting('cache_images_locally', '0'); return; } elseif(appStore_setting('cache_images_locally') == '1') { //Loop through screenshots and the app icons and cache everything if(!is_dir(CACHE_DIRECTORY."AppStore/" . $appID)) { if(!mkdir(CACHE_DIRECTORY."AppStore/" . $appID, 0755, true)) { appStore_set_setting('cache_images_locally', '0'); return; } } $urls_to_cache = array(); if(isset($app->artworkUrl30)) $urls_to_cache['artworkOriginal_30'] = $app->artworkUrl30; if(isset($app->artworkUrl60)) $urls_to_cache['artworkOriginal_60'] = $app->artworkUrl60; if(isset($app->artworkUrl100)) $urls_to_cache['artworkOriginal_100'] = $app->artworkUrl100; if(isset($app->artworkUrl512)) $urls_to_cache['artworkOriginal_512'] = $app->artworkUrl512; if(isset($app->artworkUrl600)) $urls_to_cache['artworkOriginal_600'] = $app->artworkUrl600; // Cache the original images with new name foreach($urls_to_cache as $urlname=>$url) { $content = appStore_fopen_or_curl($url); $info = pathinfo(basename($url)); $Newpath = CACHE_DIRECTORY ."AppStore/". $appID . '/' . $urlname.".".$info['extension']; $Newurl = CACHE_DIRECTORY_URL ."AppStore/". $appID . '/' . $urlname.".".$info['extension']; //$Newurl = "AppStore/". $appID . '/' . $urlname.".".$info['extension']; if($fp = fopen($Newpath, "w+")) { fwrite($fp, $content); fclose($fp); $settingName = $urlname."_cached"; $app->$settingName = $Newurl; //$urlExtensionName = $urlname."_ext"; //$app->$urlExtensionName = $info['extension']; } else { //Couldnt write the file. Permissions must be wrong. appStore_set_setting('cache_images_locally', '0'); return; } } //Choose best image and create additional sizes $bestFilePath = appStore_getBestIcon($appID); $bestFilePathParts = pathinfo($bestFilePath); $bestFileName = $bestFilePathParts['filename']; $bestFileExt = $bestFilePathParts['extension']; $editor = wp_get_image_editor( $bestFilePath ); $size = $editor->get_size(); $filePrefix = "asaArtwork_"; $filePath_Start = CACHE_DIRECTORY."AppStore/". $appID . '/'.$filePrefix; $fileURL_Start = CACHE_DIRECTORY_URL."AppStore/". $appID . '/'.$filePrefix; if(appStore_setting('appicon_size_featured_w') < $size['width'] || appStore_setting('appicon_size_featured_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_featured_w'); $newSize_h = appStore_setting('appicon_size_featured_h'); $newSize_c = (appStore_setting('appicon_size_featured_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); } $filename = $filePath_Start."featured.".$bestFileExt; $new_image_info = $editor->save($filename); $app->imageFeatured_cached = $fileURL_Start."featured.".$bestFileExt; $app->imageFeatured_path = $filePath_Start."featured.".$bestFileExt; $editor = wp_get_image_editor( $bestFilePath ); if(appStore_setting('appicon_size_ios_w') < $size['width'] || appStore_setting('appicon_size_ios_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_ios_w'); $newSize_h = appStore_setting('appicon_size_ios_h'); $newSize_c = (appStore_setting('appicon_size_ios_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); $filename = $filePath_Start."ios.".$bestFileExt; $new_image_info = $editor->save($filename); } $filename = $filePath_Start."ios.".$bestFileExt; $new_image_info = $editor->save($filename); $app->imageiOS_cached = $fileURL_Start."ios.".$bestFileExt; $editor = wp_get_image_editor( $bestFilePath ); if(appStore_setting('appicon_size_widget_w') < $size['width'] || appStore_setting('appicon_size_widget_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_widget_w'); $newSize_h = appStore_setting('appicon_size_widget_h'); $newSize_c = (appStore_setting('appicon_size_widget_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); $filename = $filePath_Start."widget.".$bestFileExt; $new_image_info = $editor->save($filename); } $filename = $filePath_Start."widget.".$bestFileExt; $new_image_info = $editor->save($filename); $app->imageWidget_cached = $fileURL_Start."widget.".$bestFileExt; $editor = wp_get_image_editor( $bestFilePath ); if(appStore_setting('appicon_size_rss_w') < $size['width'] || appStore_setting('appicon_size_rss_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_rss_w'); $newSize_h = appStore_setting('appicon_size_rss_h'); $newSize_c = (appStore_setting('appicon_size_rss_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); } $filename = $filePath_Start."rss.".$bestFileExt; $new_image_info = $editor->save($filename); $app->imageRSS_cached = $fileURL_Start."rss.".$bestFileExt; $editor = wp_get_image_editor( $bestFilePath ); if(appStore_setting('appicon_size_lists_w') < $size['width'] || appStore_setting('appicon_size_lists_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_lists_w'); $newSize_h = appStore_setting('appicon_size_lists_h'); $newSize_c = (appStore_setting('appicon_size_lists_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); } $filename = $filePath_Start."list.".$bestFileExt; $new_image_info = $editor->save($filename); $app->imageLists_cached = $fileURL_Start."list.".$bestFileExt; $editor = wp_get_image_editor( $bestFilePath ); if(appStore_setting('appicon_size_posts_w') < $size['width'] || appStore_setting('appicon_size_posts_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_posts_w'); $newSize_h = appStore_setting('appicon_size_posts_h'); $newSize_c = (appStore_setting('appicon_size_posts_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); } $filename = $filePath_Start."post.".$bestFileExt; $new_image_info = $editor->save($filename); $app->imagePosts_cached = $fileURL_Start."post.".$bestFileExt; $editor = wp_get_image_editor( $bestFilePath ); if(appStore_setting('appicon_size_element_w') < $size['width'] || appStore_setting('appicon_size_element_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_element_w'); $newSize_h = appStore_setting('appicon_size_element_h'); $newSize_c = (appStore_setting('appicon_size_element_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); } $filename = $filePath_Start."element.".$bestFileExt; $new_image_info = $editor->save($filename); $app->imageElements_cached = $fileURL_Start."element.".$bestFileExt; if(isset($app->screenshotUrls)) { $screenshotUrls = ""; foreach($app->screenshotUrls as $ssid=>$ssurl) { $content = appStore_fopen_or_curl($ssurl); $info = pathinfo(basename($ssurl)); $Newname = "ios_ss_".$ssid.".".$info['extension']; $Newpath = CACHE_DIRECTORY ."AppStore/". $appID . '/' . $Newname; $Newurl = CACHE_DIRECTORY_URL ."AppStore/". $appID . '/' . $Newname; $currentExtension = $info['extension']; //$Newurl = "AppStore/". $appID . '/' . $Newname; if($fp = fopen($Newpath, "w+")) { fwrite($fp, $content); fclose($fp); } else { //Couldnt write the file. Permissions must be wrong. appStore_set_setting('cache_images_locally', '0'); return; } $editor = wp_get_image_editor( $Newpath ); if(appStore_setting('appicon_size_iphoness_w') < $size['width'] || appStore_setting('appicon_size_iphoness_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_iphoness_w'); $newSize_h = appStore_setting('appicon_size_iphoness_h'); $newSize_c = (appStore_setting('appicon_size_iphoness_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); } $filename = $filePath_Start."ios_ss_".$ssid.".".$currentExtension; $new_image_info = $editor->save($filename); if($currentExtension == "jpg" || $currentExtension == "png" || $currentExtension == "jpeg") $screenshotUrls[] = $fileURL_Start."ios_ss_".$ssid.".".$currentExtension; } $app->screenshotUrls_cached = $screenshotUrls; } if(isset($app->ipadScreenshotUrls)) { $iPadScreenshotUrls = ""; foreach($app->ipadScreenshotUrls as $ssid=>$ssurl) { $content = appStore_fopen_or_curl($ssurl); $info = pathinfo(basename($ssurl)); $Newname = "ipad_ss_".$ssid.".".$info['extension']; $Newpath = CACHE_DIRECTORY ."AppStore/". $appID . '/' . $Newname; $Newurl = CACHE_DIRECTORY_URL ."AppStore/". $appID . '/' . $Newname; $currentExtension = $info['extension']; if($fp = fopen($Newpath, "w+")) { fwrite($fp, $content); fclose($fp); } else { //Couldnt write the file. Permissions must be wrong. appStore_set_setting('cache_images_locally', '0'); return; } $editor = wp_get_image_editor( $Newpath ); if(appStore_setting('appicon_size_ipadss_w') < $size['width'] || appStore_setting('appicon_size_ipadss_h') < $size['height']) { $newSize_w = appStore_setting('appicon_size_ipadss_w'); $newSize_h = appStore_setting('appicon_size_ipadss_h'); $newSize_c = (appStore_setting('appicon_size_ipadss_c') ? true : false); $editor->resize( $newSize_w, $newSize_h, $newSize_c ); } $filename = $filePath_Start."ipad_ss_".$ssid.".".$currentExtension; $new_image_info = $editor->save($filename); if($currentExtension == "jpg" || $currentExtension == "png" || $currentExtension == "jpeg") $iPadScreenshotUrls[] = $fileURL_Start."ipad_ss_".$ssid.".".$currentExtension; } $app->ipadScreenshotUrls_cached = $iPadScreenshotUrls; } } $app->appID = $appID; return $app; } $appStore_settings = array(); function appStore_setting($name) { global $appStore_settings; $appStore_settings = get_option('appStore_options'); if(!$appStore_settings) { appStore_add_defaults(); $appStore_settings = get_option('appStore_options'); } return $appStore_settings[$name]; } function appStore_set_setting($name, $value) { global $appStore_settings; $appStore_settings = get_option('appStore_options'); if(!$appStore_settings) { appStore_add_defaults(); $appStore_settings = get_option('appStore_options'); } $appStore_settings[$name] = $value; } function appStore_shortenDescription($description,$mode="normal"){ if($mode == "rss") { $maxLength = appStore_setting('max_description_rss'); } else { $maxLength = appStore_setting('max_description'); } $shortenedDescription = nl2br(wp_trim_words($description,$maxLength,"…")); return $shortenedDescription; } function appStore_array_sort_by_column(&$arr, $col, $dir = SORT_ASC) { $sort_col = array(); foreach ($arr as $key=> $row) { $sort_col[$key] = $row[$col]; } array_multisort($sort_col, $dir, $arr); } function wpb_find_shortcode($atts, $content=null) { ob_start(); extract( shortcode_atts( array( 'find' => '', ), $atts ) ); $string = $atts['find']; $args = array( 's' => $string, ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) { echo '