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/theme-update/class-astra-pb-compatibility.php | 186 ++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 inc/theme-update/class-astra-pb-compatibility.php (limited to 'inc/theme-update/class-astra-pb-compatibility.php') diff --git a/inc/theme-update/class-astra-pb-compatibility.php b/inc/theme-update/class-astra-pb-compatibility.php new file mode 100644 index 0000000..1b707d5 --- /dev/null +++ b/inc/theme-update/class-astra-pb-compatibility.php @@ -0,0 +1,186 @@ +update_meta_values( $current_post_id ); + } + } + + // get all post types. + $all_post_type = get_post_types( + array( + 'public' => true, + ) + ); + unset( $all_post_type['attachment'] ); + + // wp_query array. + $query = array( + 'post_type' => $all_post_type, + 'posts_per_page' => '30', + 'no_found_rows' => true, + 'post_status' => 'any', + 'offset' => $offset_comp, + 'date_query' => array( + array( + 'before' => $comp_time, + 'inclusive' => true, + ), + ), + 'fields' => 'ids', + ); + + // exicute wp_query. + $posts = new WP_Query( $query ); + + $continue = false; + foreach ( $posts->posts as $id ) { + $this->update_meta_values( $id ); + $continue = true; + } + + if ( $continue ) { + $offset_comp += 30; + update_option( '_astra_pb_compatibility_offset', $offset_comp ); + } else { + delete_option( '_astra_pb_compatibility_offset' ); + delete_option( '_astra_pb_compatibility_time' ); + astra_update_option( '_astra_pb_compatibility_completed', true ); + } + } + + /** + * Update meta values + * + * @since 1.0.13 + * @param int $id Post id. + * @return void + */ + public function update_meta_values( $id ) { + + $layout_flag = get_post_meta( $id, '_astra_content_layout_flag', true ); + if ( empty( $layout_flag ) ) { + $site_content = get_post_meta( $id, 'site-content-layout', true ); + + if ( 'default' == $site_content ) { + $post_type = get_post_type( $id ); + if ( 'page' == $post_type ) { + $site_content = astra_get_option( 'single-page-content-layout', '' ); + } elseif ( 'post' == $post_type ) { + $site_content = astra_get_option( 'single-post-content-layout', '' ); + } + + if ( 'default' == $site_content ) { + $site_content = astra_get_option( 'site-content-layout', '' ); + } + } + + $elementor = get_post_meta( $id, '_elementor_edit_mode', true ); + $vc = get_post_meta( $id, '_wpb_vc_js_status', true ); + if ( 'page-builder' === $site_content ) { + 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, 'site-sidebar-layout', 'no-sidebar' ); + } elseif ( 'builder' === $elementor || true === $vc || 'true' === $vc ) { + update_post_meta( $id, '_astra_content_layout_flag', 'disabled' ); + } + } + } + } +} + + + +/** + * Kicking this off by calling 'get_instance()' method + */ +Astra_PB_Compatibility::get_instance(); -- cgit v1.2.3-70-g09d2