Skip to content

Instantly share code, notes, and snippets.

@lucasstark
Created February 2, 2013 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucasstark/4698439 to your computer and use it in GitHub Desktop.
Save lucasstark/4698439 to your computer and use it in GitHub Desktop.
sample trial download shortcode
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