From 59bca65c288673343012a0b21c93c5bb99540542 Mon Sep 17 00:00:00 2001 From: Geoff Dusome Date: Tue, 27 Jan 2026 12:41:39 -0500 Subject: [PATCH 01/11] [MOOSE-336]: icon card controller; image card controller --- .../src/Components/Icon_Card_Controller.php | 101 +++++++++++++++++ .../src/Components/Image_Card_Controller.php | 102 ++++++++++++++++++ .../core/blocks/tribe/icon-card/render.php | 45 +++----- .../core/blocks/tribe/image-card/render.php | 43 +++----- 4 files changed, 232 insertions(+), 59 deletions(-) create mode 100644 wp-content/plugins/core/src/Components/Icon_Card_Controller.php create mode 100644 wp-content/plugins/core/src/Components/Image_Card_Controller.php diff --git a/wp-content/plugins/core/src/Components/Icon_Card_Controller.php b/wp-content/plugins/core/src/Components/Icon_Card_Controller.php new file mode 100644 index 000000000..33ec08994 --- /dev/null +++ b/wp-content/plugins/core/src/Components/Icon_Card_Controller.php @@ -0,0 +1,101 @@ + + */ + private array $attributes; + private Block_Animation_Attributes $block_animation_attributes; + private string $animation_classes; + private string $animation_styles; + private Icon_Picker $icon_picker; + private string $icon_wrapper_styles; + private string $icon_svg; + private string $classes; + private string $title; + private string $description; + private string $link_url; + private bool $link_opens_in_new_tab; + private string $link_text; + private string $link_a11y_label; + + public function __construct( array $args = [] ) { + $this->attributes = $args['attributes'] ?? []; + $this->block_animation_attributes = new Block_Animation_Attributes( $this->attributes ); + $this->animation_classes = $this->block_animation_attributes->get_classes(); + $this->animation_styles = $this->block_animation_attributes->get_styles(); + $this->icon_picker = new Icon_Picker( $this->attributes ); + $this->icon_wrapper_styles = $this->icon_picker->get_icon_wrapper_styles(); + $this->icon_svg = $this->icon_picker->get_svg(); + $this->classes = 'b-icon-card'; + $this->title = $this->attributes['title'] ?? ''; + $this->description = $this->attributes['description'] ?? ''; + $this->link_url = $this->attributes['linkUrl'] ?? ''; + $this->link_opens_in_new_tab = $this->attributes['linkOpensInNewTab'] ?? false; + $this->link_text = $this->attributes['linkText'] ?? ''; + $this->link_a11y_label = $this->attributes['linkA11yLabel'] ?? ''; + } + + public function get_classes(): string { + if ( '' === $this->animation_classes ) { + $this->classes .= ' ' . $this->animation_classes; + } + + return $this->classes; + } + + public function get_styles(): string { + return $this->animation_styles; + } + + public function get_icon_wrapper_styles(): string { + return $this->icon_wrapper_styles; + } + + public function has_icon(): bool { + return ! empty( $this->icon_svg ); + } + + public function get_icon_svg(): string { + return $this->icon_svg; + } + + public function get_title(): string { + return $this->title; + } + + public function has_description(): bool { + return (bool) $this->description; + } + + public function get_description(): string { + return $this->description; + } + + public function has_link_url(): bool { + return (bool) $this->link_url; + } + + public function get_link_url(): string { + return $this->link_url; + } + + public function does_link_open_in_new_tab(): bool { + return $this->link_opens_in_new_tab; + } + + public function get_link_text(): string { + return $this->link_text; + } + + public function get_link_a11y_label(): string { + return $this->link_a11y_label; + } + +} diff --git a/wp-content/plugins/core/src/Components/Image_Card_Controller.php b/wp-content/plugins/core/src/Components/Image_Card_Controller.php new file mode 100644 index 000000000..f4241811f --- /dev/null +++ b/wp-content/plugins/core/src/Components/Image_Card_Controller.php @@ -0,0 +1,102 @@ + + */ + private array $attributes; + private Block_Animation_Attributes $block_animation_attributes; + private string $animation_classes; + private string $animation_styles; + private string $classes; + private int $media_id; + private string $media_url; + private string $title; + private string $description; + private string $link_url; + private bool $link_opens_in_new_tab; + private string $link_text; + private string $link_a11y_label; + + public function __construct( array $args = [] ) { + $this->attributes = $args['attributes'] ?? []; + $this->block_animation_attributes = new Block_Animation_Attributes( $this->attributes ); + $this->animation_classes = $this->block_animation_attributes->get_classes(); + $this->animation_styles = $this->block_animation_attributes->get_styles(); + $this->classes = 'b-image-card'; + $this->media_id = $this->attributes['mediaId'] ? (int) $this->attributes['mediaId'] : 0; + $this->media_url = $this->attributes['mediaUrl'] ?? ''; + $this->title = $this->attributes['title'] ?? ''; + $this->description = $this->attributes['description'] ?? ''; + $this->link_url = $this->attributes['linkUrl'] ?? ''; + $this->link_opens_in_new_tab = $this->attributes['linkOpensInNewTab'] ?? false; + $this->link_text = $this->attributes['linkText'] ?? ''; + $this->link_a11y_label = $this->attributes['linkA11yLabel'] ?? ''; + } + + public function get_classes(): string { + if ( '' === $this->animation_classes ) { + $this->classes .= ' ' . $this->animation_classes; + } + + return $this->classes; + } + + public function get_styles(): string { + return $this->animation_styles; + } + + public function has_media(): bool { + return 0 !== $this->media_id || '' !== $this->media_url; + } + + public function get_media(): string { + if ( 0 !== $this->media_id ) { + return wp_get_attachment_image( $this->media_id, 'large' ); + } + + if ( '' !== $this->media_url ) { + return '' . esc_attr__( 'Block placeholder image', 'tribe' ) . ''; + } + + return ''; + } + + public function get_title(): string { + return $this->title; + } + + public function has_description(): bool { + return '' !== $this->description; + } + + public function get_description(): string { + return $this->description; + } + + public function has_link_url(): bool { + return '' !== $this->link_url; + } + + public function get_link_url(): string { + return $this->link_url; + } + + public function does_link_open_in_new_tab(): bool { + return $this->link_opens_in_new_tab; + } + + public function get_link_text(): string { + return $this->link_text; + } + + public function get_link_a11y_label(): string { + return $this->link_a11y_label; + } + +} diff --git a/wp-content/themes/core/blocks/tribe/icon-card/render.php b/wp-content/themes/core/blocks/tribe/icon-card/render.php index f6ba80240..8abef54e9 100644 --- a/wp-content/themes/core/blocks/tribe/icon-card/render.php +++ b/wp-content/themes/core/blocks/tribe/icon-card/render.php @@ -1,58 +1,43 @@ get_styles(); -$animation_classes = $animation_attributes->get_classes(); -$icon_picker = new Icon_Picker( $attributes ); -$icon_wrapper_styles = $icon_picker->get_icon_wrapper_styles(); -$icon_svg = $icon_picker->get_svg(); -$classes = 'b-icon-card'; -$title = $attributes['title'] ?? ''; -$description = $attributes['description'] ?? ''; -$link_url = $attributes['linkUrl'] ?? ''; -$link_opens_in_new_tab = $attributes['linkOpensInNewTab'] ?? false; -$link_text = $attributes['linkText'] ?? ''; -$link_a11y_label = $attributes['linkA11yLabel'] ?? ''; - -if ( $animation_classes !== '' ) { - $classes .= ' ' . $animation_classes; -} +$c = new Icon_Card_Controller( [ + 'attributes' => $attributes, +] ); ?> -
esc_attr( $classes ), 'style' => $animation_styles ] ); ?>> + diff --git a/wp-content/themes/core/blocks/tribe/image-card/render.php b/wp-content/themes/core/blocks/tribe/image-card/render.php index efb24e397..267842f8d 100644 --- a/wp-content/themes/core/blocks/tribe/image-card/render.php +++ b/wp-content/themes/core/blocks/tribe/image-card/render.php @@ -1,56 +1,41 @@ get_classes() !== '' ) { - $classes .= ' ' . $animation_attributes->get_classes(); -} +$c = new Image_Card_Controller( [ + 'attributes' => $attributes, +] ); ?> -
esc_attr( $classes ), 'style' => $animation_attributes->get_styles() ] ); ?>> + From e6d70fefb6482db4d7d5cffadc549de986e5119e Mon Sep 17 00:00:00 2001 From: Geoff Dusome Date: Tue, 27 Jan 2026 13:15:56 -0500 Subject: [PATCH 02/11] [MOOSE-336]: add image overlay card controller --- .../src/Components/Icon_Card_Controller.php | 4 +- .../src/Components/Image_Card_Controller.php | 2 +- .../Image_Overlay_Card_Controller.php | 106 ++++++++++++++++++ .../tribe/image-overlay-card/render.php | 54 ++------- 4 files changed, 121 insertions(+), 45 deletions(-) create mode 100644 wp-content/plugins/core/src/Components/Image_Overlay_Card_Controller.php diff --git a/wp-content/plugins/core/src/Components/Icon_Card_Controller.php b/wp-content/plugins/core/src/Components/Icon_Card_Controller.php index 33ec08994..aa3d8d515 100644 --- a/wp-content/plugins/core/src/Components/Icon_Card_Controller.php +++ b/wp-content/plugins/core/src/Components/Icon_Card_Controller.php @@ -43,7 +43,7 @@ public function __construct( array $args = [] ) { } public function get_classes(): string { - if ( '' === $this->animation_classes ) { + if ( '' !== $this->animation_classes ) { $this->classes .= ' ' . $this->animation_classes; } @@ -97,5 +97,5 @@ public function get_link_text(): string { public function get_link_a11y_label(): string { return $this->link_a11y_label; } - + } diff --git a/wp-content/plugins/core/src/Components/Image_Card_Controller.php b/wp-content/plugins/core/src/Components/Image_Card_Controller.php index f4241811f..a384cb949 100644 --- a/wp-content/plugins/core/src/Components/Image_Card_Controller.php +++ b/wp-content/plugins/core/src/Components/Image_Card_Controller.php @@ -40,7 +40,7 @@ public function __construct( array $args = [] ) { } public function get_classes(): string { - if ( '' === $this->animation_classes ) { + if ( '' !== $this->animation_classes ) { $this->classes .= ' ' . $this->animation_classes; } diff --git a/wp-content/plugins/core/src/Components/Image_Overlay_Card_Controller.php b/wp-content/plugins/core/src/Components/Image_Overlay_Card_Controller.php new file mode 100644 index 000000000..5f5044f75 --- /dev/null +++ b/wp-content/plugins/core/src/Components/Image_Overlay_Card_Controller.php @@ -0,0 +1,106 @@ + + */ + private array $attributes; + private Block_Animation_Attributes $block_animation_attributes; + private string $animation_classes; + private string $animation_styles; + private string $classes; + private int $media_id; + private string $media_url; + private string $overlay_color; + private string $overlay_hover_color; + private bool $card_uses_dark_theme; + private string $title; + private string $link_url; + private bool $link_opens_in_new_tab; + private string $link_text; + private string $link_a11y_label; + + public function __construct( array $args = [] ) { + $this->attributes = $args['attributes'] ?? []; + $this->block_animation_attributes = new Block_Animation_Attributes( $this->attributes ); + $this->animation_classes = $this->block_animation_attributes->get_classes(); + $this->animation_styles = $this->block_animation_attributes->get_styles(); + $this->classes = 'b-image-overlay-card'; + $this->media_id = $this->attributes['mediaId'] ? (int) $this->attributes['mediaId'] : 0; + $this->media_url = $this->attributes['mediaUrl'] ?? ''; + $this->overlay_color = $this->attributes['overlayColor'] ?? '#0000001C'; + $this->overlay_hover_color = $this->attributes['overlayHoverColor'] ?? '#00000033'; + $this->card_uses_dark_theme = $this->attributes['cardUsesDarkTheme'] ?? false; + $this->title = $this->attributes['title'] ?? ''; + $this->link_url = $this->attributes['linkUrl'] ?? ''; + $this->link_opens_in_new_tab = $this->attributes['linkOpensInNewTab'] ?? false; + $this->link_text = $this->attributes['linkText'] ?? ''; + $this->link_a11y_label = $this->attributes['linkA11yLabel'] ?? ''; + } + + public function get_classes(): string { + if ( $this->card_uses_dark_theme ) { + $this->classes .= ' b-image-overlay-card--dark-theme'; + } + + if ( '' !== $this->animation_classes ) { + $this->classes .= ' ' . $this->animation_classes; + } + + return $this->classes; + } + + public function get_styles(): string { + $styles = $this->animation_styles; + $styles .= "--card-image-overlay-color: {$this->overlay_color};"; + $styles .= "--card-image-overlay-hover-color: {$this->overlay_hover_color};"; + + return $styles; + } + + public function has_media(): bool { + return 0 !== $this->media_id || '' !== $this->media_url; + } + + public function get_media(): string { + if ( 0 !== $this->media_id ) { + return wp_get_attachment_image( $this->media_id, 'large' ); + } + + if ( '' !== $this->media_url ) { + return '' . esc_attr__( 'Block placeholder image', 'tribe' ) . ''; + } + + return ''; + } + + public function get_title(): string { + return $this->title; + } + + public function has_link_url(): bool { + return '' !== $this->link_url; + } + + public function get_link_url(): string { + return $this->link_url; + } + + public function does_link_open_in_new_tab(): bool { + return $this->link_opens_in_new_tab; + } + + public function get_link_text(): string { + return $this->link_text; + } + + public function get_link_a11y_label(): string { + return $this->link_a11y_label; + } + +} diff --git a/wp-content/themes/core/blocks/tribe/image-overlay-card/render.php b/wp-content/themes/core/blocks/tribe/image-overlay-card/render.php index 18813ef61..5ff03c7ca 100644 --- a/wp-content/themes/core/blocks/tribe/image-overlay-card/render.php +++ b/wp-content/themes/core/blocks/tribe/image-overlay-card/render.php @@ -1,62 +1,32 @@ get_styles(); -$animation_classes = $animation_attributes->get_classes(); -$media_id = $attributes['mediaId'] ? (int) $attributes['mediaId'] : 0; // this returns a float by default so we need to cast it to int -$media_url = $attributes['mediaUrl'] ?? ''; -$overlay_color = $attributes['overlayColor'] ?? '#0000001C'; -$overlay_hover_color = $attributes['overlayHoverColor'] ?? '#00000033'; -$card_uses_dark_theme = $attributes['cardUsesDarkTheme']; -$title = $attributes['title'] ?? ''; -$link_url = $attributes['linkUrl'] ?? ''; -$link_opens_in_new_tab = $attributes['linkOpensInNewTab'] ?? false; -$link_text = $attributes['linkText'] ?? ''; -$link_a11y_label = $attributes['linkA11yLabel'] ?? ''; - -// add overlay color as CSS custom property -$styles = $animation_styles; -$styles .= "--card-image-overlay-color: {$overlay_color};"; -$styles .= "--card-image-overlay-hover-color: {$overlay_hover_color};"; - -// add dark theme class if applicable -if ( $card_uses_dark_theme ) { - $classes .= ' b-image-overlay-card--dark-theme'; -} - -// add animation attribute classes -if ( $animation_classes !== '' ) { - $classes .= ' ' . $animation_classes; -} +$c = new Image_Overlay_Card_Controller( [ + 'attributes' => $attributes, +] ); ?> -
esc_attr( $classes ), 'style' => esc_attr( $styles ) ] ); ?>> - -
- -
- + From 5e6445bb9db1fdbd075f700c6aeb5ec994cd2525 Mon Sep 17 00:00:00 2001 From: Geoff Dusome Date: Tue, 27 Jan 2026 13:33:12 -0500 Subject: [PATCH 03/11] [MOOSE-336]: add mashead search controller --- .../Components/Masthead_Search_Controller.php | 59 +++++++++++++++++++ .../blocks/tribe/masthead-search/render.php | 33 +++-------- 2 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 wp-content/plugins/core/src/Components/Masthead_Search_Controller.php diff --git a/wp-content/plugins/core/src/Components/Masthead_Search_Controller.php b/wp-content/plugins/core/src/Components/Masthead_Search_Controller.php new file mode 100644 index 000000000..4e4acc46d --- /dev/null +++ b/wp-content/plugins/core/src/Components/Masthead_Search_Controller.php @@ -0,0 +1,59 @@ +search_icon = ''; + $this->search_icon_uri = trailingslashit( get_stylesheet_directory_uri() ) . '/assets/media/icons/search.svg'; + $this->search_icon_path = trailingslashit( get_stylesheet_directory() ) . '/assets/media/icons/search.svg'; + } + + public function get_search_icon(): string { + // If the file doesn't exist or we have already loaded it, return early + if ( ! file_exists( $this->search_icon_path ) || $this->search_icon !== '' ) { + return $this->search_icon; + } + + // Attempt to get the file contents from the file system + $this->search_icon = file_get_contents( $this->search_icon_path ); + + // Fallback to wp_remote_get if file_get_contents fails + if ( $this->search_icon === false ) { + $response = wp_remote_get( $this->search_icon_uri ); + + if ( ! is_wp_error( $response ) ) { + // wp_remote_retrieve_body returns an empty string on failure, so it's fine to end here + $this->search_icon = wp_remote_retrieve_body( $response ); + } + } + + return $this->search_icon; + } + + public function get_toggle_button_a11y_label(): string { + return __( 'Toggle Search Overlay', 'tribe' ); + } + + public function get_form_action(): string { + return home_url(); + } + + public function get_label_text(): string { + return __( 'Search', 'tribe' ); + } + + public function get_input_placeholder(): string { + return __( 'What are you looking for?', 'tribe' ); + } + + public function get_submit_button_text(): string { + return __( 'Search', 'tribe' ); + } + +} diff --git a/wp-content/themes/core/blocks/tribe/masthead-search/render.php b/wp-content/themes/core/blocks/tribe/masthead-search/render.php index 01e59f95b..ab2285318 100644 --- a/wp-content/themes/core/blocks/tribe/masthead-search/render.php +++ b/wp-content/themes/core/blocks/tribe/masthead-search/render.php @@ -1,34 +1,19 @@