public function __construct() { global $wpdb; $this->wpdb =& $wpdb; $this->_users_table = $wpdb->prefix . $this->_users_table; $this->_dealers_affiliates_table = $wpdb->prefix . $this->_dealers_affiliates_table; $this->_manufacturers_table = $wpdb->prefix . $this->_manufacturers_table; $this->_models_table = $wpdb->prefix . $this->_models_table; $this->_body_types_table = $wpdb->prefix . $this->_body_types_table; $this->_transmissions_table = $wpdb->prefix . $this->_transmissions_table; $this->_equipments_table = $wpdb->prefix . $this->_equipments_table; $this->_doors_table = $wpdb->prefix . $this->_doors_table; $this->_fuels_table = $wpdb->prefix . $this->_fuels_table; $this->_technical_conditions_table = $wpdb->prefix . $this->_technical_conditions_table; $this->_currencies_table = $wpdb->prefix . $this->_currencies_table; $this->_transport_types_table = $wpdb->prefix . $this->_transport_types_table; $this->_regions_table = $wpdb->prefix . $this->_regions_table; $this->_cities_table = $wpdb->prefix . $this->_cities_table; $this->_region_types_table = $wpdb->prefix . $this->_region_types_table; $this->_states_table = $wpdb->prefix . $this->_states_table; $this->_drive_table = $wpdb->prefix . $this->_drive_table; $this->_colors_table = $wpdb->prefix . $this->_colors_table; $this->_photos_table = $wpdb->prefix . $this->_photos_table; $this->_recovery_password_table = $wpdb->prefix . $this->_recovery_password_table; $this->_transactions_table = $wpdb->prefix . $this->_transactions_table; $this->load = AT_Loader::get_instance(); $this->core = AT_Core::get_instance(); $this->registry = AT_Registry::get_instance(); }
public static function init_actions() { add_action('wp_enqueue_scripts', array(AT_Core::get_instance()->view, 'render_styles')); add_action('wp_enqueue_scripts', array(AT_Core::get_instance()->view, 'render_scripts')); add_action('template_redirect', array(AT_Core::get_instance()->view, 'render')); add_action('template_redirect', array(AT_Core::get_instance()->view, 'display')); add_action('after_setup_theme', array('AT_Core', 'locale')); // MOVE TO after_setup_theme IN RELEASE 2.0 }
public static function get_custom_sidebars() { $data = AT_Core::get_instance()->get_option('custom_sidebars', array()); $sidebars = array(); foreach ($data as $key => $value) { $sidebars['at_custom_sidebar_' . $key] = $value['name']; } return $sidebars; }
private function _additional_data() { $data = array(); if ($this->core->get_option('footer_logo_src', '') != '') { $data['logo'] = '<img src="' . $this->core->get_option('footer_logo_src') . '">'; } $data['sociable_view'] = $this->core->get_option('footer_sociable_view', true); $data['sociable'] = AT_Core::get_instance()->get_option('sociable', array()); return $data; }
private function __construct() { //session_settings $session_settings = AT_Core::get_instance()->get_option('session_settings', array()); if (count($session_settings) > 0) { if (isset($session_settings['sess_expiration'])) { $this->_sess_expiration = (int) $session_settings['sess_expiration']; } if (isset($session_settings['sess_time_to_update']) && (int) $session_settings['sess_time_to_update'] > 0) { $this->_sess_time_to_update = (int) $session_settings['sess_time_to_update']; } if (isset($session_settings['sess_expire_on_close'])) { $this->_sess_expire_on_close = $session_settings['sess_expire_on_close']; } if (isset($session_settings['sess_match_ip'])) { $this->_sess_match_ip = $session_settings['sess_match_ip']; } if (isset($session_settings['sess_match_useragent'])) { $this->_sess_match_useragent = $session_settings['sess_match_useragent']; } if (!empty($session_settings['sess_cookie_name'])) { $this->_sess_cookie_name = $session_settings['sess_cookie_name']; } if (!isset($session_settings['cookie_prefix'])) { $this->_cookie_prefix = $session_settings['cookie_prefix']; } if (!empty($session_settings['cookie_path'])) { $this->_cookie_path = $session_settings['cookie_path']; } if (!isset($session_settings['cookie_domain'])) { $this->_cookie_domain = $session_settings['cookie_domain']; } if (!isset($session_settings['cookie_secure'])) { $this->_cookie_secure = $session_settings['cookie_secure']; } if (!empty($session_settings['encryption_key'])) { $this->_encryption_key = $session_settings['encryption_key']; } } if ($this->_sess_expiration == 0) { $this->_sess_expiration = 60 * 60 * 24 * 365 * 2; } $this->_sess_cookie_name = $this->_cookie_prefix . $this->_sess_cookie_name; if ($this->sess_read()) { $this->_sess_update(); } else { if (is_user_logged_in() && AT_Core::get_instance()->get_option('site_type', 'mode_soletrader') == 'mode_soletrader') { $data = array('logged' => true, 'user_id' => 1); $this->sess_create($data); } } }
public function __construct() { $this->core = AT_Core::get_instance(); // if ( !$this->core->get_option( 'theme_is_activated', false ) && is_user_logged_in() ) { // AT_Notices::set_frontend_notice( // '<h3>'.__( 'New to AutoDealer?' , AT_TEXTDOMAIN ) . '</h3>' . // __( 'You almost ready to use full theme features. Please complete two last steps before move your website to production mode.' , AT_TEXTDOMAIN ) . // '<br />' . // sprintf(__( '<a href="%1$s">Click here to continue →</a>' , AT_TEXTDOMAIN ), get_admin_url() . 'admin.php?page=at_site_options_general'), // $class = 'notice' // ); // Header('Location: ' . get_admin_url() . 'admin.php?page=at_site_options_general'); // die(); // // exit( __( 'Theme is not activated' , AT_TEXTDOMAIN ) ); // } // SSL and ajax tricks // if ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] != rtrim( home_url(), '/' ) ) { // AT_Common::redirect( AT_Router::get_instance()->server('REQUEST_URI'), '301' ); // } $this->uri = AT_Router::get_instance(); if ($this->uri->get_method() != 'show_underconstruction' && $this->core->get_option('status_site', 'production') == 'underconstruction') { AT_Core::show_underconstruction(); } $this->view = $this->core->view; $this->load = AT_Loader::get_instance(); $this->session = AT_Session::get_instance(); $this->registry = AT_Registry::get_instance(); $this->load->library('breadcrumbs'); $this->breadcrumbs = AT_Breadcrumbs::get_instance(); $validation_rules = $this->load->helper('validation_rules', true); $this->validation = $this->load->library('form_validation', true, $validation_rules->rules); //$this->validation->set_rules(); if (AT_Common::is_user_logged() && $this->core->get_option('theme_is_activated', false)) { $user_model = $this->load->model('user_model'); $user_info = $user_model->get_user_by_id(AT_Common::get_logged_user_id()); $this->registry->set('user_info', $user_info); if ($this->core->get_option('confirm_email_enable', true) && !in_array($this->uri->segments(1), array('confirm_email', 'unlogged')) && (is_null($user_info['date_active']) || empty($user_info['date_active']))) { AT_Common::redirect('auth/confirm_email'); } } }
private function _controller($view, $params) { $content = ''; if (empty($params['name'])) { if (!empty(AT_Core::get_instance()->view->global_sidebar)) { $params['name'] = AT_Core::get_instance()->view->global_sidebar; } else { if (is_category() || is_tag() || is_day() || is_month() || is_year() || is_author() || is_tax() || is_search()) { $params['name'] = 'primary'; } else { if (is_home()) { $post_id = get_option('page_for_posts'); } else { $post_id = get_queried_object_id(); } $layout = get_post_meta($post_id, '_layout', true); } } if (isset($params['layout'])) { $layout = $params['layout']; } } if (empty($layout) || !$view->check_layout($layout)) { $layout = $this->core->get_option('default_page_layout', 'content_right'); } if ($layout != 'content' || !empty($params['name'])) { if (!empty($params['name'])) { $sidebar_name = $params['name']; } else { if (($custom_sidebar = get_post_meta($post_id, '_custom_sidebar', true)) != '') { $sidebar_name = $custom_sidebar; } else { $sidebar_name = 'primary'; } } ob_start(); dynamic_sidebar($sidebar_name); $content = ob_get_clean(); } return array('content' => $content); }
public function form($instance) { $defaults = array('title' => 'Social networks', 'color' => '#0000FF', 'description' => 'Website powered by WinterJuice theme'); $instance = wp_parse_args((array) $instance, $defaults); if (!isset($instance['skin'])) { $instance['skin'] = 'default'; } echo ' <p> <label for="' . $this->get_field_id('title') . '">Widget Title:</label> <input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" value="' . $instance['title'] . '" /> </p> <p> <label for="' . $this->get_field_id('title') . '">Custom Text:</label> <input class="widefat" id="' . $this->get_field_id('description') . '" name="' . $this->get_field_name('description') . '" value="' . $instance['description'] . '" /> </p>'; $skin = $instance['skin']; $sociable = AT_Core::get_instance()->get_option('sociable'); $sociables = ""; $total = count($sociable) - 1; $width = 100 / $total; $size = $width / 2; echo '<h3>Icons Preview:</h3>'; $sociables .= '<div class="custom-socials">'; foreach ($sociable as $key => $item) { $sociable_link = !empty($item['link']) ? $item['link'] : '#'; $sociables .= ' <a href="' . esc_url($sociable_link) . '"> <i class="' . $item['icon'] . '"></i> </a> '; } $sociables .= '</div>'; echo $sociables; echo '<hr />'; }
public static function route() { $coreProfile = AT_Core::get_instance(); try { if (is_admin()) { // init admin panel if (isset($_GET['page'])) { if ($segments = AT_Route::admin($_GET['page'])) { // if (isset($_GET['tab'])) // $segments[2] = $_GET['tab']; throw new Exception(serialize($segments)); } } else { if (isset($_GET['activated'])) { global $pagenow; if ($pagenow === 'themes.php') { throw new Exception(serialize(array('admin', 'install', 'redirect'))); } } } } else { //////////////////////////////////////////////////// // view inited URI //////////////////////////////////////////////////// //$segments = explode( '/', ltrim( trim($_SERVER['REQUEST_URI'], '/' ), 'index.php' ) ); $host = explode(rtrim($_SERVER['HTTP_HOST'], '/'), rtrim(home_url(), '/')); $request_uri = trim($_SERVER['REQUEST_URI'], '/'); if (!empty($host[1])) { $request_uri = substr_replace($request_uri, '', 0, strlen($host[1])); $request_uri = trim($request_uri, '/'); } $request_uri = explode('?', $request_uri); $segments = explode('/', trim($request_uri[0], '/')); if (!empty($segments[0]) && array_key_exists($segments[0], AT_Route::fronted())) { $param_segment = AT_Route::fronted($segments[0]); array_splice($segments, 0, $param_segment['segment_start']); if (!isset($segments[0])) { $segments[0] = 'vehicles'; } if ($param_segment['without_index']) { self::$without_index = $param_segment['without_index']; } throw new Exception(serialize($segments)); } //////////////////////////////////////////////////// // view inited single post type //////////////////////////////////////////////////// if (is_single() && in_array(get_post_type(), AT_Posttypes::get_post_types())) { $segments = array(get_post_type(), 'single'); throw new Exception(serialize($segments)); } if (is_archive() && (is_category() || is_tag() || is_day() || is_month() || is_year() || is_author() || is_tax())) { throw new Exception(serialize(array('post', 'archive'))); } //////////////////////////////////////////////////// // view inited archive custom post type // news, reviews //////////////////////////////////////////////////// if (is_archive() && in_array(get_post_type(), AT_Posttypes::get_post_types())) { if (isset($segments[1]) && $segments[1] == 'page' && isset($segments[2]) && is_numeric($segments[2])) { throw new Exception(serialize(array(get_post_type(), 'archive', $segments[2]))); } else { throw new Exception(serialize(array(get_post_type(), 'archive'))); } //$segments = array(get_post_type(), 'archive' ); throw new Exception(serialize($segments)); } //////////////////////////////////////////////////// // page view //////////////////////////////////////////////////// if (is_page()) { $segments = array('page', 'index'); throw new Exception(serialize($segments)); } //////////////////////////////////////////////////// // category view //////////////////////////////////////////////////// if (is_category()) { throw new Exception(serialize(array('post', 'archive'))); } //////////////////////////////////////////////////// // front page view //////////////////////////////////////////////////// if (is_front_page()) { throw new Exception(serialize(array('blog', 'index'))); } //////////////////////////////////////////////////// // blog view //////////////////////////////////////////////////// if (is_home()) { if (isset($segments[1]) && $segments[1] == 'page' && isset($segments[2]) && is_numeric($segments[2])) { throw new Exception(serialize(array('blog', 'index', $segments[2]))); } else { throw new Exception(serialize(array('blog', 'index'))); } } //////////////////////////////////////////////////// // search view //////////////////////////////////////////////////// if (is_search()) { throw new Exception(serialize(array('search', 'index'))); } //////////////////////////////////////////////////// // 404 view //////////////////////////////////////////////////// if (is_404()) { throw new Exception(serialize(array('errors', 'show_404'))); } if (is_attachment()) { throw new Exception(serialize(array('post', 'single'))); } if (is_single()) { throw new Exception(serialize(array('post', 'single'))); } if (is_feed()) { throw new Exception(''); } // other pages && post types throw new Exception(serialize(array('errors', 'show_404'))); //echo "don't find"; die; } } catch (Exception $e) { if ($e->getMessage() != '') { $route = AT_Router::get_instance(unserialize($e->getMessage())); $route->run(); } } }
public function widget($args, $instance) { extract($args); $defaults = array('title' => '', 'description' => ''); $instance = wp_parse_args((array) $instance, $defaults); $title = ''; if (isset($instance['title'])) { $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); } if (!empty($title)) { $title_array = explode(" ", $title); $title = ""; foreach ($title_array as $tcount => $word) { if ($tcount == 0) { $word = "<strong>" . $word . "</strong>"; } $title .= $word . " "; } $title = "<h3>" . $title . "</h3>"; } $description = $instance['description']; $loans = AT_Core::get_instance()->get_option('loans'); $html = '<form name="loan_calculator" class="loan calculator form">'; $annual_rate = array(); $downpay = array(); $period_min = array(); $period_max = array(); $name = array(); $total = count($loans) - 1; foreach ($loans as $key => $loan) { $period_min[] = $loan['period_min']; $period_max[] = $loan['period_max']; $annual_rate[] = str_replace('%', '', $loan['annual_rate']); $downpay[] = str_replace('%', '', $loan['downpay']); $names[] = $loan['name']; } $cn = 0; $html .= '<div class="loan calculator-wrapper">'; $html .= $title; // Loan amount $html .= '<label><strong>' . __('Loan Amount', AT_TEXTDOMAIN) . ':</strong></label>'; $html .= '<input name="amount" class="text loan amount" value="" />'; // Down pay $html .= '<div class="select_wrapper">'; $html .= '<label><strong>' . __('Down Payment', AT_TEXTDOMAIN) . ':</strong></label>'; $html .= '<select name="downpay" class="custom-select loan down pay">'; // $html .= '<option value="-1" selected>' . __( 'Please select...', AT_TEXTDOMAIN ) . '</option>'; foreach ($names as $name) { $html .= '<option value="' . $cn . '">' . $downpay[$cn] . '%</option>'; $cn++; } $html .= '</select>'; $html .= '</div>'; // Annual rate $html .= '<div class="select_wrapper">'; $html .= '<label><strong>' . __('Annual Rate', AT_TEXTDOMAIN) . ':</strong></label>'; $html .= '<select name="rate" class="custom-select loan annual rate">'; $html .= '<option value="">' . __('Please select...', AT_TEXTDOMAIN) . '</option>'; $html .= '</select>'; $html .= '</div>'; // period_max $html .= '<div class="select_wrapper">'; $html .= '<label><strong>' . __('Loan Period', AT_TEXTDOMAIN) . ':</strong></label>'; $html .= '<select name="period" class="custom-select loan period">'; $html .= '<option value="">' . __('Please select...', AT_TEXTDOMAIN) . '</option>'; $html .= '</select>'; $html .= '</div>'; $html .= '<input type="submit" value="' . __('Calculate', AT_TEXTDOMAIN) . '" class="btn_calc">'; $html .= '</div>'; $script = ' <noscript> ' . __('Loan Calculator requires enable Javascript support. Please enable Javascript in your browser settings to continue, and reload page.', AT_TEXTDOMAIN) . ' </noscript> <script> jQuery(document).ready(function(){ var $j = jQuery; var period = ' . json_encode($period_max) . '; var downpay = ' . json_encode($downpay) . '; var rate = ' . json_encode($annual_rate) . '; var settings = []; var downpay_html = []; var meta = $j(".car_characteristics .price"); var dropdown_period = $j(".loan.calculator .loan.period"); var amount = $j(".loan.calculator .loan.amount"); var annual_rate = $j(".loan.calculator .loan.annual.rate"); var selector = $j(".loan.calculator-wrapper .loan.down.pay"); var initLoanCalculator = function(el) { var val = el.val(); if ( val.length > 0 ) { settings["period"]=period[val]*1; settings["downpay"]=downpay[val]; settings["rate"]=rate[val]*1; dropdown_period.html(""); annual_rate.html(""); // Period for (var p = 1; p < (period[val]*1+1); p++) { $j("<option/>", {value: p, text: p + " year"}).appendTo(dropdown_period); } // Rate $j("<option/>", {value: rate[val], text: rate[val] + "%"}).appendTo(annual_rate); } } $j(".loan.calculator-wrapper .loan.down.pay option").each(function(e) { if ( meta.length > 0) { settings["price"] = meta.data("price")*1; settings["currency"] = meta.data("currency"); // downpay_html[e] = downpay[e] * (((meta.data("price"))*1) / 100); // downpay_html[e] += " " + meta.data("currency"); amount.val(meta.data("price")); amount.attr("readonly","true"); $j(this).html(downpay_html[e]); } }); initLoanCalculator(selector); selector.change( function(){ var el = $j(this); initLoanCalculator(el); } ); $j("form.loan.calculator.form").bind("submit", function() { var html = ""; settings["period"]=(dropdown_period.val())*1; var total_rate = settings["period"] * settings["rate"]; var total_fee_amount = 0; var paid = ( amount.val()*1 ) - (settings["downpay"] * ( amount.val()*1 / 100 )); for ( var v=0; v < settings["period"]; v++ ) { total_fee_amount += (( settings["rate"]*1 ) * paid / 100 ); paid = ( ( settings["rate"]*1 ) * paid / 100 ) + paid; } var monthly_payment = paid/( settings["period"]*1*12 ); var html = ""; var total_month = 1; for ( var v=1; v < (settings["period"]*1*12+1); v++ ) { html += "<tr><td>Month " + v + "</td><td>" + monthly_payment.toFixed(2) + " " + settings["currency"] + "</td></tr>"; } html = "<table width=100% cellpadding=5 cellspacing=0 border=1><tbody>" + html + "</tbody></table>"; html += "<h3>Fee amount: " + total_fee_amount.toFixed(2) + "</h3>"; html += "<h3>Total price: " + (total_fee_amount + ( amount.val()*1 )).toFixed(2) + "</h3>"; AT_Application.ModalBox({"width": 940, "handler": "prepend"},html); return false; }); }); </script> '; if (!empty($description)) { $description = '<p>' . $description . '</p>'; } if (isset($instance['type']) && $instance['type'] == 'page_content') { echo '<div class="wj_loan_calculators">'; // echo '<h3>' . $title . '</h3>'; echo $html; echo $script; echo '</div>'; } else { echo $before_widget; // echo "<h3>" . $title . "</h3>"; echo $html; echo $script; echo $description; echo $after_widget; } }
private function _frontend_header($params) { $data = array(); switch ($this->core->get_option('logo_settings')) { case 'logo_image': $width = $this->core->get_option('header_logo_width') != '' ? ' style="max-width:' . $this->core->get_option('header_logo_width') . ';"' : ''; if ($this->core->get_option('header_logo_src') != '') { $data['logo'] = '<img src="' . $this->core->get_option('header_logo_src') . '"' . $width . '>'; } else { $data['logo'] = '<img src="' . AT_Common::static_url('/assets/images/pics/logo_auto_dealer.png') . '"' . $width . '>'; } break; case 'logo_text': $data['logo'] = $this->core->get_option('header_logo_text'); break; default: $data['logo'] = get_bloginfo('name'); break; } $data['header_style'] = $this->core->get_option('header_content_style', 'info'); $data['add_car_button'] = $this->core->get_option('header_add_car_button', true); $data['add_car_button'] = $this->core->get_option('header_add_car_button', true); $data['sociable_view'] = $this->core->get_option('header_sociable_view', true); $data['sociable'] = AT_Core::get_instance()->get_option('sociable', array()); $data['site_type'] = $this->core->get_option('site_type', 'mode_soletrader'); $data['phone'] = $this->core->get_option('header_phone', ''); $data['adress'] = $this->core->get_option('header_adress', ''); $data['header_custom_html'] = $this->core->get_option('header_custom_html', ''); $data['searchbox'] = $this->core->get_option('header_searchbox', true); return $data; }
public function get_option($item, $default = null) { if ($default != null) { $value = AT_Core::get_instance()->get_option($item, $default); } else { $value = AT_Core::get_instance()->get_option($item); } return !is_null($value) ? $value : ''; }
public static function car_mileage($view = 1) { $car_mileage = AT_Core::get_instance()->get_option('car_mileage', 'miles'); $types = array('miles' => array(__('Miles', AT_ADMIN_TEXTDOMAIN), __('miles', AT_ADMIN_TEXTDOMAIN), __('miles', AT_ADMIN_TEXTDOMAIN)), 'kilometers' => array(__('Kilometers', AT_ADMIN_TEXTDOMAIN), __('kilometers', AT_ADMIN_TEXTDOMAIN), __('km', AT_ADMIN_TEXTDOMAIN))); return $types[$car_mileage][$view]; }
public static function options() { if (isset($_GET['page'])) { AT_Core::get_instance()->view->display(); } }
private function _field_backup($args) { $defaults = array('title' => '', 'description' => '', 'name' => '', 'value' => ''); $args = wp_parse_args($args, $defaults); $args['value'] = base64_encode(serialize(AT_Core::get_instance()->get_options())); $this->view->add_block($this->_get_block_id(), 'admin/fields/textarea', $args); }
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?> " /> <meta property="og:title" content="<?php echo $page_title; ?> " /> <meta property="og:url" content="<?php if (is_home()) { print site_url(); } else { print get_permalink(); } ?> " /> <?php if (AT_Core::get_instance()->get_option('favicon')) { echo '<link href="' . AT_Core::get_instance()->get_option('favicon') . '" rel="icon" type="image/x-icon" />'; } ?> <?php wp_head(); ?> </head> <body <?php body_class(); ?> > <?php AT_Notices::get_frontend_notice();