astra_is_sidebar_style_boxed( mixed $post_id = false )
Check if the sidebar style is boxed.
Description
Parameters
- $post_id
-
(mixed) (Optional) Current post ID.
Default value: false
Return
(bool) Whether the sidebar style is boxed.
Source
File: inc/markup-extras.php
function astra_is_sidebar_style_boxed( $post_id = false ) { $post_type = strval( get_post_type() ); $blog_type = is_singular() ? 'single' : 'archive'; $global_sidebar_style = astra_get_option( 'site-sidebar-style' ); $meta_sidebar_style = astra_get_option_meta( 'site-sidebar-style', '', true ); $is_sidebar_boxed = false; $is_third_party_shop = false; // Editor compatibility. if ( $post_id ) { $blog_type = 'single'; $meta_sidebar_style = get_post_meta( $post_id, 'site-sidebar-style', true ); } $sidebar_style = astra_get_option( $blog_type . '-' . $post_type . '-sidebar-style', '' ); // Third party compatibility. $third_party = astra_with_third_party( true ); if ( ! empty( $third_party ) ) { $third_party_sidebar_style = astra_get_option( $third_party . '-sidebar-style', '' ); if ( in_array( $third_party, array( 'lifterlms', 'learndash' ) ) && ! in_array( $post_type, Astra_Posts_Structure_Loader::get_supported_post_types() ) && empty( $meta_sidebar_style ) ) { $blog_type = ''; } // Get global sidebar style if third party is default. $global_sidebar_style = ( 'default' === $third_party_sidebar_style || empty( $third_party_sidebar_style ) ) ? $global_sidebar_style : $third_party_sidebar_style; // Woo Cart & Checkout Page if ( 'woocommerce' === $third_party && ( is_cart() || is_checkout() ) ) { return ( 'boxed' === $global_sidebar_style ); } // Third party shop/archive page meta case. $third_party_meta_page = astra_third_party_archive_meta( 'site-sidebar-style' ); $meta_sidebar_style = isset( $third_party_meta_page ) && $third_party_meta_page ? $third_party_meta_page : $meta_sidebar_style; $is_third_party_shop = isset( $third_party_meta_page ) && $third_party_meta_page ? true : false; } // Global. if ( 'boxed' === $global_sidebar_style ) { $is_sidebar_boxed = true; } // Archive. if ( 'archive' === $blog_type && ! empty( $sidebar_style ) && 'default' !== $sidebar_style ) { $is_sidebar_boxed = ( 'boxed' === $sidebar_style ); } // Single. if ( 'single' === $blog_type && ! empty( $sidebar_style ) && 'default' !== $sidebar_style ) { $is_sidebar_boxed = ( 'boxed' === $sidebar_style ); } // Meta. if ( ( 'single' === $blog_type || $is_third_party_shop ) && ! empty( $meta_sidebar_style ) && 'default' !== $meta_sidebar_style && ! $post_id ) { if ( 'boxed' === $meta_sidebar_style ) { $is_sidebar_boxed = true; } else { $is_sidebar_boxed = false; } } return $is_sidebar_boxed; }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
4.2.0 | Introduced. |