Skip to content

Commit a026d1b

Browse files
committed
spellcheck fixes
1 parent 9ae7a31 commit a026d1b

3 files changed

Lines changed: 26 additions & 18 deletions

File tree

.typos.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[default]
2+
extend-ignore-re = [
3+
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$",
4+
"(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on",
5+
"(#|//)\\s*spellchecker:ignore-next-line\\n.*"
6+
]

src/Export_Command.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,15 @@ private function check_post_status( $status ) {
441441
return true;
442442
}
443443

444-
$stati = get_post_stati();
445-
if ( empty( $stati ) || is_wp_error( $stati ) ) {
446-
WP_CLI::warning( 'Could not find any post stati.' );
444+
// spellchecker:ignore-next-line
445+
$statuses = get_post_stati();
446+
if ( empty( $statuses ) || is_wp_error( $statuses ) ) {
447+
WP_CLI::warning( 'Could not find any post statuses.' );
447448
return false;
448449
}
449450

450-
if ( ! isset( $stati[ $status ] ) ) {
451-
WP_CLI::warning( sprintf( 'Could not find a post_status matching %s. Here is a list of available stati: %s', $status, implode( ', ', array_keys( $stati ) ) ) );
451+
if ( ! isset( $statuses[ $status ] ) ) {
452+
WP_CLI::warning( sprintf( 'Could not find a post_status matching %s. Here is a list of available statuses: %s', $status, implode( ', ', array_keys( $statuses ) ) ) );
452453
return false;
453454
}
454455
$this->export_args['status'] = $status;

src/WP_Export_Query.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ class WP_Export_Query {
2626
private $post_ids;
2727
private $filters;
2828

29-
private $wheres = [];
30-
private $joins = [];
29+
private $where_clauses = [];
30+
31+
private $joins = [];
3132

3233
private $author;
3334
private $category;
@@ -177,7 +178,7 @@ private function calculate_post_ids() {
177178
$this->start_id_where();
178179
$this->category_where();
179180

180-
$where = implode( ' AND ', array_filter( $this->wheres ) );
181+
$where = implode( ' AND ', array_filter( $this->where_clauses ) );
181182
if ( $where ) {
182183
$where = "WHERE $where";
183184
}
@@ -216,30 +217,30 @@ private function post_type_where() {
216217
}
217218

218219
if ( ! $post_types ) {
219-
$this->wheres[] = 'p.post_type IS NULL';
220+
$this->where_clauses[] = 'p.post_type IS NULL';
220221
return;
221222
}
222223

223224
if ( false === $this->filters['with_attachments'] && ( ! $this->filters['post_type'] || ! in_array( 'attachment', $this->filters['post_type'], true ) ) ) {
224225
unset( $post_types['attachment'] );
225226
}
226227

227-
$this->wheres[] = _wp_export_build_IN_condition( 'p.post_type', $post_types );
228+
$this->where_clauses[] = _wp_export_build_IN_condition( 'p.post_type', $post_types );
228229
}
229230

230231
private function status_where() {
231232
global $wpdb;
232233
if ( ! $this->filters['status'] ) {
233-
$this->wheres[] = "p.post_status != 'auto-draft'";
234+
$this->where_clauses[] = "p.post_status != 'auto-draft'";
234235
return;
235236
}
236-
$this->wheres[] = $wpdb->prepare( 'p.post_status = %s', $this->filters['status'] );
237+
$this->where_clauses[] = $wpdb->prepare( 'p.post_status = %s', $this->filters['status'] );
237238
}
238239

239240
private function author_where() {
240241
global $wpdb;
241242
if ( is_object( $this->author ) && property_exists( $this->author, 'ID' ) ) {
242-
$this->wheres[] = $wpdb->prepare( 'p.post_author = %d', $this->author->ID );
243+
$this->where_clauses[] = $wpdb->prepare( 'p.post_author = %d', $this->author->ID );
243244
}
244245
}
245246

@@ -249,7 +250,7 @@ private function start_date_where() {
249250
if ( ! $timestamp ) {
250251
return;
251252
}
252-
$this->wheres[] = $wpdb->prepare( 'p.post_date >= %s', date( 'Y-m-d 00:00:00', $timestamp ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
253+
$this->where_clauses[] = $wpdb->prepare( 'p.post_date >= %s', date( 'Y-m-d 00:00:00', $timestamp ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
253254
}
254255

255256
private function end_date_where() {
@@ -265,7 +266,7 @@ private function end_date_where() {
265266
if ( ! $timestamp ) {
266267
return;
267268
}
268-
$this->wheres[] = $wpdb->prepare( 'p.post_date <= %s', date( 'Y-m-d 23:59:59', $timestamp ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
269+
$this->where_clauses[] = $wpdb->prepare( 'p.post_date <= %s', date( 'Y-m-d 23:59:59', $timestamp ) ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
269270
}
270271

271272
private function start_id_where() {
@@ -275,7 +276,7 @@ private function start_id_where() {
275276
if ( 0 === $start_id ) {
276277
return;
277278
}
278-
$this->wheres[] = $wpdb->prepare( 'p.ID >= %d', $start_id );
279+
$this->where_clauses[] = $wpdb->prepare( 'p.ID >= %d', $start_id );
279280
}
280281

281282
private function get_timestamp_for_the_last_day_of_a_month( $yyyy_mm ) {
@@ -293,7 +294,7 @@ private function category_where() {
293294
}
294295
$this->category = $category;
295296
$this->joins[] = "INNER JOIN {$wpdb->term_relationships} AS tr ON (p.ID = tr.object_id)";
296-
$this->wheres[] = $wpdb->prepare( 'tr.term_taxonomy_id = %d', $category->term_taxonomy_id );
297+
$this->where_clauses[] = $wpdb->prepare( 'tr.term_taxonomy_id = %d', $category->term_taxonomy_id );
297298
}
298299

299300
private function max_num_posts() {
@@ -310,7 +311,7 @@ private function include_attachment_ids( $post_ids ) {
310311
return [];
311312
}
312313
$attachment_ids = [];
313-
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition -- Assigment is part of the break condition.
314+
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition -- Assignment is part of the break condition.
314315
while ( $batch_of_post_ids = array_splice( $post_ids, 0, self::QUERY_CHUNK ) ) {
315316
$post_parent_condition = _wp_export_build_IN_condition( 'post_parent', $batch_of_post_ids );
316317
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Escaped in wpcli_export_build_in_condition() function.

0 commit comments

Comments
 (0)