/** * Fixes links to the tours archive page. Filter used by WPML plugin to disaply list of trnslated pages. * * @param assoc $languages * @return assoc */ public function filter_icl_ls_languages_fix_tours_link($languages) { static $first_call = true, $tour_page_id; if ($first_call) { // checking if current page is tours page, if no - removing this filter // need improve $first_call = false; if (!adventure_tours_check('is_tour_search')) { remove_filter('icl_ls_languages', array($this, 'filter_icl_ls_languages_fix_tours_link'), 20); return $languages; } } if (null === $tour_page_id) { $tour_page_id = adventure_tours_get_option('tours_page', ''); } global $sitepress; foreach ($languages as $code => $language) { // for WPML version prior 3.3.0 // $languages[$code]['url'] = get_permalink( apply_filters( 'translate_object_id', $tour_page_id, 'page', true, $language['language_code'] ) ); // for WPML version > 3.3.0 $sitepress->switch_lang($language['language_code']); $languages[$code]['url'] = get_permalink(apply_filters('translate_object_id', $tour_page_id, 'page', true, $language['language_code'])); $sitepress->switch_lang(); } return $languages; }
/** * Callback for 'init' action. * * @return void */ function adventure_tours_action_init() { if (adventure_tours_check('tour_category_taxonomy_exists')) { // Initing services related on images and icons processing for tour_category taxonomy. adventure_tours_di('taxonomy_display_data'); adventure_tours_di('taxonomy_images'); adventure_tours_di('taxonomy_icons'); adventure_tours_di('taxonomy_header_sections'); // Init for the tour booking form. adventure_tours_di('booking_form'); } if (adventure_tours_check('woocommerce_active')) { adventure_tours_di('wc_shortcodes_helper'); } if (is_admin()) { // To init shortcodes menu for tinyMCE. require 'shortcodes/menu.php'; } }
<?php /** * Sidebar template used for woocommerce related page. * * @author Themedelight * @package Themedelight/AdventureTours * @version 1.0.9 */ $is_tour_query = adventure_tours_check('is_tour_search'); $current_product = is_single() ? wc_get_product() : null; $is_single_tour = $current_product && $current_product->is_type('tour'); $is_tour_category = is_tax('tour_category'); $show_booking_form = $is_single_tour; $sidebar_id = $is_tour_query || $is_single_tour || $is_tour_category ? 'tour-sidebar' : 'shop-sidebar'; $show_sidebar = is_active_sidebar($sidebar_id); $tour_search_form = $is_tour_query && adventure_tours_get_option('tours_archive_show_search_form', 1) ? adventure_tours_render_tour_search_form() : null; if (!$show_sidebar && !$show_booking_form && !$tour_search_form) { return; } ?> <aside class="col-md-3 sidebar" role="complementary"> <?php if ($tour_search_form) { print adventure_tours_render_tour_search_form(); } if ($show_booking_form) { get_template_part('templates/tour/price-decoration'); echo adventure_tours_render_tour_booking_form($current_product); } if ($show_sidebar) {
/** * Return list for tour_category selector. * * @return array */ function adventure_tours_vp_get_tour_start_category_list() { $result = array(); if (!adventure_tours_check('tour_category_taxonomy_exists')) { return $result; } $list = get_terms('tour_category', array('hierarchical' => true)); if ($list) { $top = array(); $children = array(); foreach ($list as $item) { $el = array('value' => $item->term_id, 'label' => $item->name . "({$item->count})"); if ($item->parent) { $children[$item->parent][$item->term_id] = $el; } else { $top[$item->term_id] = $el; } } foreach ($top as $top_id => $el) { __at_vp_cat_list_walker($result, $children, $top_id, $el, ''); } } return $result; }
<div class="form-block__description"><?php echo esc_html($note); ?> </div> <?php } ?> <form method="get" action="<?php echo esc_url(home_url('/')); ?> "> <input type="hidden" name="toursearch" value="1"> <?php if (adventure_tours_check('is_wpml_in_use')) { ?> <input type="hidden" name="lang" value="<?php echo esc_attr(ICL_LANGUAGE_CODE); ?> "> <?php } ?> <?php if (!$hide_text_field) { ?> <div class="form-block__item form-block__field-width-icon"> <input type="text" placeholder="<?php echo esc_attr_x('Search Tour', 'placeholder', 'adventure-tours');
public static function get_tour_base_rewrite_rule($with_front = false, $reset_cache = true) { static $base_url, $base_full, $is_front_page, $default_lang, $cur_lang; if (null === $base_url || $reset_cache) { $tours_page_id = adventure_tours_get_option('tours_page'); // if WPML in use we need ensure that we have page_id in default language if (adventure_tours_check('is_wpml_in_use') && !is_admin()) { if (null === $cur_lang) { $default_lang = apply_filters('wpml_default_language', ''); $cur_lang = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : $cur_lang; } if ($default_lang != $cur_lang) { $page_id_in_default_lang = icl_object_id($tours_page_id, 'page', true, $default_lang); if ($page_id_in_default_lang) { $tours_page_id = $page_id_in_default_lang; } } } if ($tours_page_id && 'page' == get_option('show_on_front') && $tours_page_id == get_option('page_on_front')) { $base_url = ''; $is_front_page = true; } else { $base_url = $tours_page_id ? get_page_uri($tours_page_id) : 'tours'; if ($base_url) { $base_url .= '/'; } } } if ($with_front) { if (null === $base_full || $reset_cache) { $base_full = $base_url || $is_front_page ? $GLOBALS['wp_rewrite']->front . $base_url : ''; } return $base_full; } return $base_url; }
/** * Renders Tour Booking management tab on the product management page. * * @return void */ public function filter_woocommerce_product_write_panels() { wp_enqueue_script('theme-tools', PARENT_URL . '/assets/js/ThemeTools.js', array('jquery'), '1.0.0'); wp_enqueue_script('tour-booking-tab', PARENT_URL . '/assets/js/AdminTourBookingTab.js', array('jquery'), '1.0.0'); global $post; adventure_tours_render_template_part('templates/admin/tour-booking-tab', '', array('periods' => adventure_tours_di('tour_booking_service')->get_rows($post->ID), 'product_translation' => $this->is_product_translation(), 'disable_ajax_saving' => adventure_tours_check('is_wpml_in_use'), 'nonce_field' => array('name' => self::$booking_form_nonce_field_name, 'value' => self::$booking_form_nonce_key))); }
protected function check_import_type_requirements($type, $options, $full_check = false) { $errors = array(); if (empty($options['enabled'])) { $errors[] = 'This option is disabled.'; } elseif (!in_array($type, $this->types_allowed_for_import)) { $errors[] = 'Unknown import type.'; } if (!$errors) { $check_keys = array('file', 'file_adventure_addons'); foreach ($check_keys as $key_name) { if (!empty($options[$key_name]) && !file_exists($options[$key_name])) { $errors[] = 'Import file is missed. Please contact support.'; } } } switch ($type) { case 'faq': case 'page': case 'post': case 'product': // wordpress-importer plugin check $import_plugin_file = 'wordpress-importer/wordpress-importer.php'; if (!is_plugin_active($import_plugin_file)) { $errors[] = $this->get_missed_plugin_message('WordPress Importer', 'wordpress-importer'); } if ($full_check) { if (!class_exists('WP_Import')) { /*if (!defined('WP_LOAD_IMPORTERS') ) { define('WP_LOAD_IMPORTERS', true); include ABSPATH . '/wp-content/plugins/' . $import_plugin_file; }*/ if (!class_exists('WP_Import')) { $errors[] = 'Can not load WP_Import class.'; } } } if ('product' == $type) { if (!class_exists('woocommerce')) { $errors[] = $this->get_missed_plugin_message('Woocommerce', 'woocommerce'); } if (!adventure_tours_check('tour_category_taxonomy_exists')) { $errors[] = $this->get_missed_plugin_message('Data types for Adventure Tours theme', ''); } } break; case 'configurate_woocommerce': if (!class_exists('woocommerce')) { $errors[] = $this->get_missed_plugin_message('Woocommerce', 'woocommerce'); } break; case 'theme_widgets': // widget-importer-exporter plugin check $wie_plugin_file = 'widget-importer-exporter/widget-importer-exporter.php'; if (!is_plugin_active($wie_plugin_file)) { $errors[] = $this->get_missed_plugin_message('Widget Importer & Exporter', 'widget-importer-exporter'); } break; } $result = array('available' => empty($errors)); if ($errors) { $result['errors'] = $errors; } return $result; }
/** * Filter for woocommerce bredcrumbs generation function. * To fix breadcrumbs for tours and tour categories. * * @param array $list * @param array $init_list * @return array */ public function filter_woocommerce_get_breadcrumb($list, $init_list) { $isTourDetails = false; if (!empty($GLOBALS['product'])) { $p = wc_get_product(); if ($p && $p->is_type('tour')) { $isTourDetails = true; } } $tour_cat_tax_name = 'tour_category'; $is_set_tour = $isTourDetails || adventure_tours_check('is_tour_search'); $is_tour_cat = !$is_set_tour ? is_tax($tour_cat_tax_name) : false; $tour_element = array(); if ($is_set_tour || $is_tour_cat) { $toursPageId = adventure_tours_get_option('tours_page'); $toursLink = $toursPageId ? get_permalink($toursPageId) : ''; if ($toursLink) { $tour_element = array(get_the_title($toursPageId), $toursLink); } } if ($is_set_tour) { if ($tour_element) { $first_element = isset($list[1]) ? $list[1] : null; $list[1] = $tour_element; // case when init list contatins only Home/ Tour X if ($isTourDetails && $first_element && empty($list[2]) && is_single()) { $list[] = $first_element; } } if (adventure_tours_check('is_tour_search')) { $last_index = count($list) - 1; if (is_search()) { // replacement for breadcrumbs "Search results for ''" if (!get_search_query(false)) { $list[$last_index][0] = esc_html__('Search results', 'adventure-tours'); // $list[ $last_index ][0] = str_replace('“”', '', $list[ $last_index ][0]); } } elseif (!empty($_REQUEST['tourtax'])) { // adding 'Search results' element to breadcrumbs in case if search in use and last element is "Tours" if ($tour_element == $list[$last_index]) { $list[] = array(esc_html__('Search results', 'adventure-tours'), ''); } } } } elseif ($is_tour_cat) { $new_list = array($list[0], $tour_element); $current_term = $GLOBALS['wp_query']->get_queried_object(); $ancestors = get_ancestors($current_term->term_id, $tour_cat_tax_name); $ancestors = array_reverse($ancestors); foreach ($ancestors as $ancestor) { $ancestor = get_term($ancestor, $tour_cat_tax_name); if (!is_wp_error($ancestor) && $ancestor) { $new_list[] = array($ancestor->name, get_term_link($ancestor)); } } $new_list[] = array($current_term->name); return $new_list; } return $list; }
$result[] = array('name' => "tour_badge_{$bid}_is_active", 'label' => sprintf(esc_html__('Is Active Badge #%d', 'adventure-tours'), $bid), 'type' => 'toggle', 'default' => '0'); $result[] = array('name' => "tour_badge_{$bid}_title", 'label' => sprintf(esc_html__('Title #%d', 'adventure-tours'), $bid), 'type' => 'textbox', 'default' => '', 'dependency' => array('field' => "tour_badge_{$bid}_is_active", 'function' => 'vp_dep_boolean')); $result[] = array('name' => "tour_badge_{$bid}_color", 'label' => sprintf(esc_html__('Color #%d', 'adventure-tours'), $bid), 'type' => 'color', 'default' => '', 'dependency' => array('field' => "tour_badge_{$bid}_is_active", 'function' => 'vp_dep_boolean')); } return $result; } function _adventure_tours_shop_cart_option() { $descriptionNoticeText = ''; if (!class_exists('WooCommerce')) { $descriptionNoticeText = esc_html__('Please install and activate the WooCommerce plugin.', 'adventure-tours'); } return array('name' => 'show_header_shop_cart', 'label' => esc_html__('Show Shopping Cart', 'adventure-tours'), 'description' => $descriptionNoticeText ? '<span style="color:#EE0000">' . $descriptionNoticeText . '</span>' : '', 'type' => 'toggle', 'default' => '1'); } function _adventure_tours_additional_social_icons($limit = 5) { $result = array(); for ($cur_index = 1; $cur_index <= $limit; $cur_index++) { $result[] = array('name' => "social_link_{$cur_index}_is_active", 'label' => sprintf(esc_html__('Link #%d', 'adventure-tours'), $cur_index), 'type' => 'toggle', 'default' => '0'); $result[] = array('name' => "social_link_{$cur_index}_icon", 'label' => sprintf(esc_html__('Icon #%d', 'adventure-tours'), $cur_index), 'type' => 'fontawesome', 'default' => '', 'validation' => 'required', 'dependency' => array('field' => "social_link_{$cur_index}_is_active", 'function' => 'vp_dep_boolean')); $result[] = array('name' => "social_link_{$cur_index}_url", 'label' => sprintf(esc_html__('Url #%d', 'adventure-tours'), $cur_index), 'type' => 'textbox', 'default' => '', 'validation' => 'required|url', 'dependency' => array('field' => "social_link_{$cur_index}_is_active", 'function' => 'vp_dep_boolean')); } return $result; } if (!adventure_tours_check('faq_taxonomies')) { unset($full_options_config['menus']['faq_section']); } if (!adventure_tours_check('tours_active')) { unset($full_options_config['menus']['tours_section']); } return $full_options_config;
/** * Tour details page, tab description rendeing function. * * @return void */ function adventure_tours_render_tab_description() { global $product; if (adventure_tours_check('tour_category_taxonomy_exists')) { $taxonomy = 'tour_category'; $terms = get_the_terms($product->ID, $taxonomy); if ($terms) { echo '<ul class="list-block list-block--tour-tabs">'; foreach ($terms as $term) { echo '<li><a href="' . get_term_link($term->slug, $taxonomy) . '">' . $term->name . '</a></li>'; } echo '</ul>'; } } the_content(); if (!empty($GLOBALS['_tour_additional_attributes'])) { adventure_tours_render_template_part('templates/tour/additional-attributes', '', array('title' => esc_html__('Additional information', 'adventure-tours'), 'attributes' => $GLOBALS['_tour_additional_attributes'])); } }
* * @author Themedelight * @package Themedelight/AdventureTours * @version 1.1.2 */ get_header(); $cat_tax_name = 'faq_category'; $mode_all = false; $cat_taxonomies = array(); TdJsClientScript::addScript('faqAccorsionChagesIconInit', 'Theme.faqAccordionCahgesIcon();'); $is_sidebar = is_active_sidebar('faq-sidebar'); $show_question_form = adventure_tours_get_option('faq_show_question_form'); $is_show_col = $is_sidebar || $show_question_form; $accordion_id = 1; $accordion_item_id = 1; if (adventure_tours_check('faq_taxonomies')) { if (is_tax($cat_tax_name)) { // query for particular category $cur_category = get_queried_object(); if ($cur_category) { $cat_taxonomies[] = $cur_category; } } elseif (have_posts()) { // page template is used $mode_all = true; the_post(); $cat_taxonomies = get_terms($cat_tax_name); } $cat_ids = array(); if ($cat_taxonomies) { foreach ($cat_taxonomies as $category) {
<?php /** * Sidebar template file. * * @author Themedelight * @package Themedelight/AdventureTours * @version 1.0.0 */ $show_sidebar = is_active_sidebar('sidebar'); $tour_search_form = adventure_tours_check('is_tour_search') ? adventure_tours_render_tour_search_form() : null; if (!$show_sidebar && !$tour_search_form) { return; } ?> <aside class="col-md-3 sidebar" role="complementary"> <?php if ($tour_search_form) { print adventure_tours_render_tour_search_form(); } dynamic_sidebar('sidebar'); ?> </aside>
protected function get_section_id_for_archive_page() { $result = 0; if (adventure_tours_check('is_tour_search')) { // static page for tours $result = adventure_tours_get_option('tours_page'); } elseif (is_home()) { $result = get_option('page_for_posts'); } elseif (is_post_type_archive('product')) { $result = wc_get_page_id('shop'); } elseif (is_tax('tour_category')) { $tour_category = get_queried_object(); if ($tour_category && isset($tour_category->term_id)) { $storage = adventure_tours_di('tour_category_header_sections_storage'); if ($storage && $storage->is_active()) { $result = $storage->getData($tour_category->term_id); } } } return $result; }