| @@ -77,13 +77,19 @@ | ||
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Replace old URLs with new URLs in all Elementor pages. |
| 80 | 80 | * |
| 81 | + * [--force] | |
| 82 | + * Suppress error messages. instead, return "0 affected rows.". | |
| 83 | + * | |
| 81 | 84 | * ## EXAMPLES |
| 82 | 85 | * |
| 83 | 86 | * 1. wp elementor replace-urls <old> <new> |
| 84 | 87 | * - This will replace all <old> URLs with the <new> URL. |
| 85 | 88 | * |
| 89 | + * 2. wp elementor replace-urls <old> <new> --force | |
| 90 | + * - This will replace all <old> URLs with the <new> URL without throw errors. | |
| 91 | + * | |
| 86 | 92 | * @access public |
| 87 | 93 | * @alias replace-urls |
| 88 | 94 | */ |
| 89 | 95 | public function replace_urls( $args, $assoc_args ) { |
| @@ -98,9 +104,13 @@ | ||
| 98 | 104 | try { |
| 99 | 105 | $results = Utils::replace_urls( $args[0], $args[1] ); |
| 100 | 106 | \WP_CLI::success( $results ); |
| 101 | 107 | } catch ( \Exception $e ) { |
| 102 | - \WP_CLI::error( $e->getMessage() ); | |
| 108 | + if ( isset( $assoc_args['force'] ) ) { | |
| 109 | + \WP_CLI::success( '0 rows affected.' ); | |
| 110 | + } else { | |
| 111 | + \WP_CLI::error( $e->getMessage() ); | |
| 112 | + } | |
| 103 | 113 | } |
| 104 | 114 | } |
| 105 | 115 | |
| 106 | 116 | /** |