Created
April 9, 2012 21:53
-
-
Save anderly/2346802 to your computer and use it in GitHub Desktop.
Changed set_cookie() function to use new cookie_expiration option.
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 this section after the single entry table row (Line 70) --> | |
<tr id="cookie_expiration"> | |
<td style="padding-left:75px;" valign="top"><label><?php _e('Cookie Expiration', 'formidable') ?></label></td> | |
<td> | |
<input type="radio" name="options[cookie_expiration]" value="midnight" id="cookie_expiration_midnight" <?php checked($values['cookie_expiration'], 'midnight') ?>/> <label for="cookie_expiration_midnight"><?php _e('Midnight', 'formidable') ?></label><br/> | |
<input type="radio" name="options[cookie_expiration]" value="one-day-from-now" id="cookie_expiration_one_day" <?php checked($values['cookie_expiration'], 'one-day-from-now') ?>/> <label for="cookie_expiration_one_day"><?php _e('One day from now', 'formidable') ?></label><br/> | |
<input type="radio" name="options[cookie_expiration]" value="one-week-from-now" id="cookie_expiration_one_week" <?php checked($values['cookie_expiration'], 'one-week-from-now') ?>/> <label for="cookie_expiration_one_week"><?php _e('One week from now', 'formidable') ?></label><br/> | |
</td> | |
</tr> | |
<!-- Add this to the script block at the bottom of the page --> | |
jQuery(document).ready(function() { | |
jQuery('#single_entry_type').change(function() { | |
if (jQuery('#single_entry_type option:selected').val() == "cookie") { | |
jQuery('tr#cookie_expiration').css('display','block'); | |
} else { | |
jQuery('tr#cookie_expiration').css('display','none'); | |
} | |
}); | |
}); |
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
/* AJAX */ | |
function set_cookie($entry_id, $form_id){ | |
global $frm_form; | |
$form = $frm_form->getOne($form_id); | |
$form->options = stripslashes_deep(maybe_unserialize($form->options)); | |
$expires = time() + 30000000; | |
if ( $form->options['cookie_expiration'] == 'midnight' ) { | |
$expires = mktime( 23, 59, 59, date( 'm' ), date( 'd' ), date( 'y' ) ); | |
} elseif ( $form->options['cookie_expiration'] == 'one-day-from-now' ) { | |
$expires = time() + 60 * 60 * 24 * 1; | |
} elseif ( $form->options['cookie_expiration'] == 'one-week-from-now' ) { | |
$expires = time() + 60 * 60 * 24 * 7; | |
} | |
//setcookie('frm_form'.$form_id.'_' . COOKIEHASH, current_time('mysql', 1), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN); | |
setcookie('frm_form'.$form_id.'_' . COOKIEHASH, current_time('mysql', 1), $expires, COOKIEPATH, COOKIE_DOMAIN); | |
die(); | |
} |
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
// Added 'cookie_expiration' into the list of default options | |
function get_default_opts(){ | |
global $frmpro_settings; | |
return array( | |
'edit_value' => $frmpro_settings->update_value, 'edit_msg' => $frmpro_settings->edit_msg, | |
'logged_in' => 0, 'logged_in_role' => '', 'editable' => 0, | |
'editable_role' => '', 'open_editable' => 0, 'open_editable_role' => '', | |
'copy' => 0, 'single_entry' => 0, 'single_entry_type' => 'user', 'cookie_expiration' => '', | |
'success_page_id' => '', 'success_url' => '', 'ajax_submit' => 0, | |
'create_post' => 0, | |
'post_type' => 'post', 'post_category' => array(), 'post_content' => '', | |
'post_excerpt' => '', 'post_title' => '', 'post_name' => '', 'post_date' => '', | |
'post_status' => '', 'post_custom_fields' => array(), 'post_password' => '', | |
'plain_text' => 0, 'also_email_to' => array(), 'update_email' => 0, | |
'email_subject' => '', 'email_message' => '[default-message]', | |
'inc_user_info' => 1, 'auto_responder' => 0, 'ar_plain_text' => 0, | |
'ar_email_to' => '', 'ar_reply_to' => get_option('admin_email'), | |
'ar_reply_to_name' => get_option('blogname'), 'ar_email_subject' => '', | |
'ar_email_message' => '', 'ar_update_email' => 0, | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment