From 4ede90d5adc1ea657b266dae277ec9fe49073f2b Mon Sep 17 00:00:00 2001 From: Glynn Quelch Date: Thu, 29 May 2025 11:44:36 +0100 Subject: [PATCH 1/2] Move all prod changes over to staging --- .../acf-fields/group_68381f7bdc12b.json | 72 +++++++ themes/osi/footer-ai.php | 182 ++---------------- themes/osi/inc/block-patterns.php | 147 +++++++++++++- themes/osi/templates/ai-wide.php | 13 +- 4 files changed, 249 insertions(+), 165 deletions(-) create mode 100644 plugins/osi-features/acf-fields/group_68381f7bdc12b.json diff --git a/plugins/osi-features/acf-fields/group_68381f7bdc12b.json b/plugins/osi-features/acf-fields/group_68381f7bdc12b.json new file mode 100644 index 0000000..c48506a --- /dev/null +++ b/plugins/osi-features/acf-fields/group_68381f7bdc12b.json @@ -0,0 +1,72 @@ +{ + "key": "group_68381f7bdc12b", + "title": "AI Template Toggle", + "fields": [{ + "key": "field_68381f7c701f6", + "label": "Use AI Header", + "name": "osi_use_ai_header", + "aria-label": "", + "type": "true_false", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "relevanssi_exclude": 0, + "message": "This will use any menu named 'ai' for the menu when active", + "default_value": 0, + "allow_in_bindings": 0, + "ui": 0, + "ui_on_text": "", + "ui_off_text": "" + }, + { + "key": "field_68381fc3701f8", + "label": "Use AI Footer", + "name": "osi_use_ai_footer", + "aria-label": "", + "type": "true_false", + "instructions": "", + "required": 0, + "conditional_logic": 0, + "wrapper": { + "width": "", + "class": "", + "id": "" + }, + "relevanssi_exclude": 0, + "message": "When selected this will use the ai footer, you can edit the footer in reusable blocks.", + "default_value": 0, + "allow_in_bindings": 0, + "ui": 0, + "ui_on_text": "", + "ui_off_text": "" + } + ], + "location": [ + [{ + "param": "post_type", + "operator": "==", + "value": "page" + }, + { + "param": "post_template", + "operator": "==", + "value": "templates\/ai-wide.php" + } + ] + ], + "menu_order": 0, + "position": "normal", + "style": "default", + "label_placement": "top", + "instruction_placement": "label", + "hide_on_screen": "", + "active": true, + "description": "", + "show_in_rest": 0, + "modified": 1748508671 +} \ No newline at end of file diff --git a/themes/osi/footer-ai.php b/themes/osi/footer-ai.php index 9a860c9..396d1e3 100755 --- a/themes/osi/footer-ai.php +++ b/themes/osi/footer-ai.php @@ -8,173 +8,31 @@ * @package osi */ -// Get the footer icon -$image_url = get_template_directory_uri() . '/assets/img/osi-horizontal-white.svg'; - -// Compile the block markup for the footer -$footer_block = << - - -HTML; +$footer_block_id = osi_create_or_find_ai_footer_block_content(); ?> - - + diff --git a/themes/osi/inc/block-patterns.php b/themes/osi/inc/block-patterns.php index b4d3642..3df87c6 100644 --- a/themes/osi/inc/block-patterns.php +++ b/themes/osi/inc/block-patterns.php @@ -1024,4 +1024,149 @@ function allow_font_awesome_icons($tags) { ); return $tags; } -add_filter('wp_kses_allowed_html', 'allow_font_awesome_icons', 10, 2); \ No newline at end of file +add_filter('wp_kses_allowed_html', 'allow_font_awesome_icons', 10, 2); + +/** + * Create the base AI footer reusable block programmatically. + * + * @return integer + */ +function osi_create_or_find_ai_footer_block_content(): int { + $title = 'OSI AI Footer'; + $slug = sanitize_title( $title ); + + // Check if block already exists + $existing = get_page_by_path( $slug, OBJECT, 'wp_block' ); + if ( $existing ) { + return $existing->ID; + } + + $image_url = get_template_directory_uri() . '/assets/img/osi-horizontal-white.svg'; + + // Compile the block markup for the footer + $block_content = << + + +HTML; + + $post_id = wp_insert_post( + array( + 'post_title' => $title, + 'post_name' => $slug, + 'post_type' => 'wp_block', + 'post_status' => 'publish', + 'post_content' => $block_content, + ) + ); + + return $post_id; +} diff --git a/themes/osi/templates/ai-wide.php b/themes/osi/templates/ai-wide.php index bf1e062..f86036d 100644 --- a/themes/osi/templates/ai-wide.php +++ b/themes/osi/templates/ai-wide.php @@ -5,7 +5,12 @@ Description: Custom template for full width */ -get_header( 'ai' ); ?> +if ( osi_field_check( 'osi_use_ai_header' ) && true === (bool) osi_get_valid_field( 'osi_use_ai_header' ) ) : + get_header( 'ai' ); +else : + get_header(); +endif; +?>
@@ -23,4 +28,8 @@
Date: Thu, 29 May 2025 12:02:42 +0100 Subject: [PATCH 2/2] Fix simple liniting issues --- themes/osi/inc/block-patterns.php | 404 +++++++++++++++++++----------- 1 file changed, 254 insertions(+), 150 deletions(-) diff --git a/themes/osi/inc/block-patterns.php b/themes/osi/inc/block-patterns.php index 3df87c6..6d0735f 100644 --- a/themes/osi/inc/block-patterns.php +++ b/themes/osi/inc/block-patterns.php @@ -1,21 +1,42 @@ __('AI', 'osi')] // Category label (visible in the editor) - ); -}); +// General WordPress filters and actions for the Open Source AI Definition +add_filter( 'block_editor_rest_api_preload_paths', '__return_empty_array' ); +/** + * Registers teh AI patterns for the Open Source AI Definition. + * + * @return void + */ +function osi_register_ai_patterns() { + register_block_pattern_category( + 'ai', // Unique slug for the category + array( 'label' => __( 'AI', 'osi' ) ) // Category label (visible in the editor) + ); +} +add_action( 'init', 'osi_register_ai_patterns' ); + + +/** + * Registers the "About Area" pattern for the Open Source AI Definition. + * + * This pattern includes a reusable section with tabs and custom content. + * + * @return void + */ function osi_register_about_area_pattern() { - register_block_pattern( - 'custom/about-area', - [ - 'title' => __('About Area', 'osi'), - 'description' => __('A reusable section with tabs and custom content.', 'osi'), - 'categories' => ['ai'], - 'content' => ' + register_block_pattern( + 'custom/about-area', + array( + 'title' => __( 'About Area', 'osi' ), + 'description' => __( 'A reusable section with tabs and custom content.', 'osi' ), + 'categories' => array( 'ai' ), + 'content' => '
@@ -78,19 +99,26 @@ function osi_register_about_area_pattern() {
', - ] - ); + ) + ); } -add_action('init', 'osi_register_about_area_pattern'); +add_action( 'init', 'osi_register_about_area_pattern' ); +/** + * Registers the "Banner Area" pattern for the Open Source AI Definition. + * + * This pattern includes a banner section with a title, description, and button. + * + * @return void + */ function osi_register_banner_area_pattern() { - register_block_pattern( - 'custom/banner-area', - [ - 'title' => __('Banner Area', 'osi'), - 'description' => __('A banner section with a title, description, and button.', 'osi'), - 'categories' => ['ai'], - 'content' => ' + register_block_pattern( + 'custom/banner-area', + array( + 'title' => __( 'Banner Area', 'osi' ), + 'description' => __( 'A banner section with a title, description, and button.', 'osi' ), + 'categories' => array( 'ai' ), + 'content' => '