Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions private/src/scripts/editor/blocks/menu/DisplayComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,31 @@ class DisplayComponent extends Component {
);
}

renderCustomMenu() {
const { attributes } = this.props;
const { color } = attributes;

return (
<Fragment>
<div
className={classnames('postlist-categoriesContainer', {
[`section--${color}`]: !!color,
})}
>
<ul className="postlist-categories">
{attributes?.items?.map(({ id, label }) => (
<li key={id}>
<a className="btn btn--white" href={`#${id}`}>
{label}
</a>
</li>
))}
</ul>
</div>
</Fragment>
);
}

render() {
const { attributes, setAttributes } = this.props;

Expand All @@ -162,6 +187,8 @@ class DisplayComponent extends Component {
{ label: __('Standard Menu', 'amnesty'), value: 'standard-menu' },
// translators: [admin]
{ label: __('In-page Menu', 'amnesty'), value: 'inpage-menu' },
// translators: [admin]
{ label: __('Custom Menu', 'amnesty'), value: 'custom-menu' },
]}
onChange={(option) => setAttributes({ type: option })}
/>
Expand All @@ -186,6 +213,7 @@ class DisplayComponent extends Component {
</InspectorControls>
{attributes.type === 'standard-menu' && this.renderStandardMenu()}
{attributes.type === 'inpage-menu' && this.renderInPageMenu()}
{attributes.type === 'custom-menu' && this.renderCustomMenu()}
</Fragment>
);
}
Expand Down
4 changes: 4 additions & 0 deletions private/src/scripts/editor/blocks/menu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ registerBlockType('amnesty-core/block-menu', {
type: 'string',
default: 'standard-menu',
},
items: {
type: 'array',
default: [],
},
},

edit: DisplayComponent,
Expand Down
1 change: 1 addition & 0 deletions private/src/styles/blocks/button/_all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
@import "./sizes";
@import "./fill";
@import "./layout";
@import "./spacing";

/**
Expand Down
3 changes: 3 additions & 0 deletions private/src/styles/blocks/button/_layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.wp-block-buttons.is-content-justification-start {
justify-content: start;
}
21 changes: 17 additions & 4 deletions private/src/styles/blocks/core-blocks/_cover.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
.wp-block-cover .wp-block-cover__image-background img {
object-fit: cover;
width: 100%;
height: 100%;
.wp-block-cover {
min-height: unset;
}

.wp-block-cover .wp-block-cover__image-background,
.wp-block-cover video.wp-block-cover__video-background,
.wp-block-cover-image .wp-block-cover__image-background,
.wp-block-cover-image video.wp-block-cover__video-background {
&[data-object-fit="cover"] {
object-fit: cover;
width: 100%;
height: 100%;
}

&[data-object-fit="contain"] {
object-fit: contain;
}
}
4 changes: 4 additions & 0 deletions private/src/styles/blocks/core-blocks/post/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
background: var(--wp--preset--color--white);
}

.tax-location .wp-block-post {
min-height: unset;
}

.wp-block-post > .wp-block-group:not(.post--result) {
display: flex;
flex-direction: column;
Expand Down
4 changes: 4 additions & 0 deletions private/src/styles/blocks/postlist/_post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
}

@include mq(medium-sm) {
.tax-location .post {
min-height: unset;
}

.tax-location .post+.post {
margin-left: flexy-gutter();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public function id(): int {
* @return string
*/
public function metadata( bool $include_caption = true, bool $include_credit = true, string $type = 'image' ): string {
$caption = $this->caption();
$credit = $this->credit();
$caption = apply_filters( 'amnesty_image_data_caption', $this->caption(), $this->image_id, $type, $this );
$credit = apply_filters( 'amnesty_image_data_credit', $this->credit(), $this->image_id, $type, $this );

if ( ! $caption && ! $credit ) {
return '';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/**
* Title: Locations Taxonomy country selection
* Description: Outputs country selection dropdown
* Slug: amnesty/taxonomy-location-country-selection
* Inserter: no
*/

$object = get_queried_object();
$options = [];

if ( is_a( $object, WP_Term::class ) ) {
$top_level = get_term_top_most_parent( $object->term_id, $object->taxonomy );
$countries = amnesty_get_locations_by_type( [ 'term' => $top_level ] );

$options = [
amnesty_term_link( $top_level ) => $top_level->name,
];

foreach ( $countries as $child ) {
$options[ amnesty_term_link( $child ) ] = $child->name;
}
}

if ( ! count( $options ) && is_admin() ) {
$options['-'] = __( 'Region name', 'amnesty' );
$options['~'] = __( 'Country within region', 'amnesty' );
}

$select_args = [
/* translators: [front] Countries Locations Page */
'label' => _x( 'View other countries in', 'shown before region name', 'aitc' ),
'show_label' => true,
'options' => $options,
'is_nav' => true,
'type' => 'nav',
];

?>
<!-- wp:amnesty-core/custom-select <?php echo wp_json_encode( $select_args ); ?> /-->

<!-- wp:group {"tagName":"section","className":"section section--small section--countrySelect"} -->
<section class="wp-block-group section section--small section--countrySelect">
<!-- wp:group {"tagName":"div","className":"container has-gutter"} -->
<div class="wp-block-group container has-gutter">
<!-- wp:html {"content":"<?php echo wp_json_encode( $html_content ); ?>"} -->
<?php echo $html_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped at source ?>
<!-- /wp:html -->
</div>
<!-- /wp:group -->
</section>
<!-- /wp:group -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/**
* Title: Locations Taxonomy hero
* Description: Outputs hero block for taxonomy archive pages
* Slug: amnesty/taxonomy-location-hero
* Inserter: no
*/

$object = get_queried_object();
$image_id = absint( get_term_meta( $object?->term_id, 'image_id', true ) );

// if the term is a report with no image, grab its parent term image instead
if ( ! $image_id && 'report' === get_term_meta( $object?->term_id, 'type', true ) ) {
$image_id = absint( get_term_meta( get_term_parent( $object )?->term_id, 'image_id', true ) );
}

$hero_data = [
'title' => $object?->name,
'content' => $object->labels?->archives ?? $object?->description,
'imageID' => $image_id,
'hideImageCaption' => false,
];

if ( is_a( $object, WP_Term::class ) ) {
$disclaimer = fn (): string => strval( amnesty_get_location_disclaimer( $object ) );
} else {
$disclaimer = fn ( ?string $text ): ?string => $text;
}

add_filter( 'amnesty_image_data_caption', $disclaimer );
printf( '<!-- wp:amnesty-core/hero %s /-->', wp_kses_data( wp_json_encode( $hero_data, JSON_UNESCAPED_UNICODE ) ) );
remove_filter( 'amnesty_image_data_caption', $disclaimer );
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/**
* Title: Locations Taxonomy human rights status
* Description: Outputs human rights status for locations
* Slug: amnesty/taxonomy-location-human-rights
* Inserter: no
*/

$template_type = get_term_meta( get_queried_object_id(), 'type', true );
$global_report = get_human_rights_report();
$penalty_status = null;

if ( function_exists( 'get_death_penalty_status' ) ) {
$penalty_status = get_death_penalty_status( get_queried_object() );
}

// show something in the editor
if ( ! $penalty_status && is_admin() && function_exists( 'get_death_penalty_statuses' ) ) {
$penalty_status = get_death_penalty_statuses()['retentionist'];
}

do_action( 'amnesty_location_template_before_humanrights', $template_type );

if ( ! $penalty_status && ! $global_report ) {
do_action( 'amnesty_location_template_after_humanrights', $template_type );
return;
}

?>
<!-- wp:group {"tagName":"section","className":"section section\u002d\u002dno-padding is-fullWidth\u002d\u002dmobile"} -->
<section id="human-rights" class="wp-block-group section section--no-padding is-fullWidth--mobile"><!-- wp:group {"className":"container has-gutter"} -->
<div class="wp-block-group container has-gutter"><!-- wp:group {"className":"human-rightsStatus","layout":{"type":"grid","columnCount":2,"minimumColumnWidth":null}} -->
<div class="wp-block-group human-rightsStatus"><!-- wp:group {"className":"human-rights is-style-default","layout":{"type":"flex","orientation":"vertical","justifyContent":"center","flexWrap":"nowrap","verticalAlignment":"center"}} -->
<div class="wp-block-group human-rights is-style-default"><!-- wp:heading {"level":3,"className":"human-rightsHeading"} -->
<h3 class="wp-block-heading human-rightsHeading"><?php /* translators: [front] Countries Locations Page */ echo esc_html_x( 'Death Penalty status', 'death penalty heading', 'aitc' ); ?></h3>
<!-- /wp:heading -->

<!-- wp:heading {"className":"human-rightsAnswer"} -->
<h2 class="wp-block-heading human-rightsAnswer"><?php echo esc_html( $penalty_status['label'] ); ?></h2>
<!-- /wp:heading -->

<!-- wp:paragraph {"className":"wp-block-paragraph human-rightsDescription"} -->
<p class="wp-block-paragraph human-rightsDescription"><?php echo esc_html( $penalty_status['description'] ); ?></p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:group {"className":"human-rights","style":{"spacing":{"padding":{"top":"0","bottom":"0","left":"0","right":"0"}}}} -->
<div class="wp-block-group human-rights" style="padding-top:0;padding-right:0;padding-bottom:0;padding-left:0"><!-- wp:cover {"url":"<?php echo esc_url( wp_get_attachment_image_url( absint( $global_report['image_id'] ?? 0 ), 'lwi-block-md@2x' ) ); ?>","id":<?php echo absint( $global_report['image_id'] ?? 0 ); ?>,"dimRatio":50,"customOverlayColor":"#FFF","isUserOverlayColor":false,"focalPoint":{"x":1,"y":1},"isDark":false,"layout":{"type":"constrained"}} -->
<div class="wp-block-cover is-light"><span aria-hidden="true" class="wp-block-cover__background has-background-dim" style="background-color:#FFF"></span><img class="wp-block-cover__image-background wp-image-<?php echo absint( $global_report['image_id'] ?? 0 ); ?>" alt="" src="<?php echo esc_url( wp_get_attachment_image_url( absint( $global_report['image_id'] ?? 0 ), 'lwi-block-md@2x' ) ); ?>" style="object-position:100% 100%" data-object-fit="cover" data-object-position="100% 100%"/><div class="wp-block-cover__inner-container"><!-- wp:heading {"textAlign":"center","className":"human-rightsHeading u-textUpper"} -->
<h2 class="wp-block-heading has-text-align-center human-rightsHeading u-textUpper"><?php echo esc_html( sprintf( '%s %s', /* translators: [front] Countries Locations Page */ __( 'View the Amnesty International Report', 'aitc' ), $global_report['year'] ) ); ?></h2>
<!-- /wp:heading -->

<!-- wp:buttons {"className":"is-content-justification-center"} -->
<div class="wp-block-buttons is-content-justification-center"><?php foreach ( $global_report['links'] as $button ) : // phpcs:ignore Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace ?><!-- wp:button {"className":"is-style-<?php echo esc_attr( $button['style'] ); ?>"} -->
<div class="wp-block-button is-style-<?php echo esc_attr( $button['style'] ); ?>"><a class="wp-block-button__link wp-element-button" href="<?php echo esc_url( $button['link'] ); ?>"><?php echo esc_html( $button['text'] ); ?></a></div>
<!-- /wp:button --><?php endforeach; // phpcs:ignore PEAR.WhiteSpace.ScopeClosingBrace ?></div>
<!-- /wp:buttons --></div></div>
<!-- /wp:cover --></div>
<!-- /wp:group --></div>
<!-- /wp:group --></div>
<!-- /wp:group --></section>
<!-- /wp:group -->
<?php

do_action( 'amnesty_location_template_after_humanrights', $template_type );
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* Title: Locations Taxonomy menu
* Description: Outputs menu block for locations templates
* Slug: amnesty/taxonomy-location-menu
* Inserter: no
*/

$menu_options = [
[
'id' => 'overview',
/* translators: [front] Countries Locations Page */
'label' => __( 'Overview', 'aitc' ),
],
];

if ( have_posts() ) {
$menu_options[] = [
'id' => 'news',
/* translators: [front] Countries Locations Page */
'label' => __( 'News', 'aitc' ),
];
}

$template_type = get_term_meta( get_queried_object_id(), 'type', true ) ?: 'default';
$menu_options = apply_filters( 'amnesty_location_template_menu_options', $menu_options, $template_type );

$block_attributes = [
'color' => 'dark',
'type' => 'custom-menu',
'items' => $menu_options,
];

do_action( 'amnesty_location_template_before_menu', $template_type );

?>
<!-- wp:group {"tagName":"section","className":"section section--no-padding"} -->
<section class="wp-block-group section section--no-padding">
<!-- wp:group {"tagName":"div","className":"container has-gutter"} -->
<div class="wp-block-group container has-gutter">
<!-- wp:amnesty-core/block-menu <?php echo wp_kses_data( wp_json_encode( $block_attributes ) ); ?> /-->
</div>
<!-- /wp:group -->
</section>
<!-- /wp:group -->
<?php

do_action( 'amnesty_location_template_after_menu', $template_type );
Loading