$value ) { $instance = null; $class = ''; $typeof = gettype( $value ); switch ( $typeof ) { case 'string': $class = $value; break; case 'array': $class = array_shift( $value ); break; default: $instance = $value; $class = get_class( $instance ); break; } $diKey = is_string( $key ) ? $key : $class; if ( isset( $di[$diKey] ) ) { continue; } $di[$diKey] = $instance ? $instance : JuiceDefinition::create( $class, $value ); } } } // -----------------------------------------------------------------# // Theme settings functions // -----------------------------------------------------------------# /** * Option name used for storing theme settings. * * @see adventure_tours_get_option * @see adventure_tours_filter_after_theme_setup */ if ( ! defined( 'VP_OPTION_KEY' ) ) { define( 'VP_OPTION_KEY', 'adventure_tours_theme_options' ); } // Vafpress framework integration. if ( ! defined( 'VP_URL' ) ) { define( 'VP_URL', PARENT_URL . '/vendor/vafpress' ); } require PARENT_DIR . '/vendor/vafpress/bootstrap.php'; // Additional vafpress fields implementation. // VP_AutoLoader::add_directories(PARENT_DIR .'/includes/vafpress-addon/classes', 'VP_'); . // VP_FileSystem::instance()->add_directories('views', PARENT_DIR .'/includes/vafpress-addon/views'); . if ( ! function_exists( 'adventure_tours_get_option' ) ) { /** * Returns theme option value. * * @param string $name option name. * @param mixed $default default value. * @return mixed */ function adventure_tours_get_option($name, $default = null) { return vp_option( VP_OPTION_KEY .'.'.$name, $default ); } } if ( ! function_exists( 'adventure_tours_filter_after_theme_setup' ) ) { /** * Init theme function. * * @return void */ function adventure_tours_filter_after_theme_setup() { load_theme_textdomain( 'adventure-tours', PARENT_DIR . '/languages' ); do_action( 'adventure_tours_init_di', adventure_tours_di(), require PARENT_DIR . '/config.php' ); $autoinit_services = adventure_tours_di( 'register' )->getVar( 'autoinit_services' ); if ( $autoinit_services ) { foreach ( $autoinit_services as $service_id ) { adventure_tours_di( $service_id ); } } // Initing Vafpress Framework theme options. $vp_theme_option = new VP_Option(array( // 'is_dev_mode' => THEME_IS_DEV_MODE, 'option_key' => VP_OPTION_KEY, 'page_slug' => 'theme_options_page', 'template' => PARENT_DIR . '/includes/theme-options-config.php', 'menu_page' => 'themes.php', 'use_auto_group_naming' => true, 'use_exim_menu' => true, 'minimum_role' => 'edit_theme_options', 'layout' => 'fixed', 'page_title' => esc_html__( 'Theme Options', 'adventure-tours' ), 'menu_label' => esc_html__( 'Theme Options', 'adventure-tours' ), )); adventure_tours_di( 'register' )->setVar( '_vp_theme_option', $vp_theme_option ); if ( adventure_tours_check( 'is_wpml_in_use' ) ) { new AtWPMLIntegrationHelper(array( 'option_name' => VP_OPTION_KEY, 'settings_for_translation' => array( 'banner_default_subtitle', 'contact_phone', 'contact_time', 'footer_text_note', 'tour_badge_1_title', 'tour_badge_2_title', 'tour_badge_3_title', 'tours_search_form_title', 'tours_search_form_note', 'excerpt_text', 'faq_show_question_form', ), 'page_id_settings_for_translation' => array( 'tours_page', ) )); } if ( adventure_tours_check( 'is_wordpress_seo_in_use' ) ) { new AtWordpressSEOIntegrationHelper(); } if ( is_super_admin() && !THEME_IS_DEV_MODE && adventure_tours_get_option( 'update_notifier' ) ) { adventure_tours_di( 'theme_updater' ); } } add_action( 'after_setup_theme', 'adventure_tours_filter_after_theme_setup' ); } if ( ! function_exists( 'adventure_tours_action_init' ) ) { /** * 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() ) { adveture_tours_init_tiny_mce_integration(); } } add_action( 'init', 'adventure_tours_action_init' ); } if ( ! function_exists( 'adveture_tours_init_tiny_mce_integration' ) ) { function adveture_tours_init_tiny_mce_integration() { // To init shortcodes menu for tinyMCE. $integrator = adventure_tours_di( 'shortcodes_tiny_mce_integrator' ); if ( $integrator && $integrator->registerService ) { $schorcodes_register = $integrator->registerService; $load_shortcodes = apply_filters( 'adventure_tours_shortcodes_register_preload_list', array() ); if ( $load_shortcodes ) { $tables_menu = esc_html__( 'Tables', 'adventure-tours' ) . '.'; $schorcodes_register->add( '_edit_', esc_html__( 'Edit', 'adventure-tours' ), array() ); $schorcodes_register->add( 'table', $tables_menu . esc_html__( 'Table', 'adventure-tours' ), array( 'rows' => '', 'cols' => '', 'css_class' => '', ) ); $schorcodes_register->add( 'tour_table', $tables_menu . esc_html__( 'Tour Table', 'adventure-tours' ), array( 'rows' => '', 'cols' => '', 'css_class' => '', ) ); foreach ( $load_shortcodes as $shortcode => $details ) { $schorcodes_register->add( $shortcode, $details['name'], $details['params'] ); } } } } } if ( ! function_exists( 'adveture_tours_filter_tour_loop_settings' ) ) { /** * Filter function that loads settings for the tour page from theme options. * * @param assoc $settings * @param string $view_type allowed values are: 'list' or 'grid' * @return assoc */ function adveture_tours_filter_tour_loop_settings( $settings, $view_type = '' ) { $settings['show_categories'] = adventure_tours_get_option( 'tours_archive_tour_display_category', '1' ); $settings['description_words_limit'] = adventure_tours_get_option( 'tours_archive_tour_description_words_limit', '13' ); if ( 'grid' == $view_type ) { $settings['columns'] = adventure_tours_get_option( 'tours_archive_columns_number', '2' ); $settings['price_style'] = adventure_tours_get_option( 'tours_archive_tour_price_style', 'default' ); if ( 2 == $settings['columns'] ) { $settings['image_size'] = 'thumb_tour_listing'; } } return $settings; } add_filter( 'adveture_tours_loop_settings', 'adveture_tours_filter_tour_loop_settings', 10, 2 ); } if ( is_admin() ) { require 'admin/plugins.php'; require 'admin/demo-data-import.php'; } require 'theme-options-functions.php'; require 'template-functions.php'; if ( class_exists( 'woocommerce' ) ) { add_theme_support( 'woocommerce' ); require_once PARENT_DIR . '/woocommerce/woocommerce.php'; } // -----------------------------------------------------------------# // Asserts registration // -----------------------------------------------------------------# if ( ! function_exists( 'adventure_tours_init_theme_asserts' ) ) { /** * Defines theme assets. * * @return void */ function adventure_tours_init_theme_asserts() { $minExt = SCRIPT_DEBUG ? '' : '.min'; $is_rtl = is_rtl(); if ( THEME_IS_DEV_MODE ) { if ( $is_rtl ) { wp_enqueue_style( 'bootstrap-custom-rtl', PARENT_URL . '/assets/csslib/bootstrap-custom-rtl.css' ); } else { wp_enqueue_style( 'bootstrap-custom', PARENT_URL . '/assets/csslib/bootstrap-custom.css' ); } wp_enqueue_style( 'fontawesome', PARENT_URL . '/assets/csslib/font-awesome.min.css' ); wp_enqueue_style( 'bootstrap-select', PARENT_URL . '/assets/csslib/bootstrap-select.min.css' ); wp_register_style( 'magnific-popup', PARENT_URL . '/assets/csslib/magnific-popup.css', array(), '1.0.0' ); wp_register_style( 'swipebox', PARENT_URL . '/assets/csslib/swipebox.css' ); wp_register_style( 'swiper', PARENT_URL . '/assets/csslib/swiper.min.css' ); wp_enqueue_script( 'bootstrap', PARENT_URL . '/assets/jslib/bootstrap.min.js',array( 'jquery' ), '',true ); wp_enqueue_script( 'bootstrap-select', PARENT_URL . '/assets/jslib/bootstrap-select/bootstrap-select.min.js', array( 'jquery', 'bootstrap' ), '', true ); wp_enqueue_script( 'slicknav', PARENT_URL . '/assets/jslib/jquery.slicknav.js',array( 'jquery' ), '',true ); wp_enqueue_script( 'tabcollapse', PARENT_URL . '/assets/jslib/bootstrap-tabcollapse.js', array( 'jquery' ), '', true ); wp_enqueue_script( 'theme', PARENT_URL . '/assets/js/Theme.js', array( 'jquery' ), '', true ); wp_register_script( 'magnific-popup', PARENT_URL . '/assets/jslib/jquery.magnific-popup.min.js', array( 'jquery' ), '1.0.0', true ); if ( adventure_tours_get_option( 'show_header_search' ) ) { wp_enqueue_style( 'magnific-popup' ); wp_enqueue_script( 'magnific-popup' ); } wp_register_script( 'swipebox', PARENT_URL . '/assets/jslib/jquery.swipebox.js', array( 'jquery' ), '1.3.0.2', true ); wp_register_script( 'swiper', PARENT_URL . '/assets/jslib/swiper/swiper.jquery.min.js', array(), '', true ); wp_register_script( 'parallax', PARENT_URL . '/assets/jslib/jquery.parallax-1.1.3.js', array( 'jquery' ), '1.1.3', true ); wp_register_script( 'sharrre', PARENT_URL . '/assets/jslib/jquery.sharrre.js', array( 'jquery' ), '',true ); } else { wp_enqueue_style( 'theme-addons', PARENT_URL . '/assets/csslib/theme-addons' . ( $is_rtl ? '-rtl' : '' ) . $minExt . '.css', array(), '1.3.0' ); wp_enqueue_script( 'theme', PARENT_URL . '/assets/js/theme-full' . $minExt . '.js', array( 'jquery' ), ADVENTURE_TOURS_VERSION, true ); } $styleCollection = apply_filters('get-theme-styles', array( 'style-css' => get_stylesheet_uri(), )); if ( $styleCollection ) { foreach ( $styleCollection as $_itemKey => $resourceInfo ) { $_styleText = null; $_styleUrl = null; if ( ! is_array( $resourceInfo ) ) { $_styleUrl = $resourceInfo; } else { if ( isset( $resourceInfo['text'] ) ) { $_styleText = $resourceInfo['text']; } elseif ( isset( $resourceInfo['url'] ) ) { $_styleUrl = $resourceInfo['url']; } } if ( $_styleUrl ) { wp_enqueue_style( $_itemKey, $_styleUrl ); } elseif ( $_styleText ) { adventure_tours_di( 'register' )->pushVar('header_inline_css_text', array( 'id' => $_itemKey, 'text' => $_styleText, )); } } } wp_register_script( 'jPages', PARENT_URL . '/assets/jslib/jPages.js', array( 'jquery' ), '', true ); // wp_register_style( 'jquery-ui-datepicker-custom', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css', array(), '1.8.2' ); wp_register_style( 'jquery-ui-datepicker-custom', PARENT_URL . '/assets/csslib/jquery-ui-custom/jquery-ui.min.css', array(), '1.11.4' ); } add_action( 'wp_enqueue_scripts', 'adventure_tours_init_theme_asserts' ); } // -----------------------------------------------------------------# // Widgets registration // -----------------------------------------------------------------# if ( ! function_exists( 'adventure_tours_register_widgets' ) ) { /** * Hook for widgets registration. * * @return void */ function adventure_tours_register_widgets() { // Make a Wordpress built-in Text widget process shortcodes. add_filter( 'widget_text', 'shortcode_unautop'); add_filter( 'widget_text', 'do_shortcode', 11); register_widget( 'AtWidgetLatestPosts' ); register_widget( 'AtWidgetContactUs' ); register_widget( 'AtWidgetTwitterTweets' ); if ( class_exists( 'woocommerce' ) ) { register_widget( 'AtWidgetTours' ); } register_sidebar(array( 'id' => 'sidebar', 'name' => esc_html__( 'Sidebar', 'adventure-tours' ), 'description' => esc_html__( 'Sidebar located on the right side of blog page.', 'adventure-tours' ), 'before_widget' => '
', 'before_title' => '* array( * 'Collection 1' => array( * 'icon icon-1' => 'Icon #1', * 'icon icon-1' => 'Icon #2', * ), * 'Set #2' => array( * 'iset icon-1' => 'ISet icon #1', * 'iset icon-2' => 'ISet icon #2', * ), * ) ** * @return assoc */ function adventure_tours_filter_theme_fonts_icon_sets( $icons ) { $di = adventure_tours_di(); if ( isset( $di['icons_manager'] ) ) { $at_icons_list = adventure_tours_di( 'icons_manager' )->get_list(); if ( $at_icons_list ) { $set = array(); foreach ( $at_icons_list as $icon ) { $set[$icon['value']] = $icon['label']; } $icons['Themedelight'] = $set; } } $icons_manager = new TdFontIconsManager( array( 'font_file_url' => PARENT_URL . '/assets/csslib/font-awesome.min.css', 'pattern' => '/\.(fa-(?:\w+(?:-)?)+):before\s*{\s*content/', 'cache_key' => 'at-font-awesome-icons-list', ) ); $font_awesome_icons_list = $icons_manager->get_list(); if ( $font_awesome_icons_list ) { $set = array(); foreach ( $font_awesome_icons_list as $icon ) { $icon_class = 'fa ' . $icon['value']; $set[$icon_class] = $icon['label']; } $icons['Font Awesome'] = $set; } return $icons; } add_filter( 'atdtp_get_at_icon_shortcode_icons', 'adventure_tours_filter_theme_fonts_icon_sets' ); } if ( ! function_exists( 'adventure_tours_filter_upgrader_package_options' ) ) { function adventure_tours_filter_upgrader_package_options( $options ){ if ( !empty( $options['hook_extra']['theme'] ) && 'adventure-tours' == $options['hook_extra']['theme'] ) { $package = !empty( $options['package'] ) ? $options['package'] : ''; if ( $package && preg_match( '`^(http|https|ftp)://`i', $package ) && ! file_exists( $package ) ) { // downloads update package to resolve issue with long name generated by `wp_tempnam` in `download_url` function $tmpfname = wp_tempnam(); if ( $tmpfname ) { $response = wp_safe_remote_get( $url, array( 'timeout' => 300, 'stream' => true, 'filename' => $tmpfname ) ); if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { unlink( $tmpfname ); } else { $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); if ( $content_md5 ) { $md5_check = verify_file_md5( $tmpfname, $content_md5 ); if ( is_wp_error( $md5_check ) ) { unlink( $tmpfname ); } } if ( file_exists($tmpfname) ) { $options['package'] = $tmpfname; } } } } } return $options; } add_filter( 'upgrader_package_options', 'adventure_tours_filter_upgrader_package_options' ); } if ( ! function_exists( 'adventure_tours_check' ) ) { function adventure_tours_check( $check_name, $ignore_cache = false ) { static $cache = array(); if ( ! isset( $cache[ $check_name ] ) || $ignore_cache ) { $result = false; switch( $check_name ) { case 'is_single_tour': if ( is_singular( 'product' ) && function_exists( 'wc_get_product' ) ) { $product = wc_get_product(); $result = $product && $product->is_type( 'tour' ); } break; case 'is_tour_search': return $GLOBALS['wp_query']->get( 'is_tour_query' ); break; case 'tour_category_taxonomy_exists': $result = taxonomy_exists( 'tour_category' ); break; case 'media_category_taxonomy_exists': $result = taxonomy_exists( 'media_category' ); break; case 'faq_taxonomies': $result = taxonomy_exists( 'faq_category' ) && post_type_exists( 'faq' ); break; case 'woocommerce_active': case 'tours_active': $result = class_exists( 'woocommerce' ); break; case 'is_wpml_in_use': $result = defined( 'ICL_SITEPRESS_VERSION' ); // function_exists( 'icl_object_id' ); break; case 'is_wordpress_seo_in_use': $result = defined( 'WPSEO_VERSION' ); break; } $cache[ $check_name ] = $result; } return $cache[ $check_name ]; } }