Astra_PB_Compatibility::page_builder_compatibility()
Update options of older version than 1.0.13.
Description
Return
(void)
Source
File: inc/theme-update/class-astra-pb-compatibility.php
public function page_builder_compatibility() {
$offset_comp = get_option( '_astra_pb_compatibility_offset', false );
$comp_time = get_option( '_astra_pb_compatibility_time', false );
if ( ! $offset_comp || ! $comp_time ) {
astra_update_option( '_astra_pb_compatibility_completed', true );
return;
}
// Get current post id.
$current_post_id = (int) get_the_ID();
if ( $current_post_id ) {
$post_date = strtotime( get_the_date( 'Y-m-d H:i:s', $current_post_id ) );
$backward_date = strtotime( $comp_time );
if ( $post_date < $backward_date ) {
$this->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 );
}
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.0.13 | Introduced. |