| @@ -1,7 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | +use Elementor\Core\Settings\Page\Manager; | |
| 5 | + | |
| 4 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | 7 | exit; // Exit if accessed directly. |
| 6 | 8 | } |
| 7 | 9 | |
| @@ -149,12 +151,25 @@ | ||
| 149 | 151 | "SET `meta_value` = REPLACE(`meta_value`, '" . str_replace( '/', '\\\/', $from ) . "', '" . str_replace( '/', '\\\/', $to ) . "') " . |
| 150 | 152 | "WHERE `meta_key` = '_elementor_data' AND `meta_value` LIKE '[%' ;" ); // meta_value LIKE '[%' are json formatted |
| 151 | 153 | // @codingStandardsIgnoreEnd |
| 152 | 154 | |
| 155 | + $second_rows_affected = $wpdb->query( | |
| 156 | + "UPDATE {$wpdb->postmeta} " . | |
| 157 | + $wpdb->prepare( 'SET `meta_value` = REPLACE(`meta_value`, %s, %s) ', $from, $to ) . | |
| 158 | + 'WHERE `meta_key` = \'' . Manager::META_KEY . '\'' | |
| 159 | + ); | |
| 160 | + | |
| 161 | + if ( $second_rows_affected ) { | |
| 162 | + $rows_affected += $second_rows_affected; | |
| 163 | + } | |
| 164 | + | |
| 153 | 165 | if ( false === $rows_affected ) { |
| 154 | 166 | throw new \Exception( __( 'An error occurred', 'elementor' ) ); |
| 155 | 167 | } |
| 156 | 168 | |
| 169 | + // Allow externals to replace-urls, when they have to. | |
| 170 | + $rows_affected += (int) apply_filters( 'elementor/tools/replace-urls', 0, $from, $to ); | |
| 171 | + | |
| 157 | 172 | Plugin::$instance->files_manager->clear_cache(); |
| 158 | 173 | |
| 159 | 174 | return sprintf( |
| 160 | 175 | /* translators: %d: Number of rows */ |
| @@ -654,6 +669,29 @@ | ||
| 654 | 669 | * @return string |
| 655 | 670 | */ |
| 656 | 671 | public static function validate_html_tag( $tag ) { |
| 657 | 672 | return in_array( strtolower( $tag ), self::ALLOWED_HTML_WRAPPER_TAGS ) ? $tag : 'div'; |
| 673 | + } | |
| 674 | + | |
| 675 | + /** | |
| 676 | + * Get recently edited posts query. | |
| 677 | + * | |
| 678 | + * Returns `WP_Query` of the recent edited posts. | |
| 679 | + * By default max posts ( $args['posts_per_page'] ) is 3. | |
| 680 | + * | |
| 681 | + * @param array $args | |
| 682 | + * | |
| 683 | + * @return \WP_Query | |
| 684 | + */ | |
| 685 | + public static function get_recently_edited_posts_query( $args = [] ) { | |
| 686 | + $args = wp_parse_args( $args, [ | |
| 687 | + 'post_type' => 'any', | |
| 688 | + 'post_status' => [ 'publish', 'draft' ], | |
| 689 | + 'posts_per_page' => '3', | |
| 690 | + 'meta_key' => '_elementor_edit_mode', | |
| 691 | + 'meta_value' => 'builder', | |
| 692 | + 'orderby' => 'modified', | |
| 693 | + ] ); | |
| 694 | + | |
| 695 | + return new \WP_Query( $args ); | |
| 658 | 696 | } |
| 659 | 697 | } |