set_response_type('array'); $purchase_data = $obj_envato->call('/buyer/list-purchases?filter_by=wordpress-themes'); if(isset($purchase_data['results']) && is_array($purchase_data['results'])) { foreach($purchase_data['results'] as $result_arr) { if(isset($result_arr['item']['id']) && $result_arr['item']['id'] == ENVATOITEMID) { $is_verified_envato_purchase_code = true; update_option("pp_verified_envato_grandcarrental", true); break; } } } else if(isset($_REQUEST['pp_envato_personal_token']) && $_REQUEST['pp_envato_personal_token'] == '[ThemeGoods Activation]') { $is_verified_envato_purchase_code = true; } else { $is_verified_envato_purchase_code = false; delete_option("pp_verified_envato_grandcarrental", true); } if(!$is_verified_envato_purchase_code) { $redirect_uri.= '&action=invalid-purchase'; } } foreach ($grandcarrental_options as $value) { if($value['type'] != 'image' && isset($value['id']) && isset($_REQUEST[ $value['id'] ])) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } } foreach ($grandcarrental_options as $value) { if( isset($value['id']) && isset( $_REQUEST[ $value['id'] ] )) { if($value['id'] != GRANDCARRENTAL_SHORTNAME."_sidebar0" && $value['id'] != GRANDCARRENTAL_SHORTNAME."_ggfont0") { //if sortable type if(is_admin() && $value['type'] == 'sortable') { $sortable_array = serialize($_REQUEST[ $value['id'] ]); $sortable_data = $_REQUEST[ $value['id'].'_sort_data']; $sortable_data_arr = explode(',', $sortable_data); $new_sortable_data = array(); foreach($sortable_data_arr as $key => $sortable_data_item) { $sortable_data_item_arr = explode('_', $sortable_data_item); if(isset($sortable_data_item_arr[0])) { $new_sortable_data[] = $sortable_data_item_arr[0]; } } update_option( $value['id'], $sortable_array ); update_option( $value['id'].'_sort_data', serialize($new_sortable_data) ); } elseif(is_admin() && $value['type'] == 'font') { if(!empty($_REQUEST[ $value['id'] ])) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); update_option( $value['id'].'_value', $_REQUEST[ $value['id'].'_value' ] ); } else { delete_option( $value['id'] ); delete_option( $value['id'].'_value' ); } } elseif(is_admin()) { if($value['type']=='image') { update_option( $value['id'], esc_url($_REQUEST[ $value['id'] ]) ); } elseif($value['type']=='textarea') { if(isset($value['validation']) && !empty($value['validation'])) { update_option( $value['id'], esc_textarea($_REQUEST[ $value['id'] ]) ); } else { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } } elseif($value['type']=='iphone_checkboxes' OR $value['type']=='jslider') { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { if(isset($value['validation']) && !empty($value['validation'])) { $request_value = $_REQUEST[ $value['id'] ]; //Begin data validation switch($value['validation']) { case 'text': default: $request_value = sanitize_text_field($request_value); break; case 'email': $request_value = sanitize_email($request_value); break; case 'javascript': $request_value = sanitize_text_field($request_value); break; } update_option( $value['id'], $request_value); } else { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } } } } elseif(is_admin() && isset($_REQUEST[ $value['id'] ]) && !empty($_REQUEST[ $value['id'] ])) { if($value['id'] == GRANDCARRENTAL_SHORTNAME."_sidebar0") { //get last sidebar serialize array $current_sidebar = get_option(GRANDCARRENTAL_SHORTNAME."_sidebar"); $request_value = $_REQUEST[ $value['id'] ]; $request_value = sanitize_text_field($request_value); $current_sidebar[ $request_value ] = $request_value; update_option( GRANDCARRENTAL_SHORTNAME."_sidebar", $current_sidebar ); } elseif($value['id'] == GRANDCARRENTAL_SHORTNAME."_ggfont0") { //get last ggfonts serialize array $current_ggfont = get_option(GRANDCARRENTAL_SHORTNAME."_ggfont"); $current_ggfont[ $_REQUEST[ $value['id'] ] ] = $_REQUEST[ $value['id'] ]; update_option( GRANDCARRENTAL_SHORTNAME."_ggfont", $current_ggfont ); } } } else { if(is_admin() && isset($value['id'])) { delete_option( $value['id'] ); } } } header("Location: admin.php?page=functions.php&saved=true".$redirect_uri.$_REQUEST['current_tab']); } } add_theme_page('Theme Setting', 'Theme Setting', 'administrator', 'functions.php', 'grandcarrental_admin', ''); } function grandcarrental_enqueue_admin_page_scripts() { $current_screen = grandcarrental_get_current_screen(); wp_enqueue_style('thickbox'); if(property_exists($current_screen, 'base') && $current_screen->base != 'toplevel_page_revslider') { wp_enqueue_style('jquery-ui', get_template_directory_uri().'/functions/jquery-ui/css/custom-theme/jquery-ui-1.8.24.custom.css', false, '1.0', 'all'); } wp_enqueue_style('grandcarrental-functions', get_template_directory_uri().'/functions/functions.css', false, GRANDCARRENTAL_THEMEVERSION, 'all'); if(property_exists($current_screen, 'post_type') && ($current_screen->post_type == 'page' OR $current_screen->post_type == 'portfolios')) { wp_enqueue_style('grandcarrental-jqueryui', get_template_directory_uri().'/css/jqueryui/custom.css', false, GRANDCARRENTAL_THEMEVERSION, 'all'); } wp_enqueue_style('grandcarrental-colorpicker', get_template_directory_uri().'/functions/colorpicker/css/colorpicker.css', false, GRANDCARRENTAL_THEMEVERSION, 'all'); wp_enqueue_style('fancybox', get_template_directory_uri().'/js/fancybox/jquery.fancybox.admin.css', false, GRANDCARRENTAL_THEMEVERSION, 'all'); wp_enqueue_style('switchery', get_template_directory_uri().'/css/switchery.css', false, GRANDCARRENTAL_THEMEVERSION, 'all'); wp_enqueue_style('timepicker', get_template_directory_uri().'/functions/jquery.timepicker.css', false, GRANDCARRENTAL_THEMEVERSION, 'all'); wp_enqueue_style("fontawesome", get_template_directory_uri()."/css/font-awesome.min.css", false, GRANDCARRENTAL_THEMEVERSION, "all"); wp_enqueue_style("tooltipster", get_template_directory_uri()."/css/tooltipster.css", false, GRANDCARRENTAL_THEMEVERSION, "all"); if(isset($current_screen->base) && $current_screen->base == 'appearance_page_functions') { wp_enqueue_style("codemirror", get_template_directory_uri()."/css/codemirror.css", false, GRANDCARRENTAL_THEMEVERSION, "all"); } wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('media-upload'); wp_enqueue_script('thickbox'); wp_enqueue_script('jquery-ui-datepicker'); $ap_vars = array( 'url' => esc_url(get_home_url('/')), 'includes_url' => esc_url(includes_url()) ); wp_register_script( 'js-wpeditor', get_template_directory_uri() . '/functions/js-wp-editor.js', array( 'jquery' ), '1.1', true ); wp_localize_script( 'js-wpeditor', 'ap_vars', $ap_vars ); wp_enqueue_script( 'js-wpeditor' ); wp_enqueue_script('grandcarrental-colorpicker', get_template_directory_uri().'/functions/colorpicker/js/colorpicker.js', false, GRANDCARRENTAL_THEMEVERSION); wp_enqueue_script('eye', get_template_directory_uri().'/functions/colorpicker/js/eye.js', false, GRANDCARRENTAL_THEMEVERSION); wp_enqueue_script('utils', get_template_directory_uri().'/functions/colorpicker/js/utils.js', false, GRANDCARRENTAL_THEMEVERSION); wp_enqueue_script('switchery', get_template_directory_uri().'/functions/switchery.js', false, GRANDCARRENTAL_THEMEVERSION); wp_enqueue_script('fancybox', get_template_directory_uri().'/js/fancybox/jquery.fancybox.admin.js', false, GRANDCARRENTAL_THEMEVERSION); wp_enqueue_script('timepicker', get_template_directory_uri().'/functions/jquery.timepicker.js', false, GRANDCARRENTAL_THEMEVERSION); wp_enqueue_script('tooltipster', get_template_directory_uri().'/js/jquery.tooltipster.min.js', false, GRANDCARRENTAL_THEMEVERSION); if(isset($current_screen->base) && $current_screen->base == 'appearance_page_functions') { wp_enqueue_script('codemirror', get_template_directory_uri().'/functions/codemirror.js', false, GRANDCARRENTAL_THEMEVERSION); wp_enqueue_script('codemirror-css', get_template_directory_uri().'/functions/css.js', false, GRANDCARRENTAL_THEMEVERSION); } wp_register_script('grandcarrental-theme-script', get_template_directory_uri().'/functions/theme_script.js', false, GRANDCARRENTAL_THEMEVERSION, true); $params = array( 'ajaxurl' => esc_url(admin_url('admin-ajax.php')), ); wp_localize_script( 'grandcarrental-theme-script', 'tgAjax', $params ); wp_enqueue_script( 'grandcarrental-theme-script' ); } add_action('admin_enqueue_scripts', 'grandcarrental_enqueue_admin_page_scripts' ); function grandcarrental_enqueue_front_page_scripts() { wp_enqueue_style("grandcarrental-reset-css", get_template_directory_uri()."/css/reset.css", false, ""); wp_enqueue_style("grandcarrental-wordpress-css", get_template_directory_uri()."/css/wordpress.css", false, ""); wp_enqueue_style("grandcarrental-animation-css", get_template_directory_uri()."/css/animation.css", false, "", "all"); wp_enqueue_style("ilightbox", get_template_directory_uri()."/css/ilightbox/ilightbox.css", false, "", "all"); wp_enqueue_style("jquery-ui", get_template_directory_uri()."/css/jqueryui/custom.css", false, ""); wp_enqueue_style("mediaelement", get_template_directory_uri()."/js/mediaelement/mediaelementplayer.css", false, "", "all"); wp_enqueue_style("flexslider", get_template_directory_uri()."/js/flexslider/flexslider.css", false, "", "all"); wp_enqueue_style("tooltipster", get_template_directory_uri()."/css/tooltipster.css", false, "", "all"); wp_enqueue_style("odometer-theme", get_template_directory_uri()."/css/odometer-theme-minimal.css", false, "", "all"); wp_enqueue_style("grandcarrental-screen", get_template_directory_uri().'/css/screen.css', false, "", "all"); //Check menu layout $tg_menu_layout = grandcarrental_menu_layout(); switch($tg_menu_layout) { case 'leftalign': wp_enqueue_style("grandcarrental-leftalignmenu", get_template_directory_uri().'/css/menus/leftalignmenu.css', false, "", "all"); break; case 'hammenufull': wp_enqueue_style("grandcarrental-hammenufull", get_template_directory_uri().'/css/menus/hammenufull.css', false, "", "all"); break; case 'centeralogo': wp_enqueue_style("grandcarrental-centeralogo", get_template_directory_uri().'/css/menus/centeralogo.css', false, "", "all"); break; } //Add Font Awesome Support wp_enqueue_style("fontawesome", get_template_directory_uri()."/css/font-awesome.min.css", false, "", "all"); wp_enqueue_style("themify-icons", get_template_directory_uri()."/css/themify-icons.css", false, GRANDCARRENTAL_THEMEVERSION, "all"); $tg_boxed = kirki_get_option('tg_boxed'); if(GRANDCARRENTAL_THEMEDEMO && isset($_GET['boxed']) && !empty($_GET['boxed'])) { $tg_boxed = 1; } if(!empty($tg_boxed) && $tg_menu_layout != 'leftmenu') { wp_enqueue_style("grandcarrental-boxed", get_template_directory_uri().'/css/tg_boxed.css', false, "", "all"); } //Add custom CSS if(GRANDCARRENTAL_THEMEDEMO && isset($_GET['menulayout']) && !empty($_GET['menulayout'])) { wp_enqueue_style("grandcarrental-script-custom-css", admin_url('admin-ajax.php')."?action=grandcarrental_custom_css&menulayout=".$_GET['menulayout'], false, "", "all"); } else { wp_enqueue_style("grandcarrental-script-custom-css", admin_url('admin-ajax.php')."?action=grandcarrental_custom_css", false, "", "all"); } //If using child theme if(is_child_theme()) { wp_enqueue_style('grandcarrental-childtheme', get_stylesheet_directory_uri()."/style.css", false, "", "all"); } //Enqueue javascripts wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-datepicker'); $js_path = get_template_directory()."/js/"; $js_arr = array( 'requestAnimationFrame' => 'jquery.requestAnimationFrame.js', 'ilightbox' => 'ilightbox.packed.js', 'easing' => 'jquery.easing.js', 'waypoints' => 'waypoints.min.js', 'isotope' => 'jquery.isotope.js', 'masory' => 'jquery.masory.js', 'tooltipster' => 'jquery.tooltipster.min.js', 'jarallax' => 'jarallax.js', 'sticky-kit' => 'jquery.sticky-kit.min.js', 'stellar' => 'jquery.stellar.min.js', 'cookie' => 'jquery.cookie.js', 'grandcarrental-custom-plugins' => 'custom_plugins.js', 'grandcarrental-custom-script' =>'custom.js', ); $js = ""; foreach($js_arr as $key => $file) { if($file != 'jquery.js' && $file != 'jquery-ui.js') { wp_enqueue_script($key, get_template_directory_uri()."/js/".$file, false, "", true); } } //If display photostream $pp_photostream = get_option('pp_photostream'); if(!empty($pp_photostream)) { wp_enqueue_script("modernizr", get_template_directory_uri()."/js/modernizr.js", false, GRANDCARRENTAL_THEMEVERSION, true); wp_enqueue_script("gridrotator", get_template_directory_uri()."/js/jquery.gridrotator.js", false, GRANDCARRENTAL_THEMEVERSION, true); wp_enqueue_script("grandcarrental-script-footer-gridrotator", admin_url('admin-ajax.php')."?action=grandcarrental_script_gridrotator&grid=footer_photostream&rows=1", false, GRANDCARRENTAL_THEMEVERSION, true); } } add_action( 'wp_enqueue_scripts', 'grandcarrental_enqueue_front_page_scripts' ); //Enqueue mobile CSS after all others CSS load function grandcarrental_register_mobile_css() { //Check if enable responsive layout $tg_mobile_responsive = kirki_get_option('tg_mobile_responsive'); if(!empty($tg_mobile_responsive)) { //enqueue frontend css files wp_enqueue_style('grandcarrental-script-responsive-css', get_template_directory_uri()."/css/grid.css", false, "", "all"); } } add_action('wp_enqueue_scripts', 'grandcarrental_register_mobile_css', 99); function grandcarrental_admin() { $grandcarrental_options = grandcarrental_get_options(); $i=0; $pp_font_family = get_option('pp_font_family'); if(function_exists( 'wp_enqueue_media' )){ wp_enqueue_media(); } ?>

0 && $image_height > 0) { ?> <?php esc_attr(get_bloginfo('name')); ?> <?php esc_attr(get_bloginfo('name')); ?>




'.str_replace('-', ' ', esc_html($value['name'])).''; } } ?>
" />









 

" class="color_picker" readonly/>
url(/functions/images/trigger.png) center no-repeat;"> 






$option) { ?>
value=""/>



    $sortable_data_item) { if(!empty($sortable_data_item)) { ?>




/>
/>



$attr_item) { $last_class = ''; if(++$i_count === $num_attr) { $last_class = 'last'; } if(!isset($attr_item['title'])) { $attr_title = ucfirst($attr_name); } else { $attr_title = $attr_item['title']; } if($attr_item['type']=='jslider') { ?>











   px       px 
   px       px 




 










$ppb_form_item) { if(isset($_POST[$ppb_form_item.'_data'])) { $data_arr[$ppb_form_item] = $_POST[$ppb_form_item.'_data']; $size_arr[$ppb_form_item] = $_POST[$ppb_form_item.'_size']; } } } set_transient('grandcarrental_'.$page_id.'_data', $data_arr, 3600 ); set_transient('grandcarrental_'.$page_id.'_size', $size_arr, 3600 ); ?>

'; print_r($ppb_form_item_data_obj); print '';*/ $ppb_shortcodes = array(); require_once get_template_directory() . "/lib/contentbuilder.shortcode.lib.php"; if(isset($ppb_form_item_data_obj->$ppb_shortcode_content_name)) { $ppb_shortcode_code = '['.$ppb_form_item_data_obj->shortcode.' size="'.$ppb_form_item_size.'" '; //Get shortcode title $ppb_shortcode_title_name = $ppb_form_item_data_obj->shortcode.'_title'; if(isset($ppb_form_item_data_obj->$ppb_shortcode_title_name)) { $ppb_shortcode_code.= 'title="'.esc_attr(rawurldecode($ppb_form_item_data_obj->$ppb_shortcode_title_name), ENT_QUOTES, "UTF-8").'" '; } //Get shortcode attributes if(isset($ppb_shortcodes[$ppb_form_item_data_obj->shortcode])) { $ppb_shortcode_arr = $ppb_shortcodes[$ppb_form_item_data_obj->shortcode]; foreach($ppb_shortcode_arr['attr'] as $attr_name => $attr_item) { $ppb_shortcode_attr_name = $ppb_form_item_data_obj->shortcode.'_'.$attr_name; if(isset($ppb_form_item_data_obj->$ppb_shortcode_attr_name)) { $ppb_shortcode_code.= $attr_name.'="'.esc_attr(rawurldecode($ppb_form_item_data_obj->$ppb_shortcode_attr_name)).'" '; } } } $ppb_shortcode_code.= ']'.rawurldecode($ppb_form_item_data_obj->$ppb_shortcode_content_name).'[/'.$ppb_form_item_data_obj->shortcode.']'; } else { $ppb_shortcode_code = '['.$ppb_form_item_data_obj->shortcode.' size="'.$ppb_form_item_size.'" '; //Get shortcode title $ppb_shortcode_title_name = $ppb_form_item_data_obj->shortcode.'_title'; if(isset($ppb_form_item_data_obj->$ppb_shortcode_title_name)) { $ppb_shortcode_code.= 'title="'.esc_attr(rawurldecode($ppb_form_item_data_obj->$ppb_shortcode_title_name), ENT_QUOTES, "UTF-8").'" '; } //Get shortcode attributes if(isset($ppb_shortcodes[$ppb_form_item_data_obj->shortcode])) { $ppb_shortcode_arr = $ppb_shortcodes[$ppb_form_item_data_obj->shortcode]; foreach($ppb_shortcode_arr['attr'] as $attr_name => $attr_item) { $ppb_shortcode_attr_name = $ppb_form_item_data_obj->shortcode.'_'.$attr_name; if(isset($ppb_form_item_data_obj->$ppb_shortcode_attr_name)) { $ppb_shortcode_code.= $attr_name.'="'.esc_attr(rawurldecode($ppb_form_item_data_obj->$ppb_shortcode_attr_name)).'" '; } } } $ppb_shortcode_code.= ']'; } echo do_shortcode($ppb_shortcode_code); } die(); } /** * Save current as template function **/ add_action('wp_ajax_grandcarrental_ppb_set_template', 'grandcarrental_ppb_set_template'); add_action('wp_ajax_nopriv_grandcarrental_ppb_set_template', 'grandcarrental_ppb_set_template'); function grandcarrental_ppb_set_template() { if(is_admin() && isset($_POST['template_name']) && !empty($_POST['template_name']) && isset($_GET['page_id']) && !empty($_GET['page_id']) && strlen($_POST['template_name']) >= 3) { //Get page ID $page_id = $_GET['page_id']; //get list of my templates in array $my_current_templates = get_option(GRANDCARRENTAL_SHORTNAME."_my_templates"); //set new template ID and name $new_template_name = sanitize_text_field($_POST['template_name']); $new_template_id = $page_id.'_'.time(); $my_current_templates[$new_template_id] = $new_template_name; //Update my template list update_option( GRANDCARRENTAL_SHORTNAME."_my_templates", $my_current_templates ); //Save current page builder content to my template $ppb_form_data_order = get_post_meta($page_id, 'ppb_form_data_order'); $export_options_arr = array(); if(!empty($ppb_form_data_order)) { $export_options_arr['ppb_form_data_order'] = $ppb_form_data_order; //Get each builder module data $ppb_form_item_arr = explode(',', $ppb_form_data_order[0]); foreach($ppb_form_item_arr as $key => $ppb_form_item) { $ppb_form_item_data = get_post_meta($page_id, $ppb_form_item.'_data'); $export_options_arr[$ppb_form_item.'_data'] = $ppb_form_item_data; $ppb_form_item_size = get_post_meta($page_id, $ppb_form_item.'_size'); $export_options_arr[$ppb_form_item.'_size'] = $ppb_form_item_size; } } update_option( GRANDCARRENTAL_SHORTNAME."_template_".$new_template_id, json_encode($export_options_arr) ); //return template ID echo intval($new_template_id); } die(); } /** * Remove current template function **/ add_action('wp_ajax_grandcarrental_ppb_remove_template', 'grandcarrental_ppb_remove_template'); add_action('wp_ajax_nopriv_grandcarrental_ppb_remove_template', 'grandcarrental_ppb_remove_template'); function grandcarrental_ppb_remove_template() { if(is_admin() && isset($_GET['template_id']) && !empty($_GET['template_id'])) { //get list of my templates in array $my_current_templates = get_option(GRANDCARRENTAL_SHORTNAME."_my_templates"); $template_id = $_GET['template_id']; if(isset($my_current_templates[$template_id])) { //Remove template from array unset($my_current_templates[$template_id]); //Remove from my template list update_option( GRANDCARRENTAL_SHORTNAME."_my_templates", $my_current_templates ); //Remove template data delete_option( GRANDCARRENTAL_SHORTNAME."_template_".$template_id ); //display to AJAX response echo 1; } } die(); } /** * Save page builder custom fields **/ add_action('wp_ajax_grandcarrental_ppb_save_page_builder', 'grandcarrental_ppb_save_page_builder'); add_action('wp_ajax_nopriv_grandcarrental_ppb_save_page_builder', 'grandcarrental_ppb_save_page_builder'); function grandcarrental_ppb_save_page_builder() { if(is_admin() && isset($_POST['data_order']) && isset($_GET['page_id']) && !empty($_GET['page_id'])) { $page_id = $_GET['page_id']; //Get builder item $ppb_form_data_order = $_POST['data_order']; $ppb_form_item_arr = array(); if(isset($ppb_form_data_order)) { $ppb_form_item_arr = explode(',', $ppb_form_data_order); } if(!empty($ppb_form_item_arr)) { update_post_meta($page_id, 'ppb_form_data_order', $ppb_form_data_order); foreach($ppb_form_item_arr as $key => $ppb_form_item) { if(isset($_POST[$ppb_form_item.'_data']) && $_POST[$ppb_form_item.'_data'] != 'undefined') { update_post_meta($page_id, $ppb_form_item.'_data', $_POST[$ppb_form_item.'_data']); } if(isset($_POST[$ppb_form_item.'_size']) && $_POST[$ppb_form_item.'_size'] != 'undefined') { update_post_meta($page_id, $ppb_form_item.'_size', $_POST[$ppb_form_item.'_size']); } } } } die(); } /** * Save page custom fields **/ add_action('wp_ajax_grandcarrental_ppb_save_page_custom_field', 'grandcarrental_ppb_save_page_custom_field'); add_action('grandcarrental_ppb_save_page_custom_field', 'grandcarrental_ppb_save_page_custom_field'); function grandcarrental_ppb_save_page_custom_field() { if(is_admin() && isset($_GET['page_id']) && !empty($_GET['page_id']) && isset($_POST['field']) && !empty($_POST['field']) && isset($_POST['data'])) { echo intval($page_id); $page_id = $_GET['page_id']; update_post_meta($page_id, $_POST['field'], $_POST['data']); } die(); } /** * Setup one click importer function **/ add_action('wp_ajax_grandcarrental_import_demo_content', 'grandcarrental_import_demo_content'); add_action('wp_ajax_nopriv_grandcarrental_import_demo_content', 'grandcarrental_import_demo_content'); function grandcarrental_import_demo_content() { if(is_admin() && isset($_POST['demo']) && !empty($_POST['demo'])) { if ( !defined('WP_LOAD_IMPORTERS') ) define('WP_LOAD_IMPORTERS', true); // Load Importer API require_once ABSPATH . 'wp-admin/includes/import.php'; if ( ! class_exists( 'WP_Importer' ) ) { $class_wp_importer = ABSPATH . 'wp-admin/includes/class-wp-importer.php'; if ( file_exists( $class_wp_importer ) ) { require_once $class_wp_importer; } } if ( ! class_exists( 'WP_Import' ) ) { $class_wp_importer = get_template_directory() ."/modules/import/wordpress-importer.php"; if ( file_exists( $class_wp_importer ) ) require_once $class_wp_importer; } $import_files = array(); $page_on_front =''; switch($_POST['demo']) { case 1: default: $main_left_menu_exists = wp_get_nav_menu_object('Main Menu Left'); if(!$main_left_menu_exists) { $main_left_menu_id = wp_create_nav_menu('Main Menu Left'); } $main_right_menu_exists = wp_get_nav_menu_object('Main Menu Right'); if(!$main_right_menu_exists) { $main_right_menu_id = wp_create_nav_menu('Main Menu Right'); } $main_menu_exists = wp_get_nav_menu_object('Main Menu'); if(!$main_menu_exists) { $main_menu_id = wp_create_nav_menu('Main Menu'); } $footer_menu_exists = wp_get_nav_menu_object('Footer Menu'); if(!$footer_menu_exists) { $footer_menu_id = wp_create_nav_menu('Footer Menu'); } break; } //Check import selected demo if ( class_exists( 'WP_Import' ) ) { switch($_POST['demo']) { case 1: default: //Check if install Woocommerce if(!class_exists('Woocommerce')) { $import_filepath = get_template_directory() ."/cache/demos/xml/demo1/1.xml" ; } else { $import_filepath = get_template_directory() ."/cache/demos/xml/demo1/1_woo.xml" ; } $styling_file = get_template_directory() . "/cache/demos/xml/demo1/1.dat"; $import_widget_filepath = get_template_directory() ."/cache/demos/xml/demo1/1.wie" ; $page_on_front = 3075; //Demo Homepage ID $oldurl = 'http://themes.themegoods.com/grandcarrental/demo'; break; } //Run and download demo contents $wp_import = new WP_Import(); $wp_import->fetch_attachments = true; $wp_import->import($import_filepath); //Remove default Hello World post wp_delete_post(1); } //Setup default front page settings. update_option('show_on_front', 'page'); update_option('page_on_front', $page_on_front); //Set default custom menu settings $locations = get_theme_mod('nav_menu_locations'); switch($_POST['demo']) { case 1: default: $locations['primary-menu'] = $main_menu_id; $locations['footer-menu'] = $footer_menu_id; $locations['side-menu'] = $main_menu_id; break; } set_theme_mod( 'nav_menu_locations', $locations ); //Setup default styling if(file_exists($styling_file)) { WP_Filesystem(); $wp_filesystem = grandcarrental_get_wp_filesystem(); $styling_data = $wp_filesystem->get_contents($styling_file); $styling_data_arr = unserialize($styling_data); if(isset($styling_data_arr['mods']) && is_array($styling_data_arr['mods'])) { foreach($styling_data_arr['mods'] as $key => $styling_mod) { if(!is_array($styling_mod)) { set_theme_mod( $key, $styling_mod ); } } } } //Import widgets if(file_exists($import_widget_filepath)) { // Get file contents and decode WP_Filesystem(); $wp_filesystem = grandcarrental_get_wp_filesystem(); $data = $wp_filesystem->get_contents($import_widget_filepath); $data = json_decode( $data ); // Import the widget data // Make results available for display on import/export page $widget_import_results = grandcarrental_import_data( $data ); } //Import Revolution Slider if activate if(class_exists('RevSlider')) { $slider_array = array(); switch($_POST['demo']) { case 1: default: $slider_array = array( get_template_directory() ."/cache/demos/xml/demo1/home-4-slider.zip", ); break; } if(!empty($slider_array)) { require_once ABSPATH . 'wp-admin/includes/file.php'; $obj_revslider = new RevSlider(); foreach($slider_array as $revslider_filepath) { $obj_revslider->importSliderFromPost(true,true,$revslider_filepath); } } } //Change all URLs from demo URL to localhost $update_options = array ( 0 => 'content', 1 => 'excerpts', 2 => 'links', 3 => 'attachments', 4 => 'custom', 5 => 'guids', ); $newurl = esc_url( site_url() ) ; grandcarrental_update_urls($update_options, $oldurl, $newurl); //Refresh rewrite rules flush_rewrite_rules(); exit(); } } /** * Setup get styling function **/ add_action('wp_ajax_grandcarrental_get_styling', 'grandcarrental_get_styling'); add_action('wp_ajax_nopriv_grandcarrental_get_styling', 'grandcarrental_get_styling'); function grandcarrental_get_styling() { if(is_admin() && isset($_POST['styling']) && !empty($_POST['styling'])) { $styling_file = get_template_directory() . "/cache/demos/customizer/settings/".$_POST['styling'].".dat"; if(file_exists($styling_file)) { WP_Filesystem(); $wp_filesystem = grandcarrental_get_wp_filesystem(); $styling_data = $wp_filesystem->get_contents($styling_file); $styling_data_arr = unserialize($styling_data); if(isset($styling_data_arr['mods']) && is_array($styling_data_arr['mods'])) { // Get menu locations and save to array $locations = get_theme_mod('nav_menu_locations'); $save_menus = array(); foreach( $locations as $key => $val ) { $save_menus[$key] = $val; } //Remove all theme customizer remove_theme_mods(); //Re-add the menus set_theme_mod('nav_menu_locations', array_map( 'absint', $save_menus )); foreach($styling_data_arr['mods'] as $key => $styling_mod) { if(!is_array($styling_mod)) { set_theme_mod( $key, $styling_mod ); } } } exit(); } } } /** * Setup custom CSS function **/ add_action('wp_ajax_grandcarrental_custom_css', 'grandcarrental_custom_css'); add_action('wp_ajax_nopriv_grandcarrental_custom_css', 'grandcarrental_custom_css'); function grandcarrental_custom_css() { get_template_part("/modules/custom_css"); die(); } /** * Setup responsive CSS function **/ add_action('wp_ajax_grandcarrental_responsive_css', 'grandcarrental_responsive_css'); add_action('wp_ajax_nopriv_grandcarrental_responsive_css', 'grandcarrental_responsive_css'); function grandcarrental_responsive_css() { get_template_part("/modules/responsive_css"); die(); } /** * End responsive CSS function **/ /** * Setup custom script function **/ add_action('wp_ajax_grandcarrental_script_animate_circle_shortcode', 'grandcarrental_script_animate_circle_shortcode'); add_action('wp_ajax_nopriv_grandcarrental_script_animate_circle_shortcode', 'grandcarrental_script_animate_circle_shortcode'); function grandcarrental_script_animate_circle_shortcode() { get_template_part("/modules/script/script-animate-circle-shortcode"); die(); } add_action('wp_ajax_grandcarrental_script_animate_counter_shortcode', 'grandcarrental_script_animate_counter_shortcode'); add_action('wp_ajax_nopriv_grandcarrental_script_animate_counter_shortcode', 'grandcarrental_script_animate_counter_shortcode'); function grandcarrental_script_animate_counter_shortcode() { get_template_part("/modules/script/script-animate-counter-shortcode"); die(); } add_action('wp_ajax_grandcarrental_script_audio_shortcode', 'grandcarrental_script_audio_shortcode'); add_action('wp_ajax_nopriv_grandcarrental_script_audio_shortcode', 'grandcarrental_script_audio_shortcode'); function grandcarrental_script_audio_shortcode() { get_template_part("/modules/script/script-audio-shortcode"); die(); } add_action('wp_ajax_grandcarrental_script_demo', 'grandcarrental_script_demo'); add_action('wp_ajax_nopriv_grandcarrental_script_demo', 'grandcarrental_script_demo'); function grandcarrental_script_demo() { get_template_part("/modules/script/script-demo"); die(); } /** * Setup add product to cart function **/ add_action('wp_ajax_grandcarrental_add_to_cart', 'grandcarrental_add_to_cart'); add_action('wp_ajax_nopriv_grandcarrental_add_to_cart', 'grandcarrental_add_to_cart'); function grandcarrental_add_to_cart() { if(isset($_GET['product_id']) && !empty($_GET['product_id']) && class_exists('Woocommerce')) { $woocommerce = grandcarrental_get_woocommerce(); $woocommerce->cart->add_to_cart($_GET['product_id']); } die(); } /** * End add product to cart function **/ add_action('wp_ajax_grandcarrental_script_gallery_flexslider', 'grandcarrental_script_gallery_flexslider'); add_action('wp_ajax_nopriv_grandcarrental_script_gallery_flexslider', 'grandcarrental_script_gallery_flexslider'); function grandcarrental_script_gallery_flexslider() { get_template_part("/modules/script/script-gallery-flexslider"); die(); } add_action('wp_ajax_grandcarrental_script_gridrotator', 'grandcarrental_script_gridrotator'); add_action('wp_ajax_nopriv_grandcarrental_script_gridrotator', 'grandcarrental_script_gridrotator'); function grandcarrental_script_gridrotator() { get_template_part("/modules/script/script-gridrotator"); die(); } add_action('wp_ajax_grandcarrental_script_jwplayer_shortcode', 'grandcarrental_script_jwplayer_shortcode'); add_action('wp_ajax_nopriv_grandcarrental_script_jwplayer_shortcode', 'grandcarrental_script_jwplayer_shortcode'); function grandcarrental_script_jwplayer_shortcode() { get_template_part("/modules/script/script-jwplayer-shortcode"); die(); } add_action('wp_ajax_grandcarrental_script_map_shortcode', 'grandcarrental_script_map_shortcode'); add_action('wp_ajax_nopriv_grandcarrental_script_map_shortcode', 'grandcarrental_script_map_shortcode'); function grandcarrental_script_map_shortcode() { get_template_part("/modules/script/script-map-shortcode"); die(); } add_action('wp_ajax_grandcarrental_script_self_hosted_video', 'grandcarrental_script_self_hosted_video'); add_action('wp_ajax_nopriv_grandcarrental_script_self_hosted_video', 'grandcarrental_script_self_hosted_video'); function grandcarrental_script_self_hosted_video() { get_template_part("/modules/script/script-self-hosted-video"); die(); } add_action('wp_ajax_grandcarrental_script_slider_flexslider', 'grandcarrental_script_slider_flexslider'); add_action('wp_ajax_nopriv_grandcarrental_script_slider_flexslider', 'grandcarrental_script_slider_flexslider'); function grandcarrental_script_slider_flexslider() { get_template_part("/modules/script/script-slider-flexslider"); die(); } add_action('wp_ajax_grandcarrental_script_testimonials_flexslider', 'grandcarrental_script_testimonials_flexslider'); add_action('wp_ajax_nopriv_grandcarrental_script_testimonials_flexslider', 'grandcarrental_script_testimonials_flexslider'); function grandcarrental_script_testimonials_flexslider() { get_template_part("/modules/script/script-testimonials-flexslider"); die(); } add_action('wp_ajax_kirki_dynamic_css', 'kirki_dynamic_css'); add_action('wp_ajax_nopriv_kirki_dynamic_css', 'kirki_dynamic_css'); function kirki_dynamic_css() { $kirki = grandcarrental_get_kirki(); die(); } /** * End custom script function **/ if(GRANDCARRENTAL_THEMEDEMO) { function grandcarrental_add_my_query_var( $link ) { $arr_params = array(); if(isset($_GET['topbar'])) { $arr_params['topbar'] = $_GET['topbar']; } if(isset($_GET['menu'])) { $arr_params['menu'] = $_GET['menu']; } if(isset($_GET['frame'])) { $arr_params['frame'] = $_GET['frame']; } if(isset($_GET['frame_color'])) { $arr_params['frame_color'] = $_GET['frame_color']; } if(isset($_GET['boxed'])) { $arr_params['boxed'] = $_GET['boxed']; } if(isset($_GET['footer'])) { $arr_params['footer'] = $_GET['footer']; } if(isset($_GET['menulayout'])) { $arr_params['menulayout'] = $_GET['menulayout']; } $link = add_query_arg( $arr_params, $link ); return $link; } add_filter('category_link','grandcarrental_add_my_query_var'); add_filter('page_link','grandcarrental_add_my_query_var'); add_filter('post_link','grandcarrental_add_my_query_var'); add_filter('term_link','grandcarrental_add_my_query_var'); add_filter('tag_link','grandcarrental_add_my_query_var'); add_filter('category_link','grandcarrental_add_my_query_var'); add_filter('post_type_link','grandcarrental_add_my_query_var'); add_filter('attachment_link','grandcarrental_add_my_query_var'); add_filter('year_link','grandcarrental_add_my_query_var'); add_filter('month_link','grandcarrental_add_my_query_var'); add_filter('day_link','grandcarrental_add_my_query_var'); add_filter('search_link','grandcarrental_add_my_query_var'); add_filter('previous_post_link','grandcarrental_add_my_query_var'); add_filter('next_post_link','grandcarrental_add_my_query_var'); } //Setup custom settings when theme is activated if (isset($_GET['activated']) && $_GET['activated']){ //Add default contact fields $pp_contact_form = get_option('pp_contact_form'); if(empty($pp_contact_form)) { add_option( 'pp_contact_form', 's:1:"3";' ); } $pp_contact_form_sort_data = get_option('pp_contact_form_sort_data'); if(empty($pp_contact_form_sort_data)) { add_option( 'pp_contact_form_sort_data', 'a:3:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:1:"3";}' ); } wp_redirect(admin_url("admin.php?page=functions.php&activate=true")); } ?>