Plugin Directory

Changeset 3489159


Ignore:
Timestamp:
03/23/2026 03:30:12 PM (7 months ago)
Author:
josephnimoson
Message:

Release version 1.5.5 of Wolve Loyalty plugin

Location:
wolve-loyalty
Files:
4 added
14 edited
16 copied

Legend:

Unmodified
Added
Removed
  • wolve-loyalty/tags/1.5.5/includes/Info-page/info-page.php

    r3391502 r3489159  
    515515
    516516        // Get custom CTA title text from options
    517         $cta_title_format = get_option( 'wolve_loyalty_info_cta_title', __( 'Eksklusive tilbud kun for %s-medlemmer', 'wolve-loyalty' ) );
     517        $cta_title_format = get_option( 'wolve_loyalty_info_cta_title', Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_info_cta_title' ) );
    518518        $html .= sprintf(
    519519            esc_html( $cta_title_format ),
    … …  
    526526
    527527        // Get custom button text from options
    528         $button_text = get_option( 'wolve_loyalty_info_button_text', __( 'Registrer deg nå', 'wolve-loyalty' ) );
     528        $button_text = get_option( 'wolve_loyalty_info_button_text', Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_info_button_text' ) );
    529529
    530530        $html .= '  <a href="' . esc_url( $registration_url ) . '" class="wolve-cta-button">';
  • wolve-loyalty/tags/1.5.5/includes/admin-page.php

    r3478959 r3489159  
    5252function wolve_loyalty_settings_page()
    5353{
     54    // Handle "Reset Text Defaults" form submission
     55    if ( isset( $_POST['wolve_reset_text_defaults'] ) && check_admin_referer( 'wolve_reset_text_defaults', 'wolve_reset_text_nonce' ) ) {
     56        $locale   = isset( $_POST['wolve_reset_locale'] ) ? sanitize_text_field( wp_unslash( $_POST['wolve_reset_locale'] ) ) : 'en_US';
     57        $defaults = Wolve_Loyalty_Text_Defaults::get_defaults( $locale );
     58
     59        // Update individual text options
     60        foreach ( $defaults as $key => $value ) {
     61            if ( strpos( $key, 'signup_' ) === 0 ) {
     62                continue;
     63            }
     64            update_option( $key, $value );
     65        }
     66
     67        // Update signup defaults array (merge text into existing array to preserve non-text fields)
     68        $existing_signup = get_option( 'wolve_loyalty_signup_defaults', array() );
     69        $locale_signup   = Wolve_Loyalty_Text_Defaults::get_signup_defaults( $locale );
     70        $merged_signup   = array_merge( $existing_signup, $locale_signup );
     71        update_option( 'wolve_loyalty_signup_defaults', $merged_signup );
     72
     73        update_option( 'wolve_loyalty_default_locale', $locale );
     74
     75        add_settings_error( 'wolve_loyalty_options', 'text_defaults_reset',
     76            sprintf( __( 'Text defaults have been reset to %s.', 'wolve-loyalty' ), Wolve_Loyalty_Text_Defaults::get_supported_locales()[ $locale ] ?? $locale ),
     77            'updated'
     78        );
     79    }
     80
    5481    // Unslash and sanitize the 'tab' parameter
    5582    $tab = isset($_GET['tab']) ? sanitize_text_field(wp_unslash($_GET['tab'])) : 'general';
    … …  
    108135        </div>
    109136    </form>
     137
     138    <!-- Reset Text Defaults to Language -->
     139    <div style="margin-top: 30px; padding: 20px; background: #fff; border: 1px solid #ccd0d4; border-radius: 4px; max-width: 600px;">
     140        <h3 style="margin-top: 0;"><?php esc_html_e( 'Reset Text Defaults', 'wolve-loyalty' ); ?></h3>
     141        <p class="description" style="margin-bottom: 12px;">
     142            <?php esc_html_e( 'Reset all customer-facing text fields (signup form, my page, benefits, info page) to the selected language defaults. This will overwrite your current text settings but will not affect colors or API settings.', 'wolve-loyalty' ); ?>
     143        </p>
     144        <form method="post">
     145            <?php wp_nonce_field( 'wolve_reset_text_defaults', 'wolve_reset_text_nonce' ); ?>
     146            <?php $current_locale = get_option( 'wolve_loyalty_default_locale', get_locale() ); ?>
     147            <select name="wolve_reset_locale" style="vertical-align: middle;">
     148                <?php foreach ( Wolve_Loyalty_Text_Defaults::get_supported_locales() as $code => $name ) : ?>
     149                    <option value="<?php echo esc_attr( $code ); ?>" <?php selected( $code, $current_locale ); ?>><?php echo esc_html( $name ); ?></option>
     150                <?php endforeach; ?>
     151            </select>
     152            <button type="submit" name="wolve_reset_text_defaults" class="button button-secondary" style="vertical-align: middle;"
     153                    onclick="return confirm('<?php echo esc_js( __( 'This will overwrite all your current text settings with the selected language defaults. Are you sure?', 'wolve-loyalty' ) ); ?>');">
     154                <?php esc_html_e( 'Reset to Language Defaults', 'wolve-loyalty' ); ?>
     155            </button>
     156        </form>
     157    </div>
     158
    110159    <?php
    111160        } elseif ($tab === 'connect-and-activate') {
    … …  
    335384            }
    336385        }
    337        
     386
     387        // Save My Account tab label
     388        if (isset($_POST['wolve_loyalty_myaccount_tab_label'])) {
     389            update_option('wolve_loyalty_myaccount_tab_label', sanitize_text_field(wp_unslash($_POST['wolve_loyalty_myaccount_tab_label'])));
     390        }
     391
    338392        // Save colors
    339393        $color_fields = [
    … …  
    363417   
    364418    // Get current values
    365     $default_welcome = __('Hey! Welcome to our loyalty program. You can see all your rewards below (if any). To use any rewards, please go to the checkout page.', 'wolve-loyalty');
    366     $welcome_message = get_option('wolve_loyalty_welcome_message', $default_welcome);
    367    
    368     $default_greeting = __('Kjære %navn', 'wolve-loyalty');
    369     $greeting_format = get_option('wolve_loyalty_greeting_format', $default_greeting);
    370    
    371     $default_login_prompt = __('Please [login_link]log in[/login_link] to view your loyalty rewards.', 'wolve-loyalty');
    372     $login_prompt = get_option('wolve_loyalty_login_prompt', $default_login_prompt);
     419    $welcome_message = get_option('wolve_loyalty_welcome_message', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_welcome_message'));
     420    $greeting_format = get_option('wolve_loyalty_greeting_format', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_greeting_format'));
     421    $login_prompt = get_option('wolve_loyalty_login_prompt', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_login_prompt'));
    373422   
    374423    $login_url = get_option('wolve_loyalty_login_url', '');
    … …  
    558607                                   <?php checked(1, get_option('wolve_loyalty_enable_myaccount_endpoint', 0)); ?> />
    559608                            <label for="wolve_loyalty_enable_myaccount_endpoint">
    560                                 <?php esc_html_e('Add a "Lojalitetsprogram" tab to the WooCommerce My Account menu', 'wolve-loyalty'); ?>
     609                                <?php esc_html_e('Add a loyalty tab to the WooCommerce My Account menu', 'wolve-loyalty'); ?>
    561610                            </label>
    562611                            <p class="description">
    563                                 <?php esc_html_e('When enabled, customers will see a native "Lojalitetsprogram" tab in their My Account sidebar (next to Dashboard, Orders, etc.) that displays their loyalty profile. If disabled, you can use the [wolve_loyalty_profile] shortcode to display the profile on any page.', 'wolve-loyalty'); ?>
     612                                <?php esc_html_e('When enabled, customers will see a loyalty tab in their My Account sidebar (next to Dashboard, Orders, etc.) that displays their loyalty profile. If disabled, you can use the [wolve_loyalty_profile] shortcode to display the profile on any page.', 'wolve-loyalty'); ?>
    564613                                <br>
    565614                                <strong><?php esc_html_e('Note:', 'wolve-loyalty'); ?></strong>
    566615                                <?php esc_html_e('After enabling or disabling this option, go to Settings → Permalinks and click "Save Changes" to refresh rewrite rules.', 'wolve-loyalty'); ?>
     616                            </p>
     617                        </td>
     618                    </tr>
     619                    <tr>
     620                        <th scope="row">
     621                            <label for="wolve_loyalty_myaccount_tab_label"><?php esc_html_e('Tab Label', 'wolve-loyalty'); ?></label>
     622                        </th>
     623                        <td>
     624                            <input type="text"
     625                                   id="wolve_loyalty_myaccount_tab_label"
     626                                   name="wolve_loyalty_myaccount_tab_label"
     627                                   value="<?php echo esc_attr( get_option( 'wolve_loyalty_myaccount_tab_label', Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_myaccount_tab_label' ) ) ); ?>"
     628                                   style="width: 100%; max-width: 400px;">
     629                            <p class="description">
     630                                <?php esc_html_e('The label shown in the WooCommerce My Account sidebar menu.', 'wolve-loyalty'); ?>
    567631                            </p>
    568632                        </td>
    … …  
    760824   
    761825    // Get current values
    762     $default_heading = __('Your benefits', 'wolve-loyalty');
    763     $benefits_heading = get_option('wolve_loyalty_benefits_heading', $default_heading);
    764 
    765     $default_no_rewards = __('Do not use my rewards', 'wolve-loyalty');
    766     $no_rewards_text = get_option('wolve_loyalty_no_rewards_text', $default_no_rewards);
    767 
    768     $default_no_available_rewards = __('No available rewards at this time.', 'wolve-loyalty');
    769     $no_available_rewards_text = get_option('wolve_loyalty_no_available_rewards_text', $default_no_available_rewards);
     826    $benefits_heading = get_option('wolve_loyalty_benefits_heading', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_benefits_heading'));
     827    $no_rewards_text = get_option('wolve_loyalty_no_rewards_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_no_rewards_text'));
     828    $no_available_rewards_text = get_option('wolve_loyalty_no_available_rewards_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_no_available_rewards_text'));
    770829    ?>
    771830   
    … …  
    880939                                   id="wolve_loyalty_points_text"
    881940                                   name="wolve_loyalty_points_text"
    882                                    value="<?php echo esc_attr(get_option('wolve_loyalty_points_text', __('Earn {points} points with this purchase', 'wolve-loyalty'))); ?>"
     941                                   value="<?php echo esc_attr(get_option('wolve_loyalty_points_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_points_text'))); ?>"
    883942                                   style="width: 100%; max-width: 400px;">
    884943                            <p class="description">
    … …  
    13011360                                   id="wolve_loyalty_tier_points_format"
    13021361                                   name="wolve_loyalty_tier_points_format"
    1303                                    value="<?php echo esc_attr(get_option('wolve_loyalty_tier_points_format', '{current} / {total}')); ?>"
     1362                                   value="<?php echo esc_attr(get_option('wolve_loyalty_tier_points_format', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_format'))); ?>"
    13041363                                   placeholder="{current} / {total}"
    13051364                                   style="width: 100%; max-width: 400px;">
    … …  
    13331392                                   id="wolve_loyalty_tier_points_remaining"
    13341393                                   name="wolve_loyalty_tier_points_remaining"
    1335                                    value="<?php echo esc_attr(get_option('wolve_loyalty_tier_points_remaining', '{points_remaining} points left')); ?>"
     1394                                   value="<?php echo esc_attr(get_option('wolve_loyalty_tier_points_remaining', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining'))); ?>"
    13361395                                   placeholder="{points_remaining} points left"
    13371396                                   style="width: 100%; max-width: 400px;">
    … …  
    19572016            // Get current values
    19582017            $registration_url = get_option('wolve_loyalty_registration_url', '');
    1959             $button_text = get_option('wolve_loyalty_info_button_text', 'Registrer deg nå');
    1960             $cta_title = get_option('wolve_loyalty_info_cta_title', 'Eksklusive tilbud kun for %s-medlemmer');
     2018            $button_text = get_option('wolve_loyalty_info_button_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_info_button_text'));
     2019            $cta_title = get_option('wolve_loyalty_info_cta_title', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_info_cta_title'));
    19612020            ?>
    19622021
    … …  
    23702429function wolve_loyalty_signup_defaults_callback()
    23712430{
    2372     $defaults = get_option('wolve_loyalty_signup_defaults', [
    2373         'show_fields' => 'country_code,phone_number,email,first_name,last_name',
    2374         'required_fields' => 'country_code,phone_number',
    2375         'button_text' => 'Bli medlem',
    2376         'success_message' => 'Takk for at du ble medlem i vår kundeklubb!',
    2377         'already_member_message' => 'Du er allerede medlem av vår kundeklubb!',
    2378         'form_title' => 'Bli med i vår kundeklubb',
    2379         'form_description' => '',
    2380         'marketing_consent_notice' => 'Ved å bli medlem aksepterer du våre markedsføringsbetingelser, og vil motta tilbud på e-post og SMS',
    2381         'hide_form_shadow' => ''
    2382     ]);
     2431    $defaults = get_option('wolve_loyalty_signup_defaults', Wolve_Loyalty_Text_Defaults::get_signup_defaults());
    23832432   
    23842433    error_log('Form display - retrieved defaults: ' . print_r($defaults, true));
  • wolve-loyalty/tags/1.5.5/includes/benefits/benefits_display.php

    r3458103 r3489159  
    3636    // Check if data is retrieved
    3737    if (empty($wolve_loyalty_benefits)) {
    38         $no_available_rewards_text = get_option('wolve_loyalty_no_available_rewards_text', __('No available rewards at this time.', 'wolve-loyalty'));
     38        $no_available_rewards_text = get_option('wolve_loyalty_no_available_rewards_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_no_available_rewards_text'));
    3939        echo '<p>' . esc_html($no_available_rewards_text) . '</p>';
    4040        return;
    … …  
    4444   
    4545    // Get custom benefits heading or use default
    46     $default_heading = __('Your benefits', 'wolve-loyalty');
    47     $benefits_heading = get_option('wolve_loyalty_benefits_heading', $default_heading);
    48    
     46    $benefits_heading = get_option('wolve_loyalty_benefits_heading', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_benefits_heading'));
     47
    4948    // Get custom no rewards text or use default
    50     $default_no_rewards = __('Do not use my rewards', 'wolve-loyalty');
    51     $no_rewards_text = get_option('wolve_loyalty_no_rewards_text', $default_no_rewards);
     49    $no_rewards_text = get_option('wolve_loyalty_no_rewards_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_no_rewards_text'));
    5250
    5351    // Get tile color settings
    … …  
    142140        $points_label = get_option('wolve_loyalty_tier_points_label', '');
    143141        if (empty($points_label)) {
    144             $points_label = __('Points', 'wolve-loyalty');
    145         }
    146 
    147         $points_format = get_option('wolve_loyalty_tier_points_format', '{current} / {total}');
     142            $points_label = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_label');
     143        }
     144
     145        $points_format = get_option('wolve_loyalty_tier_points_format', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_format'));
    148146        if (empty($points_format)) {
    149             $points_format = '{current} / {total}';
     147            $points_format = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_format');
    150148        }
    151149        // Replace placeholders with actual values
    … …  
    158156        $next_tier_label = get_option('wolve_loyalty_tier_next_label', '');
    159157        if (empty($next_tier_label)) {
    160             $next_tier_label = __('Next tier', 'wolve-loyalty');
    161         }
    162 
    163         $points_remaining_format = get_option('wolve_loyalty_tier_points_remaining', '{points_remaining} points left');
     158            $next_tier_label = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_next_label');
     159        }
     160
     161        $points_remaining_format = get_option('wolve_loyalty_tier_points_remaining', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining'));
    164162        if (empty($points_remaining_format)) {
    165             $points_remaining_format = '{points_remaining} points left';
     163            $points_remaining_format = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining');
    166164        }
    167165        // Replace placeholder with actual points remaining
  • wolve-loyalty/tags/1.5.5/includes/my-account/my-account-endpoint.php

    r3395952 r3489159  
    107107        $menu_label = apply_filters(
    108108            'wolve_loyalty_menu_label',
    109             __( 'Lojalitetsprogram', 'wolve-loyalty' )
     109            get_option( 'wolve_loyalty_myaccount_tab_label', Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_myaccount_tab_label' ) )
    110110        );
    111111
  • wolve-loyalty/tags/1.5.5/includes/my-account/my-account.php

    r3478959 r3489159  
    1212    if ( ! is_user_logged_in() ) {
    1313      // Get the custom login prompt message or use default
    14       $default_prompt = __('Please [login_link]log in[/login_link] to view your loyalty rewards.', 'wolve-loyalty');
    15       $login_prompt = get_option('wolve_loyalty_login_prompt', $default_prompt);
     14      $login_prompt = get_option('wolve_loyalty_login_prompt', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_login_prompt'));
    1615     
    1716      // Get the login URL - use custom URL if set, otherwise use WordPress default
    … …  
    9089    $points_label = get_option('wolve_loyalty_tier_points_label', '');
    9190    if ( empty( $points_label ) ) {
    92         $points_label = __( 'Points', 'wolve-loyalty' );
     91        $points_label = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_tier_points_label' );
    9392    }
    9493
    … …  
    9897    $optout_label = get_option('wolve_loyalty_optout_label', '');
    9998    if ( empty( $optout_label ) ) {
    100         $optout_label = __( 'Avmelding', 'wolve-loyalty' );
     99        $optout_label = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_optout_label' );
    101100    }
    102101
    … …  
    148147            $next_tier_label = get_option('wolve_loyalty_tier_next_label', '');
    149148            if ( empty( $next_tier_label ) ) {
    150                 $next_tier_label = __( 'Current tier', 'wolve-loyalty' );
     149                $next_tier_label = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_tier_next_label' );
    151150            }
    152151            $html .= '<div class="wolve-member-next-tier">' . esc_html( $next_tier_label ) . ': ' . esc_html( $current_tier_name ) . '</div>';
    … …  
    155154        // Points remaining
    156155        if ( $points_to_next > 0 && ! empty( $next_tier_name ) ) {
    157             $points_remaining_format = get_option('wolve_loyalty_tier_points_remaining', '{points_remaining} points left');
     156            $points_remaining_format = get_option('wolve_loyalty_tier_points_remaining', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining'));
    158157            if ( empty( $points_remaining_format ) ) {
    159                 $points_remaining_format = '{points_remaining} points left';
     158                $points_remaining_format = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining');
    160159            }
    161160            $formatted_remaining = str_replace( '{points_remaining}', number_format( $points_to_next ), $points_remaining_format );
    … …  
    176175    $checkout_prompt = get_option('wolve_loyalty_checkout_prompt', '');
    177176    if ( empty( $checkout_prompt ) ) {
    178         $checkout_prompt = __( 'Gå til kassen for å bruke dine fordeler', 'wolve-loyalty' );
     177        $checkout_prompt = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_checkout_prompt' );
    179178    }
    180179    $html .= '<div class="wolve-member-checkout-prompt">' . esc_html( $checkout_prompt ) . '</div>';
    … …  
    230229        $coupons_title = get_option('wolve_loyalty_coupons_title', '');
    231230        if ( empty( $coupons_title ) ) {
    232             $coupons_title = __( 'Dine kuponger', 'wolve-loyalty' );
     231            $coupons_title = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_coupons_title' );
    233232        }
    234233
  • wolve-loyalty/tags/1.5.5/includes/product-points/product-points-display.php

    r3415409 r3489159  
    114114
    115115    // Get customized text template
    116     $points_text_template = get_option('wolve_loyalty_points_text', __('Earn {points} points with this purchase', 'wolve-loyalty'));
     116    $points_text_template = get_option('wolve_loyalty_points_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_points_text'));
    117117    $display_style = get_option('wolve_loyalty_points_style', 'default');
    118118
  • wolve-loyalty/tags/1.5.5/includes/signupForm/signup-form.php

    r3458103 r3489159  
    8181
    8282        // Get default settings from admin
    83         $admin_defaults = get_option('wolve_loyalty_signup_defaults', [
    84             'show_fields' => 'country_code,phone_number,email,first_name,last_name',
    85             'required_fields' => 'country_code,phone_number',
    86             'button_text' => __('Bli medlem', 'wolve-loyalty'),
    87             'success_message' => __('Takk for at du ble medlem i vår kundeklubb!', 'wolve-loyalty'),
    88             'form_title' => __('Bli med i vår kundeklubb', 'wolve-loyalty'),
    89             'form_description' => '',
    90             'marketing_consent_notice' => __('Ved å bli medlem aksepterer du våre markedsføringsbetingelser, og vil motta tilbud på e-post og SMS', 'wolve-loyalty')
    91         ]);
     83        $admin_defaults = get_option('wolve_loyalty_signup_defaults', Wolve_Loyalty_Text_Defaults::get_signup_defaults());
    9284
    9385        // Parse shortcode attributes with admin defaults as fallback
    … …  
    335327                        break;
    336328                    case 'phone_number':
    337                         // Combine country code with local number
    338329                        if (!empty($value)) {
    339                             // Remove all non-numeric characters
    340                             $value = preg_replace('/[^0-9]/', '', $value);
    341                             // Remove leading zeros
    342                             $value = ltrim($value, '0');
    343                             $member_data['phone_number'] = $country_code . $value;
     330                            if (strpos($value, '+') === 0) {
     331                                // Phone already has country code (e.g. from combined field) — use as-is
     332                                $member_data['phone_number'] = preg_replace('/[^0-9+]/', '', $value);
     333                            } else {
     334                                // Local number only — combine with country code
     335                                $value = preg_replace('/[^0-9]/', '', $value);
     336                                $value = ltrim($value, '0');
     337                                $member_data['phone_number'] = $country_code . $value;
     338                            }
    344339                        }
    345340                        break;
  • wolve-loyalty/tags/1.5.5/includes/signupForm/vipps-signup-form.js

    r3478959 r3489159  
    540540
    541541                const phoneNumberVal = $phoneDisplay.val().replace(/\s+/g, '');
    542                 const fullPhone = countryCodeVal + phoneNumberVal;
    543                 $phoneHidden.val(fullPhone);
     542                // Set phone_number to local number only (backend combines with country_code)
     543                $phoneHidden.val(phoneNumberVal);
    544544                // Also update the display field's name for proper form submission
    545545                $phoneDisplay.attr('name', 'phone_number_display_only');
     546
     547                // Add country_code field for backend processing
     548                if (!$form.find('input[name="country_code"]').length) {
     549                    $form.append('<input type="hidden" name="country_code" value="' + countryCodeVal + '">');
     550                } else {
     551                    $form.find('input[name="country_code"]').val(countryCodeVal);
     552                }
    546553            }
    547554        }
  • wolve-loyalty/tags/1.5.5/includes/signupForm/vipps-signup-form.php

    r3478959 r3489159  
    203203    public function render_vipps_shortcode($atts) {
    204204        // Get default settings from admin
    205         $admin_defaults = get_option('wolve_loyalty_signup_defaults', [
    206             'show_fields' => 'phone_number,email,first_name,last_name',
    207             'required_fields' => 'phone_number',
    208             'button_text' => __('Bli medlem', 'wolve-loyalty'),
    209             'success_message' => __('Takk for at du ble medlem i vår kundeklubb!', 'wolve-loyalty'),
    210             'form_title' => __('Bli med i vår kundeklubb', 'wolve-loyalty'),
    211             'form_description' => '',
    212             'marketing_consent_notice' => __('Ved å bli medlem aksepterer du våre markedsføringsbetingelser, og vil motta tilbud på e-post og SMS', 'wolve-loyalty')
    213         ]);
     205        $admin_defaults = get_option('wolve_loyalty_signup_defaults', Wolve_Loyalty_Text_Defaults::get_signup_defaults());
    214206
    215207        // Parse shortcode attributes
  • wolve-loyalty/tags/1.5.5/readme.txt

    r3478959 r3489159  
    11=== Wolve Loyalty ===
    22Contributors: josephnimoson
    3 Tags: loyalty, rewards, customer engagement, retention, points, referrals, woocommerce
     3Tags: loyalty, customer engagement, retention, points, woocommerce
    44Requires at least: 1.0.0
    55Tested up to: 6.9.1
    6 Stable tag: 1.5.3
     6Stable tag: 1.5.5
    77License: GPL-2.0-or-later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
    99
    10 == Short Description ==
    1110Losing customers without understanding why? Use Wolve to win customers back. Loyalty and Retention solution.
    1211
    … …  
    2625== Installation ==
    2726
    28 1. Upload the plugin files to the `/wp-content/plugins/wolve-loyalty`= directory, or install via the WordPress plugin repository.
     271. Upload the plugin files to the `/wp-content/plugins/wolve-loyalty/` directory, or install via the WordPress plugin repository.
    29282. Activate the plugin through the 'Plugins' screen in WordPress.
    30293. Access the plugin settings via the newly created 'Wolve Loyalty' menu.
    … …  
    51505. **Shopper Experience (End-to-End)** - Show points on product pages, give customers a My Loyalty page in their account, and let them redeem at checkout without leaving the flow. A complete earn-and-burn experience for WooCommerce.
    52516. **Support** - Fast, live support available 24/7 across time zones. Get help with onboarding, best-practice playbooks, and optimization whenever you need it.
     52
     53= 1.5.5 =
     54- translation preset update and bugfix in form.
    5355
    5456= 1.5.3 =
    … …  
    133135
    134136– Added support for woocommerce datavisualization.
    135 
    136 
  • wolve-loyalty/tags/1.5.5/wolve-loyalty.php

    r3478959 r3489159  
    66 * Author URI:        https://wolve.ai
    77 * Tested up to:      6.9.1
    8  * Version:           1.5.3
     8 * Version:           1.5.5
    99 * Text Domain:       wolve-loyalty
    1010 * License:           GPL-2.0-or-later
    … …  
    1717}
    1818
     19require_once plugin_dir_path(__FILE__) . 'includes/i18n/text-defaults.php';
    1920require_once plugin_dir_path(__FILE__) . 'includes/admin-page.php';
    2021require_once plugin_dir_path(__FILE__) . 'includes/member/member.php';
    … …  
    7475        $this->is_connected = get_option('wolve_loyalty_is_connected');
    7576
     77        // Run upgrade check for version-based migrations
     78        $this->maybe_run_upgrade();
     79
    7680        // Load plugin text domain for translations
    7781        add_action('plugins_loaded', array($this, 'load_textdomain'));
    … …  
    8791    public function load_textdomain() {
    8892        load_plugin_textdomain('wolve-loyalty', false, dirname(plugin_basename(__FILE__)) . '/languages/');
     93    }
     94
     95    /**
     96     * Run version-based upgrades. Populates new text fields added in later versions
     97     * using add_option() so existing customised values are never overwritten.
     98     */
     99    private function maybe_run_upgrade() {
     100        $current_version = '1.5.4';
     101        $stored_version  = get_option( 'wolve_loyalty_plugin_version', '0' );
     102
     103        if ( version_compare( $stored_version, $current_version, '>=' ) ) {
     104            return;
     105        }
     106
     107        // For existing clients (have API key), preserve the Norwegian tab label
     108        // they've been seeing, rather than switching to their locale's default.
     109        if ( get_option( 'wolve_loyalty_api_key', false ) ) {
     110            add_option( 'wolve_loyalty_myaccount_tab_label', 'Lojalitetsprogram' );
     111        }
     112
     113        // Populate any text defaults that don't exist yet (safe for existing values)
     114        $locale   = get_option( 'wolve_loyalty_default_locale', get_locale() );
     115        $defaults = Wolve_Loyalty_Text_Defaults::get_defaults( $locale );
     116
     117        foreach ( $defaults as $key => $value ) {
     118            if ( strpos( $key, 'signup_' ) === 0 ) {
     119                continue;
     120            }
     121            add_option( $key, $value );
     122        }
     123
     124        update_option( 'wolve_loyalty_plugin_version', $current_version );
    89125    }
    90126
    … …  
    470506
    471507
     508// ── Activation hook: populate locale-aware text defaults on fresh install ──
     509register_activation_hook( __FILE__, 'wolve_loyalty_activate' );
     510
     511function wolve_loyalty_activate() {
     512    $has_version = get_option( 'wolve_loyalty_plugin_version', false );
     513    $has_api_key = get_option( 'wolve_loyalty_api_key', false );
     514
     515    if ( ! $has_version && ! $has_api_key ) {
     516        // Fresh install — populate text defaults based on site locale
     517        $locale   = get_locale();
     518        $defaults = Wolve_Loyalty_Text_Defaults::get_defaults( $locale );
     519
     520        // Individual text options (add_option is a no-op if option already exists)
     521        foreach ( $defaults as $key => $value ) {
     522            // Skip signup_ prefixed keys — those go into the array option
     523            if ( strpos( $key, 'signup_' ) === 0 ) {
     524                continue;
     525            }
     526            add_option( $key, $value );
     527        }
     528
     529        // Signup defaults array
     530        $signup_defaults = Wolve_Loyalty_Text_Defaults::get_signup_defaults( $locale );
     531        add_option( 'wolve_loyalty_signup_defaults', $signup_defaults );
     532
     533        update_option( 'wolve_loyalty_default_locale', $locale );
     534    }
     535
     536    update_option( 'wolve_loyalty_plugin_version', '1.5.4' );
     537}
     538
    472539new Wolveloyalty();
    473540
  • wolve-loyalty/trunk/includes/Info-page/info-page.php

    r3391502 r3489159  
    515515
    516516        // Get custom CTA title text from options
    517         $cta_title_format = get_option( 'wolve_loyalty_info_cta_title', __( 'Eksklusive tilbud kun for %s-medlemmer', 'wolve-loyalty' ) );
     517        $cta_title_format = get_option( 'wolve_loyalty_info_cta_title', Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_info_cta_title' ) );
    518518        $html .= sprintf(
    519519            esc_html( $cta_title_format ),
    … …  
    526526
    527527        // Get custom button text from options
    528         $button_text = get_option( 'wolve_loyalty_info_button_text', __( 'Registrer deg nå', 'wolve-loyalty' ) );
     528        $button_text = get_option( 'wolve_loyalty_info_button_text', Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_info_button_text' ) );
    529529
    530530        $html .= '  <a href="' . esc_url( $registration_url ) . '" class="wolve-cta-button">';
  • wolve-loyalty/trunk/includes/admin-page.php

    r3478959 r3489159  
    5252function wolve_loyalty_settings_page()
    5353{
     54    // Handle "Reset Text Defaults" form submission
     55    if ( isset( $_POST['wolve_reset_text_defaults'] ) && check_admin_referer( 'wolve_reset_text_defaults', 'wolve_reset_text_nonce' ) ) {
     56        $locale   = isset( $_POST['wolve_reset_locale'] ) ? sanitize_text_field( wp_unslash( $_POST['wolve_reset_locale'] ) ) : 'en_US';
     57        $defaults = Wolve_Loyalty_Text_Defaults::get_defaults( $locale );
     58
     59        // Update individual text options
     60        foreach ( $defaults as $key => $value ) {
     61            if ( strpos( $key, 'signup_' ) === 0 ) {
     62                continue;
     63            }
     64            update_option( $key, $value );
     65        }
     66
     67        // Update signup defaults array (merge text into existing array to preserve non-text fields)
     68        $existing_signup = get_option( 'wolve_loyalty_signup_defaults', array() );
     69        $locale_signup   = Wolve_Loyalty_Text_Defaults::get_signup_defaults( $locale );
     70        $merged_signup   = array_merge( $existing_signup, $locale_signup );
     71        update_option( 'wolve_loyalty_signup_defaults', $merged_signup );
     72
     73        update_option( 'wolve_loyalty_default_locale', $locale );
     74
     75        add_settings_error( 'wolve_loyalty_options', 'text_defaults_reset',
     76            sprintf( __( 'Text defaults have been reset to %s.', 'wolve-loyalty' ), Wolve_Loyalty_Text_Defaults::get_supported_locales()[ $locale ] ?? $locale ),
     77            'updated'
     78        );
     79    }
     80
    5481    // Unslash and sanitize the 'tab' parameter
    5582    $tab = isset($_GET['tab']) ? sanitize_text_field(wp_unslash($_GET['tab'])) : 'general';
    … …  
    108135        </div>
    109136    </form>
     137
     138    <!-- Reset Text Defaults to Language -->
     139    <div style="margin-top: 30px; padding: 20px; background: #fff; border: 1px solid #ccd0d4; border-radius: 4px; max-width: 600px;">
     140        <h3 style="margin-top: 0;"><?php esc_html_e( 'Reset Text Defaults', 'wolve-loyalty' ); ?></h3>
     141        <p class="description" style="margin-bottom: 12px;">
     142            <?php esc_html_e( 'Reset all customer-facing text fields (signup form, my page, benefits, info page) to the selected language defaults. This will overwrite your current text settings but will not affect colors or API settings.', 'wolve-loyalty' ); ?>
     143        </p>
     144        <form method="post">
     145            <?php wp_nonce_field( 'wolve_reset_text_defaults', 'wolve_reset_text_nonce' ); ?>
     146            <?php $current_locale = get_option( 'wolve_loyalty_default_locale', get_locale() ); ?>
     147            <select name="wolve_reset_locale" style="vertical-align: middle;">
     148                <?php foreach ( Wolve_Loyalty_Text_Defaults::get_supported_locales() as $code => $name ) : ?>
     149                    <option value="<?php echo esc_attr( $code ); ?>" <?php selected( $code, $current_locale ); ?>><?php echo esc_html( $name ); ?></option>
     150                <?php endforeach; ?>
     151            </select>
     152            <button type="submit" name="wolve_reset_text_defaults" class="button button-secondary" style="vertical-align: middle;"
     153                    onclick="return confirm('<?php echo esc_js( __( 'This will overwrite all your current text settings with the selected language defaults. Are you sure?', 'wolve-loyalty' ) ); ?>');">
     154                <?php esc_html_e( 'Reset to Language Defaults', 'wolve-loyalty' ); ?>
     155            </button>
     156        </form>
     157    </div>
     158
    110159    <?php
    111160        } elseif ($tab === 'connect-and-activate') {
    … …  
    335384            }
    336385        }
    337        
     386
     387        // Save My Account tab label
     388        if (isset($_POST['wolve_loyalty_myaccount_tab_label'])) {
     389            update_option('wolve_loyalty_myaccount_tab_label', sanitize_text_field(wp_unslash($_POST['wolve_loyalty_myaccount_tab_label'])));
     390        }
     391
    338392        // Save colors
    339393        $color_fields = [
    … …  
    363417   
    364418    // Get current values
    365     $default_welcome = __('Hey! Welcome to our loyalty program. You can see all your rewards below (if any). To use any rewards, please go to the checkout page.', 'wolve-loyalty');
    366     $welcome_message = get_option('wolve_loyalty_welcome_message', $default_welcome);
    367    
    368     $default_greeting = __('Kjære %navn', 'wolve-loyalty');
    369     $greeting_format = get_option('wolve_loyalty_greeting_format', $default_greeting);
    370    
    371     $default_login_prompt = __('Please [login_link]log in[/login_link] to view your loyalty rewards.', 'wolve-loyalty');
    372     $login_prompt = get_option('wolve_loyalty_login_prompt', $default_login_prompt);
     419    $welcome_message = get_option('wolve_loyalty_welcome_message', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_welcome_message'));
     420    $greeting_format = get_option('wolve_loyalty_greeting_format', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_greeting_format'));
     421    $login_prompt = get_option('wolve_loyalty_login_prompt', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_login_prompt'));
    373422   
    374423    $login_url = get_option('wolve_loyalty_login_url', '');
    … …  
    558607                                   <?php checked(1, get_option('wolve_loyalty_enable_myaccount_endpoint', 0)); ?> />
    559608                            <label for="wolve_loyalty_enable_myaccount_endpoint">
    560                                 <?php esc_html_e('Add a "Lojalitetsprogram" tab to the WooCommerce My Account menu', 'wolve-loyalty'); ?>
     609                                <?php esc_html_e('Add a loyalty tab to the WooCommerce My Account menu', 'wolve-loyalty'); ?>
    561610                            </label>
    562611                            <p class="description">
    563                                 <?php esc_html_e('When enabled, customers will see a native "Lojalitetsprogram" tab in their My Account sidebar (next to Dashboard, Orders, etc.) that displays their loyalty profile. If disabled, you can use the [wolve_loyalty_profile] shortcode to display the profile on any page.', 'wolve-loyalty'); ?>
     612                                <?php esc_html_e('When enabled, customers will see a loyalty tab in their My Account sidebar (next to Dashboard, Orders, etc.) that displays their loyalty profile. If disabled, you can use the [wolve_loyalty_profile] shortcode to display the profile on any page.', 'wolve-loyalty'); ?>
    564613                                <br>
    565614                                <strong><?php esc_html_e('Note:', 'wolve-loyalty'); ?></strong>
    566615                                <?php esc_html_e('After enabling or disabling this option, go to Settings → Permalinks and click "Save Changes" to refresh rewrite rules.', 'wolve-loyalty'); ?>
     616                            </p>
     617                        </td>
     618                    </tr>
     619                    <tr>
     620                        <th scope="row">
     621                            <label for="wolve_loyalty_myaccount_tab_label"><?php esc_html_e('Tab Label', 'wolve-loyalty'); ?></label>
     622                        </th>
     623                        <td>
     624                            <input type="text"
     625                                   id="wolve_loyalty_myaccount_tab_label"
     626                                   name="wolve_loyalty_myaccount_tab_label"
     627                                   value="<?php echo esc_attr( get_option( 'wolve_loyalty_myaccount_tab_label', Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_myaccount_tab_label' ) ) ); ?>"
     628                                   style="width: 100%; max-width: 400px;">
     629                            <p class="description">
     630                                <?php esc_html_e('The label shown in the WooCommerce My Account sidebar menu.', 'wolve-loyalty'); ?>
    567631                            </p>
    568632                        </td>
    … …  
    760824   
    761825    // Get current values
    762     $default_heading = __('Your benefits', 'wolve-loyalty');
    763     $benefits_heading = get_option('wolve_loyalty_benefits_heading', $default_heading);
    764 
    765     $default_no_rewards = __('Do not use my rewards', 'wolve-loyalty');
    766     $no_rewards_text = get_option('wolve_loyalty_no_rewards_text', $default_no_rewards);
    767 
    768     $default_no_available_rewards = __('No available rewards at this time.', 'wolve-loyalty');
    769     $no_available_rewards_text = get_option('wolve_loyalty_no_available_rewards_text', $default_no_available_rewards);
     826    $benefits_heading = get_option('wolve_loyalty_benefits_heading', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_benefits_heading'));
     827    $no_rewards_text = get_option('wolve_loyalty_no_rewards_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_no_rewards_text'));
     828    $no_available_rewards_text = get_option('wolve_loyalty_no_available_rewards_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_no_available_rewards_text'));
    770829    ?>
    771830   
    … …  
    880939                                   id="wolve_loyalty_points_text"
    881940                                   name="wolve_loyalty_points_text"
    882                                    value="<?php echo esc_attr(get_option('wolve_loyalty_points_text', __('Earn {points} points with this purchase', 'wolve-loyalty'))); ?>"
     941                                   value="<?php echo esc_attr(get_option('wolve_loyalty_points_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_points_text'))); ?>"
    883942                                   style="width: 100%; max-width: 400px;">
    884943                            <p class="description">
    … …  
    13011360                                   id="wolve_loyalty_tier_points_format"
    13021361                                   name="wolve_loyalty_tier_points_format"
    1303                                    value="<?php echo esc_attr(get_option('wolve_loyalty_tier_points_format', '{current} / {total}')); ?>"
     1362                                   value="<?php echo esc_attr(get_option('wolve_loyalty_tier_points_format', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_format'))); ?>"
    13041363                                   placeholder="{current} / {total}"
    13051364                                   style="width: 100%; max-width: 400px;">
    … …  
    13331392                                   id="wolve_loyalty_tier_points_remaining"
    13341393                                   name="wolve_loyalty_tier_points_remaining"
    1335                                    value="<?php echo esc_attr(get_option('wolve_loyalty_tier_points_remaining', '{points_remaining} points left')); ?>"
     1394                                   value="<?php echo esc_attr(get_option('wolve_loyalty_tier_points_remaining', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining'))); ?>"
    13361395                                   placeholder="{points_remaining} points left"
    13371396                                   style="width: 100%; max-width: 400px;">
    … …  
    19572016            // Get current values
    19582017            $registration_url = get_option('wolve_loyalty_registration_url', '');
    1959             $button_text = get_option('wolve_loyalty_info_button_text', 'Registrer deg nå');
    1960             $cta_title = get_option('wolve_loyalty_info_cta_title', 'Eksklusive tilbud kun for %s-medlemmer');
     2018            $button_text = get_option('wolve_loyalty_info_button_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_info_button_text'));
     2019            $cta_title = get_option('wolve_loyalty_info_cta_title', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_info_cta_title'));
    19612020            ?>
    19622021
    … …  
    23702429function wolve_loyalty_signup_defaults_callback()
    23712430{
    2372     $defaults = get_option('wolve_loyalty_signup_defaults', [
    2373         'show_fields' => 'country_code,phone_number,email,first_name,last_name',
    2374         'required_fields' => 'country_code,phone_number',
    2375         'button_text' => 'Bli medlem',
    2376         'success_message' => 'Takk for at du ble medlem i vår kundeklubb!',
    2377         'already_member_message' => 'Du er allerede medlem av vår kundeklubb!',
    2378         'form_title' => 'Bli med i vår kundeklubb',
    2379         'form_description' => '',
    2380         'marketing_consent_notice' => 'Ved å bli medlem aksepterer du våre markedsføringsbetingelser, og vil motta tilbud på e-post og SMS',
    2381         'hide_form_shadow' => ''
    2382     ]);
     2431    $defaults = get_option('wolve_loyalty_signup_defaults', Wolve_Loyalty_Text_Defaults::get_signup_defaults());
    23832432   
    23842433    error_log('Form display - retrieved defaults: ' . print_r($defaults, true));
  • wolve-loyalty/trunk/includes/benefits/benefits_display.php

    r3458103 r3489159  
    3636    // Check if data is retrieved
    3737    if (empty($wolve_loyalty_benefits)) {
    38         $no_available_rewards_text = get_option('wolve_loyalty_no_available_rewards_text', __('No available rewards at this time.', 'wolve-loyalty'));
     38        $no_available_rewards_text = get_option('wolve_loyalty_no_available_rewards_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_no_available_rewards_text'));
    3939        echo '<p>' . esc_html($no_available_rewards_text) . '</p>';
    4040        return;
    … …  
    4444   
    4545    // Get custom benefits heading or use default
    46     $default_heading = __('Your benefits', 'wolve-loyalty');
    47     $benefits_heading = get_option('wolve_loyalty_benefits_heading', $default_heading);
    48    
     46    $benefits_heading = get_option('wolve_loyalty_benefits_heading', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_benefits_heading'));
     47
    4948    // Get custom no rewards text or use default
    50     $default_no_rewards = __('Do not use my rewards', 'wolve-loyalty');
    51     $no_rewards_text = get_option('wolve_loyalty_no_rewards_text', $default_no_rewards);
     49    $no_rewards_text = get_option('wolve_loyalty_no_rewards_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_no_rewards_text'));
    5250
    5351    // Get tile color settings
    … …  
    142140        $points_label = get_option('wolve_loyalty_tier_points_label', '');
    143141        if (empty($points_label)) {
    144             $points_label = __('Points', 'wolve-loyalty');
    145         }
    146 
    147         $points_format = get_option('wolve_loyalty_tier_points_format', '{current} / {total}');
     142            $points_label = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_label');
     143        }
     144
     145        $points_format = get_option('wolve_loyalty_tier_points_format', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_format'));
    148146        if (empty($points_format)) {
    149             $points_format = '{current} / {total}';
     147            $points_format = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_format');
    150148        }
    151149        // Replace placeholders with actual values
    … …  
    158156        $next_tier_label = get_option('wolve_loyalty_tier_next_label', '');
    159157        if (empty($next_tier_label)) {
    160             $next_tier_label = __('Next tier', 'wolve-loyalty');
    161         }
    162 
    163         $points_remaining_format = get_option('wolve_loyalty_tier_points_remaining', '{points_remaining} points left');
     158            $next_tier_label = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_next_label');
     159        }
     160
     161        $points_remaining_format = get_option('wolve_loyalty_tier_points_remaining', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining'));
    164162        if (empty($points_remaining_format)) {
    165             $points_remaining_format = '{points_remaining} points left';
     163            $points_remaining_format = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining');
    166164        }
    167165        // Replace placeholder with actual points remaining
  • wolve-loyalty/trunk/includes/my-account/my-account-endpoint.php

    r3395952 r3489159  
    107107        $menu_label = apply_filters(
    108108            'wolve_loyalty_menu_label',
    109             __( 'Lojalitetsprogram', 'wolve-loyalty' )
     109            get_option( 'wolve_loyalty_myaccount_tab_label', Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_myaccount_tab_label' ) )
    110110        );
    111111
  • wolve-loyalty/trunk/includes/my-account/my-account.php

    r3478959 r3489159  
    1212    if ( ! is_user_logged_in() ) {
    1313      // Get the custom login prompt message or use default
    14       $default_prompt = __('Please [login_link]log in[/login_link] to view your loyalty rewards.', 'wolve-loyalty');
    15       $login_prompt = get_option('wolve_loyalty_login_prompt', $default_prompt);
     14      $login_prompt = get_option('wolve_loyalty_login_prompt', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_login_prompt'));
    1615     
    1716      // Get the login URL - use custom URL if set, otherwise use WordPress default
    … …  
    9089    $points_label = get_option('wolve_loyalty_tier_points_label', '');
    9190    if ( empty( $points_label ) ) {
    92         $points_label = __( 'Points', 'wolve-loyalty' );
     91        $points_label = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_tier_points_label' );
    9392    }
    9493
    … …  
    9897    $optout_label = get_option('wolve_loyalty_optout_label', '');
    9998    if ( empty( $optout_label ) ) {
    100         $optout_label = __( 'Avmelding', 'wolve-loyalty' );
     99        $optout_label = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_optout_label' );
    101100    }
    102101
    … …  
    148147            $next_tier_label = get_option('wolve_loyalty_tier_next_label', '');
    149148            if ( empty( $next_tier_label ) ) {
    150                 $next_tier_label = __( 'Current tier', 'wolve-loyalty' );
     149                $next_tier_label = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_tier_next_label' );
    151150            }
    152151            $html .= '<div class="wolve-member-next-tier">' . esc_html( $next_tier_label ) . ': ' . esc_html( $current_tier_name ) . '</div>';
    … …  
    155154        // Points remaining
    156155        if ( $points_to_next > 0 && ! empty( $next_tier_name ) ) {
    157             $points_remaining_format = get_option('wolve_loyalty_tier_points_remaining', '{points_remaining} points left');
     156            $points_remaining_format = get_option('wolve_loyalty_tier_points_remaining', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining'));
    158157            if ( empty( $points_remaining_format ) ) {
    159                 $points_remaining_format = '{points_remaining} points left';
     158                $points_remaining_format = Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_tier_points_remaining');
    160159            }
    161160            $formatted_remaining = str_replace( '{points_remaining}', number_format( $points_to_next ), $points_remaining_format );
    … …  
    176175    $checkout_prompt = get_option('wolve_loyalty_checkout_prompt', '');
    177176    if ( empty( $checkout_prompt ) ) {
    178         $checkout_prompt = __( 'Gå til kassen for å bruke dine fordeler', 'wolve-loyalty' );
     177        $checkout_prompt = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_checkout_prompt' );
    179178    }
    180179    $html .= '<div class="wolve-member-checkout-prompt">' . esc_html( $checkout_prompt ) . '</div>';
    … …  
    230229        $coupons_title = get_option('wolve_loyalty_coupons_title', '');
    231230        if ( empty( $coupons_title ) ) {
    232             $coupons_title = __( 'Dine kuponger', 'wolve-loyalty' );
     231            $coupons_title = Wolve_Loyalty_Text_Defaults::get_default( 'wolve_loyalty_coupons_title' );
    233232        }
    234233
  • wolve-loyalty/trunk/includes/product-points/product-points-display.php

    r3415409 r3489159  
    114114
    115115    // Get customized text template
    116     $points_text_template = get_option('wolve_loyalty_points_text', __('Earn {points} points with this purchase', 'wolve-loyalty'));
     116    $points_text_template = get_option('wolve_loyalty_points_text', Wolve_Loyalty_Text_Defaults::get_default('wolve_loyalty_points_text'));
    117117    $display_style = get_option('wolve_loyalty_points_style', 'default');
    118118
  • wolve-loyalty/trunk/includes/signupForm/signup-form.php

    r3458103 r3489159  
    8181
    8282        // Get default settings from admin
    83         $admin_defaults = get_option('wolve_loyalty_signup_defaults', [
    84             'show_fields' => 'country_code,phone_number,email,first_name,last_name',
    85             'required_fields' => 'country_code,phone_number',
    86             'button_text' => __('Bli medlem', 'wolve-loyalty'),
    87             'success_message' => __('Takk for at du ble medlem i vår kundeklubb!', 'wolve-loyalty'),
    88             'form_title' => __('Bli med i vår kundeklubb', 'wolve-loyalty'),
    89             'form_description' => '',
    90             'marketing_consent_notice' => __('Ved å bli medlem aksepterer du våre markedsføringsbetingelser, og vil motta tilbud på e-post og SMS', 'wolve-loyalty')
    91         ]);
     83        $admin_defaults = get_option('wolve_loyalty_signup_defaults', Wolve_Loyalty_Text_Defaults::get_signup_defaults());
    9284
    9385        // Parse shortcode attributes with admin defaults as fallback
    … …  
    335327                        break;
    336328                    case 'phone_number':
    337                         // Combine country code with local number
    338329                        if (!empty($value)) {
    339                             // Remove all non-numeric characters
    340                             $value = preg_replace('/[^0-9]/', '', $value);
    341                             // Remove leading zeros
    342                             $value = ltrim($value, '0');
    343                             $member_data['phone_number'] = $country_code . $value;
     330                            if (strpos($value, '+') === 0) {
     331                                // Phone already has country code (e.g. from combined field) — use as-is
     332                                $member_data['phone_number'] = preg_replace('/[^0-9+]/', '', $value);
     333                            } else {
     334                                // Local number only — combine with country code
     335                                $value = preg_replace('/[^0-9]/', '', $value);
     336                                $value = ltrim($value, '0');
     337                                $member_data['phone_number'] = $country_code . $value;
     338                            }
    344339                        }
    345340                        break;
  • wolve-loyalty/trunk/includes/signupForm/vipps-signup-form.js

    r3478959 r3489159  
    540540
    541541                const phoneNumberVal = $phoneDisplay.val().replace(/\s+/g, '');
    542                 const fullPhone = countryCodeVal + phoneNumberVal;
    543                 $phoneHidden.val(fullPhone);
     542                // Set phone_number to local number only (backend combines with country_code)
     543                $phoneHidden.val(phoneNumberVal);
    544544                // Also update the display field's name for proper form submission
    545545                $phoneDisplay.attr('name', 'phone_number_display_only');
     546
     547                // Add country_code field for backend processing
     548                if (!$form.find('input[name="country_code"]').length) {
     549                    $form.append('<input type="hidden" name="country_code" value="' + countryCodeVal + '">');
     550                } else {
     551                    $form.find('input[name="country_code"]').val(countryCodeVal);
     552                }
    546553            }
    547554        }
  • wolve-loyalty/trunk/includes/signupForm/vipps-signup-form.php

    r3478959 r3489159  
    203203    public function render_vipps_shortcode($atts) {
    204204        // Get default settings from admin
    205         $admin_defaults = get_option('wolve_loyalty_signup_defaults', [
    206             'show_fields' => 'phone_number,email,first_name,last_name',
    207             'required_fields' => 'phone_number',
    208             'button_text' => __('Bli medlem', 'wolve-loyalty'),
    209             'success_message' => __('Takk for at du ble medlem i vår kundeklubb!', 'wolve-loyalty'),
    210             'form_title' => __('Bli med i vår kundeklubb', 'wolve-loyalty'),
    211             'form_description' => '',
    212             'marketing_consent_notice' => __('Ved å bli medlem aksepterer du våre markedsføringsbetingelser, og vil motta tilbud på e-post og SMS', 'wolve-loyalty')
    213         ]);
     205        $admin_defaults = get_option('wolve_loyalty_signup_defaults', Wolve_Loyalty_Text_Defaults::get_signup_defaults());
    214206
    215207        // Parse shortcode attributes
  • wolve-loyalty/trunk/readme.txt

    r3478959 r3489159  
    11=== Wolve Loyalty ===
    22Contributors: josephnimoson
    3 Tags: loyalty, rewards, customer engagement, retention, points, referrals, woocommerce
     3Tags: loyalty, customer engagement, retention, points, woocommerce
    44Requires at least: 1.0.0
    55Tested up to: 6.9.1
    6 Stable tag: 1.5.3
     6Stable tag: 1.5.5
    77License: GPL-2.0-or-later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
    99
    10 == Short Description ==
    1110Losing customers without understanding why? Use Wolve to win customers back. Loyalty and Retention solution.
    1211
    … …  
    2625== Installation ==
    2726
    28 1. Upload the plugin files to the `/wp-content/plugins/wolve-loyalty`= directory, or install via the WordPress plugin repository.
     271. Upload the plugin files to the `/wp-content/plugins/wolve-loyalty/` directory, or install via the WordPress plugin repository.
    29282. Activate the plugin through the 'Plugins' screen in WordPress.
    30293. Access the plugin settings via the newly created 'Wolve Loyalty' menu.
    … …  
    51505. **Shopper Experience (End-to-End)** - Show points on product pages, give customers a My Loyalty page in their account, and let them redeem at checkout without leaving the flow. A complete earn-and-burn experience for WooCommerce.
    52516. **Support** - Fast, live support available 24/7 across time zones. Get help with onboarding, best-practice playbooks, and optimization whenever you need it.
     52
     53= 1.5.5 =
     54- translation preset update and bugfix in form.
    5355
    5456= 1.5.3 =
    … …  
    133135
    134136– Added support for woocommerce datavisualization.
    135 
    136 
  • wolve-loyalty/trunk/wolve-loyalty.php

    r3478959 r3489159  
    66 * Author URI:        https://wolve.ai
    77 * Tested up to:      6.9.1
    8  * Version:           1.5.3
     8 * Version:           1.5.5
    99 * Text Domain:       wolve-loyalty
    1010 * License:           GPL-2.0-or-later
    … …  
    1717}
    1818
     19require_once plugin_dir_path(__FILE__) . 'includes/i18n/text-defaults.php';
    1920require_once plugin_dir_path(__FILE__) . 'includes/admin-page.php';
    2021require_once plugin_dir_path(__FILE__) . 'includes/member/member.php';
    … …  
    7475        $this->is_connected = get_option('wolve_loyalty_is_connected');
    7576
     77        // Run upgrade check for version-based migrations
     78        $this->maybe_run_upgrade();
     79
    7680        // Load plugin text domain for translations
    7781        add_action('plugins_loaded', array($this, 'load_textdomain'));
    … …  
    8791    public function load_textdomain() {
    8892        load_plugin_textdomain('wolve-loyalty', false, dirname(plugin_basename(__FILE__)) . '/languages/');
     93    }
     94
     95    /**
     96     * Run version-based upgrades. Populates new text fields added in later versions
     97     * using add_option() so existing customised values are never overwritten.
     98     */
     99    private function maybe_run_upgrade() {
     100        $current_version = '1.5.4';
     101        $stored_version  = get_option( 'wolve_loyalty_plugin_version', '0' );
     102
     103        if ( version_compare( $stored_version, $current_version, '>=' ) ) {
     104            return;
     105        }
     106
     107        // For existing clients (have API key), preserve the Norwegian tab label
     108        // they've been seeing, rather than switching to their locale's default.
     109        if ( get_option( 'wolve_loyalty_api_key', false ) ) {
     110            add_option( 'wolve_loyalty_myaccount_tab_label', 'Lojalitetsprogram' );
     111        }
     112
     113        // Populate any text defaults that don't exist yet (safe for existing values)
     114        $locale   = get_option( 'wolve_loyalty_default_locale', get_locale() );
     115        $defaults = Wolve_Loyalty_Text_Defaults::get_defaults( $locale );
     116
     117        foreach ( $defaults as $key => $value ) {
     118            if ( strpos( $key, 'signup_' ) === 0 ) {
     119                continue;
     120            }
     121            add_option( $key, $value );
     122        }
     123
     124        update_option( 'wolve_loyalty_plugin_version', $current_version );
    89125    }
    90126
    … …  
    470506
    471507
     508// ── Activation hook: populate locale-aware text defaults on fresh install ──
     509register_activation_hook( __FILE__, 'wolve_loyalty_activate' );
     510
     511function wolve_loyalty_activate() {
     512    $has_version = get_option( 'wolve_loyalty_plugin_version', false );
     513    $has_api_key = get_option( 'wolve_loyalty_api_key', false );
     514
     515    if ( ! $has_version && ! $has_api_key ) {
     516        // Fresh install — populate text defaults based on site locale
     517        $locale   = get_locale();
     518        $defaults = Wolve_Loyalty_Text_Defaults::get_defaults( $locale );
     519
     520        // Individual text options (add_option is a no-op if option already exists)
     521        foreach ( $defaults as $key => $value ) {
     522            // Skip signup_ prefixed keys — those go into the array option
     523            if ( strpos( $key, 'signup_' ) === 0 ) {
     524                continue;
     525            }
     526            add_option( $key, $value );
     527        }
     528
     529        // Signup defaults array
     530        $signup_defaults = Wolve_Loyalty_Text_Defaults::get_signup_defaults( $locale );
     531        add_option( 'wolve_loyalty_signup_defaults', $signup_defaults );
     532
     533        update_option( 'wolve_loyalty_default_locale', $locale );
     534    }
     535
     536    update_option( 'wolve_loyalty_plugin_version', '1.5.4' );
     537}
     538
    472539new Wolveloyalty();
    473540
Note: See TracChangeset for help on using the changeset viewer.