Plugin Directory

Changeset 3639204


Ignore:
Timestamp:
08/09/2026 09:30:54 AM (2 months ago)
Author:
wizupapp
Message:

Release version 1.0.2

Location:
wizupapp
Files:
2 added
6 edited
14 copied

Legend:

Unmodified
Added
Removed
  • wizupapp/tags/1.0.2/includes/class-wizup-admin.php

    r3612235 r3639204  
    357357                if (isset($_POST['cwep_access_token']) && current_user_can('manage_options')) {
    358358                    $token = sanitize_text_field(wp_unslash($_POST['cwep_access_token']));
    359                     update_option('wizup_access_token', $token);
     359                    // Only update if it is not the masked placeholder value
     360                    if (!preg_match('/^\*+$/', $token)) {
     361                        if (empty($token)) {
     362                            delete_option('wizup_access_token');
     363                        } else {
     364                            update_option('wizup_access_token', $token);
     365                        }
     366                    }
    360367                    echo '<div class="updated"><p>' . esc_html__('Access token saved successfully.', 'wizupapp') . '</p></div>';
    361368                }
    … …  
    370377            $nonce = sanitize_text_field(wp_unslash($_POST['cwep_submit_whatsapp_button_nonce']));
    371378            if (wp_verify_nonce($nonce, 'cwep_submit_whatsapp_button')) {
    372                 if (current_user_can('manage_options') && isset($_POST['wizup_show_product_whatsapp_button'])) {
    373                     $isChecked = sanitize_text_field(wp_unslash($_POST['wizup_show_product_whatsapp_button']));
    374                     update_option('wizup_show_product_whatsapp_button', $isChecked);
     379                if (current_user_can('manage_options')) {
     380                    update_option('wizup_show_product_whatsapp_button', isset($_POST['wizup_show_product_whatsapp_button']) ? 1 : 0);
    375381                }
    376382                if (isset($_POST['cwep_whatsapp_button_message_product']) && isset($_POST['cwep_whatsapp_button_message_general'])) {
  • wizupapp/tags/1.0.2/includes/class-wizup-api.php

    r3544452 r3639204  
    2424    public function __construct()
    2525    {
    26         // Register actions to fetch templates when token is saved
     26        // Register actions to fetch templates when token is saved.
     27        // update_option_* only fires when the option already exists and its
     28        // value changes, so the very first save (add_option_*) needs its own hook.
     29        add_action('add_option_wizup_access_token', array($this, 'fetch_templates_on_add'), 10, 2);
    2730        add_action('update_option_wizup_access_token', array($this, 'fetch_templates'), 10, 2);
     31    }
     32
     33    /**
     34     * Fetch templates the first time the access token option is created.
     35     *
     36     * @param string $option Option name.
     37     * @param string $value  Newly saved access token value.
     38     * @return void
     39     */
     40    public function fetch_templates_on_add($option, $value)
     41    {
     42        $this->fetch_templates(null, $value);
    2843    }
    2944
    … …  
    4459            'headers' => [
    4560                'Authorization' => 'Bearer ' . $new_value,
    46                 'Content-Type'  => 'application/json',
     61                'Accept'        => 'application/json',
    4762            ],
     63            'timeout' => 15,
    4864        ]);
    4965
    50         if (!is_wp_error($response)) {
    51             $body = wp_remote_retrieve_body($response);
    52             update_option('wizup_templates', json_decode($body, true));
     66        if (is_wp_error($response)) {
     67            error_log('Wizup: failed to fetch templates - ' . $response->get_error_message());
     68            return;
    5369        }
     70
     71        $status_code = wp_remote_retrieve_response_code($response);
     72        $body = wp_remote_retrieve_body($response);
     73
     74        if ($status_code !== 200) {
     75            error_log(sprintf('Wizup: templates API returned HTTP %d - %s', $status_code, $body));
     76            return;
     77        }
     78
     79        $templates = json_decode($body, true);
     80
     81        if (json_last_error() !== JSON_ERROR_NONE) {
     82            error_log('Wizup: failed to decode templates response - ' . json_last_error_msg());
     83            return;
     84        }
     85
     86        update_option('wizup_templates', $templates);
    5487    }
    5588
    … …  
    6699        $access_token = get_option('wizup_access_token');
    67100        $templates = get_option('wizup_templates');
    68         $template_language = $this->get_template_language_code(json_decode($templates, true), $template_name);
     101        $templates = is_array($templates) ? $templates : (array) json_decode((string) $templates, true);
     102        $template_language = $this->get_template_language_code($templates, $template_name);
    69103
    70104        if (empty($access_token)) {
  • wizupapp/tags/1.0.2/readme.txt

    r3612235 r3639204  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    … …  
    6464== Changelog ==
    6565= 1.0.1 =
     66* Updated Wizup Template APIs
     67* Fixed Whatsapp Embedded Button
     68
     69= 1.0.1 =
    6670* Add Webhook settings
    6771* Auto WooCommerce order sync with Webhook
  • wizupapp/tags/1.0.2/views/admin-settings.php

    r3612235 r3639204  
    2929                    <th scope="row"><?php esc_html_e('Access Token', 'wizupapp'); ?></th>
    3030                    <td>
    31                         <input type="text" name="cwep_access_token" id="wizup_access_token"
    32                             value="<?php echo esc_attr(get_option('wizup_access_token')); ?>" class="regular-text" />
     31                        <?php
     32                        $saved_access_token = get_option('wizup_access_token');
     33                        $display_access_token = !empty($saved_access_token) ? str_repeat('*', 32) : '';
     34                        ?>
     35                        <input type="password" name="cwep_access_token" id="wizup_access_token"
     36                            value="<?php echo esc_attr($display_access_token); ?>"
     37                            class="regular-text" autocomplete="new-password" />
    3338                        <p class="description">
    3439                            <?php esc_html_e('Get this token from your Wizup dashboard.', 'wizupapp'); ?>
  • wizupapp/tags/1.0.2/wizupapp.php

    r3612235 r3639204  
    55 * Plugin URI: https://wizup.app/woocommerce-plugin
    66 * Description: Integrates WooCommerce with wizup.app API to send WhatsApp messages for order notifications, status updates, abandoned carts, and more.
    7  * Version: 1.0.1
     7 * Version: 1.0.2
    88 * Author: wizupapp
    99 * Author URI: https://wizup.app
  • wizupapp/trunk/includes/class-wizup-admin.php

    r3612235 r3639204  
    357357                if (isset($_POST['cwep_access_token']) && current_user_can('manage_options')) {
    358358                    $token = sanitize_text_field(wp_unslash($_POST['cwep_access_token']));
    359                     update_option('wizup_access_token', $token);
     359                    // Only update if it is not the masked placeholder value
     360                    if (!preg_match('/^\*+$/', $token)) {
     361                        if (empty($token)) {
     362                            delete_option('wizup_access_token');
     363                        } else {
     364                            update_option('wizup_access_token', $token);
     365                        }
     366                    }
    360367                    echo '<div class="updated"><p>' . esc_html__('Access token saved successfully.', 'wizupapp') . '</p></div>';
    361368                }
    … …  
    370377            $nonce = sanitize_text_field(wp_unslash($_POST['cwep_submit_whatsapp_button_nonce']));
    371378            if (wp_verify_nonce($nonce, 'cwep_submit_whatsapp_button')) {
    372                 if (current_user_can('manage_options') && isset($_POST['wizup_show_product_whatsapp_button'])) {
    373                     $isChecked = sanitize_text_field(wp_unslash($_POST['wizup_show_product_whatsapp_button']));
    374                     update_option('wizup_show_product_whatsapp_button', $isChecked);
     379                if (current_user_can('manage_options')) {
     380                    update_option('wizup_show_product_whatsapp_button', isset($_POST['wizup_show_product_whatsapp_button']) ? 1 : 0);
    375381                }
    376382                if (isset($_POST['cwep_whatsapp_button_message_product']) && isset($_POST['cwep_whatsapp_button_message_general'])) {
  • wizupapp/trunk/includes/class-wizup-api.php

    r3544452 r3639204  
    2424    public function __construct()
    2525    {
    26         // Register actions to fetch templates when token is saved
     26        // Register actions to fetch templates when token is saved.
     27        // update_option_* only fires when the option already exists and its
     28        // value changes, so the very first save (add_option_*) needs its own hook.
     29        add_action('add_option_wizup_access_token', array($this, 'fetch_templates_on_add'), 10, 2);
    2730        add_action('update_option_wizup_access_token', array($this, 'fetch_templates'), 10, 2);
     31    }
     32
     33    /**
     34     * Fetch templates the first time the access token option is created.
     35     *
     36     * @param string $option Option name.
     37     * @param string $value  Newly saved access token value.
     38     * @return void
     39     */
     40    public function fetch_templates_on_add($option, $value)
     41    {
     42        $this->fetch_templates(null, $value);
    2843    }
    2944
    … …  
    4459            'headers' => [
    4560                'Authorization' => 'Bearer ' . $new_value,
    46                 'Content-Type'  => 'application/json',
     61                'Accept'        => 'application/json',
    4762            ],
     63            'timeout' => 15,
    4864        ]);
    4965
    50         if (!is_wp_error($response)) {
    51             $body = wp_remote_retrieve_body($response);
    52             update_option('wizup_templates', json_decode($body, true));
     66        if (is_wp_error($response)) {
     67            error_log('Wizup: failed to fetch templates - ' . $response->get_error_message());
     68            return;
    5369        }
     70
     71        $status_code = wp_remote_retrieve_response_code($response);
     72        $body = wp_remote_retrieve_body($response);
     73
     74        if ($status_code !== 200) {
     75            error_log(sprintf('Wizup: templates API returned HTTP %d - %s', $status_code, $body));
     76            return;
     77        }
     78
     79        $templates = json_decode($body, true);
     80
     81        if (json_last_error() !== JSON_ERROR_NONE) {
     82            error_log('Wizup: failed to decode templates response - ' . json_last_error_msg());
     83            return;
     84        }
     85
     86        update_option('wizup_templates', $templates);
    5487    }
    5588
    … …  
    6699        $access_token = get_option('wizup_access_token');
    67100        $templates = get_option('wizup_templates');
    68         $template_language = $this->get_template_language_code(json_decode($templates, true), $template_name);
     101        $templates = is_array($templates) ? $templates : (array) json_decode((string) $templates, true);
     102        $template_language = $this->get_template_language_code($templates, $template_name);
    69103
    70104        if (empty($access_token)) {
  • wizupapp/trunk/readme.txt

    r3612235 r3639204  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.1
     7Stable tag: 1.0.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    … …  
    6464== Changelog ==
    6565= 1.0.1 =
     66* Updated Wizup Template APIs
     67* Fixed Whatsapp Embedded Button
     68
     69= 1.0.1 =
    6670* Add Webhook settings
    6771* Auto WooCommerce order sync with Webhook
  • wizupapp/trunk/views/admin-settings.php

    r3612235 r3639204  
    2929                    <th scope="row"><?php esc_html_e('Access Token', 'wizupapp'); ?></th>
    3030                    <td>
    31                         <input type="text" name="cwep_access_token" id="wizup_access_token"
    32                             value="<?php echo esc_attr(get_option('wizup_access_token')); ?>" class="regular-text" />
     31                        <?php
     32                        $saved_access_token = get_option('wizup_access_token');
     33                        $display_access_token = !empty($saved_access_token) ? str_repeat('*', 32) : '';
     34                        ?>
     35                        <input type="password" name="cwep_access_token" id="wizup_access_token"
     36                            value="<?php echo esc_attr($display_access_token); ?>"
     37                            class="regular-text" autocomplete="new-password" />
    3338                        <p class="description">
    3439                            <?php esc_html_e('Get this token from your Wizup dashboard.', 'wizupapp'); ?>
  • wizupapp/trunk/wizupapp.php

    r3612235 r3639204  
    55 * Plugin URI: https://wizup.app/woocommerce-plugin
    66 * Description: Integrates WooCommerce with wizup.app API to send WhatsApp messages for order notifications, status updates, abandoned carts, and more.
    7  * Version: 1.0.1
     7 * Version: 1.0.2
    88 * Author: wizupapp
    99 * Author URI: https://wizup.app
Note: See TracChangeset for help on using the changeset viewer.