diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml
index 587109b..1de4a4c 100644
--- a/.gitea/workflows/release.yml
+++ b/.gitea/workflows/release.yml
@@ -9,7 +9,7 @@ on:
push:
branches: [ main ]
paths:
- - 'master-file.php'
+ - 'siti-wash-instructions.php'
- 'includes/**'
- 'assets/**'
- 'languages/**'
@@ -18,8 +18,8 @@ jobs:
release:
uses: roberto/ci-workflows/.gitea/workflows/wp-plugin-release.yml@c6393ed47258d6f040ceeed3994b17b7faa3ef23
with:
- main_file: master-file.php
- slug: siti-plugin-template
+ main_file: siti-wash-instructions.php
+ slug: siti-wash-instructions
release_body: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.release_notes || '' }}
secrets:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
\ No newline at end of file
diff --git a/includes/SitiWashInstructions.php b/includes/SitiWashInstructions.php
new file mode 100644
index 0000000..6beac18
--- /dev/null
+++ b/includes/SitiWashInstructions.php
@@ -0,0 +1,337 @@
+ [
+ 'label' => __('Temperatuur', 'siti-wash-instructions'),
+ 'term_key' => 'lb_wash_temp',
+ 'product_key' => '_lb_wash_temp',
+ 'icon' => '🌡️',
+ 'options' => [
+ '' => __('Geen advies', 'siti-wash-instructions'),
+ 'cold' => __('Koud wassen (max 20°C)', 'siti-wash-instructions'),
+ '30h' => __('30°C handwas', 'siti-wash-instructions'),
+ '30' => __('30°C fijnwas', 'siti-wash-instructions'),
+ '40' => __('40°C normaal', 'siti-wash-instructions'),
+ '60' => __('60°C intensief', 'siti-wash-instructions'),
+ 'hand' => __('Alleen handwas', 'siti-wash-instructions'),
+ ],
+ ],
+ 'dryer' => [
+ 'label' => __('Droger', 'siti-wash-instructions'),
+ 'term_key' => 'lb_wash_dryer',
+ 'product_key' => '_lb_wash_dryer',
+ 'icon' => '🌀',
+ 'options' => [
+ '' => __('Geen advies', 'siti-wash-instructions'),
+ 'no' => __('Niet in de droger', 'siti-wash-instructions'),
+ 'low' => __('Alleen lage stand', 'siti-wash-instructions'),
+ 'yes' => __('Droger toegestaan', 'siti-wash-instructions'),
+ ],
+ ],
+ 'iron' => [
+ 'label' => __('Strijken', 'siti-wash-instructions'),
+ 'term_key' => 'lb_wash_iron',
+ 'product_key' => '_lb_wash_iron',
+ 'icon' => '🧺',
+ 'options' => [
+ '' => __('Geen advies', 'siti-wash-instructions'),
+ 'no' => __('Niet strijken', 'siti-wash-instructions'),
+ 'low' => __('Lage temperatuur', 'siti-wash-instructions'),
+ 'med' => __('Gemiddelde temperatuur', 'siti-wash-instructions'),
+ 'high' => __('Hoge temperatuur', 'siti-wash-instructions'),
+ ],
+ ],
+ 'bleach' => [
+ 'label' => __('Bleken', 'siti-wash-instructions'),
+ 'term_key' => 'lb_wash_bleach',
+ 'product_key' => '_lb_wash_bleach',
+ 'icon' => '🫧',
+ 'options' => [
+ '' => __('Geen advies', 'siti-wash-instructions'),
+ 'no' => __('Niet bleken', 'siti-wash-instructions'),
+ 'yes' => __('Alleen zuurstofbleekmiddel', 'siti-wash-instructions'),
+ ],
+ ],
+ ];
+ }
+
+ public static function register_brand_hooks(): void
+ {
+ $tax = self::TAXONOMY;
+ add_action("{$tax}_add_form_fields", [__CLASS__, 'render_brand_add_form']);
+ add_action("{$tax}_edit_form_fields", [__CLASS__, 'render_brand_edit_form'], 10, 2);
+ add_action("created_{$tax}", [__CLASS__, 'save_brand_fields']);
+ add_action("edited_{$tax}", [__CLASS__, 'save_brand_fields']);
+ }
+
+ public static function render_brand_add_form($taxonomy): void
+ {
+ foreach (self::fields() as $field) {
+ self::render_brand_field('', $field);
+ }
+ }
+
+ public static function render_brand_edit_form($term, $taxonomy): void
+ {
+ foreach (self::fields() as $field) {
+ $value = (string) get_term_meta($term->term_id, $field['term_key'], true);
+ ?>
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+ __('Wasadvies', 'siti-wash-instructions'),
+ 'target' => 'lb_wash_advice_panel',
+ 'class' => ['lb-wash-advice-tab', 'show_if_simple', 'show_if_variable', 'show_if_grouped', 'show_if_external'],
+ 'priority' => 66,
+ ];
+
+ return $tabs;
+ }
+
+ public static function render_product_panel(): void
+ {
+ global $post;
+ ?>
+
+
+ $field) {
+ $product_value = get_post_meta($post->ID, $field['product_key'], true);
+ $options = ['inherit' => __('Volg merk (standaard)', 'siti-wash-instructions')] + $field['options'];
+ woocommerce_wp_select([
+ 'id' => $field['product_key'],
+ 'label' => $field['label'],
+ 'value' => $product_value !== '' ? $product_value : 'inherit',
+ 'options' => $options,
+ 'desc_tip' => false,
+ 'description' => __('Kies hier om het merkadvies te overschrijven.', 'siti-wash-instructions'),
+ ]);
+ }
+ ?>
+
+
+
+
+ $field) {
+ $value = get_post_meta($product_id, $field['product_key'], true);
+ if ($value === '' || $value === 'inherit') {
+ $value = self::get_brand_value($product_id, $field['term_key']);
+ }
+
+ if ($value && isset($field['options'][$value])) {
+ $result[$field_key] = [
+ 'label' => $field['label'],
+ 'text' => $field['options'][$value],
+ 'icon' => $field['icon'],
+ ];
+ }
+ }
+
+ return $result;
+ }
+
+ private static function get_brand_value(int $product_id, string $meta_key): string
+ {
+ $terms = get_the_terms($product_id, self::TAXONOMY);
+ if (empty($terms) || is_wp_error($terms)) {
+ return '';
+ }
+
+ foreach ($terms as $term) {
+ $value = get_term_meta($term->term_id, $meta_key, true);
+ if ($value !== '') {
+ return (string) $value;
+ }
+ }
+
+ return '';
+ }
+
+ public static function render_frontend_block(bool $echo = true, $product = null): string
+ {
+ if ($product === null) {
+ global $product;
+ }
+
+ if (!$product instanceof WC_Product) {
+ return '';
+ }
+
+ $output = self::build_wash_markup($product);
+ if ($echo && $output !== '') {
+ echo $output;
+ }
+
+ return $output;
+ }
+
+ private static function build_wash_markup(WC_Product $product): string
+ {
+ $data = self::get_product_advice($product->get_id());
+ if (empty($data)) {
+ return '';
+ }
+ ob_start();
+
+ static $printed_styles = false;
+ if (!$printed_styles) {
+ $printed_styles = true;
+ ?>
+
+
+
+ 'Version',
- ],
- false
- );
-
- $plugin_version = isset( $plugin_data['Version'] ) && $plugin_data['Version'] ? $plugin_data['Version'] : '1.0.0';
- define( 'PLUGIN_SLUG_VERSION', $plugin_version );
-}
-
-if( ! class_exists( 'SitiWebUpdater2' ) ){
- include_once( plugin_dir_path( __FILE__ ) . 'includes/SitiWebUpdater2.php' );
-}
-
-$updater = new SitiWebUpdater2( __FILE__ );
-$updater->set_owner( 'roberto' );
-$updater->set_repository( 'siti-plugin-template' );
-$updater->initialize();
\ No newline at end of file
diff --git a/siti-wash-instructions.php b/siti-wash-instructions.php
new file mode 100644
index 0000000..c01a02a
--- /dev/null
+++ b/siti-wash-instructions.php
@@ -0,0 +1,53 @@
+ 'Version',
+ ],
+ false
+ );
+
+ $plugin_version = isset($plugin_data['Version']) && $plugin_data['Version'] ? $plugin_data['Version'] : '1.0.0';
+ define('SITI_WASH_INSTRUCTIONS_VERSION', $plugin_version);
+}
+
+if (!class_exists('SitiWebUpdater2')) {
+ include_once(plugin_dir_path(__FILE__) . 'includes/SitiWebUpdater2.php');
+}
+
+$updater = new SitiWebUpdater2(__FILE__);
+$updater->set_owner('roberto');
+$updater->set_repository('siti-wash-instructions');
+$updater->initialize();
+
+include_once plugin_dir_path(__FILE__) . 'includes/SitiWashInstructions.php';
+
+SitiWashInstructions::init();