Created
March 26, 2022 02:38
-
-
Save 1naveengiri/c12bf27a1aee7894533686f2aab7007d to your computer and use it in GitHub Desktop.
kadence theme options not working for GD page templates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'kadence_post_layout', 'buddy_check_condition' ); | |
| function buddy_check_condition() { | |
| $boxed = 'boxed'; | |
| $layout = 'normal'; | |
| $feature = 'hide'; | |
| $f_position = 'above'; | |
| $comments = 'hide'; | |
| $navigation = 'hide'; | |
| $title = 'normal'; | |
| $sidebar = 'disable'; | |
| $sidebar_id = Kadence\Layout\Component::PRIMARY_SIDEBAR_SLUG; | |
| $side = 'right'; | |
| $vpadding = 'show'; | |
| $header = 'enable'; | |
| $footer = 'enable'; | |
| $content = 'enable'; | |
| $transparent = ( Kadence\kadence()->option( 'transparent_header_enable' ) ? 'enable' : 'disable' ); | |
| if ( ( is_singular() || is_front_page() ) && ! is_home() ) { | |
| if ( is_front_page() ) { | |
| $post_id = get_option( 'page_on_front' ); | |
| $post_type = 'page'; | |
| $trans_type = 'page'; | |
| } else { | |
| $post_id = get_the_ID(); | |
| $post_type = get_post_type(); | |
| $trans_type = $post_type; | |
| } | |
| $postlayout = get_post_meta( $post_id, '_kad_post_layout', true ); | |
| $postsidebar = get_post_meta( $post_id, '_kad_post_sidebar_id', true ); | |
| $postboxed = get_post_meta( $post_id, '_kad_post_content_style', true ); | |
| $postfeature = get_post_meta( $post_id, '_kad_post_feature', true ); | |
| $postf_position = get_post_meta( $post_id, '_kad_post_feature_position', true ); | |
| $posttitle = get_post_meta( $post_id, '_kad_post_title', true ); | |
| $posttrans = get_post_meta( $post_id, '_kad_post_transparent', true ); | |
| $postvpadding = get_post_meta( $post_id, '_kad_post_vertical_padding', true ); | |
| $postheader = get_post_meta( $post_id, '_kad_post_header', true ); | |
| $postfooter = get_post_meta( $post_id, '_kad_post_footer', true ); | |
| // header. | |
| if ( isset( $postheader ) && true == $postheader ) { | |
| $header = 'disable'; | |
| } | |
| // Footer. | |
| if ( isset( $postfooter ) && true == $postfooter ) { | |
| $footer = 'disable'; | |
| } | |
| // Sidebar ID. | |
| if ( isset( $postsidebar ) && ! empty( $postsidebar ) && 'defualt' !== $postsidebar && 'default' !== $postsidebar ) { | |
| $sidebar_id = $postsidebar; | |
| } else { | |
| $sidebar_id = Kadence\kadence()->option( $post_type . '_sidebar_id', $sidebar_id ); | |
| } | |
| // Transparent. | |
| if ( isset( $posttrans ) && ( 'enable' === $posttrans || 'disable' === $posttrans ) ) { | |
| $transparent = $posttrans; | |
| } else { | |
| $option_trans = Kadence\kadence()->option( 'transparent_header_' . $trans_type, null ); | |
| if ( true === $option_trans ) { | |
| $transparent = 'disable'; | |
| } else if ( is_null( $option_trans ) ) { | |
| $transparent = 'disable'; | |
| } | |
| } | |
| // Title. | |
| if ( isset( $posttitle ) && ( 'above' === $posttitle || 'normal' === $posttitle || 'hide' === $posttitle ) ) { | |
| $title = $posttitle; | |
| } elseif ( isset( $posttitle ) && 'show' === $posttitle ) { | |
| $option_title_layout = Kadence\kadence()->option( $post_type . '_title_layout' ); | |
| if ( 'above' === $option_title_layout || 'normal' === $option_title_layout ) { | |
| $title = $option_title_layout; | |
| } | |
| } else { | |
| $option_title = Kadence\kadence()->option( $post_type . '_title' ); | |
| if ( false === $option_title ) { | |
| $title = 'hide'; | |
| } else { | |
| $option_title_layout = Kadence\kadence()->option( $post_type . '_title_layout' ); | |
| if ( 'above' === $option_title_layout || 'normal' === $option_title_layout ) { | |
| $title = $option_title_layout; | |
| } | |
| } | |
| } | |
| // Post Vertical Padding. | |
| if ( isset( $postvpadding ) && ( 'show' === $postvpadding || 'hide' === $postvpadding || 'top' === $postvpadding || 'bottom' === $postvpadding ) ) { | |
| $vpadding = $postvpadding; | |
| } else { | |
| $option_vpadding = Kadence\kadence()->option( $post_type . '_vertical_padding' ); | |
| if ( 'show' === $option_vpadding || 'hide' === $option_vpadding || 'top' === $option_vpadding || 'bottom' === $option_vpadding ) { | |
| $vpadding = $option_vpadding; | |
| } | |
| } | |
| // Post Navigation. | |
| if ( 'post' === $post_type ) { | |
| $option_navigation = Kadence\kadence()->option( $post_type . '_navigation' ); | |
| if ( $option_navigation ) { | |
| $navigation = 'show'; | |
| } | |
| } | |
| // Post Comments. | |
| $option_comments = Kadence\kadence()->option( $post_type . '_comments' ); | |
| if ( $option_comments ) { | |
| $comments = 'show'; | |
| } | |
| if ( 'product' === $post_type ) { | |
| $comments = 'show'; | |
| } | |
| // Post Boxed. | |
| if ( isset( $postboxed ) && ( 'unboxed' === $postboxed || 'boxed' === $postboxed ) ) { | |
| $boxed = $postboxed; | |
| } else { | |
| $option_boxed = Kadence\kadence()->option( $post_type . '_content_style' ); | |
| if ( 'unboxed' === $option_boxed || 'boxed' === $option_boxed ) { | |
| $boxed = $option_boxed; | |
| } | |
| } | |
| // Post Feature. | |
| if ( isset( $postfeature ) && ( 'show' === $postfeature || 'hide' === $postfeature ) ) { | |
| $feature = $postfeature; | |
| } else { | |
| $option_feature = Kadence\kadence()->option( $post_type . '_feature' ); | |
| if ( $option_feature ) { | |
| $feature = 'show'; | |
| } | |
| } | |
| // Post Feature position. | |
| if ( isset( $postf_position ) && ( 'above' === $postf_position || 'behind' === $postf_position || 'below' === $postf_position ) ) { | |
| $f_position = $postf_position; | |
| } else { | |
| $option_f_position = Kadence\kadence()->option( $post_type . '_feature_position' ); | |
| if ( 'above' === $option_f_position || 'behind' === $option_f_position || 'below' === $option_f_position ) { | |
| $f_position = $option_f_position; | |
| } | |
| } | |
| // Post Layout. | |
| if ( isset( $postlayout ) && ( 'narrow' === $postlayout || 'fullwidth' === $postlayout ) ) { | |
| $layout = $postlayout; | |
| } elseif ( ( isset( $postlayout ) && 'default' === $postlayout ) || empty( $postlayout ) ) { | |
| $option_layout = Kadence\kadence()->option( $post_type . '_layout' ); | |
| if ( 'narrow' === $option_layout || 'fullwidth' === $option_layout ) { | |
| $layout = $option_layout; | |
| } | |
| } | |
| // Post Sidebar. | |
| if ( isset( $postlayout ) && ( 'left' === $postlayout || 'right' === $postlayout ) ) { | |
| $side = $postlayout; | |
| $sidebar = 'enable'; | |
| $layout = $postlayout; | |
| } elseif ( ( isset( $postlayout ) && 'default' === $postlayout ) || empty( $postlayout ) ) { | |
| $option_layout = Kadence\kadence()->option( $post_type . '_layout' ); | |
| if ( 'left' === $option_layout || 'right' === $option_layout ) { | |
| $side = $option_layout; | |
| $sidebar = 'enable'; | |
| } | |
| } | |
| } elseif ( is_archive() || is_search() || is_home() || is_404() ) { | |
| if ( is_home() && is_front_page() ) { | |
| $archive_type = 'post_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_home() && ! is_front_page() ) { | |
| $post_id = get_option( 'page_for_posts' ); | |
| $archivelayout = get_post_meta( $post_id, '_kad_post_layout', true ); | |
| $archiveboxed = get_post_meta( $post_id, '_kad_post_content_style', true ); | |
| $archivesidebar = get_post_meta( $post_id, '_kad_post_sidebar_id', true ); | |
| $archivefeature = get_post_meta( $post_id, '_kad_post_feature', true ); | |
| $archivetitle = get_post_meta( $post_id, '_kad_post_title', true ); | |
| $archivetrans = get_post_meta( $post_id, '_kad_post_transparent', true ); | |
| $archivevpadding = get_post_meta( $post_id, '_kad_post_vertical_padding', true ); | |
| $postf_position = get_post_meta( $post_id, '_kad_post_feature_position', true ); | |
| $archive_type = 'post_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( class_exists( 'woocommerce' ) && is_shop() && ! is_search() ) { | |
| $post_id = wc_get_page_id( 'shop' ); | |
| $archivelayout = get_post_meta( $post_id, '_kad_post_layout', true ); | |
| $archiveboxed = get_post_meta( $post_id, '_kad_post_content_style', true ); | |
| $archivesidebar = get_post_meta( $post_id, '_kad_post_sidebar_id', true ); | |
| $archivefeature = get_post_meta( $post_id, '_kad_post_feature', true ); | |
| $archivetitle = get_post_meta( $post_id, '_kad_post_title', true ); | |
| $archivetrans = get_post_meta( $post_id, '_kad_post_transparent', true ); | |
| $archivevpadding = get_post_meta( $post_id, '_kad_post_vertical_padding', true ); | |
| $postf_position = get_post_meta( $post_id, '_kad_post_feature_position', true ); | |
| $archive_type = 'product_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( class_exists( 'woocommerce' ) && ( is_product_category() || is_product_tag() || is_tax( 'product_brands' ) || ( is_shop() && is_search() ) ) ) { | |
| $archive_type = 'product_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_post_type_archive( 'llms_membership' ) && function_exists( 'llms_get_page_id' ) ) { | |
| $post_id = llms_get_page_id( 'memberships' ); | |
| $archivelayout = get_post_meta( $post_id, '_kad_post_layout', true ); | |
| $archiveboxed = get_post_meta( $post_id, '_kad_post_content_style', true ); | |
| $archivesidebar = get_post_meta( $post_id, '_kad_post_sidebar_id', true ); | |
| $archivefeature = get_post_meta( $post_id, '_kad_post_feature', true ); | |
| $archivetitle = get_post_meta( $post_id, '_kad_post_title', true ); | |
| $archivetrans = get_post_meta( $post_id, '_kad_post_transparent', true ); | |
| $archivevpadding = get_post_meta( $post_id, '_kad_post_vertical_padding', true ); | |
| $postf_position = get_post_meta( $post_id, '_kad_post_feature_position', true ); | |
| $archive_type = 'llms_membership_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_tax( 'membership_cat' ) || is_tax( 'membership_tag' ) ) { | |
| $archive_type = 'llms_membership_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( geodir_is_page( 'detail' ) ) { | |
| $post_id = geodir_details_page_id( get_post_type( get_the_ID() ) ); | |
| $archivelayout = get_post_meta( $post_id, '_kad_post_layout', true ); | |
| $archiveboxed = get_post_meta( $post_id, '_kad_post_content_style', true ); | |
| $archivesidebar = get_post_meta( $post_id, '_kad_post_sidebar_id', true ); | |
| $archivefeature = get_post_meta( $post_id, '_kad_post_feature', true ); | |
| $archivetitle = get_post_meta( $post_id, '_kad_post_title', true ); | |
| $archivetrans = get_post_meta( $post_id, '_kad_post_transparent', true ); | |
| $archivevpadding = get_post_meta( $post_id, '_kad_post_vertical_padding', true ); | |
| $postf_position = get_post_meta( $post_id, '_kad_post_feature_position', true ); | |
| // $archive_type = 'llms_membership_archive'; | |
| // $trans_type = 'archive'; | |
| } elseif ( geodir_is_page( 'post_type' ) || geodir_is_page( 'archive' ) ) { | |
| $post_id = geodir_archive_page_id( get_post_type( get_the_ID() ) ); | |
| $archivelayout = get_post_meta( $post_id, '_kad_post_layout', true ); | |
| $archiveboxed = get_post_meta( $post_id, '_kad_post_content_style', true ); | |
| $archivesidebar = get_post_meta( $post_id, '_kad_post_sidebar_id', true ); | |
| $archivefeature = get_post_meta( $post_id, '_kad_post_feature', true ); | |
| $archivetitle = get_post_meta( $post_id, '_kad_post_title', true ); | |
| $archivetrans = get_post_meta( $post_id, '_kad_post_transparent', true ); | |
| $archivevpadding = get_post_meta( $post_id, '_kad_post_vertical_padding', true ); | |
| $postf_position = get_post_meta( $post_id, '_kad_post_feature_position', true ); | |
| // $archive_type = 'llms_membership_archive'; | |
| // $trans_type = 'archive'; | |
| } elseif ( is_post_type_archive( 'course' ) && function_exists( 'llms_get_page_id' ) ) { | |
| $post_id = llms_get_page_id( 'courses' ); | |
| $archivelayout = get_post_meta( $post_id, '_kad_post_layout', true ); | |
| $archiveboxed = get_post_meta( $post_id, '_kad_post_content_style', true ); | |
| $archivesidebar = get_post_meta( $post_id, '_kad_post_sidebar_id', true ); | |
| $archivefeature = get_post_meta( $post_id, '_kad_post_feature', true ); | |
| $archivetitle = get_post_meta( $post_id, '_kad_post_title', true ); | |
| $archivetrans = get_post_meta( $post_id, '_kad_post_transparent', true ); | |
| $archivevpadding = get_post_meta( $post_id, '_kad_post_vertical_padding', true ); | |
| $postf_position = get_post_meta( $post_id, '_kad_post_feature_position', true ); | |
| $archive_type = 'course_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_tax( 'course_cat' ) || is_tax( 'course_tag' ) || is_tax( 'course_track' ) ) { | |
| $archive_type = 'course_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_post_type_archive( 'tribe_events' ) && function_exists( 'tribe_is_month' ) && tribe_is_month() ) { | |
| $archive_type = 'tribe_events_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_tax( 'portfolio-type' ) || is_tax( 'portfolio-tag' ) ) { | |
| $archive_type = 'portfolio_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_tax( 'staff-group' ) ) { | |
| $archive_type = 'staff_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_tax( 'testimonial-group' ) ) { | |
| $archive_type = 'testimonial_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( ( is_tax( 'ht_kb_category' ) || is_tax( 'ht_kb_tag' ) || is_post_type_archive( 'ht_kb' ) || ( is_search() && array_key_exists( 'ht-kb-search', $_REQUEST ) ) ) ) { | |
| $archive_type = 'ht_kb_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_search() && !geodir_is_page( 'search' ) ) { | |
| $archive_type = 'search_archive'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_404() ) { | |
| $archive_type = '404'; | |
| $trans_type = 'archive'; | |
| } elseif ( is_category() || is_tag() ) { | |
| $archive_type = 'post_archive'; | |
| $trans_type = 'archive'; | |
| } else { | |
| $post_type = get_post_type(); | |
| $archive_type = $post_type . '_archive'; | |
| $trans_type = 'archive'; | |
| } | |
| // Sidebar ID. | |
| if ( isset( $archivesidebar ) && ! empty( $archivesidebar ) && 'default' !== $archivesidebar && 'defualt' !== $archivesidebar ) { | |
| $sidebar_id = $archivesidebar; | |
| } else { | |
| $sidebar_id = Kadence\kadence()->option( $archive_type . '_sidebar_id', $sidebar_id ); | |
| } | |
| // Archive Transparent. | |
| if ( isset( $archivetrans ) && ( 'enable' === $archivetrans || 'disable' === $archivetrans ) ) { | |
| $transparent = $archivetrans; | |
| } else { | |
| $option_trans = Kadence\kadence()->option( 'transparent_header_' . $trans_type ); | |
| if ( true === $option_trans ) { | |
| $transparent = 'disable'; | |
| } | |
| } | |
| // Archive Title. | |
| if ( isset( $archivetitle ) && ( 'above' === $archivetitle || 'normal' === $archivetitle || 'hide' === $archivetitle ) ) { | |
| $title = $archivetitle; | |
| } else { | |
| $option_title = Kadence\kadence()->option( $archive_type . '_title' ); | |
| if ( false === $option_title ) { | |
| $title = 'hide'; | |
| } else { | |
| $option_title_layout = Kadence\kadence()->option( $archive_type . '_title_layout' ); | |
| if ( empty( $option_title_layout ) ) { | |
| $option_title_layout = Kadence\kadence()->option( 'post_archive_title_layout' ); | |
| } | |
| if ( 'above' === $option_title_layout || 'normal' === $option_title_layout ) { | |
| $title = $option_title_layout; | |
| } | |
| } | |
| } | |
| if ( is_home() && is_front_page() ) { | |
| if ( ! Kadence\kadence()->option( 'post_archive_home_title' ) ) { | |
| $title = 'hide'; | |
| } | |
| } | |
| if ( is_404() ) { | |
| $title = 'normal'; | |
| $transparent = 'disable'; | |
| } | |
| // Archive Feature. | |
| if ( isset( $archivefeature ) && ( 'show' === $archivefeature || 'hide' === $archivefeature ) ) { | |
| $feature = $archivefeature; | |
| } | |
| // Post Feature position. | |
| if ( isset( $postf_position ) && ( 'above' === $postf_position || 'behind' === $postf_position || 'below' === $postf_position ) ) { | |
| $f_position = $postf_position; | |
| } | |
| // Archive Boxed. | |
| if ( isset( $archiveboxed ) && ( 'unboxed' === $archiveboxed || 'boxed' === $archiveboxed ) ) { | |
| $boxed = $archiveboxed; | |
| } else { | |
| $option_boxed = Kadence\kadence()->option( $archive_type . '_content_style' ); | |
| if ( empty( $option_boxed ) ) { | |
| $option_boxed = Kadence\kadence()->option( 'post_archive_content_style' ); | |
| } | |
| if ( 'unboxed' === $option_boxed || 'boxed' === $option_boxed ) { | |
| $boxed = $option_boxed; | |
| } | |
| } | |
| // Archive Vertical Padding. | |
| if ( isset( $archivevpadding ) && ( 'show' === $archivevpadding || 'hide' === $archivevpadding || 'top' === $archivevpadding || 'bottom' === $archivevpadding ) ) { | |
| $vpadding = $archivevpadding; | |
| } else { | |
| $option_vpadding = Kadence\kadence()->option( $archive_type . '_vertical_padding' ); | |
| if ( $option_vpadding && ( 'show' === $option_vpadding || 'hide' === $option_vpadding || 'top' === $option_vpadding || 'bottom' === $option_vpadding ) ) { | |
| $vpadding = $option_vpadding; | |
| } | |
| } | |
| // Archive Layout. | |
| if ( isset( $archivelayout ) && ( 'narrow' === $archivelayout || 'fullwidth' === $archivelayout ) ) { | |
| $layout = $archivelayout; | |
| } elseif ( ( isset( $archivelayout ) && 'default' === $archivelayout ) || empty( $archivelayout ) ) { | |
| $option_layout = Kadence\kadence()->option( $archive_type . '_layout' ); | |
| if ( empty( $option_layout ) ) { | |
| $option_layout = Kadence\kadence()->option( 'post_archive_layout' ); | |
| } | |
| if ( 'narrow' === $option_layout || 'fullwidth' === $option_layout ) { | |
| $layout = $option_layout; | |
| } | |
| } | |
| // Archive Sidebar. | |
| if ( isset( $archivelayout ) && ( 'left' === $archivelayout || 'right' === $archivelayout ) ) { | |
| $side = $archivelayout; | |
| $sidebar = 'enable'; | |
| } elseif ( ( isset( $archivelayout ) && 'default' === $archivelayout ) || empty( $archivelayout ) ) { | |
| $option_layout = Kadence\kadence()->option( $archive_type . '_layout' ); | |
| if ( empty( $option_layout ) ) { | |
| $option_layout = Kadence\kadence()->option( 'post_archive_layout' ); | |
| } | |
| if ( 'left' === $option_layout || 'right' === $option_layout ) { | |
| $side = $option_layout; | |
| $sidebar = 'enable'; | |
| } | |
| } | |
| } | |
| $return_array = array( | |
| 'layout' => $layout, | |
| 'boxed' => $boxed, | |
| 'feature' => $feature, | |
| 'feature_position' => $f_position, | |
| 'comments' => $comments, | |
| 'navigation' => $navigation, | |
| 'title' => $title, | |
| 'transparent' => $transparent, | |
| 'side' => $side, | |
| 'sidebar' => $sidebar, | |
| 'vpadding' => $vpadding, | |
| 'sidebar_id' => $sidebar_id, | |
| 'footer' => $footer, | |
| 'header' => $header, | |
| 'content' => $content, | |
| ); | |
| return $return_array; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment