function test() { if (cjtheme_get_option('maintenance_mode_status') == 'enable') { echo '<div class="error"> <p> ' . sprintf(__('Maintenance mode is active. <a href="%s">Manage Settings</a>', 'cjtheme'), cjtheme_callback_url('core_maintenance_mode')) . ' </p> </div>'; } }
function cjtheme_replace_user_menus($args = '') { global $wpdb, $current_user; $user_role = cjtheme_user_role($current_user->ID); $cjtheme_role_menus = cjtheme_get_option('cjtheme_role_menus'); if (isset($cjtheme_role_menus[$user_role]) && $cjtheme_role_menus[$user_role]['menu_location'] != '') { if ($args['theme_location'] == $cjtheme_role_menus[$user_role]['menu_location']) { $args['menu'] = $cjtheme_role_menus[$user_role]['menu']; } } return $args; }
function cjtheme_price_finder_get_price() { global $wpdb; $api_url = cjtheme_get_option('api_url'); parse_str($_POST['formdata'], $formdata); $api_url = $api_url . 'get-price/' . $formdata['brands'] . '/' . $formdata['models']; $data = wp_remote_get($api_url); $data = json_decode($data['body']); if (!$data->error) { $display[] = '<div class="table-responsive">'; $display[] = '<table class="table table-striped table-hover">'; $display[] = '<thead>'; $display[] = '<tr>'; $display[] = '<th width="200px">Variant Name</th>'; $display[] = '<th width="200px" class="textcenter">Fuel</th>'; $display[] = '<th width="200px" class="textcenter">Delhi</th>'; $display[] = '<th width="200px" class="textcenter">Mumbai</th>'; $display[] = '<th width="200px" class="textcenter">Chennai</th>'; $display[] = '<th width="200px" class="textcenter">Bangolore</th>'; $display[] = '<th width="200px" class="textcenter">Chandigarh</th>'; $display[] = '</tr>'; $display[] = '</thead>'; $display[] = '<tbody>'; foreach ($data->models as $key => $value) { foreach ($value as $key => $ovalue) { $delhipric = $ovalue->delhipric > 0 ? '₹ ' . cjtheme_inr($ovalue->delhipric) : '--'; $mumpric = $ovalue->mumpric > 0 ? '₹ ' . cjtheme_inr($ovalue->mumpric) : '--'; $chennaipric = $ovalue->chennaipric > 0 ? '₹ ' . cjtheme_inr($ovalue->chennaipric) : '--'; $bangalorepric = $ovalue->bangalorepric > 0 ? '₹ ' . cjtheme_inr($ovalue->bangalorepric) : '--'; $chdpric = $ovalue->chdpric > 0 ? '₹ ' . cjtheme_inr($ovalue->chdpric) : '--'; $display[] = '<tr>'; $display[] = '<td width="200px">' . $ovalue->name . '</td>'; $display[] = '<td width="200px" class="textcenter">' . $ovalue->type . '</td>'; $display[] = '<td width="200px" class="textcenter">' . $delhipric . '</td>'; $display[] = '<td width="200px" class="textcenter">' . $mumpric . '</td>'; $display[] = '<td width="200px" class="textcenter">' . $chennaipric . '</td>'; $display[] = '<td width="200px" class="textcenter">' . $bangalorepric . '</td>'; $display[] = '<td width="200px" class="textcenter">' . $chdpric . '</td>'; $display[] = '</tr>'; } } $display[] = '</tbody>'; $display[] = '</table>'; $display[] = '</div>'; } else { $display[] = cjtheme_show_message('warning', 'No data found.'); } echo implode('', $display); die; }
function cjtheme_custom_js_code_files() { $js_code = cjtheme_get_option('wp_head_js_code'); if ($js_code) { echo '<script type="text/javascript">'; echo $js_code; echo '</script>'; } $js_files = cjtheme_get_option('wp_head_js_files'); if ($js_files) { $files_array = explode("\n", $js_files); foreach ($files_array as $key => $value) { echo '<script type="text/javascript" src="' . $value . '"></script>'; } } }
?> </a> </div><!-- /.questions-extra-buttons --> <?php } ?> </div><!-- /.section-content --> </section><!-- /#latest-news --> </main><!-- /#main --> <div class="col-sm-5 col-lg-5"> <section id="latest-questions"> <?php global $current_user; $question_cats = get_terms('qna_type', array('hide_empty' => 0)); $show_only = cjtheme_get_option('question_cats'); $include = array(); if ($show_only != '') { $include = ''; foreach ($show_only as $key => $value) { $value = explode('~~~~', $value); $include[] = $value[0]; } } ?> <header class="section-header"> <h1 class="section-title">Latest Questions</h1><!-- /.section-title --> </header><!-- /.section-header --> <div class="section-content"> <form action="" method="post" class="ask-question">
function cjtheme_google_fonts_string() { global $cjtheme_item_vars; $google_fonts = cjtheme_get_option('google_fonts'); $load_google_fonts_array = array(); if (!empty($google_fonts)) { $google_fonts_keys = array_keys(cjtheme_get_option('google_fonts')); $item_options = cjtheme_item_options(); foreach ($item_options as $key => $options) { foreach ($options as $key => $option) { if ($option['type'] == 'font') { $font_vars = cjtheme_get_option($option['id']); if (in_array($font_vars['family'], $google_fonts_keys)) { $load_google_fonts_array[$font_vars['family']] = $font_vars['family']; } } } } foreach ($load_google_fonts_array as $key => $font) { $string[] = str_replace(' ', '+', $key); } if (!empty($load_google_fonts_array)) { $return = @implode('|', $string); return $return; } else { return null; } } }
function cjtheme_footer_code() { $footer_code = cjtheme_get_option('wp_footer_code'); $analytics_scripts = cjtheme_get_option('analytics_scripts'); $footer_hidden_code = cjtheme_get_option('wp_footer_code_hidden'); echo do_shortcode($footer_code); echo str_replace(array(' ', "\n", "\t"), '', $analytics_scripts); echo '<div class="hidden">'; echo $footer_hidden_code; echo '</div>'; }
<?php global $wp_roles; $menu_locations = get_registered_nav_menus(); $saved_menus = cjtheme_navigation_menus(); $roles = $wp_roles->role_names; $roles['non-user'] = __('Visitor', 'cjtheme'); $cjtheme_role_menus = cjtheme_get_option('cjtheme_role_menus'); if (isset($_POST['cjtheme_save_menus'])) { cjtheme_update_option('cjtheme_role_menus', $_POST['data']); $location = cjtheme_string(cjtheme_callback_url()) . 'msg=saved'; wp_safe_redirect($location); exit; } if (isset($_GET['msg']) && $_GET['msg'] == 'saved') { echo cjtheme_show_message('success', __('Menu options saved successfully.', 'cjtheme')); } ?> <form action="" method="post"> <table width="100%" cellpadding="0" cellspacing="0"> <thead> <tr> <th colspan="3"><h2 class="main-heading"><?php _e('Role Based Menus', 'cjtheme'); ?> </h2></th> </tr> <tr> <td width="15%"><?php _e('User Role', 'cjtheme'); ?>
<?php # Sync Dynamic Sidebars (if present) #################################################################################################### $saved_sidebars = cjtheme_get_option('dynamic_sidebars'); if (!empty($saved_sidebars)) { foreach ($saved_sidebars as $key => $sidebar) { $sidebar_vars = cjtheme_item_vars('sidebar_vars'); $args = array('name' => $sidebar['name'], 'id' => $key, 'description' => $sidebar['description'], 'class' => $sidebar['class'], 'before_widget' => $sidebar_vars['before_widget'], 'after_widget' => $sidebar_vars['after_widget'], 'before_title' => $sidebar_vars['before_title'], 'after_title' => $sidebar_vars['after_title']); register_sidebar($args); } } # Dynamic Sidebar Meta Box #################################################################################################### add_filter('cmb_meta_boxes', 'cjtheme_custom_sidebar_metabox'); function cjtheme_custom_sidebar_metabox(array $meta_boxes) { global $wp_registered_sidebars; $default_post_types = array('post', 'page'); $custom_post_types = cjtheme_item_vars('custom_post_types'); if (!empty($custom_post_types)) { $custom_post_types = @array_keys($custom_post_types); if (is_array($custom_post_types)) { $show_metabox_on = array_merge($custom_post_types, $default_post_types); } else { $show_metabox_on = $default_post_types; } } else { $show_metabox_on = $default_post_types; } if (!empty($wp_registered_sidebars)) {
$opts .= '<label class="texture checked" for="label-' . $key . '" class="texture" style="background:#ccc url(' . $value . ') repeat;"><input class="hidden" checked id="label-' . $key . '" name="' . $option['id'] . '" value="' . $value . '" type="radio" /></label>'; } else { $opts .= '<label class="texture" for="label-' . $key . '" class="texture" style="background:#ccc url(' . $value . ') repeat;"><input class="hidden" id="label-' . $key . '" name="' . $option['id'] . '" value="' . $value . '" type="radio" /></label>'; } } $display[] = '<tr class="searchable"><td class="cj-label"><label for="' . sanitize_title($option['id']) . '">' . __($option['label'], 'cjtheme') . '</label></td>'; $display[] = '<td class="cj-panel">'; $display[] = '<div class="cj-textures">'; $display[] = $opts; $display[] = '</div>'; $display[] = '<div class="cj-info">' . __($option['info'], 'cjtheme') . '</div>'; $display[] = '</td>'; $display[] = '</tr>'; } if ($option['type'] == 'font') { $google_fonts_array = cjtheme_get_option('google_fonts'); $google_fonts['inherit'] = 'Inherit'; $google_fonts['Arial'] = 'Arial'; $google_fonts['Arial Black'] = 'Arial Black'; $google_fonts['Helvetica'] = 'Helvetica'; $google_fonts['Georgia'] = 'Georgia'; $google_fonts['Trebuchet MS'] = 'Trebuchet MS'; $google_fonts['Verdana'] = 'Verdana'; $google_fonts['Palatino Linotype'] = 'Palatino Linotype'; $google_fonts['Book Antiqua'] = 'Book Antiqua'; $google_fonts['Palatino'] = 'Palatino'; $google_fonts['Times New Roman'] = 'Times New Roman'; $google_fonts['Times'] = 'Times'; $google_fonts['Gadget'] = 'Gadget'; $google_fonts['Comic Sans MS'] = 'Comic Sans MS'; $google_fonts['Impact'] = 'Impact';
jQuery( "#' . $option['id'] . '" ).disableSelection(); }); </script>'; $display[] = '</td>'; $display[] = '</tr>'; } if ($option['type'] == 'background') { $display[] = '<tr class="searchable" class="cj-background"><td class="cj-label"><label for="' . sanitize_title($option['id']) . '">' . __($option['label'], 'cjtheme') . '</label></td>'; $display[] = '<td class="cj-panel">'; $opt_value['color'] = 'Transparent'; $opt_value['image'] = null; $opt_value['bg_repeat'] = null; $opt_value['bg_size'] = null; $opt_value['bg_attachment'] = null; $opt_value['bg_position'] = null; $opt_value = cjtheme_get_option($option['id']); // Color $saved_hex = isset($opt_value['color']) && $opt_value['color'] != '' ? $opt_value['color'] : ''; $saved_color_hex = $saved_hex == '' ? __('Transparent', 'cjtheme') : $saved_hex; $display[] = '<p><input type="text" name="' . $option['id'] . '[color]" id="' . sanitize_title($option['id'] . '_color') . '" value="' . $saved_color_hex . '" data-color="' . $saved_color_hex . '" class="color-picker" /> <span class="color-hex"><code>' . $saved_color_hex . '</code></span></p>'; // Image $opts = null; $saved_file = isset($opt_value['image']) ? $opt_value['image'] : ''; if ($saved_file != '') { $opts .= '<div class="file-list">'; $opts .= '<div class="file-info">'; $opts .= '<a href="' . $saved_file . '" target="_blank">' . basename($saved_file) . '</a>'; $opts .= '<input type="hidden" name="' . $option['id'] . '[image]" value="' . $saved_file . '" />'; $opts .= '<a href="#" class="cj-remove-background-file"><i class="fa fa-times"></i></a>'; $opts .= '</div>'; $opts .= '<div class="padding-10">';
function cjtheme_sync_car_research() { global $wpdb, $current_user; $api_url = cjtheme_get_option('api_url'); // sync models $models = wp_remote_get($api_url . 'models'); $models = json_decode($models['body']); foreach ($models->models as $key => $model) { $term_name = $model->fullname; $term_slug = sanitize_title($term_name); if (!term_exists($term_slug, 'car_models')) { $term_id = wp_insert_term($term_name, 'car_models', array('slug' => $term_slug, 'description' => $model->id)); } } // sync brands $brands = wp_remote_get($api_url . 'brands'); $brands = json_decode($brands['body']); foreach ($brands->brands as $key => $brand) { $term_name = $brand->brand_name; $term_slug = sanitize_title($term_name); if (!term_exists($term_slug, 'car_brands')) { $term_id = wp_insert_term($term_name, 'car_brands', array('slug' => $term_slug, 'description' => $brand->id)); } } // sync cars $cars = wp_remote_get($api_url . 'cars'); $cars = json_decode($cars['body']); foreach ($cars->cars as $key => $car) { $check_existing = $wpdb->get_row("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '_car_research_db_id' AND meta_value = '{$car->id}'"); if (is_null($check_existing)) { $post_slug = sanitize_title($car->name); $post_data = array('post_name' => $post_slug, 'post_title' => $car->name, 'post_status' => 'publish', 'post_type' => 'cars', 'post_author' => $current_user->ID, 'comment_status' => 'closed'); $new_post_id = wp_insert_post($post_data); update_post_meta($new_post_id, '_car_research_db_id', $car->id); update_post_meta($new_post_id, '_brandid', $car->brandid); update_post_meta($new_post_id, '_modelid', $car->modelid); update_post_meta($new_post_id, '_car_features', serialize($car)); // update_post_meta($new_post_id, '_id', $car->id); // update_post_meta($new_post_id, '_name', $car->name); // update_post_meta($new_post_id, '_search_variant', $car->search_variant); // update_post_meta($new_post_id, '_drop_variant', $car->drop_variant); // update_post_meta($new_post_id, '_img_url', $car->img_url); // update_post_meta($new_post_id, '_type', $car->type); // update_post_meta($new_post_id, '_mileage', $car->mileage); // update_post_meta($new_post_id, '_delhipric', $car->delhipric); // update_post_meta($new_post_id, '_mumpric', $car->mumpric); // update_post_meta($new_post_id, '_bangalorepric', $car->bangalorepric); // update_post_meta($new_post_id, '_chennaipric', $car->chennaipric); // update_post_meta($new_post_id, '_chdpric', $car->chdpric); // update_post_meta($new_post_id, '_budget', $car->budget); // update_post_meta($new_post_id, '_Fuelcapacity', $car->Fuelcapacity); // update_post_meta($new_post_id, '_size', $car->size); // update_post_meta($new_post_id, '_length', $car->length); // update_post_meta($new_post_id, '_width', $car->width); // update_post_meta($new_post_id, '_height', $car->height); // update_post_meta($new_post_id, '_wheelbase', $car->wheelbase); // update_post_meta($new_post_id, '_groundclearance', $car->groundclearance); // update_post_meta($new_post_id, '_bootspace', $car->bootspace); // update_post_meta($new_post_id, '_enginecc', $car->enginecc); // update_post_meta($new_post_id, '_noofcyl', $car->noofcyl); // update_post_meta($new_post_id, '_pwrbhp', $car->pwrbhp); // update_post_meta($new_post_id, '_pwrrpm', $car->pwrrpm); // update_post_meta($new_post_id, '_tornm', $car->tornm); // update_post_meta($new_post_id, '_torrpm', $car->torrpm); // update_post_meta($new_post_id, '_noofgears', $car->noofgears); // update_post_meta($new_post_id, '_geartransmission', $car->geartransmission); // update_post_meta($new_post_id, '_tyresize', $car->tyresize); // update_post_meta($new_post_id, '_kerwbweight', $car->kerwbweight); // update_post_meta($new_post_id, '_abs', $car->abs); // update_post_meta($new_post_id, '_ebd', $car->ebd); // update_post_meta($new_post_id, '_esp', $car->esp); // update_post_meta($new_post_id, '_parkingsensor', $car->parkingsensor); // update_post_meta($new_post_id, '_foglampsfront', $car->foglampsfront); // update_post_meta($new_post_id, '_foglampsback', $car->foglampsback); // update_post_meta($new_post_id, '_doormirrors', $car->doormirrors); // update_post_meta($new_post_id, '_Airbags', $car->Airbags); // update_post_meta($new_post_id, '_xenon', $car->xenon); // update_post_meta($new_post_id, '_adaptivelight', $car->adaptivelight); // update_post_meta($new_post_id, '_ac', $car->ac); // update_post_meta($new_post_id, '_climatectrl', $car->climatectrl); // update_post_meta($new_post_id, '_pwrwindows', $car->pwrwindows); // update_post_meta($new_post_id, '_cruisestrl', $car->cruisestrl); // update_post_meta($new_post_id, '_gps', $car->gps); // update_post_meta($new_post_id, '_adjseats', $car->adjseats); // update_post_meta($new_post_id, '_pwrsteer', $car->pwrsteer); // update_post_meta($new_post_id, '_tiltsteer', $car->tiltsteer); // update_post_meta($new_post_id, '_telescopesteer', $car->telescopesteer); // update_post_meta($new_post_id, '_acrear', $car->acrear); // update_post_meta($new_post_id, '_centrallock', $car->centrallock); // update_post_meta($new_post_id, '_tachometer', $car->tachometer); // update_post_meta($new_post_id, '_rainwipers', $car->rainwipers); // update_post_meta($new_post_id, '_fusedantennas', $car->fusedantennas); // update_post_meta($new_post_id, '_iPoddocks', $car->iPoddocks); // update_post_meta($new_post_id, '_audiosteer', $car->audiosteer); // update_post_meta($new_post_id, '_musicsys', $car->musicsys); // update_post_meta($new_post_id, '_phoncharge', $car->phoncharge); // update_post_meta($new_post_id, '_pushbtnstart', $car->pushbtnstart); // update_post_meta($new_post_id, '_keylessentry', $car->keylessentry); // update_post_meta($new_post_id, '_drivetype', $car->drivetype); // update_post_meta($new_post_id, '_susp_front', $car->susp_front); // update_post_meta($new_post_id, '_susp_rear', $car->susp_rear); // update_post_meta($new_post_id, '_irvm', $car->irvm); // update_post_meta($new_post_id, '_head_rest_front', $car->head_rest_front); // update_post_meta($new_post_id, '_head_rest_back', $car->head_rest_back); // update_post_meta($new_post_id, '_rear_armrest', $car->rear_armrest); // update_post_meta($new_post_id, '_cup_hold', $car->cup_hold); // update_post_meta($new_post_id, '_bluetooth', $car->bluetooth); // update_post_meta($new_post_id, '_parcel_tray', $car->parcel_tray); // update_post_meta($new_post_id, '_rear_defog', $car->rear_defog); // update_post_meta($new_post_id, '_orvm', $car->orvm); // update_post_meta($new_post_id, '_rain_sens_wip', $car->rain_sens_wip); // update_post_meta($new_post_id, '_dual_trip_meter', $car->dual_trip_meter); // update_post_meta($new_post_id, '_dig_fuel_indi', $car->dig_fuel_indi); // update_post_meta($new_post_id, '_low_fuel', $car->low_fuel); // update_post_meta($new_post_id, '_remote_fuel_lid', $car->remote_fuel_lid); // update_post_meta($new_post_id, '_brakes_front', $car->brakes_front); // update_post_meta($new_post_id, '_brakes_rear', $car->brakes_rear); // update_post_meta($new_post_id, '_no_of_speak', $car->no_of_speak); // update_post_meta($new_post_id, '_pud_lamp', $car->pud_lamp); // update_post_meta($new_post_id, '_ajar_warn', $car->ajar_warn); // update_post_meta($new_post_id, '_bc_bump', $car->bc_bump); // update_post_meta($new_post_id, '_seat_uph', $car->seat_uph); // update_post_meta($new_post_id, '_bc_door_hand', $car->bc_door_hand); // update_post_meta($new_post_id, '_alloy_wheel', $car->alloy_wheel); // update_post_meta($new_post_id, '_seating_capacity', $car->seating_capacity); // update_post_meta($new_post_id, '_turning_radius', $car->turning_radius); // update_post_meta($new_post_id, '_lastupdated', $car->lastupdated); // update_post_meta($new_post_id, '_discontinued', $car->discontinued); // update_post_meta($new_post_id, '_Ambala', $car->Ambala); // update_post_meta($new_post_id, '_Amritsar', $car->Amritsar); // update_post_meta($new_post_id, '_Aurangabad', $car->Aurangabad); // update_post_meta($new_post_id, '_Bhopal', $car->Bhopal); // update_post_meta($new_post_id, '_Bhubaneshwar', $car->Bhubaneshwar); // update_post_meta($new_post_id, '_Bilaspur', $car->Bilaspur); // update_post_meta($new_post_id, '_Calcutta', $car->Calcutta); // update_post_meta($new_post_id, '_Cochin', $car->Cochin); // update_post_meta($new_post_id, '_Coimbatore', $car->Coimbatore); // update_post_meta($new_post_id, '_Dehradun', $car->Dehradun); // update_post_meta($new_post_id, '_Dhanbad', $car->Dhanbad); // update_post_meta($new_post_id, '_Gurgaon', $car->Gurgaon); // update_post_meta($new_post_id, '_Guwahati', $car->Guwahati); // update_post_meta($new_post_id, '_Gwalior', $car->Gwalior); // update_post_meta($new_post_id, '_Haldwani', $car->Haldwani); // update_post_meta($new_post_id, '_Hyderabad', $car->Hyderabad); // update_post_meta($new_post_id, '_Indore', $car->Indore); // update_post_meta($new_post_id, '_Jabalpur', $car->Jabalpur); // update_post_meta($new_post_id, '_Jaipur', $car->Jaipur); // update_post_meta($new_post_id, '_Kanpur', $car->Kanpur); // update_post_meta($new_post_id, '_Kolhapur', $car->Kolhapur); // update_post_meta($new_post_id, '_Lucknow', $car->Lucknow); // update_post_meta($new_post_id, '_Ludhiana', $car->Ludhiana); // update_post_meta($new_post_id, '_Madurai', $car->Madurai); // update_post_meta($new_post_id, '_Mangalore', $car->Mangalore); // update_post_meta($new_post_id, '_Mathura', $car->Mathura); // update_post_meta($new_post_id, '_Mysore', $car->Mysore); // update_post_meta($new_post_id, '_Nagpur', $car->Nagpur); // update_post_meta($new_post_id, '_Noida', $car->Noida); // update_post_meta($new_post_id, '_Patna', $car->Patna); // update_post_meta($new_post_id, '_Pondicherry', $car->Pondicherry); // update_post_meta($new_post_id, '_Pune', $car->Pune); // update_post_meta($new_post_id, '_Rajkot', $car->Rajkot); // update_post_meta($new_post_id, '_Silchar', $car->Silchar); // update_post_meta($new_post_id, '_Solapur', $car->Solapur); // update_post_meta($new_post_id, '_Surat', $car->Surat); // update_post_meta($new_post_id, '_Trivandrum', $car->Trivandrum); // update_post_meta($new_post_id, '_Udaipur', $car->Udaipur); // update_post_meta($new_post_id, '_Baroda', $car->Baroda); // update_post_meta($new_post_id, '_Valsad', $car->Valsad); // update_post_meta($new_post_id, '_Vellore', $car->Vellore); // update_post_meta($new_post_id, '_Vijaywada', $car->Vijaywada); // update_post_meta($new_post_id, '_Vishakapatnam', $car->Vishakapatnam); // update_post_meta($new_post_id, '_Warangal', $car->Warangal); // update_post_meta($new_post_id, '_ahmedabad', $car->ahmedabad); } } }