Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@aede988 from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Feb 11, 2024
1 parent fb7ae58 commit 58a70ce
Showing 1 changed file with 65 additions and 10 deletions.
75 changes: 65 additions & 10 deletions includes/class-prc-platform-content-bootstrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ public function detect_lack_of_content() {
}

public function run() {
if ( !PRC_PLATFORM_TESTING_MODE ) {
return;
}
// if ( !PRC_PLATFORM_TESTING_MODE ) {
// return;
// }
$already_bootstrapped = get_option( $this->option_name );
if ( $already_bootstrapped || true !== $this->detect_lack_of_content() ) {
return;
}
$this->create_sample_topics();
$this->create_sample_report();
$this->create_sample_fact_sheet();
$this->configure_sample_options();
$this->configure_tagline();
$this->create_homepage_and_set_as_front_page();
$this->create_publication_page_and_set_as_blog_page()

}

Expand All @@ -59,6 +61,65 @@ public function create_sample_topics() {
}
}

public function create_publication_page_and_set_as_blog_page() {
// create a sample "publications" page if it doesn't already exist
$publications_page = get_page_by_title( 'Publications' );
if ( empty( $publications_page ) ) {
$publications_page = wp_insert_post( array(
'post_title' => 'Publications',
'post_type' => 'page',
'post_status' => 'publish',
) );
}
// set the "publications" page as the home page
update_option( 'page_for_posts', $publications_page );
}

public function create_homepage_and_set_as_front_page() {
ob_start();
?>
<!-- wp:group {"layout":{"type":"constrained","contentSize":"1200px"}} -->
<div class="wp-block-group"><!-- wp:prc-block/grid-controller {"dividerColor":"gray","className":"is-pattern__featured-layout"} -->
<!-- wp:prc-block/grid-column {"gridLayout":{"index":1,"desktopSpan":"3","tabletSpan":"6","mobileSpan":"4"}} -->
<!-- wp:prc-block/story-item {"imageSize":"A2","postId":0,"metaTaxonomy":"category"} /-->

<!-- wp:prc-block/story-item {"imageSize":"A2","postId":0,"metaTaxonomy":"category"} /-->
<!-- /wp:prc-block/grid-column -->

<!-- wp:prc-block/grid-column {"gridLayout":{"index":2,"desktopSpan":"6","tabletSpan":"12","mobileSpan":"4"}} -->
<!-- wp:prc-block/story-item {"postId":0,"metaTaxonomy":"category"} /-->
<!-- /wp:prc-block/grid-column -->

<!-- wp:prc-block/grid-column {"gridLayout":{"index":3,"desktopSpan":"3","tabletSpan":"6","mobileSpan":"4"}} -->
<!-- wp:prc-block/story-item {"imageSize":"A2","postId":0,"metaTaxonomy":"category"} /-->

<!-- wp:prc-block/story-item {"imageSize":"A2","postId":0,"metaTaxonomy":"category"} /-->
<!-- /wp:prc-block/grid-column -->
<!-- /wp:prc-block/grid-controller --></div>
<!-- /wp:group -->
<?php
$template = ob_get_clean();
// create a sample "home" page if it doesn't already exist
$home_page = get_page_by_title( 'Home' );
if ( empty( $home_page ) ) {
$home_page = wp_insert_post( array(
'post_title' => 'Home',
'post_type' => 'page',
'post_status' => 'publish',
'post_content' => $template,
) );
}
// set the "home" page as the home page
update_option( 'page_on_front', $home_page );
update_option( 'show_on_front', 'page' );
}

public function configure_tagline() {
$tagline = 'Numbers, Facts and Trends Shaping Your World';
update_option( 'blogdescription', $tagline );
update_option( self::$option_name, true );
}

public function create_sample_report() {
?>
<p>Ipsum....</p>
Expand Down Expand Up @@ -135,10 +196,4 @@ public function create_sample_block_module() {
<?php
$content = ob_get_clean();
}

public function configure_sample_options() {
$tagline = 'Numbers, Facts and Trends Shaping Your World';
update_option( 'blogdescription', $tagline );
update_option( self::$option_name, true );
}
}

0 comments on commit 58a70ce

Please sign in to comment.