fix: complete CHRNX responsive edge states
This commit is contained in:
15 files changed
+384
-35
No files matched your search
@@ -11,6 +11,11 @@ $chrnx_seed_host = wp_parse_url( home_url( '/' ), PHP_URL_HOST );
|
||||
if ( ! in_array( $chrnx_seed_host, array( 'localhost', '127.0.0.1' ), true ) ) {
|
||||
WP_CLI::error( 'Refusing to seed a non-local WordPress site.' );
|
||||
}
|
||||
$chrnx_seed_scenario = isset( $args[0] ) && is_string( $args[0] ) ? $args[0] : 'default';
|
||||
$chrnx_seed_scenarios = array( 'default', 'featured-1', 'featured-2', 'featured-3', 'subscribe-unpublished', 'subscribe-unavailable' );
|
||||
if ( ! in_array( $chrnx_seed_scenario, $chrnx_seed_scenarios, true ) ) {
|
||||
WP_CLI::error( 'Unknown local fixture scenario.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Read one fixture JSON document from the mapped theme.
|
||||
@@ -114,7 +119,7 @@ foreach ( $chrnx_seed_posts as $chrnx_seed_index => $chrnx_seed_post ) {
|
||||
wp_set_object_terms( $chrnx_seed_post_id, array(), 'chrnx_show', false );
|
||||
}
|
||||
|
||||
foreach ( array( 'chrnx_episode_number', 'chrnx_episode_duration' ) as $chrnx_seed_meta_key ) {
|
||||
foreach ( array( 'chrnx_episode_number', 'chrnx_episode_duration', 'canonical_episode_url' ) as $chrnx_seed_meta_key ) {
|
||||
delete_post_meta( $chrnx_seed_post_id, $chrnx_seed_meta_key );
|
||||
}
|
||||
if ( isset( $chrnx_seed_post['episodeNumber'] ) ) {
|
||||
@@ -123,6 +128,9 @@ foreach ( $chrnx_seed_posts as $chrnx_seed_index => $chrnx_seed_post ) {
|
||||
if ( isset( $chrnx_seed_post['episodeDuration'] ) ) {
|
||||
update_post_meta( $chrnx_seed_post_id, 'chrnx_episode_duration', chrnx_sanitize_episode_duration( $chrnx_seed_post['episodeDuration'] ) );
|
||||
}
|
||||
if ( isset( $chrnx_seed_post['canonicalEpisodeUrl'] ) ) {
|
||||
update_post_meta( $chrnx_seed_post_id, 'canonical_episode_url', chrnx_sanitize_canonical_episode_url( $chrnx_seed_post['canonicalEpisodeUrl'] ) );
|
||||
}
|
||||
$chrnx_seed_post_ids[ $chrnx_seed_post['fixtureKey'] ] = $chrnx_seed_post_id;
|
||||
}
|
||||
|
||||
@@ -132,21 +140,35 @@ foreach ( $chrnx_seed_posts as $chrnx_seed_post ) {
|
||||
$chrnx_seed_sticky_ids[] = $chrnx_seed_post_ids[ $chrnx_seed_post['fixtureKey'] ];
|
||||
}
|
||||
}
|
||||
update_option( 'sticky_posts', $chrnx_seed_sticky_ids );
|
||||
$chrnx_seed_featured_count = 3;
|
||||
if ( preg_match( '/^featured-([123])$/', $chrnx_seed_scenario, $chrnx_seed_match ) ) {
|
||||
$chrnx_seed_featured_count = absint( $chrnx_seed_match[1] );
|
||||
update_option( '_chrnx_fixture_featured_limit', $chrnx_seed_featured_count );
|
||||
} else {
|
||||
delete_option( '_chrnx_fixture_featured_limit' );
|
||||
}
|
||||
update_option( 'sticky_posts', array_slice( $chrnx_seed_sticky_ids, 0, $chrnx_seed_featured_count ) );
|
||||
update_option( 'blogname', 'CHRNX' );
|
||||
update_option( 'blogdescription', 'Ideas made tangible.' );
|
||||
update_option( 'show_on_front', 'page' );
|
||||
update_option( 'page_on_front', $chrnx_seed_page_ids['home'] );
|
||||
update_option( 'page_for_posts', 0 );
|
||||
update_option( 'chrnx_subscribe_page_id', $chrnx_seed_page_ids['subscribe'] );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $chrnx_seed_page_ids['subscribe'],
|
||||
'post_status' => 'subscribe-unpublished' === $chrnx_seed_scenario ? 'draft' : 'publish',
|
||||
)
|
||||
);
|
||||
update_option( 'chrnx_subscribe_page_id', 'subscribe-unavailable' === $chrnx_seed_scenario ? 0 : $chrnx_seed_page_ids['subscribe'] );
|
||||
update_option( 'permalink_structure', '/%postname%/' );
|
||||
flush_rewrite_rules( false );
|
||||
|
||||
WP_CLI::log(
|
||||
sprintf(
|
||||
'CHRNX_FIXTURES pages=%d posts=%d front=%d',
|
||||
'CHRNX_FIXTURES pages=%d posts=%d front=%d scenario=%s',
|
||||
count( $chrnx_seed_page_ids ),
|
||||
count( $chrnx_seed_post_ids ),
|
||||
$chrnx_seed_page_ids['home']
|
||||
$chrnx_seed_page_ids['home'],
|
||||
$chrnx_seed_scenario
|
||||
)
|
||||
);
|
||||
Reference in new issue
Block a user