hor etc.) and returns -1 because that isn't
* page that is created in WP admin.
*
* @return int
*
* @version 0.1
*
* @see qode_is_woocommerce_installed()
* @see qode_is_woocommerce_shop()
*/
function qode_get_page_id() {
if(qode_is_woocommerce_installed() && qode_is_woocommerce_shop()) {
return qode_get_woo_shop_page_id();
}
if(is_archive() || is_404() || is_search()) {
return -1;
}
return get_queried_object_id();
}
}
if(!function_exists('rewrite_rules_on_theme_activation')) {
/**
* Function that sets rewrite rules when our theme is activated
*/
function rewrite_rules_on_theme_activation() {
flush_rewrite_rules();
}
add_action( 'after_switch_theme', 'rewrite_rules_on_theme_activation' );
}
if(!function_exists('qode_maintenance_mode')) {
/**
* Function that redirects user to desired landing page if maintenance mode is turned on in options
*/
function qode_maintenance_mode() {
global $qode_options_proya;
$protocol = is_ssl() ? "https://" : "http://";
if(isset($qode_options_proya['qode_maintenance_mode']) && $qode_options_proya['qode_maintenance_mode'] == 'yes' && isset($qode_options_proya['qode_maintenance_page']) && $qode_options_proya['qode_maintenance_page'] != ""
&& !in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php'))
&& !is_admin()
&& !is_user_logged_in()
&& $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] != get_permalink($qode_options_proya['qode_maintenance_page'])
) {
wp_redirect(get_permalink($qode_options_proya['qode_maintenance_page']));
exit;
}
}
if(isset($qode_options_proya['qode_maintenance_mode']) && $qode_options_proya['qode_maintenance_mode'] == 'yes') {
add_action('init', 'qode_maintenance_mode', 1);
}
}
if(!function_exists('qode_visual_composer_installed')) {
/**
* Function that checks if visual composer installed
* @return bool
*/
function qode_visual_composer_installed() {
//is Visual Composer installed?
if(class_exists('WPBakeryVisualComposerAbstract')) {
return true;
}
return false;
}
}
if(!function_exists('qode_visual_composer_custom_shortcodce_css')){
function qode_visual_composer_custom_shortcodce_css(){
if(qode_visual_composer_installed()){
if(is_page() || is_single() || is_singular('portfolio_page')){
$shortcodes_custom_css = get_post_meta( qode_get_page_id(), '_wpb_shortcodes_custom_css', true );
if ( ! empty( $shortcodes_custom_css ) ) {
echo '';
}
$post_custom_css = get_post_meta( qode_get_page_id(), '_wpb_post_custom_css', true );
if ( ! empty( $post_custom_css ) ) {
echo '';
}
}
}
}
add_action('qode_visual_composer_custom_shortcodce_css', 'qode_visual_composer_custom_shortcodce_css');
}
if (!function_exists('qode_vc_grid_elements_enabled')) {
/**
* Function that checks if Visual Composer Grid Elements are enabled
*
* @return bool
*/
function qode_vc_grid_elements_enabled() {
global $qode_options_proya;
$vc_grid_enabled = false;
if (isset($qode_options_proya['enable_grid_elements']) && $qode_options_proya['enable_grid_elements'] == 'yes') {
$vc_grid_enabled = true;
}
return $vc_grid_enabled;
}
}
if(!function_exists('qode_visual_composer_grid_elements')) {
/**
* Removes Visual Composer Grid Elements post type if VC Grid option disabled
* and enables Visual Composer Grid Elements post type
* if VC Grid option enabled
*/
function qode_visual_composer_grid_elements() {
global $qode_options_proya;
if(!qode_vc_grid_elements_enabled()){
remove_action( 'init', 'vc_grid_item_editor_create_post_type' );
}
}
add_action('vc_after_init', 'qode_visual_composer_grid_elements', 12);
}
if(!function_exists('qode_grid_elements_ajax_disable')) {
/**
* Function that disables ajax transitions if grid elements are enabled in theme options
*/
function qode_grid_elements_ajax_disable() {
global $qode_options_proya;
if(qode_vc_grid_elements_enabled()) {
$qode_options_proya['page_transitions'] = '0';
}
}
add_action('wp', 'qode_grid_elements_ajax_disable');
}
if(!function_exists('qode_get_vc_version')) {
/**
* Return Visual Composer version string
*
* @return bool|string
*/
function qode_get_vc_version()
{
if (qode_visual_composer_installed()) {
return WPB_VC_VERSION;
}
return false;
}
}
if(!function_exists('qode_get_side_menu_icon_html')) {
/**
* Function that outputs html for side area icon opener.
* Uses $qodeIconCollections global variable
* @return string generated html
*/
function qode_get_side_menu_icon_html() {
global $qodeIconCollections, $qode_options_proya;
$icon_html = '';
$icon_pack = qodef_option_get_value('side_area_button_icon_pack');
if(isset($icon_pack) && $icon_pack !== '') {
$icon_collection_obj = $qodeIconCollections->getIconCollection($icon_pack);
$icon_field_name = 'side_area_icon_'. $icon_collection_obj->param;
$side_area_icon = qodef_option_get_value($icon_field_name);
if(isset($side_area_icon) && $side_area_icon !== ''){
if (method_exists($icon_collection_obj, 'render')) {
$icon_html = $icon_collection_obj->render($side_area_icon);
}
}
}
return $icon_html;
}
}
if(!function_exists('qode_get_mobile_menu_icon_html')) {
/**
* Function that outputs html for side area icon opener.
* Uses $qodeIconCollections global variable
* @return string generated html
*/
function qode_get_mobile_menu_icon_html() {
global $qodeIconCollections, $qode_options_proya;
$icon_html = '';
$icon_pack = qodef_option_get_value('mobile_menu_button_icon_pack');
if(isset($icon_pack) && $icon_pack !== '') {
$icon_collection_obj = $qodeIconCollections->getIconCollection($icon_pack);
$icon_field_name = 'mobile_menu_icon_'. $icon_collection_obj->param;
$mobile_menu_icon = qodef_option_get_value($icon_field_name);
if(isset($mobile_menu_icon) && $mobile_menu_icon !== ''){
if (method_exists($icon_collection_obj, 'render')) {
$icon_html = $icon_collection_obj->render($mobile_menu_icon);
}
}
}
return $icon_html;
}
}