/* * This theme styles the visual editor to resemble the theme style, * specifically font, colors, icons, and column width. */ /** * function.php * Function of the theme are listed in this file. * ------------------------------------------------------------------------------------------ * 1.0 - Define Constant * ------------------------------------------------------------------------------------------ */ if(!defined('THEMEROOT')) { define('THEMEROOT', get_template_directory()); } if(!defined('BASE_URL')) { if (get_template_directory_uri() === get_stylesheet_directory_uri()) { define('BASE_URL', get_stylesheet_directory_uri()); } else { define('BASE_URL', get_template_directory_uri()); } } if(!defined('FRAMEWORK')) { define('FRAMEWORK', THEMEROOT.'/admin/'); } if(!defined('WIDGET_PATH')) { define('WIDGET_PATH', THEMEROOT.'/widgets/'); } if(!defined('FUNCTIONS_PATH')) { define('FUNCTIONS_PATH', THEMEROOT.'/functions/'); } if(!defined('PLUGIN_PATH')) { define('PLUGIN_PATH', THEMEROOT.'/includes/plugins/'); } if(!defined('CSS_PATH')) { define('CSS_PATH', BASE_URL.'/assets/css/'); } if(!defined('IMG_PATH')) { define('IMG_PATH', BASE_URL.'/assets/img/'); } if(!defined('JS_PATH')) { define('JS_PATH', BASE_URL.'/assets/js/'); } if(!defined('RAVIS_TEXT_DOMAIN')) { define('RAVIS_TEXT_DOMAIN', 'yoona'); } if ( ! isset( $content_width ) ) $content_width = 1200; /** * ------------------------------------------------------------------------------------------ * 2.0 - Include the framework options * ------------------------------------------------------------------------------------------ */ if ( !class_exists( 'ReduxFramework' ) && file_exists( FRAMEWORK . 'core/framework.php' ) ) { require_once( FRAMEWORK . 'core/framework.php' ); } if ( !isset( $redux_demo ) && file_exists( FRAMEWORK . 'options-init.php' ) ) { require_once( FRAMEWORK . 'options-init.php' ); } /** * ------------------------------------------------------------------------------------------ * 3.0 - Yoona Function Setup * ------------------------------------------------------------------------------------------ */ if ( ! function_exists( 'ravis_fn_yoona_setup' ) ) { /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. */ function ravis_fn_yoona_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on Yoona Theme, use a find and replace * to change RAVIS_TEXT_DOMAIN to the name of your theme in all the template files */ load_theme_textdomain( RAVIS_TEXT_DOMAIN, get_template_directory() . '/languages' ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. */ add_theme_support( 'title-tag' ); // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => esc_html__( 'Primary Menu', RAVIS_TEXT_DOMAIN ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); /** * Enable support for Post Thumbnails, and declare two sizes. */ add_theme_support( 'post-thumbnails' ); /* * Enable support for Post Formats. */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'audio', ) ); } } // ravis_fn_yoona_setup add_action( 'after_setup_theme', 'ravis_fn_yoona_setup' ); /** *------------------------------------------------------------------------------------------ * 4.0 Add required script files ( css / Js and etc ) * ------------------------------------------------------------------------------------------ */ if ( ! function_exists( 'ravis_fn_yoona_scripts' ) ) { function ravis_fn_yoona_scripts() { global $yoona_opt; $protocol = is_ssl() ? 'https' : 'http'; /** * Enqueue the Google font. */ $support_subset[] = (isset($yoona_opt['yoona-latin-ext']) && $yoona_opt['yoona-latin-ext'] =='1' ? 'latin' : ''); $support_subset[] = (isset($yoona_opt['yoona-cyrillic']) && $yoona_opt['yoona-cyrillic'] =='1' ? 'latin-ext' : ''); if(count($support_subset) > 0) { $subset = '&subset='; foreach ($support_subset as $subset_new) { if($subset_new !='') { $subset .= $subset_new.','; } } $subset = trim($subset, ','); } wp_enqueue_style( 'google-fonts', "$protocol://fonts.googleapis.com/css?family=Droid+Sans:400,700%7cDroid+Serif:400,700,400italic,700italic%7cGreat+Vibes".$subset ); /** * Add the css files of Yoona */ wp_enqueue_style( 'main-style-file', CSS_PATH . ((isset($yoona_opt['opt-preset']) && $yoona_opt['opt-preset'] !=='0' ) ? 'styles_'.$yoona_opt['opt-preset'].'.css' : 'styles.css')); if ( file_exists( FRAMEWORK . 'style.css' ) ) { wp_enqueue_style( 'dynamic-style-file', BASE_URL . '/admin/style.css' ); } /** * Add the JS files of Yoona */ wp_enqueue_script( "bootstrap-tab", JS_PATH . 'bootstrap/tab.js', array( 'jquery' ), get_bloginfo('version') , true ); wp_enqueue_script( "bx-slider", JS_PATH . 'jquery.bxslider.min.js', array( 'jquery' ), get_bloginfo('version') , true ); wp_enqueue_script( "owl-carousel", JS_PATH . 'owl.carousel.min.js', array( 'jquery' ), get_bloginfo('version') , true ); wp_enqueue_script( "magnific-popup", JS_PATH . 'jquery.magnific-popup.min.js', array( 'jquery' ), get_bloginfo('version') , true ); wp_enqueue_script( "helper-js", JS_PATH . 'helper.js', array( 'jquery' ), get_bloginfo('version') , true ); wp_enqueue_script( "init-js", JS_PATH . 'init.js', array( 'jquery' ), get_bloginfo('version') , true ); wp_enqueue_script( "template-js", JS_PATH . 'template.js', array( 'jquery' ), get_bloginfo('version') , true ); if(file_exists(THEMEROOT.'/style-selector.php')) { wp_enqueue_script( "style-selector-js", JS_PATH . 'demo.js', array( 'jquery' ), get_bloginfo('version') , true ); } wp_localize_script( 'template-js', 'ajax_login_object', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ), 'redirecturl' => home_url(), )); /** * Include google map required js file for the contact page */ if ( is_page_template( 'contact.php' ) ) { wp_enqueue_script( "google-mal-js", 'http://maps.googleapis.com/maps/api/js?sensor=false', array(), get_bloginfo('version') , true ); } /** * Include required js file Gallery page */ if ( is_page_template( 'gallery.php' ) ) { wp_enqueue_script( "modernizr-js", JS_PATH . 'jquery.modernizr.min.js', array( 'jquery' ), get_bloginfo('version') , true ); wp_enqueue_script( "hover-js", JS_PATH . 'jquery.hovedir.min.js', array( 'jquery' ), get_bloginfo('version') , true ); } /** * Check the rating is active */ if($yoona_opt['yoona-rate-status'] ==='1') { wp_enqueue_script('rating-js', JS_PATH.'jquery.barrating.min.js'); } if ( is_singular() ) { wp_enqueue_script( "comment-reply" ); } } } add_action( 'wp_enqueue_scripts', 'ravis_fn_yoona_scripts' ); /** * Add admin required scripts and stylesheets */ if ( ! function_exists('ravis_fn_yoona_admin_scripts')) { function ravis_fn_yoona_admin_scripts() { wp_enqueue_style('jquery-ui-custom', CSS_PATH . 'jquery-ui.min.css'); wp_enqueue_style('custom-admin-style', CSS_PATH . 'admin.css'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_script('jquery-ui-slider'); wp_enqueue_script('helper-js', JS_PATH.'helper.js', array( 'jquery' )); wp_enqueue_script('custom-admin-js', JS_PATH.'admin.js'); } } add_action( 'admin_enqueue_scripts', 'ravis_fn_yoona_admin_scripts' ); /** * ------------------------------------------------------------------------------------------ * 5.0 - Pagination function * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH. 'ravis-pagination.php' ); /** * ------------------------------------------------------------------------------------------ * 6.0 - Title Effect function - it will add "b" tag to the first word of $input * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH. 'title-effect.php' ); /** * ------------------------------------------------------------------------------------------ * 7.0 - Breadcrumb function * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH. 'ravis-breadcrumb.php' ); /** * ------------------------------------------------------------------------------------------ * 8.0 - Register SideBars * ------------------------------------------------------------------------------------------ */ if(!function_exists('ravis_fn_register_sidebar')) { function ravis_fn_register_sidebar() { register_sidebar(array( 'name' => esc_html__('Main Widget area', RAVIS_TEXT_DOMAIN), 'id' => 'main-side-bar', 'description' => esc_html__('Appears to the right side of the blog page.', RAVIS_TEXT_DOMAIN), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => esc_html__('Top Footer Widget area', RAVIS_TEXT_DOMAIN), 'id' => 'top-footer', 'description' => esc_html__('Appears in top of the website footer.', RAVIS_TEXT_DOMAIN), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); register_sidebar(array( 'name' => esc_html__('Top Header Widget area', RAVIS_TEXT_DOMAIN), 'id' => 'top-header', 'description' => esc_html__('Appears in top of the website menu.', RAVIS_TEXT_DOMAIN), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); } } add_action( 'widgets_init', 'ravis_fn_register_sidebar' ); /** * ------------------------------------------------------------------------------------------ * 9.0 - Register Menu * ------------------------------------------------------------------------------------------ */ if(!function_exists('ravis_fn_register_menus')) { function ravis_fn_register_menus() { register_nav_menus(array( 'top-menu' => esc_html__('Top Menu', RAVIS_TEXT_DOMAIN), 'footer-menu' => esc_html__('Footer Menu', RAVIS_TEXT_DOMAIN), )); } } add_action('init', 'ravis_fn_register_menus'); /** * ------------------------------------------------------------------------------------------ * 10.0 - Load post_types in the menu section * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH. 'post-type-in-menu.php' ); /** * ------------------------------------------------------------------------------------------ * 11.0 - Include required plugins to theme * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH. 'include-plugins.php' ); /** * ------------------------------------------------------------------------------------------ * 12.0 - Determine whether blog/site has more than one category. * @return bool True of there is more than one category, false otherwise. * ------------------------------------------------------------------------------------------ */ function ravis_fn_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'ravis_categories' ) ) ) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'ravis_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so ravis_fn_categorized_blog should return true. return true; } else { // This blog has only 1 category so ravis_fn_categorized_blog should return false. return false; } } /** * ------------------------------------------------------------------------------------------ * 13.0 - Post Meta function * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH. 'post-meta.php' ); /** * ------------------------------------------------------------------------------------------ * 14.0 - Update rate items value function * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH. 'update-rate.php' ); /** * ------------------------------------------------------------------------------------------ * 15.0 - Room Ajax loader * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'room-ajax-loader.php' ); /** * ------------------------------------------------------------------------------------------ * 16.0 - Include Custom Ravis Widgets * ------------------------------------------------------------------------------------------ */ include( WIDGET_PATH . 'ravis-recent-post-thumb.php' ); /** * ------------------------------------------------------------------------------------------ * 17.0 - Create required WP data based tables. * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'create-required-tables.php' ); /** * ------------------------------------------------------------------------------------------ * 18.0 - Check availability function * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'check-availability.php' ); /** * ------------------------------------------------------------------------------------------ * 19.0 - Create essential page for theme * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'essential-pages.php' ); /** * ------------------------------------------------------------------------------------------ * 20.0 - Booking form functionality * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'booking-form-funcs.php' ); /** * ------------------------------------------------------------------------------------------ * 21.0 - Get the Booking Page URL * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'get-booking-page.php' ); /** * ------------------------------------------------------------------------------------------ * 22.0 - Event check availability function * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'event-check-availability.php' ); /** * ------------------------------------------------------------------------------------------ * 23.0 - Login / Register Functions * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'login-register.php' ); /** * ------------------------------------------------------------------------------------------ * 24.0 - Update the booking table when a booking post was deleted * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'update-booking-table.php' ); /** * ------------------------------------------------------------------------------------------ * 25.0 - Include Ravis NewsLetter Widget * ------------------------------------------------------------------------------------------ */ include( WIDGET_PATH . 'ravis-news-letter.php' ); /** * ------------------------------------------------------------------------------------------ * 26 - Limit the search result for Posts * ------------------------------------------------------------------------------------------ */ if( !function_exists('ravis_fn_search_filter') ) { function ravis_fn_search_filter($query) { if ($query->is_search) { $query->set('post_type', 'post'); } return $query; } } add_filter('pre_get_posts','ravis_fn_search_filter'); /** * ------------------------------------------------------------------------------------------ * 27 - Excerpt setting of blog * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'excerpt-setting.php' ); /** * ------------------------------------------------------------------------------------------ * 28 - Link Posts links * ------------------------------------------------------------------------------------------ */ if(!function_exists('ravis_fn_get_link_url')) { function ravis_fn_get_link_url() { $has_url = get_url_in_content( get_the_content() ); return $has_url ? $has_url : apply_filters( 'the_permalink', get_permalink() ); } } /** * ------------------------------------------------------------------------------------------ * 29 - Email Notification * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'booking-confrim-notification.php' ); /** * ------------------------------------------------------------------------------------------ * 30 - Get booking information by ajax ( used for booking overview ) * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'get-booking-info.php' ); /** * ------------------------------------------------------------------------------------------ * 31 - Set Breadcrumb BG * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'set-breadcrumb-bg.php' ); /** * ------------------------------------------------------------------------------------------ * 32 - Convert the currency to HTML entity * ------------------------------------------------------------------------------------------ */ include( FUNCTIONS_PATH . 'currency-converter.php' );