Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@8d27402 from refs/heads/release/5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed Feb 8, 2024
1 parent 9dce46f commit 3a7af2c
Show file tree
Hide file tree
Showing 1,510 changed files with 83,346 additions and 1,752 deletions.
11 changes: 11 additions & 0 deletions includes/content-bootstrapper/.package.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@pewresearch/prc-platform-XX",
"description": "XX functionality for PRC Platform",
"license": "GPL-2.0-or-later",
"devDependencies": {
"@wordpress/scripts": "^26.1.0"
},
"scripts": {
"build": "wp-scripts build src/index.js"
}
}
117 changes: 117 additions & 0 deletions includes/content-bootstrapper/class-content-bootstrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php
namespace PRC\Platform;
use WP_Error;

/**
* Bootstraps content for PRC Platform development, if no data is present.
*/
class Content_Bootstrapper {
/**
* The version of this plugin.
*
* @since 1.0.0
* @access private
* @var string $version The current version of this plugin.
*/
private $version;

public static $handle = 'prc-platform-content-boostrapper';

/**
* Initialize the class and set its properties.
*
* @since 1.0.0
* @param string $plugin_name The name of this plugin.
* @param string $version The version of this plugin.
*/
public function __construct( $version, $loader ) {
$this->version = $version;
$this->init($loader);
}

public function init( $loader = null ) {
if ( !PRC_PLATFORM_TESTING_MODE ) {
return;
}
if ( null !== $loader ) {
// $loader->add_action('', $this, 'my_func');
// $loader->add_filter('', $this, 'my_func');
}
}

// Get the id of the first post of a given post type.
// if the ID is 1, then we know that the post type is empty so update_option( 'prc_platform_content_bootstrapped', true ); and return true, otherwise return false. check for the option first, if it's true, then return true.
public function detect_lack_of_content() {
$option = get_option( 'prc_platform_content_bootstrapped' );
if ( true === $option ) {
return true;
}
$posts = get_posts( array(
'post_type' => 'post',
'posts_per_page' => 1,
) );
if ( empty( $posts ) ) {
return true;
}
if ( 1 === $posts[0]->ID ) {
return true;
}
return false;
}

public function boostrap_content() {

}

public function create_sample_topics() {

}

public function create_sample_report() {

}

public function create_sample_fact_sheet() {

}

public function create_sample_short_read() {

}

public function create_sample_interactive() {

}

public function create_sample_quiz() {

}

public function create_sample_chart() {

}

public function create_sample_page() {

}

public function create_sample_staff() {

}

public function create_sample_homepage() {

}

public function create_sample_dataset() {

}

public function create_sample_block_module() {

}

public function configure_sample_options() {

}
}
16 changes: 13 additions & 3 deletions includes/embeds/class-embeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,24 @@ public function disable_admin_bar_on_iframes( $show_admin_bar ) {
* @return string
*/
public function get_template_post_content() {
$is_interactive_containment = get_query_var('interactivesContainment', false);
$post_content = '';
while ( have_posts() ) {
the_post();
$post_content = get_the_content();
if ( $this->test_for_embeddable_blocks( $post_content ) ) {
$post_content = $this->render_embeddable_block_by_id( get_query_var('iframe'), $post_content );
if ( $is_interactive_containment ) {
$blocks = parse_blocks( $post_content );
foreach ( $blocks as $block ) {
if ( array_key_exists('blockName', $block) && in_array( $block['blockName'], array('prc-platform/interactive-loader') ) ) {
$post_content = apply_filters( 'the_content', render_block( $block ) );
}
}
} else {
$post_content = apply_filters( 'the_content', $post_content );
if ( $this->test_for_embeddable_blocks( $post_content ) ) {
$post_content = $this->render_embeddable_block_by_id( get_query_var('iframe'), $post_content );
} else {
$post_content = apply_filters( 'the_content', $post_content );
}
}
}
wp_reset_postdata();
Expand Down
7 changes: 5 additions & 2 deletions includes/flash-briefings/class-flash-briefings.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ public function register_assets() {
public function enqueue_assets() {
$registered = $this->register_assets();
if ( is_admin() && ! is_wp_error( $registered ) ) {
wp_enqueue_script( self::$handle );
wp_enqueue_style( self::$handle );
$screen = get_current_screen();
if ( in_array( $screen->post_type, array(self::$post_type) ) ) {
wp_enqueue_script( self::$handle );
wp_enqueue_style( self::$handle );
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions includes/interactives/blocks/loader-block/loader-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ public function render_interactive_loader_callback($attributes, $content, $block
));

$is_legacy_wpackio = array_key_exists('legacyWpackIo', $attributes) && $attributes['legacyWpackIo'];
$is_legacy_s3 = array_key_exists('legacyAssetsS3', $attributes) && $attributes['legacyAssetsS3'];

$enqueued_handles = array();
if ( $is_legacy_wpackio && get_query_var('iframe') ) {
if ( $is_legacy_wpackio ) {
$enqueued_handles = $this->load_legacy_wpackIO($attributes['legacyWpackIo']);
} else if ( array_key_exists('legacyAssetsS3', $attributes) && $attributes['legacyAssetsS3'] ) {
} else if ( $is_legacy_s3 ) {
// Do nothing for now...
// @TODO: Build out the legacy assets S3 loader.
} else {
Expand Down
2 changes: 1 addition & 1 deletion includes/interactives/class-interactives.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public function get_assets_restfully( \WP_REST_Request $request ) {
public function get_assets( ) {
$interactives = array();

$interactives_dir = PRC_INTERACTIVES_DIR;
$interactives_dir = plugin_dir_path( __FILE__ ) . '../../interactives';
// using glob to get all directories (except /blocks) in the interactives directory
$research_teams = glob( $interactives_dir . '/*', GLOB_ONLYDIR );
foreach ( $research_teams as $research_team ) {
Expand Down
334 changes: 0 additions & 334 deletions includes/interactives/legacy-containment-system/assets/style.css

This file was deleted.

Loading

0 comments on commit 3a7af2c

Please sign in to comment.