From 9d4123cee1867ee7199b06bdc92d40611f547ecc Mon Sep 17 00:00:00 2001 From: Zach van Rijn Date: Wed, 21 Jul 2021 14:54:07 -0500 Subject: Initial unmodified import from Astra (Version: 3.6.5) @ /wp-content/themes/astra/. --- inc/compatibility/class-astra-elementor.php | 254 ++++++++++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 inc/compatibility/class-astra-elementor.php (limited to 'inc/compatibility/class-astra-elementor.php') diff --git a/inc/compatibility/class-astra-elementor.php b/inc/compatibility/class-astra-elementor.php new file mode 100644 index 0000000..9008865 --- /dev/null +++ b/inc/compatibility/class-astra-elementor.php @@ -0,0 +1,254 @@ +is_elementor_activated( $id ) ) { + + $elementor_heading_margin_comp = array( + '.elementor-widget-heading .elementor-heading-title' => array( + 'margin' => '0', + ), + ); + + /* Parse CSS from array() */ + $parse_css = astra_parse_css( $elementor_heading_margin_comp ); + + $elementor_base_css = array( + '.elementor-post.elementor-grid-item.hentry' => array( + 'margin-bottom' => '0', + ), + '.woocommerce div.product .elementor-element.elementor-products-grid .related.products ul.products li.product, .elementor-element .elementor-wc-products .woocommerce[class*=\'columns-\'] ul.products li.product' => array( + 'width' => 'auto', + 'margin' => '0', + 'float' => 'none', + ), + ); + // Load base static CSS when Elmentor is activated. + $parse_css .= astra_parse_css( $elementor_base_css ); + + if ( is_rtl() ) { + $elementor_rtl_support_css = array( + '.ast-left-sidebar .elementor-section.elementor-section-stretched,.ast-right-sidebar .elementor-section.elementor-section-stretched' => array( + 'max-width' => '100%', + 'right' => '0 !important', + ), + ); + } else { + $elementor_rtl_support_css = array( + '.ast-left-sidebar .elementor-section.elementor-section-stretched,.ast-right-sidebar .elementor-section.elementor-section-stretched' => array( + 'max-width' => '100%', + 'left' => '0 !important', + ), + ); + } + $parse_css .= astra_parse_css( $elementor_rtl_support_css ); + + + $dynamic_css .= $parse_css; + } + + $elementor_archive_page_css = array( + '.elementor-template-full-width .ast-container' => array( + 'display' => 'block', + ), + ); + $dynamic_css .= astra_parse_css( $elementor_archive_page_css ); + + return $dynamic_css; + } + + /** + * Elementor Content layout set as Page Builder + * + * @return void + * @since 1.0.2 + */ + public function elementor_default_setting() { + + if ( false === astra_enable_page_builder_compatibility() || 'post' == get_post_type() ) { + return; + } + + // don't modify post meta settings if we are not on Elementor's edit page. + if ( ! $this->is_elementor_editor() ) { + return; + } + + global $post; + $id = astra_get_post_id(); + + $page_builder_flag = get_post_meta( $id, '_astra_content_layout_flag', true ); + if ( isset( $post ) && empty( $page_builder_flag ) && ( is_admin() || is_singular() ) ) { + + if ( empty( $post->post_content ) && $this->is_elementor_activated( $id ) ) { + + update_post_meta( $id, '_astra_content_layout_flag', 'disabled' ); + update_post_meta( $id, 'site-post-title', 'disabled' ); + update_post_meta( $id, 'ast-title-bar-display', 'disabled' ); + update_post_meta( $id, 'ast-featured-img', 'disabled' ); + + $content_layout = get_post_meta( $id, 'site-content-layout', true ); + if ( empty( $content_layout ) || 'default' == $content_layout ) { + update_post_meta( $id, 'site-content-layout', 'page-builder' ); + } + + $sidebar_layout = get_post_meta( $id, 'site-sidebar-layout', true ); + if ( empty( $sidebar_layout ) || 'default' == $sidebar_layout ) { + update_post_meta( $id, 'site-sidebar-layout', 'no-sidebar' ); + } + + // In the preview mode, Apply the layouts using filters for Elementor Template Library. + add_filter( + 'astra_page_layout', + function() { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewClosure.Found + return 'no-sidebar'; + } + ); + + add_filter( + 'astra_get_content_layout', + function () { // phpcs:ignore PHPCompatibility.FunctionDeclarations.NewClosure.Found + return 'page-builder'; + } + ); + + add_filter( 'astra_the_post_title_enabled', '__return_false' ); + add_filter( 'astra_featured_image_enabled', '__return_false' ); + } + } + } + + /** + * Add z-index CSS for elementor's drag drop + * + * @return void + * @since 1.4.0 + */ + public function elementor_overlay_zindex() { + + // return if we are not on Elementor's edit page. + if ( ! $this->is_elementor_editor() ) { + return; + } + + ?> + + + db->get_edit_mode( $id ) ); + } else { + return Plugin::$instance->db->is_built_with_elementor( $id ); + } + } + + /** + * Check if Elementor Editor is open. + * + * @since 1.2.7 + * + * @return boolean True IF Elementor Editor is loaded, False If Elementor Editor is not loaded. + */ + private function is_elementor_editor() { + if ( ( isset( $_REQUEST['action'] ) && 'elementor' == $_REQUEST['action'] ) || isset( $_REQUEST['elementor-preview'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended + return true; + } + + return false; + } + + } + +endif; + +/** + * Kicking this off by calling 'get_instance()' method + */ +Astra_Elementor::get_instance(); -- cgit v1.2.3-60-g2f50