fix: finalize CHRNX fixture and landmark contracts
This commit is contained in:
6 files changed
+77
-65
No files matched your search
@@ -98,10 +98,35 @@ function chrnx_seed_upsert_post( array $fixture, string $post_type, int $offset
|
||||
}
|
||||
|
||||
chrnx_seed_editorial_terms();
|
||||
$chrnx_seed_pages = chrnx_seed_read_fixture( 'pages.json' );
|
||||
$chrnx_seed_posts = chrnx_seed_read_fixture( 'posts.json' );
|
||||
$chrnx_seed_page_ids = array();
|
||||
$chrnx_seed_post_ids = array();
|
||||
$chrnx_seed_pages = chrnx_seed_read_fixture( 'pages.json' );
|
||||
$chrnx_seed_posts = chrnx_seed_read_fixture( 'posts.json' );
|
||||
$chrnx_seed_page_ids = array();
|
||||
$chrnx_seed_post_ids = array();
|
||||
$chrnx_seed_keys = array_map(
|
||||
'sanitize_key',
|
||||
array_merge(
|
||||
array_column( $chrnx_seed_pages, 'fixtureKey' ),
|
||||
array_column( $chrnx_seed_posts, 'fixtureKey' )
|
||||
)
|
||||
);
|
||||
$chrnx_seed_removed = 0;
|
||||
$chrnx_seed_owned_ids = get_posts(
|
||||
array(
|
||||
'post_type' => array( 'page', 'post' ),
|
||||
'post_status' => 'any',
|
||||
'posts_per_page' => -1,
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
'meta_key' => '_chrnx_fixture_key',
|
||||
)
|
||||
);
|
||||
foreach ( $chrnx_seed_owned_ids as $chrnx_seed_owned_id ) {
|
||||
$chrnx_seed_owned_key = sanitize_key( get_post_meta( $chrnx_seed_owned_id, '_chrnx_fixture_key', true ) );
|
||||
if ( preg_match( '/^(?:page|post)-[a-z0-9-]+$/', $chrnx_seed_owned_key ) && ! in_array( $chrnx_seed_owned_key, $chrnx_seed_keys, true ) ) {
|
||||
wp_delete_post( $chrnx_seed_owned_id, true );
|
||||
++$chrnx_seed_removed;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $chrnx_seed_pages as $chrnx_seed_index => $chrnx_seed_page ) {
|
||||
$chrnx_seed_page_id = chrnx_seed_upsert_post( $chrnx_seed_page, 'page', $chrnx_seed_index );
|
||||
@@ -165,9 +190,10 @@ flush_rewrite_rules( false );
|
||||
|
||||
WP_CLI::log(
|
||||
sprintf(
|
||||
'CHRNX_FIXTURES pages=%d posts=%d front=%d scenario=%s',
|
||||
'CHRNX_FIXTURES pages=%d posts=%d removed=%d front=%d scenario=%s',
|
||||
count( $chrnx_seed_page_ids ),
|
||||
count( $chrnx_seed_post_ids ),
|
||||
$chrnx_seed_removed,
|
||||
$chrnx_seed_page_ids['home'],
|
||||
$chrnx_seed_scenario
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user