place('/\\.[^.\\s]{3,4}$/', '', basename(get_page_template())); if($file_name_without_ext !== '') { $file_name = $file_name_without_ext; } } return $file_name; } } if(!function_exists('qode_startit_has_shortcode')) { /** * Function that checks whether shortcode exists on current page / post * * @param string shortcode to find * @param string content to check. If isn't passed current post content will be used * * @return bool whether content has shortcode or not */ function qode_startit_has_shortcode($shortcode, $content = '') { $has_shortcode = false; if($shortcode) { //if content variable isn't past if($content == '') { //take content from current post $page_id = qode_startit_get_page_id(); if(!empty($page_id)) { $current_post = get_post($page_id); if(is_object($current_post) && property_exists($current_post, 'post_content')) { $content = $current_post->post_content; } } } //does content has shortcode added? if(stripos($content, '['.$shortcode) !== false) { $has_shortcode = true; } } return $has_shortcode; } } if(!function_exists('qode_startit_rewrite_rules_on_theme_activation')) { /** * Function that flushes rewrite rules on deactivation */ function qode_startit_rewrite_rules_on_theme_activation() { flush_rewrite_rules(); } add_action('after_switch_theme', 'qode_startit_rewrite_rules_on_theme_activation'); } if(!function_exists('qode_startit_get_dynamic_sidebar')) { /** * Return Custom Widget Area content * * @return string */ function qode_startit_get_dynamic_sidebar($index = 1) { ob_start(); dynamic_sidebar($index); $sidebar_contents = ob_get_clean(); return $sidebar_contents; } } if(!function_exists('qode_startit_get_sidebar')) { /** * Return Sidebar * * @return string */ function qode_startit_get_sidebar() { $id = qode_startit_get_page_id(); $sidebar = "sidebar"; if (get_post_meta($id, 'qodef_custom_sidebar_meta', true) != '') { $sidebar = get_post_meta($id, 'qodef_custom_sidebar_meta', true); } else { if (is_single() && qode_startit_options()->getOptionValue('blog_single_custom_sidebar') != '') { $sidebar = esc_attr(qode_startit_options()->getOptionValue('blog_single_custom_sidebar')); }elseif((qode_startit_is_product_category() || qode_startit_is_product_tag()) && qode_startit_get_woo_shop_page_id()) { $shop_id = qode_startit_get_woo_shop_page_id(); if(get_post_meta($shop_id, 'qodef_custom_sidebar_meta', true) != '') { $sidebar = esc_attr(get_post_meta($shop_id, 'qodef_custom_sidebar_meta', true)); } } elseif ((is_archive() || (is_home() && is_front_page())) && qode_startit_options()->getOptionValue('blog_custom_sidebar') != '') { $sidebar = esc_attr(qode_startit_options()->getOptionValue('blog_custom_sidebar')); } elseif (is_page() && qode_startit_options()->getOptionValue('page_custom_sidebar') != '') { $sidebar = esc_attr(qode_startit_options()->getOptionValue('page_custom_sidebar')); } } return $sidebar; } } if( !function_exists('qode_startit_sidebar_columns_class') ) { /** * Return classes for columns holder when sidebar is active * * @return array */ function qode_startit_sidebar_columns_class() { $sidebar_class = array(); $sidebar_layout = qode_startit_sidebar_layout(); switch($sidebar_layout): case 'sidebar-33-right': $sidebar_class[] = 'qodef-two-columns-66-33'; break; case 'sidebar-25-right': $sidebar_class[] = 'qodef-two-columns-75-25'; break; case 'sidebar-33-left': $sidebar_class[] = 'qodef-two-columns-33-66'; break; case 'sidebar-25-left': $sidebar_class[] = 'qodef-two-columns-25-75'; break; endswitch; $sidebar_class[] = 'qodef-content-has-sidebar clearfix'; return qode_startit_class_attribute($sidebar_class); } } if( !function_exists('qode_startit_sidebar_layout') ) { /** * Function that check is sidebar is enabled and return type of sidebar layout */ function qode_startit_sidebar_layout() { $sidebar_layout = ''; $page_id = qode_startit_get_page_id(); $page_sidebar_meta = get_post_meta($page_id, 'qodef_sidebar_meta', true); if (($page_sidebar_meta !== '' && get_post_meta(qode_startit_get_page_id(), "qodef_sidebar_meta", true) != 'default') && $page_id !== -1) { if ($page_sidebar_meta == 'no-sidebar') { $sidebar_layout = ''; } else { $sidebar_layout = $page_sidebar_meta; } } else { if (is_single() && qode_startit_options()->getOptionValue('blog_single_sidebar_layout')) { $sidebar_layout = esc_attr(qode_startit_options()->getOptionValue('blog_single_sidebar_layout')); } elseif ((qode_startit_is_product_category() || qode_startit_is_product_tag()) && qode_startit_get_woo_shop_page_id()) { $shop_id = qode_startit_get_woo_shop_page_id(); if (get_post_meta($shop_id, 'qodef_sidebar_meta', true) != '') { $sidebar_layout = esc_attr(get_post_meta($shop_id, 'qodef_sidebar_meta', true)); } } elseif ((is_archive() || (is_home() && is_front_page())) && qode_startit_options()->getOptionValue('archive_sidebar_layout')) { $sidebar_layout = esc_attr(qode_startit_options()->getOptionValue('archive_sidebar_layout')); } elseif (is_page() && qode_startit_options()->getOptionValue('page_sidebar_layout')) { $sidebar_layout = esc_attr(qode_startit_options()->getOptionValue('page_sidebar_layout')); } } return $sidebar_layout; } } if( !function_exists('qode_startit_page_custom_style') ) { /** * Function that print custom page style */ function qode_startit_page_custom_style() { $style = ''; $html = ''; $style = apply_filters('qode_startit_add_page_custom_style', $style); if($style !== '') { $html .= ''; } print $html; } add_action('wp_head', 'qode_startit_page_custom_style'); } if( !function_exists('qode_startit_container_style') ) { /** * Function that return container style */ function qode_startit_container_style($style) { $id = qode_startit_get_page_id(); $container_selector = array( '.page-id-' . $id . ' .qodef-content .qodef-content-inner > .qodef-container', '.page-id-' . $id . ' .qodef-content .qodef-content-inner > .qodef-full-width' ); $container_class = array(); $page_backgorund_color = get_post_meta($id, "qodef_page_background_color_meta", true); if($page_backgorund_color){ $container_class['background-color'] = $page_backgorund_color; } $current_style = qode_startit_dynamic_css($container_selector, $container_class); $current_style = $current_style . $style; return $current_style; } add_filter('qode_startit_add_page_custom_style', 'qode_startit_container_style'); } if(!function_exists('qode_startit_print_custom_css')) { /** * Prints out custom css from theme options */ function qode_startit_print_custom_css() { $custom_css = qode_startit_options()->getOptionValue('custom_css'); $output = ''; if($custom_css !== '') { $output .= ''; } print $output; } add_action('wp_head', 'qode_startit_print_custom_css', 1000); } if(!function_exists('qode_startit_print_custom_js')) { /** * Prints out custom css from theme options */ function qode_startit_print_custom_js() { $custom_js = qode_startit_options()->getOptionValue('custom_js'); $output = ''; if($custom_js !== '') { $output .= ''; } print $output; } add_action('wp_footer', 'qode_startit_print_custom_js', 1000); } if(!function_exists('qode_startit_get_global_variables')) { /** * Function that generates global variables and put them in array so they could be used in the theme */ function qode_startit_get_global_variables() { $global_variables = array(); $element_appear_amount = -150; $global_variables['qodefAddForAdminBar'] = is_admin_bar_showing() ? 32 : 0; $global_variables['qodefElementAppearAmount'] = qode_startit_options()->getOptionValue('element_appear_amount') !== '' ? qode_startit_options()->getOptionValue('element_appear_amount') : $element_appear_amount; $global_variables['qodefFinishedMessage'] = esc_html__('No more posts', 'startit'); $global_variables['qodefMessage'] = esc_html__('Loading new posts...', 'startit'); $global_variables = apply_filters('qode_startit_js_global_variables', $global_variables); wp_localize_script('qode_startit_modules', 'qodefGlobalVars', array( 'vars' => $global_variables )); } add_action('wp_enqueue_scripts', 'qode_startit_get_global_variables'); } if(!function_exists('qode_startit_per_page_js_variables')) { function qode_startit_per_page_js_variables() { $per_page_js_vars = apply_filters('qode_startit_per_page_js_vars', array()); wp_localize_script('qode_startit_modules', 'qodefPerPageVars', array( 'vars' => $per_page_js_vars )); } add_action('wp_enqueue_scripts', 'qode_startit_per_page_js_variables'); } if(!function_exists('qode_startit_content_elem_style_attr')) { /** * Defines filter for adding custom styles to content HTML element */ function qode_startit_content_elem_style_attr() { $styles = apply_filters('qode_startit_content_elem_style_attr', array()); qode_startit_inline_style($styles); } } if(!function_exists('qode_startit_is_woocommerce_installed')) { /** * Function that checks if woocommerce is installed * @return bool */ function qode_startit_is_woocommerce_installed() { return function_exists('is_woocommerce'); } } if(!function_exists('qode_startit_visual_composer_installed')) { /** * Function that checks if visual composer installed * @return bool */ function qode_startit_visual_composer_installed() { //is Visual Composer installed? if(class_exists('WPBakeryVisualComposerAbstract')) { return true; } return false; } } if(!function_exists('qode_startit_seo_plugin_installed')) { /** * Function that checks if popular seo plugins are installed * @return bool */ function qode_startit_seo_plugin_installed() { //is 'YOAST' or 'All in One SEO' installed? if(defined('WPSEO_VERSION') || class_exists('All_in_One_SEO_Pack')) { return true; } return false; } } if(!function_exists('qode_startit_contact_form_7_installed')) { /** * Function that checks if contact form 7 installed * @return bool */ function qode_startit_contact_form_7_installed() { //is Contact Form 7 installed? if(defined('WPCF7_VERSION')) { return true; } return false; } } if(!function_exists('qode_startit_is_wpml_installed')) { /** * Function that checks if WPML plugin is installed * @return bool * * @version 0.1 */ function qode_startit_is_wpml_installed() { return defined('ICL_SITEPRESS_VERSION'); } } if(!function_exists('qode_startit_is_live_search_installed')) { /** * Function that checks if Dave's WordPress Live Search plugin is installed * @return bool * * @version 0.1 */ function qode_startit_is_live_search_installed() { return function_exists('daves_wp_live_search_init'); } } if(!function_exists('qode_starit_remove_admin_menu_items')) { function qode_starit_remove_admin_menu_items() { if (qode_startit_is_live_search_installed()) { remove_submenu_page("options-general.php", "daves-wordpress-live-search/class-daves-wordpress-live-search.php"); } } add_action('admin_menu', 'qode_starit_remove_admin_menu_items', 999); }