Skip to content

Instantly share code, notes, and snippets.

View codename065's full-sized avatar
🐢

Shahnur Alam codename065

🐢
View GitHub Profile
@codename065
codename065 / tempStorage.js
Created February 3, 2018 10:18
JavaScript local storage handler with expiration time
var tempStorage = {
get: function (name) {
var now = Math.floor(Date.now() / 1000);
var _lsd = localStorage.getItem(name);
if(_lsd == null) return null;
var obj = JSON.parse(_lsd);
if(obj.expire >= now){
return obj.data;
} else {
localStorage.removeItem(name);
$email_template = file_get_contents(LF_BASE_DIR.'emails/generic-email.html');
$vars = array('[mail_headline]', '[banner_image_url]','[email_message]','[button_link]', '[button_text]');
$vals = array('We Received Your Query!', 'https://www.evernote.com/l/AV3XAO0XEA9GZrYqCTRLH_IKrrz_HLOmmxwB/image.jpg', $user_email_data['message'],'http://liveforms.org/query-status/', 'Check Query Status');
$email_message = str_replace($vars, $vals, $email_template);
wp_mail($email, $user_email_data['subject'], $email_message, $headers);