807 lines
39 KiB
PHP
807 lines
39 KiB
PHP
<?php
|
|
|
|
// Global consts and vars.
|
|
global $id_setting, $config, $id_version, $responsys_campaign;
|
|
|
|
$home = get_option("id_medical_home");
|
|
//$product = get_option("id_medical_product");
|
|
$shipping = get_option("id_medical_shipping");
|
|
$order = get_option("id_medical_order");
|
|
$profile = get_option("id_medical_profile");
|
|
$thank = get_option("id_medical_thank");
|
|
$accessory = get_option("id_medical_accessories");
|
|
$back_color = get_option("id_background");
|
|
|
|
$config = array();
|
|
$config['id_medical_home'] = $home;
|
|
$config['id_version'] = $id_version;
|
|
$config['responsys_campaign'] = $responsys_campaign;
|
|
|
|
|
|
//$config['id_medical_product'] = $product;
|
|
$config['id_medical_shipping'] = $shipping;
|
|
$config['id_medical_order'] = $order;
|
|
$config['id_medical_profile'] = $profile;
|
|
$config['id_medical_thank'] = $thank;
|
|
$config['id_medical_accessories'] = $accessory;
|
|
$config['id_background'] = $back_color;
|
|
|
|
|
|
$id_setting = array(
|
|
array( 'name' => 'SFDC Environment', 'option_name' => 'select-environment', 'type' => 'select-environment', 'description' => '', 'default' => ''),
|
|
//array( 'name' => 'API', 'option_name' => 'id_api_salesforce', 'type' => 'input', 'description' => 'Insert Link Api Salesforce', 'default' => ''),
|
|
array( 'name' => 'API', 'option_name' => 'select-api', 'type' => 'select-api', 'description' => '', 'default' => ''),
|
|
array( 'name' => 'Call to Action Tel ', 'option_name' => 'cta_tel', 'type' => 'select-phone', 'description' => 'Telephone', 'default' => '1.800.800.2537'),
|
|
array( 'name' => 'Brand ID', 'option_name' => 'id_brand', 'type' => 'select-brand', 'description' => 'Brand ID', 'default' => ''),
|
|
array( 'name' => 'Version', 'option_name' => 'id_version', 'type' => 'input', 'description' => '', 'default' => ''),
|
|
array( 'name' => 'Responsys Campaign', 'option_name' => 'responsys_campaign', 'type' => 'input', 'description' => 'Responsys Campaign', 'default' => ''),
|
|
|
|
/*array( 'name' => 'Encrption KEY', 'option_name' => 'encrption_key', 'type' => 'input', 'description' => 'Encrption KEY', 'default' => ''),
|
|
array( 'name' => 'Singnature KEY', 'option_name' => 'signature_key', 'type' => 'textarea', 'description' => 'Singnature KEY', 'default'
|
|
=> ''),*/
|
|
|
|
array( 'name' => 'Call to Action', 'option_name' => 'title', 'type' => 'title', 'description' => '', 'default' => 'title'),
|
|
array( 'name' => 'Call to Action Title ', 'option_name' => 'cta_title', 'type' => 'input', 'description' => '', 'default' =>
|
|
'Operators Are Standing By'),
|
|
//array( 'name' => 'Phone Assistance ', 'option_name' => 'assistance_phone', 'type' => 'input', 'description' => 'Assistance Phone(Error SF Page)', 'default' => '1.800.800.2538'),
|
|
array( 'name' => 'Call to Action Descr ', 'option_name' => 'cta_descr', 'type' => 'input', 'description' => '', 'default' => 'CALL
|
|
NOW TO ORDER!'),
|
|
array( 'name' => 'Pages Template', 'option_name' => 'Pages Template', 'type' => 'title', 'description' => '', 'default' => 'title'),
|
|
array( 'name' => 'Home', 'option_name' => 'id_medical_home', 'type' => 'select-page', 'description' => 'Select Home page', 'default' => ''),
|
|
//array( 'name' => 'Product', 'option_name' => 'id_medical_product', 'type' => 'select-page', 'description' => 'Select product page', 'default' => ''),
|
|
array( 'name' => 'Shipping', 'option_name' => 'id_medical_shipping', 'type' => 'select-page', 'description' => 'Select Shipping page', 'default' => ''),
|
|
array( 'name' => 'Order Detail', 'option_name' => 'id_medical_order', 'type' => 'select-page', 'description' => 'Select Order page', 'default' => ''),
|
|
array( 'name' => 'Profile Set up', 'option_name' => 'id_medical_profile', 'type' => 'select-page', 'description' => 'Select Profile page', 'default' => ''),
|
|
array( 'name' => 'Thank', 'option_name' => 'id_medical_thank', 'type' => 'select-page', 'description' => 'Select Thank page', 'default' => ''),
|
|
array( 'name' => 'Accessories', 'option_name' => 'id_medical_accessories', 'type' => 'select-page', 'description' => 'Select Select Accessories page', 'default' => ''),
|
|
array( 'name' => 'Colors Selection', 'option_name' => 'Colors Selection', 'type' => 'title', 'description' => '', 'default' => 'title'),
|
|
array( 'name' => 'Product Button Color', 'option_name' => 'id_product_color', 'type' => 'input', 'description' => 'Insert hexadecimal product button Color. <!--<span style="background-color:#da9333; color:#fff; padding:3px;" >Default:#da9333</span>-->', 'default' => '#da9333'),
|
|
array( 'name' => 'Products background Color', 'option_name' => 'id_product_background_color', 'type' => 'input', 'description' => 'Insert hexadecimal products background Color. <!--<span style="background-color:#89d0f2; color:#fff; padding:3px;" >Default:#89d0f2</span>-->', 'default' => '#89d0f2'),
|
|
array( 'name' => 'Objects in Evidence and Nav Color', 'option_name' => 'id_in_evidence_color', 'type' => 'input', 'description' => 'Insert hexadecimal Product in Evidence and Nav color, Modal window h1 and Upsell Price. <!--<span style="background-color:#0b2265; color:#fff; padding:3px;" >Default:#0b2265</span>-->', 'default' => '#0b2265'),
|
|
array( 'name' => 'Accessories Button Color', 'option_name' => 'id_acc_btn_color', 'type' => 'input', 'description' => 'Insert hexadecimal accessories page button Color. <!--<span style="background-color:#a8a8a7; color:#fff; padding:3px;" >Default:#a8a8a7</span>-->', 'default' => '#a8a8a7'),
|
|
array( 'name' => 'Title page, Place Order and Next Button Color', 'option_name' => 'id_next_btn_color', 'type' => 'input', 'description' => 'Insert hexadecimal Title page, Place Order and Next Button Color. <!--<span style="background-color:#9c3039; color:#fff; padding:3px;" >Default:#9c3039</span>-->', 'default' => '#9c3039')
|
|
|
|
);
|
|
|
|
add_filter('single_template','IperCptTemplate_single');
|
|
add_filter('archive_template','IperCptTemplate_archive');
|
|
|
|
/* Disable smithers for now
|
|
add_action( 'wp_footer', 'environment_indicator');
|
|
|
|
function environment_indicator() {
|
|
$s_env = get_option('select-environment');
|
|
$s_campaign = do_shortcode('[campaign_id]') ?: "N/A";
|
|
$s_five9 = do_shortcode('[campaign_five9]') ?: "Webform Submissions H";
|
|
$s_toll = do_shortcode('[phone_number]') ?: "800-800-2537";
|
|
$smithers_img = plugin_dir_url( __FILE__ ) . 'templates/images/smithers.png';
|
|
$smithers_js = plugin_dir_url( __FILE__ ) . 'templates/script/smithers.js';
|
|
|
|
|
|
if (defined('PANTHEON_ENVIRONMENT') && (PANTHEON_ENVIRONMENT !== 'live')) {
|
|
echo '
|
|
<div class="s-button-wrapper">
|
|
<ul class="s-list">
|
|
<li>SFDC Environment: ' . $s_env . '</li>
|
|
<li>Camp. ID: '.$s_campaign.'</li>
|
|
<li>800#: '.$s_toll.'</li>
|
|
<li>Five9: '.$s_five9.'</li>
|
|
</ul>
|
|
<img class="s-button" src="'.$smithers_img.'">
|
|
</div>
|
|
<script src="'.$smithers_js.'"></script>';
|
|
}
|
|
}
|
|
*/
|
|
//route single-template
|
|
if(!function_exists('IperCptTemplate_single')){
|
|
|
|
function IperCptTemplate_single($single_template){
|
|
|
|
global $post;
|
|
$found = locate_template('single-product.php');
|
|
if($post->post_type == 'product' && $found == ''){
|
|
$single_template = dirname(__FILE__).'/templates/template-product.php';
|
|
}
|
|
|
|
return $single_template;
|
|
}
|
|
}
|
|
//route archive-template
|
|
if(!function_exists('IperCptTemplate_archive')){
|
|
function IperCptTemplate_archive($template){
|
|
if(is_post_type_archive('product')){
|
|
$theme_files = array('archive-product.php');
|
|
$exists_in_theme = locate_template($theme_files, false);
|
|
if($exists_in_theme == ''){
|
|
return plugin_dir_path(__FILE__) . '/templates/template-medical-home.php';
|
|
}
|
|
}
|
|
return $template;
|
|
}
|
|
}
|
|
|
|
function ajax_shortcode() {
|
|
$stripslashes = do_shortcode( '[web_promo]' );
|
|
$stripslash = stripslashes($stripslashes);
|
|
echo $stripslash;
|
|
|
|
die();
|
|
}
|
|
|
|
|
|
add_action('admin_menu', 'iper_menu_page');
|
|
|
|
function iper_menu_page() {
|
|
|
|
$themename = "Medical Alert eCommerce";
|
|
$shortname = "iper_medical_alert";
|
|
$menu_slug="edit_posts"; //Capability
|
|
|
|
add_object_page($themename, $themename, $menu_slug, $shortname,'id_main_admin');
|
|
}
|
|
|
|
function id_main_admin(){
|
|
$i=0;
|
|
global $themename, $shortname,$id_setting;
|
|
|
|
$themename = "Medical Alert eCommerce";
|
|
$save=false;
|
|
if ( 'save' == $_POST['action'] ) {
|
|
$save=true;
|
|
foreach($id_setting as $id_single) {
|
|
update_option( sanitize_text_field($id_single['option_name']), sanitize_text_field($_POST[$id_single['option_name']]) );
|
|
$i++;
|
|
}
|
|
}
|
|
|
|
if ( $save ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' Settings save..</strong></p></div>';
|
|
?>
|
|
<div id="main_admin">
|
|
<?php $admin_header = "<h1>".$themename." </h1>";
|
|
echo $admin_header;
|
|
?>
|
|
<form method="post">
|
|
<table>
|
|
<?php
|
|
$i=0;
|
|
foreach($id_setting as $id_single) {?><tr><?php
|
|
switch($id_single['type'])
|
|
{
|
|
case 'input':
|
|
{
|
|
?>
|
|
<td><?=$id_single['name'] ?></td>
|
|
<td><input type="text" name="<?=$id_single['option_name'];?>" id="<?=$id_single['option_name'];?>" value="<?php if ( get_option( $id_single['option_name'] ) != "") { echo stripslashes(get_option( $id_single['option_name'] ) ); } ?>" />
|
|
<?php if(strpos($id_single['option_name'], 'color')){echo '<div style ="width:20px; height: 20px; margin-top: -25px;margin-left: 170px;position: absolute; background-color:'.get_option($id_single['option_name']).';" class="choosen_color"></div>';}?>
|
|
</td>
|
|
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
case 'select-environment':
|
|
{
|
|
?>
|
|
<td><?=$id_single['name'] ?></td>
|
|
<td>
|
|
<?php $selectEnv = get_option('select-environment'); ?>
|
|
<select name="select-environment">
|
|
<option value="development" <?php if($selectEnv=="development") echo 'selected="selected"'; ?>>Development</option>
|
|
<option value="staging" <?php if($selectEnv=="staging") echo 'selected="selected"'; ?>>Staging</option>
|
|
<option value="production" <?php if($selectEnv=="production") echo 'selected="selected"'; ?>>Production</option>
|
|
</select>
|
|
</td>
|
|
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
|
|
case 'select-api':
|
|
{
|
|
?>
|
|
|
|
|
|
<td><?=$id_single['name'] ?></td>
|
|
|
|
<?php
|
|
$sfdcEnv = get_option('select-environment');
|
|
if ($sfdcEnv == 'development') {
|
|
update_option( 'id_api_salesforce', 'https://partial-connectamerica.cs67.force.com/RestServices/services/apexrest/' );
|
|
} elseif ($sfdcEnv =='staging') {
|
|
update_option( 'id_api_salesforce', 'https://connectamerica--full.sandbox.my.salesforce-sites.com/RestServices/services/apexrest/' );
|
|
|
|
} else {
|
|
update_option( 'id_api_salesforce', 'https://connectamerica.my.salesforce-sites.com/RestServices/services/apexrest/' );
|
|
}
|
|
|
|
?>
|
|
<td>
|
|
<?php echo get_option('id_api_salesforce'); ?>
|
|
</td>
|
|
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
case 'title':
|
|
{
|
|
?>
|
|
<td><h1><? echo $id_single['name'] ?></h1></td>
|
|
<?php
|
|
break;
|
|
}
|
|
case 'textarea':
|
|
{
|
|
?>
|
|
<td><? echo $id_single['name'] ?></td>
|
|
<td><textarea name="<?=$id_single['option_name'];?>" id="<?=$id_single['option_name'];?>" ><?php if ( get_option( $id_single['option_name'] ) != "") { echo stripslashes(get_option( $id_single['option_name'] ) ); } ?></textarea></td>
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
|
|
case 'select-page':
|
|
{
|
|
?>
|
|
<td><? echo $id_single['name']?></td>
|
|
<td><?php echo wp_dropdown_pages(array('echo' => 0,'name' => $id_single['option_name'], 'selected' => get_option($id_single['option_name']))); ?></td>
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
|
|
}
|
|
case 'select-category':
|
|
{
|
|
?>
|
|
<td><?=$id_single['name']?></td>
|
|
<td><?=wp_dropdown_categories(array('hide_empty'=>0,'echo' => 0,'name' => $id_single['option_name'], 'selected' => stripslashes(get_option($id_single['option_name']))));?></td>
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
case 'select-product_tags':
|
|
{
|
|
?>
|
|
<td><?=$id_single['name']?></td>
|
|
<td><?=wp_dropdown_categories(array('hide_empty'=>0,'echo' => 0,'taxonomy' => 'product_tag','name' => $id_single['option_name'], 'selected' => stripslashes(get_option($id_single['option_name']))));?></td>
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
case 'select-product_category':
|
|
{
|
|
?>
|
|
<td><?=$id_single['name']?></td>
|
|
<td><?=wp_dropdown_categories(array('hide_empty'=>0,'echo' => 0,'taxonomy' => 'wpsc_product_category','name' => $id_single['option_name'], 'selected' => stripslashes(get_option($id_single['option_name']))));?></td>
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
case 'select-image':
|
|
{
|
|
?>
|
|
<td><?=$id_single['name']?></td>
|
|
<td><?php images_dropdown($id_single['option_name'],$id_single['option_name'],stripslashes(get_option($id_single['option_name'])));?></td>
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
case 'select-phone':
|
|
{
|
|
update_option('cta_tel', '800-800-2537');
|
|
$phoneNumber = get_option('cta_tel',true);
|
|
?>
|
|
<td><?=$id_single['name']?></td>
|
|
<td><?php echo $phoneNumber;?></td>
|
|
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
case 'select-brand':
|
|
{
|
|
|
|
update_option('id_brand', 'MedicalAlert');
|
|
$brand = get_option('id_brand');
|
|
?>
|
|
<td><?=$id_single['name']?></td>
|
|
<td><?php echo $brand;?></td>
|
|
|
|
<?php
|
|
break;
|
|
}
|
|
|
|
case 'select-pdf':
|
|
{
|
|
?>
|
|
<td><?=$id_single['name']?></td>
|
|
<td><?php pdf_dropdown($id_single['option_name'],$id_single['option_name'],stripslashes(get_option($id_single['option_name'])));?></td>
|
|
<td><p class="description"><?=$id_single['description']?></p></td>
|
|
<?php
|
|
break;
|
|
}
|
|
}
|
|
$i++;?></tr><?php
|
|
}
|
|
?>
|
|
</table>
|
|
<div id="inputs">
|
|
<input type="submit" value="save options" class="button-primary" />
|
|
<input type="hidden" name="action" value="save" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include_once "admin-cron.php"; ?>
|
|
<?php }
|
|
|
|
|
|
|
|
function theme_scripts_important() {
|
|
wp_enqueue_script( 'auto-complete', plugin_dir_url( __FILE__ ).'/templates/script/auto-complete.js');
|
|
wp_enqueue_script( 'mobiscroll', plugin_dir_url( __FILE__ ).'/templates/script/mobiscroll.jquery.min.js', array('jquery'));
|
|
wp_enqueue_style('mobiscroll', plugin_dir_url( __FILE__) .'/templates/script/mobiscroll.jquery.min.css');
|
|
wp_enqueue_style('fontawesome', 'https://use.fontawesome.com/releases/v5.8.1/css/all.css', '', '5.8.1', 'all');
|
|
wp_enqueue_script( 'jquery.cookie', plugin_dir_url( __FILE__ ) . 'templates/script/jquery.cookie.min.js', array( 'jquery' ) );
|
|
wp_enqueue_style( 'style', plugin_dir_url( __FILE__ ).'templates/style.css', array(), medical_version());
|
|
wp_enqueue_script( 'select-product', plugin_dir_url( __FILE__ ). '/templates/script/select-product.js', array ( 'jquery' ), medical_version(), true);
|
|
wp_enqueue_script( 'iperjs', plugin_dir_url( __FILE__ ). '/templates/script/iperjs.js', array('jquery'), filemtime( get_stylesheet_directory() . '/js/iperjs.js' ), true );
|
|
wp_enqueue_script( 'cart_functions', plugin_dir_url( __FILE__ ). '/templates/script/cart_functions.js', array('jquery'), filemtime( get_stylesheet_directory() . '/js/cart_functions.js' ), true );
|
|
wp_localize_script( 'iperjs', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ) );
|
|
wp_localize_script( 'iperjs', 'ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ),'plugin_url'=> plugin_dir_url( __FILE__ )) );
|
|
wp_enqueue_script( 'bootstrap-select', plugin_dir_url( __FILE__ ). '/templates/bootstrap/js/bootstrap-select.min.js', array('jquery'), false, true );
|
|
wp_enqueue_style( 'bootstrap-select', plugin_dir_url( __FILE__ ).'/templates/bootstrap/css/bootstrap-select.min.css', array(), false );
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'theme_scripts_important', 15 );
|
|
|
|
function theme_scripts() {
|
|
wp_enqueue_script( 'bootstrap-js', plugin_dir_url( __FILE__ ). 'templates/bootstrap/js/bootstrap.bundle.min.js', array('jquery'), false, true );
|
|
wp_enqueue_style( 'bootstrap', plugin_dir_url( __FILE__ ).'templates/bootstrap/css/bootstrap.min.css', array(), false );
|
|
wp_enqueue_script( 'jquery', plugin_dir_url( __FILE__ ). 'templates/script/jquery-3.4.1.min.js', array(), false, true );
|
|
wp_enqueue_script( 'sticky', plugin_dir_url( __FILE__ ). 'templates/script/jquery.sticky.js', array('jquery'), false, true );
|
|
|
|
|
|
}
|
|
|
|
add_action( 'wp_enqueue_scripts', 'theme_scripts' );
|
|
|
|
// ADD ACTIVE BTN TO PRODUCT POST
|
|
function publish_in_frontpage($post){
|
|
|
|
$value = get_post_meta($post->ID, 'publish_in_frontpage', true);
|
|
|
|
echo '<div class="misc-pub-section misc-pub-section-last"><span id="timestamp">'
|
|
. '<label><input type="checkbox"' . (!empty($value) ? ' checked="checked" ' : null) . 'value="1" name="publish_in_frontpage" /> Featured</label>'
|
|
.'</span></div>';
|
|
}
|
|
add_action( 'post_submitbox_misc_actions', 'publish_in_frontpage' );
|
|
|
|
function order_priority($post){
|
|
|
|
$value = get_post_meta($post->ID, 'order_priority', true);
|
|
|
|
$html_1 = '<div class="misc-pub-section misc-pub-section-last order_priority"><label>Order Priority: </label>
|
|
<select id="order_priority_value" name="order_priority_value">';
|
|
$html_2 = '<option value="-" selected>-</option>';
|
|
|
|
for($i=0; $i<5; $i++){
|
|
|
|
$if_selected='';
|
|
if(get_post_meta($post->ID, 'order_priority', true)==$i && get_post_meta($post->ID, 'order_priority', true) != '' && get_post_meta($post->ID, 'order_priority', true) != '-')
|
|
{$if_selected = 'selected';} else { $if_selected='';}
|
|
$html_2 .= '<option value="'.$i.'" '.$if_selected.'>'.$i.'</option>';}
|
|
|
|
$html_3 = '</select></div>';
|
|
$html = $html_1.$html_2.$html_3;
|
|
echo $html;
|
|
}
|
|
|
|
add_action( 'post_submitbox_misc_actions', 'order_priority' );
|
|
|
|
function meta_sortable($post){
|
|
|
|
switch ( $post->post_type ) {
|
|
|
|
case 'rateplan':
|
|
|
|
$value = get_post_meta($post->ID, 'order_priority', true);
|
|
|
|
$html = '<div class="misc-pub-section misc-pub-section-last order_priority"><label>Related Product: </label><strong>'.get_post_meta($post->ID, 'product_rateplan', true).'</strong></div>';
|
|
echo $html;
|
|
break;
|
|
|
|
case 'upsell':
|
|
|
|
$html1 = '<div class="misc-pub-section misc-pub-section-last order_priority"><label>Related Product: </label><strong>'.get_post_meta($post->ID, 'product_upsell', true).'</strong></div>';
|
|
$html2 = '<div class="misc-pub-section misc-pub-section-last order_priority"><label>Related RatePlan: </label><strong>'.get_post_meta($post->ID, 'rateplan_upsell', true).'</strong></div>';
|
|
|
|
echo $html1.$html2;
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
add_action( 'post_submitbox_misc_actions', 'meta_sortable' );
|
|
|
|
|
|
|
|
|
|
|
|
function save_postdata($postid){
|
|
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return false;
|
|
if ( !current_user_can( 'edit_page', $postid ) ) return false;
|
|
if(empty($postid) || $_POST['post_type'] != ('product' || 'rateplan')) return false;
|
|
|
|
if($_POST['action'] == 'editpost'){
|
|
delete_post_meta($postid, 'publish_in_frontpage');
|
|
delete_post_meta($postid, 'order_priority');
|
|
}
|
|
|
|
add_post_meta($postid, 'publish_in_frontpage', sanitize_text_field($_POST['publish_in_frontpage']));
|
|
add_post_meta($postid, 'order_priority', sanitize_text_field($_POST['order_priority_value']));
|
|
|
|
|
|
update_post_meta($postid, '_wp_page_template', sanitize_text_field($_POST['page_template']));
|
|
/* update_post_meta($postid, 'order_priority', $_POST['order_priority_value']);*/
|
|
}
|
|
|
|
add_action( 'save_post', 'save_postdata');
|
|
|
|
function hex2rgba($color, $opacity = false) {
|
|
|
|
$default = 'rgb(0,0,0)';
|
|
|
|
//Return default if no color provided
|
|
if(empty($color))
|
|
return $default;
|
|
|
|
//Sanitize $color if "#" is provided
|
|
if ($color[0] == '#' ) {
|
|
$color = substr( $color, 1 );
|
|
}
|
|
|
|
//Check if color has 6 or 3 characters and get values
|
|
if (strlen($color) == 6) {
|
|
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
|
|
} elseif ( strlen( $color ) == 3 ) {
|
|
$hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
|
|
} else {
|
|
return $default;
|
|
}
|
|
|
|
//Convert hexadec to rgb
|
|
$rgb = array_map('hexdec', $hex);
|
|
|
|
//Check if opacity is set(rgba or rgb)
|
|
if($opacity){
|
|
if(abs($opacity) > 1)
|
|
$opacity = 1.0;
|
|
$output = 'rgba('.implode(",",$rgb).','.$opacity.')';
|
|
} else {
|
|
$output = 'rgb('.implode(",",$rgb).')';
|
|
}
|
|
|
|
//Return rgb(a) color string
|
|
return $output;}
|
|
|
|
|
|
|
|
function iper_set_style($btn_color, $card_color, $nav_active_color, $btn_accessories, $btn_place_order){
|
|
|
|
?>
|
|
|
|
<style type="text/css">
|
|
.btn-orange{background-color:<?php echo $btn_color; ?>;}
|
|
.btn-orange:hover{color: <?php echo $nav_active_color; ?>;}
|
|
|
|
/*.breadcrumb-navbar ul li{background-color:<?php echo $nav_active_color; ?>;}*/
|
|
/*.breadcrumb-navbar ul li:hover{background-color:<?php echo $card_color; ?>;}
|
|
.breadcrumb-navbar ul li:hover span{background-color:<?php echo $nav_active_color; ?>;}*/
|
|
/*.breadcrumb-navbar ul li:last-child .item:before{border-color:transparent transparent transparent <?php echo $nav_active_color; ?>;}*/
|
|
|
|
.list-product .card-container .card .content .list-accessories ul li:before{color:<?php echo $btn_color; ?>;}
|
|
.breadcrumb-navbar ul li.active a{color:<?php echo $nav_active_color; ?>!important}
|
|
/*.breadcrumb-navbar ul li a>span{background-color:<?php echo $card_color; ?>;}*/
|
|
.list-product .card-container .card{background-color:<?php echo $card_color; ?>;}
|
|
|
|
.list-product .card-container:hover .card,
|
|
.list-product .card-container.active .card{background-color:<?php echo $nav_active_color; ?>;}
|
|
|
|
#preview-select-payment .title{background-color:<?php echo $card_color; ?>;}
|
|
|
|
|
|
.card-select:hover > a.btn, .card-select.active > a.btn{background-color:<?php echo $btn_color; ?>;}
|
|
|
|
.btn-grey2{-webkit-appearance: none;background-color:<?php echo $btn_accessories; ?>;-webkit-text-fill-color: #fff;}
|
|
.card-select:hover .checkbox:before, .card-select.active .checkbox:before{color:<?php echo $btn_color; ?>;}
|
|
.btn-grey1{background-color:<?php echo $btn_accessories; ?>;}
|
|
.btn-grey1:hover{background-color:<?php echo $btn_color; ?>;}
|
|
.btn-red1{background-color:<?php echo $btn_place_order; ?>;}
|
|
.btn-red{-webkit-appearance: none;background-color:<?php echo $btn_place_order; ?>;-webkit-text-fill-color: #fff;}
|
|
.btn-grey{background-color:<?php echo $btn_accessories; ?>;}
|
|
|
|
.title-page{ color:<?php echo $btn_place_order; ?>;}
|
|
.title-page>span{background-color:<?php echo $btn_place_order; ?>;}
|
|
|
|
.most-popular{background-color:<?php echo $btn_place_order; ?>!important;}
|
|
.most-popular:after{border-color: transparent transparent transparent <?php echo $btn_place_order; ?>;}
|
|
/*.#slider-home .item .call-out{background-color: rgba(13,13,13,0.5) url("images/arrow-slide-contact.png") no-repeat 80% top;!important*/
|
|
|
|
#slider-home .item .disclaimer{background-color: <?php echo hex2rgba($nav_active_color, 0.9); ?>;}
|
|
/*#slider-product .item .disclaimer{background-color: <?php echo hex2rgba($nav_active_color, 0.9); ?>;}*/
|
|
|
|
.product-name{color:<?php echo $nav_active_color; ?>!important; }
|
|
.modal-body .detail-plan h1{color:<?php echo $nav_active_color; ?>}
|
|
.modal-content .upsell_price{color:<?php echo $nav_active_color; ?>}
|
|
#slider-product .item .call-out{<?php echo $btn_place_order; ?> url("images/arrow-slide-contact.png") no-repeat 80% top}
|
|
|
|
@media (max-width: 992px) {
|
|
button.close {
|
|
color: <?php echo $card_color; ?>;
|
|
}
|
|
}
|
|
|
|
</style>
|
|
|
|
<?php
|
|
}
|
|
|
|
if(!function_exists('callDBStored')){
|
|
function callDBStored($preparedData,$single=false,$type=OBJECT)
|
|
{
|
|
|
|
$res = false;
|
|
$new_db = new wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
|
|
if(!$new_db){
|
|
throw new Exception('no costants set');
|
|
}
|
|
|
|
try {
|
|
|
|
if ($single) {
|
|
$res = $new_db->get_row($preparedData, $type);
|
|
} else {
|
|
$res = $new_db->get_results($preparedData, $type);
|
|
}
|
|
|
|
if ($new_db->last_errors != "") {
|
|
die("ERROR ON SQL \n" . $new_db->last_errors . "\n SQL: " . $new_db->last_query);
|
|
}
|
|
|
|
unset($new_db);
|
|
|
|
return $res;
|
|
} catch (Exception $e) {
|
|
echo 'Caught exception: ', $e->getMessage(), "\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
function call_the_style(){
|
|
iper_set_style(get_option('id_product_color'), get_option('id_product_background_color'), get_option('id_in_evidence_color'), get_option('id_acc_btn_color'), get_option('id_next_btn_color'));
|
|
}
|
|
|
|
function iper_hook_css(){
|
|
add_action('wp_head','call_the_style');
|
|
}
|
|
|
|
add_action ( 'wp_head', 'googleapi' );
|
|
|
|
function googleapi(){
|
|
global $CountdownDate;
|
|
global $days_from_eom;
|
|
global $finaldate;
|
|
?>
|
|
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAVZFBnIXRorR_YmW6M01AL2MBuE5mrPtg&libraries=places&callback=initAutocomplete" ></script>
|
|
|
|
<?php
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
add_filter( 'manage_posts_columns', 'rachel_carden_managing_my_posts_columns', 10, 2);
|
|
function rachel_carden_managing_my_posts_columns( $columns, $post_type ) {
|
|
|
|
|
|
switch ( $post_type ) {
|
|
case 'rateplan':
|
|
$new_columns = array();
|
|
foreach( $columns as $key => $value ) {
|
|
$new_columns[ $key ] = $value;
|
|
if ( $key == 'title' )
|
|
|
|
$new_columns[ 'product_rateplan' ] = 'Related Product';
|
|
$new_columns[ 'order_priority' ] = 'Order Priority';
|
|
|
|
}
|
|
return $new_columns;
|
|
|
|
case 'upsell':
|
|
$new_columns = array();
|
|
foreach( $columns as $key => $value ) {
|
|
$new_columns[ $key ] = $value;
|
|
if ( $key == 'title' )
|
|
|
|
$new_columns[ 'product_upsell' ] = 'Related Product';
|
|
$new_columns[ 'rate_plan' ] = 'Related RatePlan';
|
|
$new_columns[ 'order_priority' ] = 'Order Priority';
|
|
|
|
}
|
|
return $new_columns;
|
|
case 'product':
|
|
$new_columns = array();
|
|
foreach( $columns as $key => $value ) {
|
|
$new_columns[ $key ] = $value;
|
|
if ( $key == 'title' )
|
|
|
|
$new_columns[ 'order_priority' ] = 'order priority';
|
|
|
|
}
|
|
return $new_columns;
|
|
|
|
|
|
}
|
|
|
|
return $columns;
|
|
}
|
|
|
|
add_action('manage_posts_custom_column', 'manage_posts_custom_column_callback', 10, 2);
|
|
function manage_posts_custom_column_callback( $column_name, $post_id ) {
|
|
global $post;
|
|
|
|
if (get_post_meta($post->ID, 'order_priority', true) == '' || get_post_meta($post->ID, 'order_priority', true) == ' ') {
|
|
add_post_meta($post->ID, 'order_priority', '-');
|
|
update_post_meta($post->ID, 'order_priority', '-');
|
|
}
|
|
|
|
$post_id = sanitize_text_field($post_id);
|
|
|
|
switch ($column_name) {
|
|
case 'product_rateplan':
|
|
echo '<div id="' . $post_id . '">' . get_post_meta($post_id, 'product_rateplan', true) . '</div>';
|
|
break;
|
|
case 'order_priority':
|
|
echo '<div id="' . $post_id . '">' . get_post_meta($post_id, 'order_priority', true) . '</div>';
|
|
break;
|
|
case 'rate_plan':
|
|
echo '<div id="' . $post_id . '">' . get_post_meta($post_id, 'rateplan_upsell', true) . '</div>';
|
|
break;
|
|
case 'product_upsell':
|
|
echo '<div id="' . $post_id . '">' . get_post_meta($post_id, 'product_upsell', true) . '</div>';
|
|
break;
|
|
}
|
|
}
|
|
|
|
add_filter('manage_edit-rateplan_sortable_columns', 'tcb_register_rateplan_sortable_columns');
|
|
add_filter('manage_edit-upsell_sortable_columns', 'tcb_register_upsell_sortable_columns');
|
|
add_filter('manage_edit-product_sortable_columns', 'tcb_register_product_sortable_columns');
|
|
function tcb_register_rateplan_sortable_columns( $columns ){
|
|
$columns['order_priority'] = 'order_priority';
|
|
$columns['product_rateplan'] = 'product_rateplan';
|
|
return $columns;
|
|
}
|
|
function tcb_register_product_sortable_columns( $columns ){
|
|
$columns['order_priority'] = 'order_priority';
|
|
return $columns;
|
|
}
|
|
function tcb_register_upsell_sortable_columns( $columns ){
|
|
$columns['order_priority'] = 'order_priority';
|
|
$columns['rate_plan'] = 'rateplan_upsell';
|
|
$columns['product_upsell'] = 'product_upsell';
|
|
return $columns;
|
|
}
|
|
|
|
add_action( 'pre_get_posts', 'manage_wp_posts_be_qe_pre_get_posts', 1 );
|
|
function manage_wp_posts_be_qe_pre_get_posts( $query ) {
|
|
|
|
/**
|
|
* We only want our code to run in the main WP query
|
|
* AND if an orderby query variable is designated.
|
|
*/
|
|
if ( $query->is_main_query() && ( $orderby = $query->get( 'orderby' ) ) ) {
|
|
|
|
switch( $orderby ) {
|
|
|
|
// If we're ordering by 'film_rating'
|
|
case 'order_priority':
|
|
|
|
// set our query's meta_key, which is used for custom fields
|
|
$query->set( 'meta_key', 'order_priority' );
|
|
|
|
/**
|
|
* Tell the query to order by our custom field/meta_key's
|
|
* value, in this film rating's case: PG, PG-13, R, etc.
|
|
*
|
|
* If your meta value are numbers, change 'meta_value'
|
|
* to 'meta_value_num'.
|
|
*/
|
|
$query->set( 'orderby', 'meta_value_num' );
|
|
|
|
break;
|
|
|
|
case 'rate_plan':
|
|
|
|
// set our query's meta_key, which is used for custom fields
|
|
$query->set( 'meta_key', 'rateplan_upsell' );
|
|
|
|
/**
|
|
* Tell the query to order by our custom field/meta_key's
|
|
* value, in this film rating's case: PG, PG-13, R, etc.
|
|
*
|
|
* If your meta value are numbers, change 'meta_value'
|
|
* to 'meta_value_num'.
|
|
*/
|
|
$query->set( 'orderby', 'meta_value' );
|
|
|
|
break;
|
|
|
|
case 'product_upsell':
|
|
|
|
// set our query's meta_key, which is used for custom fields
|
|
$query->set( 'meta_key', 'product_upsell' );
|
|
|
|
/**
|
|
* Tell the query to order by our custom field/meta_key's
|
|
* value, in this film rating's case: PG, PG-13, R, etc.
|
|
*
|
|
* If your meta value are numbers, change 'meta_value'
|
|
* to 'meta_value_num'.
|
|
*/
|
|
$query->set( 'orderby', 'meta_value' );
|
|
|
|
break;
|
|
|
|
case 'product_rateplan':
|
|
|
|
// set our query's meta_key, which is used for custom fields
|
|
$query->set( 'meta_key', 'product_rateplan' );
|
|
|
|
/**
|
|
* Tell the query to order by our custom field/meta_key's
|
|
* value, in this film rating's case: PG, PG-13, R, etc.
|
|
*
|
|
* If your meta value are numbers, change 'meta_value'
|
|
* to 'meta_value_num'.
|
|
*/
|
|
$query->set( 'orderby', 'meta_value' );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
add_action( 'init', create_function('', 'register_shortcode_ajax( "ajax_shortcode", "ajax_shortcode" ); '));
|
|
|
|
function register_shortcode_ajax( $callable, $action ) {
|
|
if ( empty( $_POST['action'] ) || $_POST['action'] != $action )
|
|
return;
|
|
call_user_func( $callable );
|
|
}
|
|
|
|
include_once("page-types.php");
|
|
include_once("medical-shortcode.php");
|
|
include_once("medical-metabox.php");
|
|
|
|
// medical alert encryption classes
|
|
include_once("encryption/message-content.php");
|
|
include_once("encryption/message-content-signed.php");
|
|
include_once("encryption/encrypted-content.php");
|
|
include_once("encryption/secured-content.php");
|
|
|