| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file is used to update the database version of the plugin. |
| 4 |
* |
| 5 |
* @link https://wpsmartpost.com/ |
| 6 |
* @since 2.4.13 |
| 7 |
* |
| 8 |
* @package Smart_Post_Show |
| 9 |
* @subpackage Smart_Post_Show/includes |
| 10 |
*/ |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; // Exit if accessed directly. |
| 14 |
} |
| 15 |
|
| 16 |
update_option( 'smart_post_show_version', '2.4.13' ); |
| 17 |
update_option( 'smart_post_show_db_version', '2.4.13' ); |
| 18 |
|
| 19 |
/** |
| 20 |
* Update settings. |
| 21 |
*/ |
| 22 |
$args = new \WP_Query( |
| 23 |
array( |
| 24 |
'post_type' => array( 'page' ), |
| 25 |
'post_status' => 'publish', |
| 26 |
'posts_per_page' => '300', |
| 27 |
) |
| 28 |
); |
| 29 |
$post_ids = wp_list_pluck( $args->posts, 'ID' ); |
| 30 |
if ( count( $post_ids ) > 0 ) { |
| 31 |
add_filter( 'wp_revisions_to_keep', '__return_false' ); |
| 32 |
foreach ( $post_ids as $post_key => $pid ) { |
| 33 |
$post_data = get_post( $pid ); |
| 34 |
$post_content = isset( $post_data->post_content ) ? $post_data->post_content : ''; |
| 35 |
if ( ! empty( $post_content ) && ( strpos( $post_content, 'wp:smart-post-show' ) !== false ) ) { |
| 36 |
$post_content = preg_replace( '/wp:smart-post-show\/shortcode/i', 'wp:smart-post-show-pro/shortcode', $post_content ); |
| 37 |
|
| 38 |
$gutenberg_post = array( |
| 39 |
'ID' => $pid, |
| 40 |
'post_content' => $post_content, |
| 41 |
); |
| 42 |
// Update the post into the database. |
| 43 |
$pid = wp_update_post( $gutenberg_post ); |
| 44 |
|
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
|