OS specific download link - How to??? (4 posts)

  1. mr2essions
    Posted 3 years ago #

    Hi, could anyone help. I have a remote support link on my site for clients to download an APP to allow them to use remote access with me.

    Is there a way (i see it on larger company sites)

    That i could have a .EXE file for windows users and a .DMG for my mac clients but just have one link, the user clicks this then the site determines the OS and gives them the correct one?

    Thank you


  2. esmi
    Forum Moderator
    Posted 3 years ago #

    What does this have to do with WordPress?

  3. mr2essions
    Posted 3 years ago #

    Well i want to use this feature on my wordpress site...

  4. This is pretty simple to do. First you need to write a function to detect the OS that the visitor is using:

    function pw_get_browser_os() {
    	// A little Browser detection shall we?
    	$browser = $_SERVER[ 'HTTP_USER_AGENT' ];
    	// Mac, PC ...or Linux
    	if ( preg_match( "/Mac/", $browser ) ){
    		$os = 'mac';
    	} elseif ( preg_match( "/Windows/", $browser ) ){
    		$os = 'windows';
    	} elseif ( preg_match( "/Linux/", $browser ) ) {
    		$os = 'linux';
    	} else {
    		$os = 'unknown-os';
    	return apply_filters( 'pw_get_browser_os', $os );

    Now you can use that function in your template file when outputting the download link:

    $os = pw_get_browser_os();
    if( $os ) == 'mac' ) {
    	// output the OS X download link
    } else if( $os == 'windows' ) {
    	// output the Windows link
    } else if( $os == 'linux' ) {
    	// output the Linux download link
    } else {
    	// not a known OS, so perhaps hide the link

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.