Skip to content

Commit

Permalink
See pewresearch/pewresearch-org@8949651 from refs/heads/main
Browse files Browse the repository at this point in the history
  • Loading branch information
prcdevgitbot committed May 17, 2024
1 parent 494b2f2 commit bdce460
Show file tree
Hide file tree
Showing 19 changed files with 564 additions and 205 deletions.
4 changes: 2 additions & 2 deletions includes/apple-news/class-apple-news.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct( $version, $loader ) {
public function init($loader = null) {
if (null !== $loader) {
$loader->add_filter( 'apple_news_exporter_byline', $this, 'get_bylines', 10, 2) ;
$loader->add_filter( 'apple_news_skip_push', $this, 'skip_push', 10, 1) ;
$loader->add_filter( 'apple_news_skip_push', $this, 'skip_push_on_non_prod_env', 10, 1) ;
}
}

Expand Down Expand Up @@ -58,6 +58,6 @@ public function get_bylines($byline, $post_id) {
public function skip_push_on_non_prod_env($post_id) {
// get the post status for $post_id
$post_status = get_post_status($post_id);
return 'publish' !== $post_status || 'production' !== wp_get_environment_type();
return 'publish' !== $post_status && 'production' !== wp_get_environment_type();
}
}
2 changes: 2 additions & 0 deletions includes/class-platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ private function load_dependencies() {
$this->include('mailchimp/class-mailchimp.php');
$this->include('media/class-media.php');
$this->include('multisite-post-migration/class-multisite-post-migration.php');
$this->include('newsletter/class-newsletter.php');
$this->include('permalink-rewrites/class-permalink-rewrites.php');
$this->include('post-publish-pipeline/class-post-publish-pipeline.php');
$this->include('post-report-package/class-post-report-package.php');
Expand Down Expand Up @@ -189,6 +190,7 @@ function() {
}
);
new Multisite_Post_Migration( $this->get_version(), $this->get_loader() );
new Newsletter( $this->get_version(), $this->get_loader() );
new Permalink_Rewrites( $this->version, $this->get_loader() );
new Post_Publish_Pipeline( $this->get_version(), $this->get_loader() );
new Post_Report_Package( $this->get_version(), $this->get_loader() );
Expand Down
1 change: 1 addition & 0 deletions includes/datasets/src/dataset-description-block/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Convert this to use block bindings and the core/paragraph block.
3 changes: 3 additions & 0 deletions includes/facets/blocks/facet-template/build/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
"label": "No Label"
}
],
"ancestor": [
"prc-platform/facets-context-provider"
],
"textdomain": "facet-template",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('prc-block-utils', 'prc-components', 'prc-icons', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '22abe0797baba7bd9fff');
<?php return array('dependencies' => array('prc-block-utils', 'prc-components', 'prc-icons', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '550d3bd91706e2d61871');
2 changes: 1 addition & 1 deletion includes/facets/blocks/facet-template/build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/facets/blocks/facet-template/build/index.js.map

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions includes/facets/blocks/facet-template/facet-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public function render_dropdown_facet($facet, $inner_blocks) {
}
$options[] = $opts;
}
// sort $options such that isSelected are first
usort($options, function($a, $b) {
if ( $a['isSelected'] === $b['isSelected'] ) {
return 0;
}
return $a['isSelected'] ? -1 : 1;
});
$field['attrs']['options'] = $options;
if (null !== $field_value) {
$field['attrs']['value'] = $field_value;
Expand All @@ -101,21 +108,33 @@ public function render_checkbox_radio_facet($facet, $inner_blocks) {
$field_template = $inner_blocks[0];
$content = '';
$expanded_content = '';
$i = 1;
// make sure $selected_choices are first in the $facet_choices array
$blocks_to_generate = [];
foreach ($facet_choices as $choice) {
$field = $field_template;
$count = $choice['count'] > 250 ? '250+' : $choice['count'];
$field['attrs']['label'] = $choice['label'] . ' (' . $count . ')';
$field['attrs']['metadata']['name'] = sanitize_title($choice['label']);
$field['attrs']['value'] = $choice['value'];
$field['attrs']['defaultChecked'] = in_array($choice['value'], $selected_choices);
$blocks_to_generate[] = $field;
}
// sort it such that the defaultChecked are first
usort($blocks_to_generate, function($a, $b) {
if ( $a['attrs']['defaultChecked'] === $b['attrs']['defaultChecked'] ) {
return 0;
}
return $a['attrs']['defaultChecked'] ? -1 : 1;
});

$i = 1;
foreach ($blocks_to_generate as $block) {
$parsed = new WP_Block_Parser_Block(
$field['blockName'],
$field['attrs'],
$field['innerBlocks'],
$field['innerHTML'],
$field['innerContent']
$block['blockName'],
$block['attrs'],
$block['innerBlocks'],
$block['innerHTML'],
$block['innerContent']
);

if ( $i > 5 ) {
Expand Down
1 change: 1 addition & 0 deletions includes/facets/blocks/facet-template/src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"label": "No Label"
}
],
"ancestor": [ "prc-platform/facets-context-provider" ],
"textdomain": "facet-template",
"editorScript": "file:./index.js",
"editorStyle": "file:./index.css",
Expand Down
2 changes: 1 addition & 1 deletion includes/facets/class-facets.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Facets {
"show_expanded" => "no",
"ghosts" => "yes",
"preserve_ghosts" => "no",
"operator" => "and",
"operator" => "or",
"orderby" => "count",
"count" => "50",
"soft_limit" => "5"
Expand Down
Loading

0 comments on commit bdce460

Please sign in to comment.