Created
February 2, 2013 17:31
-
-
Save lucasstark/4698439 to your computer and use it in GitHub Desktop.
sample trial download shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_shortcode('trial_contents', 'do_trial_contents'); | |
function do_trial_contents($atts='') { | |
$content = ''; | |
if (trial_check_cookie()) { | |
$content = trial_get_the_download_link(); | |
} else { | |
if (!empty($_POST) && isset($_POST['action']) && $_POST['action'] == 'trial-signup'){ | |
//Do the mail chimp submission stuff here. | |
//Record the submission in WordPress somehwere. Maybe a custom post type to keep the Admin UI simple. | |
$content = trial_get_the_download_link(); | |
} | |
else { | |
$content = trial_get_signup_form(); | |
} | |
} | |
return $content; | |
} | |
function trial_check_cookie() { | |
return isset($_COOKIE['trialcheck']); | |
} | |
function trial_get_signup_form() { | |
return '<form><input type="hidden" name="action" value="trial-signup" /><input type="submit" value="Signup" /></form>'; | |
} | |
function trial_get_the_download_link() { | |
return '<a href="#">Download</a>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment