WordPress.org

Ready to get started?Download WordPress

Forums

App Store Assistant
[resolved] Added Affiliate standalone link functionality (2 posts)

  1. pwlk
    Member
    Posted 1 year ago #

    Wanted to share an addition I made to the plugin. Wanted to be able to reference the Affiliate link anywhere in a post.

    Using shortcode: [ios_app_affiliate id="12345678" text="App A"]
    Leaving text blank or out will default to app name.

    This is my post and it is about App A which I love so much

    Here's the updates

    <!-- appStore-main.php -->
    add_shortcode('ios_app_affiliate', 'appAffiliate_handler');
    
    function appAffiliate_handler( $atts,$content=null, $code="") {
    	// Get App 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
    	$app = appStore_get_data($id);
    	if($app) {
    		$appURL = getAffiliateURL($app->trackViewUrl);
    		if ($text == '') $text = $app->trackName;
    		$appURL = '<a href="'.$appURL.'">'.$text.'</a>';
    		return $appURL;
    	} else {
    		echo "";
    		//wp_die('No valid data for app id: ' . $id);
    	}
    }

    http://wordpress.org/extend/plugins/app-store-assistant/

  2. sealsystems
    Member
    Plugin Author

    Posted 1 year ago #

    Thanks, great idea. I have added it as two new shortcodes to version 4.6.

    [ios_app_link id="446277240" text="App Name"]
    [mac_app_link id="411372497" text="App Name"]

    I broke it up into two short codes incase Apple ever separates the handling of Mac Apps and iOS apps.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic