Created
June 19, 2013 15:53
-
-
Save anonymous/5815431 to your computer and use it in GitHub Desktop.
Zwin Theme panel.php and settings.php code
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
<?php if(!defined('IS_RBISTA_PANEL')) die();?> | |
<div class="wrap"> | |
<h1>Zwin VCard <?php _e('Options', $shortname); ?></h1> | |
<?php if($settings['update']['needUpdate']) : ?> | |
<div class="panel" style="margin:0; padding:0; margin-right:0;"> | |
<div class="message warning"><span><b><?php _e('Update', $shortname); ?> v<?php echo $settings['update']['currentVersion'] ?> : </b><?php _e('There is a new version available.', $shortname); ?><a href="#" id="installUpdate"><?php _e('Install Update', $shortname); ?></a></span></div> | |
</div> | |
<div id="instructions"> | |
<?php echo $settings['update']['instructions']; ?> | |
<ul class="update-console"></ul> | |
<button type="button" id="uploadZip" style="" class="red"><span>LOAD ZIP FILE</span></button> | |
<a href="#" class="ajax-loader update-load"></a> | |
<div class="clear"></div> | |
</div> | |
<?php endif; ?> | |
<div class="rbista-tabs"> | |
<div id="navbar"> | |
<ul> | |
<li><a href="#profile" title="<?php _e('Profile', $shortname); ?>"><?php _e('Profile', $shortname); ?></a></li> | |
<li><a href="#tabs-2" title="<?php _e('Skills', $shortname); ?>"><?php _e('Skills', $shortname); ?></a></li> | |
<li><a href="#tabs-3" title="<?php _e('Resume', $shortname); ?>"><?php _e('Resume', $shortname); ?></a></li> | |
<li><a href="#configs" title="<?php _e('Configuration', $shortname); ?>"><?php _e('Configuration', $shortname); ?></a></li> | |
</ul> | |
</div> | |
<form action="" id="settingsForm"> | |
<div class="row save"> | |
<button type="submit" class="blue"><span><?php _e('Save All Changes', $shortname); ?></span></button> | |
<a href="#" class="ajax-loader"></a> | |
</div> | |
<div class="panel" id="profile"> | |
<h2><?php _e('Personal informations', $shortname); ?></h2> | |
<div class="content"> | |
<div class="block-left w50"> | |
<div class="row"> | |
<label><?php _e('Name', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['profile']['name']; ?>" name="profile[name]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Email', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['profile']['email']; ?>" name="profile[email]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Phone', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['profile']['phone']; ?>" name="profile[phone]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Date of birth', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['profile']['birthday']; ?>" class="datepicker" placeholder="month dd, yyyy" name="profile[birthday]"/></div> | |
</div> | |
</div> | |
<div class="block-left w50"> | |
<div class="profile-picture" id="photoChange"> | |
<img alt="profile picture" src="<?php echo get_template_directory_uri() ?>/images/photo.jpg?<?php echo md5(microtime()); ?>" /> | |
<span class="border"></span> | |
<a href="#" class="change"><?php _e('Change', $shortname); ?> 153x186</a> | |
</div> | |
<div class="clear"></div> | |
</div> | |
<div class="clear"></div> | |
<div class="row"> | |
<label><?php _e('Job title', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['profile']['jobTitle']; ?>" name="profile[jobTitle]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Adress', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['profile']['adress']; ?>" name="profile[adress]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Website', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['profile']['website']; ?>" name="profile[website]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('About me', $shortname); ?></label> | |
<div class="right"><textarea rows="" cols="" name="profile[aboutMe]" style="height : 100px;"><?php echo $settings['profile']['aboutMe']; ?></textarea></div> | |
</div> | |
</div> | |
<h2><?php _e('Social', $shortname); ?></h2> | |
<div class="content"> | |
<div class="row"> | |
<label><?php _e('Facebook', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['social']['facebook']; ?>" name="social[facebook]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Twitter', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['social']['twitter']; ?>" name="social[twitter]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('LinkedIn', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['social']['linkedin']; ?>" name="social[linkedin]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Google+', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['social']['googleplus']; ?>" name="social[googleplus]"/></div> | |
</div> | |
</div> | |
</div> | |
<div class="panel" id="tabs-2"> | |
<h2><?php _e('Your skills', $shortname); ?></h2> | |
<div class="content"> | |
<div class="head-actions"> | |
<a href="#" class="sections-new"><?php _e('Add new section', $shortname); ?></a> | |
<div class="clear"></div> | |
</div> | |
<div id="skillsSections"> | |
<?php | |
$skills = $settings['skills']; | |
if(is_array($skills)) : | |
foreach($skills as $key => $section) : | |
?> | |
<div class="row skills-section"> | |
<h3> | |
<a href="#" class="skills-section-drag"></a> | |
<input type="text" class="inline-input" name="skills-sections[<?php echo $key; ?>][title]" value="<?php echo $section['title']; ?>" /> | |
</h3> | |
<a href="#" class="skills-item-add"><?php _e('Add', $shortname); ?></a> | |
<a href="#" class="skills-section-delete"><?php _e('Delete', $shortname); ?></a> | |
<ul class="skills"> | |
<?php | |
foreach($section['skills'] as $skey => $skill): ?> | |
<li> | |
<input type="hidden" class="rats" name="skills-sections[<?php echo $key; ?>][skills][<?php echo $skey; ?>][rats]" value="<?php echo $skill['rats']; ?>" /> | |
<a href="#" class="drag"></a> | |
<h4><input type="text" class="inline-input small" name="skills-sections[<?php echo $key; ?>][skills][<?php echo $skey; ?>][title]" value="<?php echo $skill['title']; ?>" /></h4> | |
<div class="rbista-vote"> | |
<div class="rbista-vote-bar" style="width:<?php echo $skill['rats']*18; ?>px;"> | |
<a href="#" style="width:126px;"></a> | |
<a href="#" style="width:108px;"></a> | |
<a href="#" style="width:90px;"></a> | |
<a href="#" style="width:72px;"></a> | |
<a href="#" style="width:54px;"></a> | |
<a href="#" style="width:36px;"></a> | |
<a href="#" style="width:18px;"></a> | |
</div> | |
</div> | |
<a href="#" class="delete"></a> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
</div> | |
<?php endforeach; endif; ?> | |
</div> | |
</div> | |
</div> | |
<div class="panel" id="tabs-3"> | |
<h2><?php _e('Resume', $shortname); ?></h2> | |
<div class="content"> | |
<div class="head-actions"> | |
<a href="#" class="resume-sections-toggle"><?php _e('Toggle All', $shortname); ?></a> | |
<a href="#" class="resume-sections-new"><?php _e('Add new section', $shortname); ?></a> | |
<div class="clear"></div> | |
</div> | |
<div id="resumeSections"> | |
<?php | |
$resume = $settings['resume']; | |
if(is_array($resume)) : | |
foreach($resume as $key => $section) : | |
?> | |
<div class="resume-section"> | |
<h3><a href="#" class="resume-section-drag"></a><input type="text" value="<?php echo $section['title']; ?>" name="resume[<?php echo $key; ?>][title]" class="inline-input"/></h3> | |
<a href="#" class="resume-item-add"><?php _e('Add', $shortname); ?></a><a href="#" class="resume-section-delete"><?php _e('Delete', $shortname); ?></a> <a href="#" class="resume-section-toggle"><?php _e('Expand', $shortname); ?></a> | |
<ul class="resume"> | |
<?php foreach($section['items'] as $rkey => $item): ?> | |
<li> | |
<a href="#" class="resume-item-drag"></a> | |
<h4><?php echo $item['title']; ?></h4><span class="timelineDate"><?php echo $item['date']; ?></span> | |
<h5><?php echo $item['place']; ?></h5> | |
<a href="#" class="resume-item-delete"><?php _e('Delete', $shortname); ?></a><a href="#" class="resume-item-update"><?php _e('Update', $shortname); ?></a> | |
<p><?php echo $item['desc']; ?></p> | |
<input type="hidden" name="resume[<?php echo $key; ?>][items][<?php echo $rkey; ?>][title]" value="<?php echo $item['title']; ?>" /> | |
<input type="hidden" name="resume[<?php echo $key; ?>][items][<?php echo $rkey; ?>][place]" value="<?php echo $item['place']; ?>" /> | |
<input type="hidden" name="resume[<?php echo $key; ?>][items][<?php echo $rkey; ?>][date]" value="<?php echo $item['date']; ?>" /> | |
<input type="hidden" name="resume[<?php echo $key; ?>][items][<?php echo $rkey; ?>][desc]" value="<?php echo $item['desc']; ?>" /> | |
</li> | |
<?php endforeach; ?> | |
</ul> | |
</div> | |
<?php endforeach; endif; ?> | |
<div class="clear"></div> | |
</div> | |
</div> | |
</div> | |
<div class="panel" id="configs"> | |
<h2><?php _e('Configurations', $shortname); ?></h2> | |
<div class="content"> | |
<div class="row" style=" overflow:hidden"> | |
<label><?php _e('Color', $shortname); ?></label> | |
<div class="right"> | |
<input type="radio" name="options[color]" id="color-1" value="yellow"<?php echo $settings['options']['color'] == 'yellow' ? ' checked="checked"' : ''; ?> /> | |
<label for="color-1"><div class="color-label" style=" background-color:#FC0"></div></label> | |
<input type="radio" name="options[color]" id="color-2" value="blue"<?php echo $settings['options']['color'] == 'blue' ? ' checked="checked"' : ''; ?> /> | |
<label for="color-2"><div class="color-label" style=" background-color: #36F"></div></label> | |
<input type="radio" name="options[color]" id="color-3" value="red"<?php echo $settings['options']['color'] == 'red' ? ' checked="checked"' : ''; ?> /> | |
<label for="color-3"><div class="color-label" style=" background-color: #C00"></div></label> | |
<input type="radio" name="options[color]" id="color-4" value="green"<?php echo $settings['options']['color'] == 'green' ? ' checked="checked"' : ''; ?> /> | |
<label for="color-4"><div class="color-label" style=" background-color: #093"></div></label> | |
<input type="radio" name="options[color]" id="color-5" value="purple"<?php echo $settings['options']['color'] == 'purple' ? ' checked="checked"' : ''; ?> /> | |
<label for="color-5"><div class="color-label" style=" background-color: #90F"></div></label> | |
</div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Portfolio Effect', $shortname); ?></label> | |
<div class="right"> | |
<select name="js[adipoliStart]"> | |
<option<?php echo $settings['js']['adipoliStart'] == '' ? ' selected="selected"' : ''; ?> value="transparent">Start Effect</option> | |
<option<?php echo $settings['js']['adipoliStart'] == 'transparent' ? ' selected="selected"' : ''; ?> value="transparent">Transparent</option> | |
<option<?php echo $settings['js']['adipoliStart'] == 'normal' ? ' selected="selected"' : ''; ?> value="normal">Normal</option> | |
<option<?php echo $settings['js']['adipoliStart'] == 'overlay' ? ' selected="selected"' : ''; ?> value="overlay">Overlay</option> | |
<option<?php echo $settings['js']['adipoliStart'] == 'grayscale' ? ' selected="selected"' : ''; ?> value="grayscale">Grayscale</option> | |
</select> | |
<select name="js[adipoliHover]"> | |
<option<?php echo $settings['js']['adipoliHover'] == '' ? ' selected="selected"' : ''; ?> value="normal">Hover Effect</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'normal' ? ' selected="selected"' : ''; ?> value="normal">Normal</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'sliceDown' ? ' selected="selected"' : ''; ?> value="sliceDown">SliceDown</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'sliceDownLeft' ? ' selected="selected"' : ''; ?> value="sliceDownLeft">SliceDownLeft</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'sliceUp' ? ' selected="selected"' : ''; ?> value="sliceUp">SliceUp</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'sliceUpLeft' ? ' selected="selected"' : ''; ?> value="sliceUpLeft">SliceUpLeft</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'sliceUpRandom' ? ' selected="selected"' : ''; ?> value="sliceUpRandom">SliceUpRandom</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'sliceUpDown' ? ' selected="selected"' : ''; ?> value="sliceUpDown">SliceUpDown</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'sliceUpDownLeft' ? ' selected="selected"' : ''; ?> value="sliceUpDownLeft">SliceUpDownLeft</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'fold' ? ' selected="selected"' : ''; ?> value="fold">Fold</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'foldLeft' ? ' selected="selected"' : ''; ?> value="foldLeft">FoldLeft</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'boxRandom' ? ' selected="selected"' : ''; ?> value="boxRandom">BoxRandom</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'boxRain' ? ' selected="selected"' : ''; ?> value="boxRain">BoxRain</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'boxRainReverse' ? ' selected="selected"' : ''; ?> value="boxRainReverse">BoxRainReverse</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'boxRainGrow' ? ' selected="selected"' : ''; ?> value="boxRainGrow">BoxRainGrow</option> | |
<option<?php echo $settings['js']['adipoliHover'] == 'boxRainGrowReverse' ? ' selected="selected"' : ''; ?> value="boxRainGrowReverse">BoxRainGrowReverse</option> | |
</select> | |
</div> | |
<a class="guideline tooltip" title="<?php _e('Control <u>Start</u> & <u>Hover</u> Effect applied on portfolio items.'); ?>" href="#"></a> | |
</div> | |
<div class="row"> | |
<label><?php _e('Favicon', $shortname); ?></label> | |
<div class="right"> | |
<img alt="favicon" id="faviconImg" style="float:left; margin:5px;" src="<?php echo get_template_directory_uri().'/favicon.ico?'.md5(microtime()); ?>" /> | |
<a href="#" id="favicon" class="file-btn"></a> | |
</div> | |
</div> | |
<div class="row" style="position:relative;"> | |
<label><?php _e('Background Image', $shortname); ?></label> | |
<a href="#" class="background-new" id="backgroundNew"><?php _e('Add new background', $shortname); ?></a> | |
<div class="right"> | |
<input type="hidden" name="options[bgImg]" value="<?php echo $settings['options']['bgImg']; ?>" id="backgroundImg" /> | |
<ul id="backgroudImgList"> | |
<?php | |
$bgs = $rbistaSettings->getBackgroundImages(); | |
foreach($bgs as $key => $bg): | |
$selected = $settings['options']['bgImg'] == $bg ? ' class="selected"' : ''; | |
?> | |
<li<?php echo $selected; ?>> | |
<a href="#<?php echo $bg; ?>" title="<?php _e('Double click to delete', $shortname); ?>" class="delete"></a> | |
<a class="img" href="#<?php echo $bg; ?>"><img src="<?php echo get_template_directory_uri().'/images/backgrounds/'.$bg; ?>" alt="" /></a> | |
</li> | |
<?php | |
endforeach; | |
?> | |
<li<?php echo $settings['options']['bgImg'] == '' ? ' class="selected"' : ''; ?>> | |
<a class="img" href="#"><img src="<?php echo get_template_directory_uri().'/images/nonebg.png';?>" alt="" /></a> | |
</li> | |
</ul> | |
<div class="clear"></div> | |
</div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Background Color', $shortname); ?></label> | |
<div class="right"> | |
<input type="hidden" name="options[bgColor]" value="<?php echo $settings['options']['bgColor']; ?>" id="backgroundColor" /> | |
<div class="color-label colorSelector"><div style="background-color:#<?php echo $settings['options']['bgColor']; ?>"></div></div> | |
</div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Tracking Code', $shortname); ?></label> | |
<div class="right"><textarea rows="" cols="" name="options[trackCode]" style="height : 100px;"><?php echo $settings['options']['trackCode']; ?></textarea></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Portfolio text', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['options']['portfolioText']; ?>" name="options[portfolioText]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Footer text', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['options']['footerText']; ?>" name="options[footerText]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Check for update', $shortname); ?></label> | |
<button type="button" id="checkUpdate" class="green"><span><?php _e('Check', $shortname); ?></span></button> | |
<div class="clear"></div> | |
</div> | |
</div> | |
<h2><?php _e('Contact Form', $shortname); ?></h2> | |
<div class="content"> | |
<div class="row"> | |
<label><?php _e('Contact mail', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['contact']['email']; ?>" name="contact[email]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Subject', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['contact']['subject']; ?>" name="contact[subject]"/></div> | |
</div> | |
<div class="row"> | |
<label><?php _e('Method', $shortname); ?></label> | |
<div class="right"> | |
<input type="radio" name="contact[method]" id="mthd-1" value="mail"<?php echo $settings['contact']['method'] == 'mail' ? ' checked="checked"' : ''; ?> /> | |
<label style="line-height: normal;" for="mthd-1"><?php _e('Mail', $shortname); ?></label> | |
<input type="radio" name="contact[method]" id="mthd-2" value="smtp"<?php echo $settings['contact']['method'] == 'smtp' ? ' checked="checked"' : ''; ?> /> | |
<label style="line-height: normal;" for="mthd-2"><?php _e('SMTP', $shortname); ?></label> | |
</div> | |
</div> | |
<div id="smtpPanel"<?php echo $settings['contact']['method'] != 'smtp' ? ' style="display:none"' : ''; ?>> | |
<div class="row"> | |
<label><?php _e('Protocol', $shortname); ?></label> | |
<div class="right"> | |
<input type="radio" name="smtp[protocol]" id="pro-1" value="tls"<?php echo $settings['smtp']['protocol'] == 'tls' ? ' checked="checked"' : ''; ?> /> | |
<label style="line-height: normal;" for="pro-1"><?php _e('TLS', $shortname); ?></label> | |
<input type="radio" name="smtp[protocol]" id="pro-2" value="ssl"<?php echo $settings['smtp']['protocol'] == 'ssl' ? ' checked="checked"' : ''; ?> /> | |
<label style="line-height: normal;" for="pro-2"><?php _e('SSL', $shortname); ?></label> | |
</div> | |
<a class="guideline tooltip" title="<?php _e('SMTP connections security protocol.<br /> Gmail use \'SSL\''); ?>" href="#"></a> | |
</div> | |
<div class="row"> | |
<label><?php _e('Host', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['smtp']['host']; ?>" name="smtp[host]"/></div> | |
<a class="guideline tooltip" title="<?php _e('SMTP connection host.<br /> Gmail : \'smtp.gmail.com\''); ?>" href="#"></a> | |
</div> | |
<div class="row"> | |
<label><?php _e('Port', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['smtp']['port']; ?>" name="smtp[port]"/></div> | |
<a class="guideline tooltip" title="<?php _e('SMTP connection port, 25 by default.<br /> Gmail : \'465\''); ?>" href="#"></a> | |
</div> | |
<div class="row"> | |
<label><?php _e('Username', $shortname); ?></label> | |
<div class="right"><input type="text" value="<?php echo $settings['smtp']['username']; ?>" name="smtp[username]"/></div> | |
<a class="guideline tooltip" title="<?php _e('SMTP server username.<br /> Gmail : \'your_mail\''); ?>" href="#"></a> | |
</div> | |
<div class="row"> | |
<label><?php _e('Password', $shortname); ?></label> | |
<div class="right"><input type="password" value="<?php echo $settings['smtp']['password']; ?>" name="smtp[password]"/></div> | |
<a class="guideline tooltip" title="<?php _e('SMTP server password.<br /> Gmail : \'your_password\''); ?>" href="#"></a> | |
</div> | |
<div class="row"> | |
<button type="button" style="float:right" id="smptTest" class="green"><span><?php _e('Test Connection', $shortname); ?></span></button> | |
<div class="clear"></div> | |
</div> | |
</div> | |
</div> | |
</div> | |
<div class="row save"> | |
<button type="submit" class="blue"><span><?php _e('Save All Changes', $shortname); ?></span></button> | |
<a href="#" class="ajax-loader"></a> | |
</div> | |
<?php /*Use nonce for verification*/ wp_nonce_field('rbista_settings_save', 'rbista_noncename' ); ?> | |
</form> | |
</div> | |
</div> | |
<!----------------> | |
<!-- Templating --> | |
<!----------------> | |
<!-- Section Template --> | |
<div class="template" id="skillsSectionTemplate"> | |
<div class="row skills-section"> | |
<h3> | |
<a href="#" class="skills-section-drag"></a> | |
<input type="text" class="inline-input" name="skills-sections[${Index}][title]" value="Section Title ${Index}" /> | |
</h3> | |
<a href="#" class="skills-item-add"><?php _e('Add', $shortname); ?></a> | |
<a href="#" class="skills-section-delete"><?php _e('Delete', $shortname); ?></a> | |
<ul class="skills"> | |
</ul> | |
</div> | |
</div> | |
<!-- Skill Template --> | |
<ul class="template" id="skillTemplate"> | |
<li> | |
<input type="hidden" class="rats" name="skills-sections[${Index}][skills][${ItemIndex}][rats]" value="${Rats}" /> | |
<a href="#" class="drag"></a> | |
<h4><input type="text" class="inline-input small" name="skills-sections[${Index}][skills][${ItemIndex}][title]" value="Item title ${ItemIndex}" /></h4> | |
<div class="rbista-vote"> | |
<div class="rbista-vote-bar" style="width:0px;"> | |
<a href="#" style="width:126px;"></a> | |
<a href="#" style="width:108px;"></a> | |
<a href="#" style="width:90px;"></a> | |
<a href="#" style="width:72px;"></a> | |
<a href="#" style="width:54px;"></a> | |
<a href="#" style="width:36px;"></a> | |
<a href="#" style="width:18px;"></a> | |
</div> | |
</div> | |
<a href="#" class="delete"></a> | |
</li> | |
</ul> | |
<!-- Messages Template --> | |
<div class="template" id="messageTemplate"> | |
<div class="message ${Type}"><span>${Message}</span></div> | |
</div> | |
<!-- Resume Input Template --> | |
<div class="template" id="resumeInputTemplate"> | |
<div class="row resume-input"> | |
<div class="right"> | |
<input type="text" class="resume-item-title" name="email" placeholder="<?php _e('Title', $shortname); ?>" value="${Title}"/> | |
<input type="text" class="resume-item-place" name="name" placeholder="<?php _e('Where ?', $shortname); ?>" value="${Place}" /> | |
<input type="text" class="resume-item-date" name="name" placeholder="<?php _e('When ?', $shortname); ?>" value="${Date}" /> | |
<textarea class="grow resume-item-desc" placeholder="<?php _e('Description', $shortname); ?>">${Desc}</textarea> | |
<button type="button" class="resume-item-cancel red"><span><?php _e('Cancel', $shortname); ?></span></button> | |
<button type="button" class="resume-item-edit"><span>${Action}</span></button> | |
</div> | |
</div> | |
</div> | |
<!-- Resume Item Template --> | |
<ul class="template" id="resumeItemTemplate"> | |
<li> | |
<a href="#" class="resume-item-drag"></a> | |
<h4>${Title}</h4><span class="timelineDate">${Date}</span> | |
<h5>${Place}</h5> | |
<a href="#" class="resume-item-delete"><?php _e('Delete', $shortname); ?></a><a href="#" class="resume-item-update"><?php _e('Update', $shortname); ?></a> | |
<p>${Desc}</p> | |
<input type="hidden" name="resume[${Index}][items][${ItemIndex}][title]" value="${Title}" /> | |
<input type="hidden" name="resume[${Index}][items][${ItemIndex}][place]" value="${Place}" /> | |
<input type="hidden" name="resume[${Index}][items][${ItemIndex}][date]" value="${Date}" /> | |
<input type="hidden" name="resume[${Index}][items][${ItemIndex}][desc]" value="${Desc}" /> | |
</li> | |
</ul> | |
<!-- Resume Section Template --> | |
<div class="template" id="resumeSectionTemplate"> | |
<div class="resume-section"> | |
<h3><a href="#" class="resume-section-drag"></a><input type="text" value="Section Title ${Index}" name="resume[${Index}][title]" class="inline-input"/></h3> | |
<a href="#" class="resume-item-add"><?php _e('Add', $shortname); ?></a><a href="#" class="resume-section-delete"><?php _e('Delete', $shortname); ?></a> <a href="#" class="resume-section-toggle"><?php _e('Expand', $shortname); ?></a> | |
<ul class="resume"> | |
</ul> | |
</div> | |
</div> | |
<!-- Background Template --> | |
<script id="backgroundTemplate" type="text/x-jquery-tmpl"> | |
<li> | |
<a href="#${File}" title="<?php _e('Double click to delete', $shortname); ?>" class="delete"></a> | |
<a class="img" href="#${File}"><img src="<?php echo get_template_directory_uri().'/images/backgrounds/'; ?>${File}" alt="" /></a> | |
</li> | |
</script> | |
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
<?php | |
class RbistaSettings { | |
/** | |
* The unique instance of the class | |
* | |
* @var RbistaSettings | |
* @since 1.0 | |
*/ | |
private static $instance = NULL; | |
/** | |
* The settings field name in the database | |
* | |
* @var String | |
* @since 1.0 | |
*/ | |
private $fieldName; | |
/** | |
* The settings | |
* | |
* @var Array | |
* @since 1.0 | |
*/ | |
private $settings = array(); | |
/** | |
* Loaded files | |
* | |
* @var Array | |
* @since 1.0 | |
*/ | |
private $files; | |
/** | |
* Theme shortname | |
* | |
* @var String | |
* @since 1.0 | |
*/ | |
private $shortname; | |
/** | |
* white list | |
* | |
* @var Array | |
* @since 1.0 | |
*/ | |
private $whiteList = array( | |
//Entity | |
'profile' => array( | |
//Field: Type, Possible values | |
'name' => array('string', NULL), | |
'email' => array('email', NULL), | |
'phone' => array('string', NULL), | |
'birthday' => array('date', NULL), | |
'jobTitle' => array('string', NULL), | |
'adress' => array('string', NULL), | |
'website' => array('url', NULL), | |
'aboutMe' => array('string', NULL) | |
), | |
'social' => array( | |
'facebook' => array('url', NULL), | |
'twitter' => array('url', NULL), | |
'linkedin' => array('url', NULL), | |
'googleplus' => array('url', NULL) | |
), | |
'options' => array( | |
'color' => array('string', array('red', 'yellow', 'green', 'purple', 'blue')), | |
'bgImg' => array('backgrounds', NULL), | |
'bgColor' => array('color', NULL), | |
'trackCode' => array('js', NULL), | |
'portfolioText' => array('string', NULL), | |
'footerText' => array('string', NULL) | |
), | |
'js' => array( | |
'adipoliStart' => array('string', array('transparent', 'normal', 'overlay', 'grayscale')), | |
'adipoliHover' => array('string', array('normal', 'sliceDown', 'sliceDownLeft', 'sliceUp', 'sliceUpLeft', 'sliceUpRandom', 'sliceUpDown', 'sliceUpDownLeft', 'fold', 'foldLeft', 'boxRandom', 'boxRain', 'boxRainReverse', 'boxRainGrow', 'boxRainGrowReverse')) | |
), | |
'smtp' => array( | |
'protocol' => array('string', array('tls', 'ssl')), | |
'host' => array('string', NULL), | |
'port' => array('int', NULL), | |
'username' => array('string', NULL), | |
'password' => array('string', NULL) | |
), | |
'contact' => array( | |
'method' => array('string', array('mail', 'smtp')), | |
'email' => array('email', NULL), | |
'subject' => array('string', NULL) | |
) | |
); | |
/** | |
* Get a unique instance of the class | |
* | |
* @return RbistaSettings | |
* @since 1.0 | |
*/ | |
public static function getInstance() { | |
if(self::$instance === NULL) { | |
self::$instance = new RbistaSettings(); | |
} | |
return self::$instance; | |
} | |
/** | |
* Constructor | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
private function __construct() { | |
global $shortname; | |
$this->shortname = $shortname; | |
$this->fieldName = 'rbista_'.$shortname.'_settings'; | |
//Add Ajax Settings Save | |
add_action('wp_ajax_rbista_settings_save', array( &$this, 'save')); | |
add_action('wp_ajax_rbista_file_upload', array( &$this, 'upload')); | |
add_action('wp_ajax_rbista_file_delete', array( &$this, 'deleteFile')); | |
add_action('wp_ajax_rbista_send_mail', array( &$this, 'sendmail')); | |
add_action('wp_ajax_rbista_smtp_test', array( &$this, 'smtpTestConnection')); | |
add_action('wp_ajax_rbista_update_log', array( &$this, 'updateLog')); | |
add_action('wp_ajax_rbista_update_check', array( &$this, 'checkUpdate')); | |
//Load Resume | |
$this->settings = get_option($this->fieldName); | |
if(!is_array($this->settings)) { | |
$this->settings = array(); | |
} | |
//Load Initial data | |
if(sizeof($this->settings['options']) == 0) { | |
if($defaultOptions = @file_get_contents(RBISTA_TMP.DS.'options.ini')) { | |
$this->settings = unserialize($defaultOptions); | |
update_option($this->fieldName, $this->settings); | |
@unlink(RBISTA_TMP.DS.'options.ini'); | |
} | |
} | |
//Update Info | |
if(is_admin()) { | |
//Check for updates | |
if(time() - $this->settings['update']['lastCheck'] > 86400) { | |
$this->checkUpdate(); | |
} | |
} | |
} | |
/** | |
* Get general settings | |
* | |
* | |
* @return Array | |
* @since 1.0 | |
*/ | |
public function &get($context = '') { | |
if($context && isset($this->settings[$context])) { | |
return $this->settings[$context]; | |
} | |
return $this->settings; | |
} | |
/** | |
* Check for available Update | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
public function checkUpdate() { | |
$serverUrl = "http://www.rbista.com/updatecenter/zwin.php"; | |
$tags = get_meta_tags($serverUrl); | |
$lastVersion = $tags['version']; | |
$themeData = get_theme_data( TEMPLATEPATH . '/style.css'); | |
$currentVersion = $themeData['Version']; | |
if (version_compare($currentVersion, $lastVersion) === -1) { | |
$this->settings['update']['needUpdate'] = true; | |
$this->settings['update']['currentVersion'] = $lastVersion; | |
$this->settings['update']['instructions'] = $this->htmtlSpecialCharsDecode($tags['instructions']); | |
}else { | |
$this->settings['update']['needUpdate'] = false; | |
} | |
$this->settings['update']['lastCheck'] = time(); | |
update_option($this->fieldName, $this->settings); | |
} | |
/** | |
* Update Template | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
private function runUpdate() { | |
define('FS_CHMOD_DIR', 0644); | |
define('FS_CHMOD_FILE', 0644); | |
global $wp_filesystem ; | |
require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php'); | |
require_once(ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php'); | |
$wp_filesystem = new WP_Filesystem_Direct(''); | |
$this->writeLog(__('Start update', $this->shortname), true); | |
$this->writeLog(__('Install update', $this->shortname).' ...'); | |
$ret = unzip_file(RBISTA_TMP.DS.'latest_update.zip', TEMPLATEPATH); | |
if ( is_wp_error($ret) ) { | |
$this->writeLog(__('Error', $this->shortname).':'.$ret->get_error_message()); | |
}else { | |
$this->settings['update']['needUpdate'] = false; | |
update_option($this->fieldName, $this->settings); | |
} | |
$this->writeLog(__('Update finished', $this->shortname).'.'); | |
} | |
/** | |
* Echo Update LOG in Console | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
public function updateLog() { | |
$response = array(); | |
$response['message'] = $this->readLog(); | |
$response['done'] = strpos($response['message'], 'Update finished') !== false ? 1 : 0; | |
echo json_encode($response); | |
die();//kill the app | |
} | |
/** | |
* Write LOG | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
private function writeLog($msg, $earse = false) { | |
$append = $earse ? 0 : FILE_APPEND; | |
return file_put_contents(RBISTA_TMP.DS.'update_log.ini', $msg."<br />", $append); | |
} | |
/** | |
* Read LOG | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
private function readLog() { | |
return file_get_contents(RBISTA_TMP.DS.'update_log.ini'); | |
} | |
/** | |
* Html Special Chars Reverse | |
* | |
* @param string html to decode | |
* | |
* @return string decoded html | |
* @since 1.0 | |
*/ | |
public function htmtlSpecialCharsDecode($html) { | |
if ( !function_exists('htmlspecialchars_decode') ) { | |
return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS))); | |
} | |
return htmlspecialchars_decode($html); | |
} | |
/** | |
* Send mail | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
public function sendmail() { | |
$response = array(); | |
require_once(RBISTA_CLASS.DS.'smtp.php'); | |
require_once(RBISTA_CLASS.DS.'phpmailer.php'); | |
$to = $this->settings['contact']['email'] ? $this->settings['contact']['email'] : $this->settings['profile']['email']; | |
$from = trim($_POST['email']); | |
$fromName = trim($_POST['name']); | |
$subject = $this->settings['contact']['subject']; | |
$body = trim($_POST['message']); | |
try { | |
// verify this came from the our screen and with proper authorization | |
if ( !wp_verify_nonce( $_POST['rbista_noncename'], 'rbista_send_mail')) | |
throw new InvalidArgumentException(__('Invalid security code', $this->shortname), 300); | |
if(empty($fromName)) | |
throw new InvalidArgumentException(__('Please enter your name', $this->shortname), 300); | |
if(empty($from) || !$this->validate($from, 'email')) | |
throw new InvalidArgumentException(__('Please enter valid e-mail', $this->shortname), 300); | |
if(empty($body)) | |
throw new InvalidArgumentException(__('Please enter your message', $this->shortname), 300); | |
$mail = new PHPMailer(); | |
if($this->settings['contact']['method'] == 'smtp') { | |
$mail->IsSMTP(); // enable SMTP | |
$mail->SMTPSecure = $this->settings['smtp']['protocol']; | |
$mail->Host = $this->settings['smtp']['host']; | |
$mail->Port = $this->settings['smtp']['port']; | |
if($this->settings['smtp']['username']) { | |
$mail->SMTPAuth = true; | |
$mail->Username = $this->settings['smtp']['username']; | |
$mail->Password = $this->settings['smtp']['password']; | |
} | |
}else { | |
$mail->IsMail(); | |
} | |
$mail->SetFrom($from, $fromName); | |
$mail->Subject = $subject; | |
$mail->Body = $body; | |
$mail->AddAddress($to); | |
if(!$mail->Send()) { | |
throw new phpmailerException(); | |
} | |
throw new Exception(__('Your message has been sent. Thank you!', $this->shortname), 200); | |
} catch(phpmailerException $ee) { | |
$response['success'] = 500; | |
$response['message'] = __('Sorry, we can\'t send this message', $this->shortname); | |
} catch(InvalidArgumentException $ia) { | |
$response['success'] = 501; | |
$response['message'] = $ia->getMessage(); | |
} catch(Exception $e) { | |
$response['success'] = 200; | |
$response['message'] = $e->getMessage(); | |
} | |
echo json_encode($response); | |
die();//kill the app | |
} | |
/** | |
* Test SMTP Connection | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
public function smtpTestConnection() { | |
if(!is_admin()) | |
die(__('Access denided', $this->shortname)); | |
if (!current_user_can('edit_theme_options')) | |
die(__('Access denided', $this->shortname)); | |
$response = array(); | |
require_once(RBISTA_CLASS.DS.'smtp.php'); | |
require_once(RBISTA_CLASS.DS.'phpmailer.php'); | |
$mail = new PHPMailer(); | |
$mail->IsSMTP(); | |
$mail->SMTPSecure = $_POST['protocol'] == 'tls' ? 'tls' : 'ssl'; | |
$mail->Host = $_POST['host']; | |
$mail->Port = intval($_POST['port']); | |
if(!empty($_POST['username']) || !empty($_POST['password'])) { | |
$mail->SMTPAuth = true; | |
$mail->Username = trim($_POST['username']); | |
$mail->Password = trim($_POST['password']); | |
} | |
try { | |
$mail->SmtpConnect(); | |
throw new Exception(__('Connected successfully', $this->shortname), 200); | |
}catch(phpmailerException $ee) { | |
$response['success'] = 0; | |
$response['message'] = $ee->getMessage(); | |
$response['data'] = $_POST; | |
}catch(Exception $e) { | |
$response['success'] = 200; | |
$response['message'] = __('Connected successfully', $this->shortname); | |
} | |
echo json_encode($response); | |
die();//kill the app | |
} | |
/** | |
* Unlink a file | |
* | |
* @param string file | |
* @param string pre-defined context in $files array ! | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
private function unlinkFile($file, $context) { | |
if (empty($context) || empty($file)) | |
throw new InvalidArgumentException(__('Invalid arguments', $this->shortname), 105); | |
//Pre-defined context for security reasons ! | |
$dir = ''; | |
if($context == 'backgrounds') { | |
$this->getBackgroundImages(); | |
$dir = TEMPLATEPATH.DS.'images'.DS.'backgrounds'.DS.$file; | |
} | |
if($dir == '') | |
throw new ErrorException(__('Context don\'t exist', $this->shortname), 500); | |
if(!in_array($file, $this->files[$context])) | |
throw new ErrorException(__('File don\'t exists in context', $this->shortname), 500); | |
if(unlink($dir)) { | |
$this->files[$context] = array(); | |
throw new Exception(__('File deleted.', $this->shortname), 200); | |
} | |
throw new ErrorException(__('System can\'t delete file', $this->shortname), 500); | |
} | |
/** | |
* Delete File from pre-defined context for security reasons | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
public function deleteFile() { | |
if(!is_admin()) | |
die(__('Access denided', $this->shortname)); | |
if (!current_user_can('edit_theme_options')) | |
die(__('Access denided', $this->shortname)); | |
$response = array(); | |
try { | |
$this->unlinkFile($_POST['file'], $_POST['context']); | |
} catch(InvalidArgumentException $ia) { | |
$response['success'] = $ia->getCode(); | |
$response['message'] = $ia->getMessage(); | |
} catch(ErrorException $ee) { | |
$response['success'] = $ee->getCode(); | |
$response['message'] = $ee->getMessage(); | |
} catch(Exception $e) { | |
$response['success'] = $e->getCode(); | |
$response['message'] = $e->getMessage(); | |
} | |
echo json_encode($response); | |
die();//kill the app | |
} | |
/** | |
* Get list files from a directory | |
* | |
* @param string directory | |
* @param array list for extension to load | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
private function getFiles($dir, $ext = array()) { | |
if(!sizeof($ext)) | |
$ext = array('jpg', 'jpeg', 'gif', 'png', 'pdf'); | |
$files = array(); | |
if ($handle = opendir($dir)) { | |
while (false !== ($file = readdir($handle))) { | |
$fext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); | |
if ($file != "." && $file != ".." && is_file($dir.DIRECTORY_SEPARATOR.$file) && in_array($fext, $ext)) { | |
$files[] = $file; | |
} | |
} | |
closedir($handle); | |
} | |
return $files; | |
} | |
/** | |
* Get list of avialable background images | |
* | |
* | |
* @return Array | |
* @since 1.0 | |
*/ | |
public function getBackgroundImages() { | |
if(!isset($this->files['backgrounds'])) { | |
$this->files['backgrounds'] = $this->getFiles(TEMPLATEPATH.DS.'images'.DS.'backgrounds', array('jpg', 'jpeg', 'gif', 'png')); | |
} | |
return $this->files['backgrounds']; | |
} | |
/** | |
* Upload files | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
public function upload() { | |
if (!current_user_can('edit_theme_options') || !is_admin()) | |
die(__('Access denided', $this->shortname)); | |
$file = NULL; | |
$destination = ''; | |
$allowedExt = array(); | |
//Background files | |
if(isset($_FILES['bgfile'])) { | |
$file = &$_FILES['bgfile']; | |
$allowedExt = array('jpg', 'png', 'jpeg', 'gif'); | |
$filename = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $file['name']); | |
if($filename == '') { | |
die(__('Invalide file name.', $this->shortname)); | |
} | |
if(in_array($filename, $this->getBackgroundImages())) { | |
die(__('File name already exist.', $this->shortname)); | |
} | |
$destination = RBISTA_BACKGROUNDS.DS.$filename; | |
//Profile picture | |
}else if(isset($_FILES['photo'])) { | |
$file = &$_FILES['photo']; | |
$allowedExt = array('jpg', 'png', 'jpeg', 'gif'); | |
$destination = RBISTA_IMAGES.DS.'photo.jpg'; | |
//Favicon | |
}else if(isset($_FILES['favicon'])) { | |
$file = &$_FILES['favicon']; | |
$allowedExt = array('ico'); | |
$destination = TEMPLATEPATH.DS.'favicon.ico'; | |
//Update file | |
}else if(isset($_FILES['update'])) { | |
$file = &$_FILES['update']; | |
$allowedExt = array('zip'); | |
$destination = RBISTA_TMP.DS.'latest_update.zip'; | |
} | |
if($file == NULL) | |
die(__('No file !', $this->shortname)); | |
if(!in_array(strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)), $allowedExt)) | |
die(__('Extension not allowed, allowed extentions : ', $this->shortname).print_r($allowedExt, true)); | |
if (!is_uploaded_file($file['tmp_name'])) { | |
switch($file['error']){ | |
case 0: //no error; possible file attack! | |
die(__("There was a problem with your upload.", $this->shortname)); | |
case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini | |
die(__("The file you are trying to upload is too big.", $this->shortname)); | |
case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form | |
die(__("The file you are trying to upload is too big.", $this->shortname)); | |
case 3: //uploaded file was only partially uploaded | |
die(__("The file you are trying upload was only partially uploaded.", $this->shortname)); | |
case 4: //no file was uploaded | |
die(__("You must select an image for upload.", $this->shortname)); | |
default: //a default error, just in case! :) | |
die(__("There was a problem with your upload.", $this->shortname)); | |
} | |
} | |
if (!move_uploaded_file($file['tmp_name'], $destination)) | |
die(__("Unknown error", $this->shortname)); | |
if(isset($_FILES['bgfile'])) { | |
//Refresh Background List | |
unset($this->files['backgrounds']); | |
}else if(isset($_FILES['update'])) { | |
// Set correct file permissions | |
@ chmod( $destination, 0755); | |
$this->runUpdate(); | |
} | |
die('200'); | |
} | |
/** | |
* Validate fields | |
* | |
* | |
* @return boolean | |
* @since 1.0 | |
*/ | |
private function validate(&$value, $type) { | |
if(empty($value)) return true; | |
switch($type) { | |
case 'backgrounds': | |
return in_array($value, $this->getBackgroundImages()); | |
case 'email': | |
return filter_var($value, FILTER_VALIDATE_EMAIL); | |
case 'url': | |
return filter_var($value, FILTER_VALIDATE_URL); | |
case 'color': | |
return preg_match('/^[a-f0-9]{6}$/i', $value); | |
case 'js': | |
$value = str_replace("'", '"', $value); | |
return true; | |
case 'date': | |
return true; //Diffrent format around the world | |
} | |
return true; | |
} | |
/** | |
* Save Submited Settings | |
* | |
* | |
* @return void | |
* @since 1.0 | |
*/ | |
public function save() { | |
if (!current_user_can('edit_theme_options') || !is_admin()) | |
die(__('Access denided', $this->shortname)); | |
$response = array(); | |
$invalidInputs = array(); | |
try { | |
// verify this came from the our screen and with proper authorization | |
if ( !wp_verify_nonce( $_POST['rbista_noncename'], 'rbista_settings_save')) | |
throw new InvalidArgumentException(__('Invalid security code', $this->shortname), 300); | |
/************************ | |
Profile | |
************************/ | |
if(isset($_POST['profile']) && is_array($_POST['profile'])) { | |
$this->settings['profile'] = array(); | |
foreach($_POST['profile'] as $name => $value) { | |
$possibleFields = array_keys($this->whiteList['profile']); | |
if(in_array($name, $possibleFields)) { | |
$fieldType = $this->whiteList['profile'][$name][0]; | |
$possibleValues = $this->whiteList['profile'][$name][1]; | |
if(($possibleValues === NULL || in_array($value, $possibleValues)) && $this->validate($value, $fieldType)) | |
$this->settings['profile'][$name] = esc_attr(stripslashes($value)); | |
else | |
$invalidInputs[] = array($name, $fieldType); | |
} | |
} | |
} | |
/************************ | |
Social | |
************************/ | |
if(isset($_POST['social']) && is_array($_POST['social'])) { | |
$this->settings['social'] = array(); | |
foreach($_POST['social'] as $name => $value) { | |
$possibleFields = array_keys($this->whiteList['social']); | |
if(in_array($name, $possibleFields)) { | |
$fieldType = $this->whiteList['social'][$name][0]; | |
$possibleValues = $this->whiteList['social'][$name][1]; | |
if(($possibleValues === NULL || in_array($value, $possibleValues)) && $this->validate($value, $fieldType)) | |
$this->settings['social'][$name] = esc_attr(stripslashes($value)); | |
else | |
$invalidInputs[] = array($name, $fieldType); | |
} | |
} | |
} | |
/************************ | |
JS | |
************************/ | |
if(isset($_POST['js']) && is_array($_POST['js'])) { | |
$this->settings['js'] = array(); | |
foreach($_POST['js'] as $name => $value) { | |
$possibleFields = array_keys($this->whiteList['js']); | |
if(in_array($name, $possibleFields)) { | |
$fieldType = $this->whiteList['js'][$name][0]; | |
$possibleValues = $this->whiteList['js'][$name][1]; | |
if(($possibleValues === NULL || in_array($value, $possibleValues)) && $this->validate($value, $fieldType)) | |
$this->settings['js'][$name] = esc_attr(stripslashes($value)); | |
else | |
$invalidInputs[] = array($name, $fieldType); | |
} | |
} | |
} | |
/************************ | |
Options | |
************************/ | |
if(isset($_POST['options']) && is_array($_POST['options'])) { | |
$this->settings['options'] = array(); | |
foreach($_POST['options'] as $name => $value) { | |
$possibleFields = array_keys($this->whiteList['options']); | |
if(in_array($name, $possibleFields)) { | |
$fieldType = $this->whiteList['options'][$name][0]; | |
$possibleValues = $this->whiteList['options'][$name][1]; | |
if($possibleValues === NULL || in_array($value, $possibleValues)) { | |
if($this->validate($value, $fieldType)) | |
$this->settings['options'][$name] = esc_attr(stripslashes($value)); | |
else { | |
$this->settings['options'][$name] = ''; | |
$invalidInputs[] = array($name, $fieldType); | |
} | |
} | |
} | |
} | |
} | |
/************************ | |
SMTP | |
************************/ | |
if(isset($_POST['smtp']) && is_array($_POST['smtp'])) { | |
$this->settings['smtp'] = array(); | |
foreach($_POST['smtp'] as $name => $value) { | |
$possibleFields = array_keys($this->whiteList['smtp']); | |
if(in_array($name, $possibleFields)) { | |
$fieldType = $this->whiteList['smtp'][$name][0]; | |
$possibleValues = $this->whiteList['smtp'][$name][1]; | |
if($possibleValues === NULL || in_array($value, $possibleValues)) { | |
if($this->validate($value, $fieldType)) | |
$this->settings['smtp'][$name] = esc_attr(stripslashes($value)); | |
else { | |
$this->settings['smtp'][$name] = ''; | |
$invalidInputs[] = array($name, $fieldType); | |
} | |
} | |
} | |
} | |
} | |
/************************ | |
Contact | |
************************/ | |
if(isset($_POST['contact']) && is_array($_POST['contact'])) { | |
$this->settings['contact'] = array(); | |
foreach($_POST['contact'] as $name => $value) { | |
$possibleFields = array_keys($this->whiteList['contact']); | |
if(in_array($name, $possibleFields)) { | |
$fieldType = $this->whiteList['contact'][$name][0]; | |
$possibleValues = $this->whiteList['contact'][$name][1]; | |
if($possibleValues === NULL || in_array($value, $possibleValues)) { | |
if($this->validate($value, $fieldType)) | |
$this->settings['contact'][$name] = esc_attr(stripslashes($value)); | |
else { | |
$this->settings['contact'][$name] = ''; | |
$invalidInputs[] = array($name, $fieldType); | |
} | |
} | |
} | |
} | |
} | |
/************************ | |
Skills | |
************************/ | |
if(isset($_POST['skills-sections']) && is_array($_POST['skills-sections'])) { | |
$this->settings['skills'] = array(); | |
$i = 0; | |
//Fill Sections | |
foreach($_POST['skills-sections'] as $key => $section) { | |
$this->settings['skills'][$i] = array(); | |
$this->settings['skills'][$i]['title'] = esc_attr(stripslashes($section['title'])); | |
//Fill Skills | |
$this->settings['skills'][$i]['skills'] = array(); | |
if(is_array($section['skills'])) { | |
$j = 0; | |
foreach($section['skills'] as $sKey => $skill) { | |
$this->settings['skills'][$i]['skills'][$j] = array(); | |
$this->settings['skills'][$i]['skills'][$j]['title'] = esc_attr($skill['title']); | |
$this->settings['skills'][$i]['skills'][$j]['rats'] = intval(stripslashes($skill['rats'])); | |
$j++; | |
} | |
} | |
$i++; | |
} | |
} | |
/************************ | |
Resume | |
************************/ | |
if(isset($_POST['resume']) && is_array($_POST['resume'])) { | |
$this->settings['resume'] = array(); | |
$i = 0; | |
//Fill Sections | |
foreach($_POST['resume'] as $key => $section) { | |
$this->settings['resume'][$i] = array(); | |
$this->settings['resume'][$i]['title'] = esc_attr(stripslashes($section['title'])); | |
//Fill Resume Section | |
$this->settings['resume'][$i]['items'] = array(); | |
if(is_array($section['items'])) { | |
$j = 0; | |
foreach($section['items'] as $iKey => $item) { | |
$this->settings['resume'][$i]['items'][$j] = array(); | |
$this->settings['resume'][$i]['items'][$j]['title'] = esc_attr(stripslashes($item['title'])); | |
$this->settings['resume'][$i]['items'][$j]['date'] = esc_attr(stripslashes($item['date'])); | |
$this->settings['resume'][$i]['items'][$j]['place'] = esc_attr(stripslashes($item['place'])); | |
$this->settings['resume'][$i]['items'][$j]['desc'] = esc_attr(stripslashes($item['desc'])); | |
$j++; | |
} | |
} | |
$i++; | |
} | |
} | |
throw new Exception(__('Your changes have been successfully saved.', $this->shortname), 200); | |
} catch(InvalidArgumentException $ia) { | |
$response['success'] = $ia->getCode(); | |
$response['message'] = $ia->getMessage(); | |
} catch(Exception $e) { | |
$response['success'] = $e->getCode(); | |
$response['message'] = $e->getMessage(); | |
update_option($this->fieldName, $this->settings); | |
} | |
$response['inputs'] = &$invalidInputs; | |
echo json_encode($response); | |
die();//kill the app | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment