Plugin Directory

Changeset 3221428


Ignore:
Timestamp:
01/13/2025 09:06:21 AM (13 months ago)
Author:
ZanderZ
Message:

Update to version 6.3.0 from GitHub

Location:
recras
Files:
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • recras/tags/6.3.0/changelog.md

    r3217607 r3221428  
    11# Changelog
     2
     3## 6.3.0 (2025-01-13)
     4* The plugin now hides certain blocks/editor buttons, when they're not available in your Recras instance
     5* Plugin now requires WP 6.5 or higher
    26
    37## 6.2.3 (2025-01-06)
  • recras/tags/6.3.0/editor/plugin.js

    r2612483 r3221428  
    1616    });
    1717
    18     editor.addButton('recras-booking', {
    19         title: recras_l10n.online_booking,
    20         image: url + '/online-booking.svg',
    21         onclick: function() {
    22             tb_show(recras_l10n.online_booking, 'admin.php?page=form-booking');
    23         }
    24     });
     18    if (recras_l10n.showOnlineBooking === 'yes') {
     19        editor.addButton('recras-booking', {
     20            title: recras_l10n.online_booking,
     21            image: url + '/online-booking.svg',
     22            onclick: function() {
     23                tb_show(recras_l10n.online_booking, 'admin.php?page=form-booking');
     24            }
     25        });
     26    }
    2527
    2628    editor.addButton('recras-bookprocess', {
     
    4850    });
    4951
    50     editor.addButton('recras-voucher-sales', {
    51         title: recras_l10n.voucherSales,
    52         image: url + '/vouchers.svg',
    53         onclick: function() {
    54             tb_show(recras_l10n.product, 'admin.php?page=form-voucher-sales');
    55         }
    56     });
     52    if (recras_l10n.showVoucherSales === 'yes') {
     53        editor.addButton('recras-voucher-sales', {
     54            title: recras_l10n.voucherSales,
     55            image: url + '/vouchers.svg',
     56            onclick: function () {
     57                tb_show(recras_l10n.product, 'admin.php?page=form-voucher-sales');
     58            }
     59        });
     60    }
    5761
    5862    editor.addButton('recras-voucher-info', {
  • recras/tags/6.3.0/readme.txt

    r3217607 r3221428  
    33Tags: recras, recreation, reservation, booking, voucher
    44Tested up to: 6.7
    5 Stable tag: 6.2.3
     5Stable tag: 6.3.0
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7777
    7878== Changelog ==
     79
     80= 6.3.0 =
     81* The plugin now hides certain blocks/editor buttons, when they're not available in your Recras instance
     82* Plugin now requires WP 6.5 or higher
    7983
    8084= 6.2.3 =
  • recras/tags/6.3.0/recras-wordpress-plugin.php

    r3217607 r3221428  
    33Plugin Name: Recras WordPress Plugin
    44Plugin URI: https://www.recras.nl/
    5 Version: 6.2.3
     5Version: 6.3.0
    66Description: Easily integrate your Recras data into your own site
    7 Requires at least: 6.4
     7Requires at least: 6.5
    88Requires PHP: 7.4.0
    99Author: Recras
  • recras/tags/6.3.0/src/Gutenberg.php

    r2915644 r3221428  
    6969            ],
    7070        ];
     71
     72        if (!Settings::allowOnlinePackageBooking()) {
     73            unset($gutenbergBlocks['onlinebooking']);
     74        }
     75        if (!Settings::allowOldVoucherSales()) {
     76            unset($gutenbergBlocks['voucher-sales']);
     77        }
     78
    7179        foreach ($gutenbergBlocks as $key => $block) {
    7280            $handle = 'recras-gutenberg-' . $key;
  • recras/tags/6.3.0/src/OnlineBooking.php

    r3217607 r3221428  
    1313    public static function renderOnlineBooking($attributes): string
    1414    {
     15        if (!Settings::allowOnlinePackageBooking()) {
     16            error_log('Online booking of packages is integrated on your website, but is disabled in your Recras');
     17            return '';
     18        }
     19
    1520        if (is_string($attributes)) {
    1621            $attributes = [];
  • recras/tags/6.3.0/src/Plugin.php

    r3217607 r3221428  
    1717        $this->setBaseUrl();
    1818        $this->transients = new Transient();
     19
     20        // Needs to run before: Gutenberg::addBlocks, self::loadAdminScripts
     21        $this->checkOldSettings();
    1922
    2023        // Init Localisation
     
    9093            'edit_pages',
    9194            Settings::PAGE_CACHE,
    92             ['\Recras\Settings', 'clearCache']
     95            ['\Recras\Settings', 'clearCachePage']
    9396        );
    9497        add_submenu_page(
     
    122125     * Register our shortcodes
    123126     */
    124     public function addShortcodes(): void
     127    private function addShortcodes(): void
    125128    {
    126129        add_shortcode(Availability::SHORTCODE, [Availability::class, 'renderAvailability']);
     
    134137    }
    135138
     139    private function checkOldSettings(): void
     140    {
     141        $subdomain = get_option('recras_subdomain');
     142        if (!$subdomain) {
     143            return;
     144        }
     145
     146        $setting = $this->transients->get($subdomain . '_show_old_online_booking');
     147        if ($setting === false) {
     148            try {
     149                $setting = Http::get($subdomain, 'instellingen/allow_online_package_booking');
     150            } catch (\Exception $e) {
     151                return;
     152            }
     153            if (is_object($setting) && property_exists($setting, 'waarde')) {
     154                $this->transients->set($subdomain . '_show_old_online_booking', $setting->waarde, DAY_IN_SECONDS);
     155            }
     156        }
     157
     158        $setting = $this->transients->get($subdomain . '_show_old_voucher_sales');
     159        if ($setting === false) {
     160            try {
     161                $setting = Http::get($subdomain, 'instellingen/allow_old_vouchers_sales');
     162            } catch (\Exception $e) {
     163                return;
     164            }
     165            if (is_object($setting) && property_exists($setting, 'waarde')) {
     166                $this->transients->set($subdomain . '_show_old_voucher_sales', $setting->waarde, DAY_IN_SECONDS);
     167            }
     168        }
     169    }
     170
    136171
    137172    //TODO: change to :never when we support only PHP 8.1+
     
    143178        $errors += ContactForm::clearCache();
    144179        $errors += Products::clearCache();
     180        $errors += Settings::clearCache();
    145181        $errors += Vouchers::clearCache();
    146182
     
    174210    public function loadAdminScripts(): void
    175211    {
    176         wp_register_script('recras-admin', $this->baseUrl . '/js/admin.js', [], '4.0.0', true);
    177         wp_localize_script('recras-admin', 'recras_l10n', [
     212        $l10n = [
    178213            'contact_form' => __('Contact form', $this::TEXT_DOMAIN),
    179214            'no_connection' => __('Could not connect to your Recras', $this::TEXT_DOMAIN),
     
    183218            'package_availability' => __('Package availability', $this::TEXT_DOMAIN),
    184219            'product' => __('Product', $this::TEXT_DOMAIN),
     220            'showOnlineBooking' => 'yes',
     221            'showVoucherSales' => 'yes',
    185222            'voucherInfo' => __('Voucher info', $this::TEXT_DOMAIN),
    186223            'voucherSales' => __('Voucher sales', $this::TEXT_DOMAIN),
    187         ]);
     224        ];
     225
     226        if (!Settings::allowOnlinePackageBooking()) {
     227            $l10n['showOnlineBooking'] = 'no';
     228        }
     229        if (!Settings::allowOldVoucherSales()) {
     230            $l10n['showVoucherSales'] = 'no';
     231        }
     232
     233        wp_register_script('recras-admin', $this->baseUrl . '/js/admin.js', [], '6.3.0', true);
     234        wp_localize_script('recras-admin', 'recras_l10n', $l10n);
    188235        wp_enqueue_script('recras-admin');
    189236        wp_enqueue_style('recras-admin-style', $this->baseUrl . '/css/admin-style.css', [], '6.0.7');
  • recras/tags/6.3.0/src/Settings.php

    r2953659 r3221428  
    115115
    116116
    117     public static function clearCache(): void
     117    public static function allowOnlinePackageBooking(): bool
     118    {
     119        global $recrasPlugin;
     120
     121        $subdomain = get_option('recras_subdomain');
     122        if (!$subdomain) {
     123            return true;
     124        }
     125        $setting = $recrasPlugin->transients->get($subdomain . '_show_old_online_booking');
     126        // if getting the transient fails, we want to show the button to be sure, so comparing with 'no' is safest
     127        return ($setting === 'no') ? false : true;
     128    }
     129
     130
     131    public static function allowOldVoucherSales(): bool
     132    {
     133        global $recrasPlugin;
     134
     135        $subdomain = get_option('recras_subdomain');
     136        if (!$subdomain) {
     137            return true;
     138        }
     139        $setting = $recrasPlugin->transients->get($subdomain . '_show_old_voucher_sales');
     140        // if getting the transient fails, we want to show the button to be sure, so comparing with 'no' is safest
     141        return ($setting === 'no') ? false : true;
     142    }
     143
     144    /**
     145     * Clear voucher template cache (transients)
     146     */
     147    public static function clearCache(): int
     148    {
     149        global $recrasPlugin;
     150
     151        $subdomain = get_option('recras_subdomain');
     152        $errors = 0;
     153        if ($recrasPlugin->transients->get($subdomain . '_show_old_online_booking')) {
     154            $errors = $recrasPlugin->transients->delete($subdomain . '_show_old_online_booking');
     155        }
     156        if ($recrasPlugin->transients->get($subdomain . '_show_old_voucher_sales')) {
     157            $errors = $recrasPlugin->transients->delete($subdomain . '_show_old_voucher_sales');
     158        }
     159
     160        return $errors;
     161    }
     162
     163    /**
     164     * Admin page to clear the cache
     165     */
     166    public static function clearCachePage(): void
    118167    {
    119168        if (!current_user_can('edit_pages')) {
  • recras/tags/6.3.0/src/Transient.php

    r3121563 r3221428  
    2525    }
    2626
    27     public function set(string $name, $value): bool
     27    // HOUR_IN_SECONDS is defined by WordPress
     28    public function set(string $name, $value, int $expiration = HOUR_IN_SECONDS): bool
    2829    {
    29         return set_transient(self::BASE . $name, $value, HOUR_IN_SECONDS);
     30        return set_transient(self::BASE . $name, $value, $expiration);
    3031    }
    3132}
  • recras/tags/6.3.0/src/Vouchers.php

    r3217607 r3221428  
    6363    public static function renderVoucherSales($attributes): string
    6464    {
     65        if (!Settings::allowOldVoucherSales()) {
     66            error_log('The old method of selling vouchers is integrated on your website, but is disabled in your Recras');
     67            return '';
     68        }
     69
    6570        if (is_string($attributes)) {
    6671            $attributes = [];
  • recras/trunk/changelog.md

    r3217607 r3221428  
    11# Changelog
     2
     3## 6.3.0 (2025-01-13)
     4* The plugin now hides certain blocks/editor buttons, when they're not available in your Recras instance
     5* Plugin now requires WP 6.5 or higher
    26
    37## 6.2.3 (2025-01-06)
  • recras/trunk/editor/plugin.js

    r2612483 r3221428  
    1616    });
    1717
    18     editor.addButton('recras-booking', {
    19         title: recras_l10n.online_booking,
    20         image: url + '/online-booking.svg',
    21         onclick: function() {
    22             tb_show(recras_l10n.online_booking, 'admin.php?page=form-booking');
    23         }
    24     });
     18    if (recras_l10n.showOnlineBooking === 'yes') {
     19        editor.addButton('recras-booking', {
     20            title: recras_l10n.online_booking,
     21            image: url + '/online-booking.svg',
     22            onclick: function() {
     23                tb_show(recras_l10n.online_booking, 'admin.php?page=form-booking');
     24            }
     25        });
     26    }
    2527
    2628    editor.addButton('recras-bookprocess', {
     
    4850    });
    4951
    50     editor.addButton('recras-voucher-sales', {
    51         title: recras_l10n.voucherSales,
    52         image: url + '/vouchers.svg',
    53         onclick: function() {
    54             tb_show(recras_l10n.product, 'admin.php?page=form-voucher-sales');
    55         }
    56     });
     52    if (recras_l10n.showVoucherSales === 'yes') {
     53        editor.addButton('recras-voucher-sales', {
     54            title: recras_l10n.voucherSales,
     55            image: url + '/vouchers.svg',
     56            onclick: function () {
     57                tb_show(recras_l10n.product, 'admin.php?page=form-voucher-sales');
     58            }
     59        });
     60    }
    5761
    5862    editor.addButton('recras-voucher-info', {
  • recras/trunk/readme.txt

    r3217607 r3221428  
    33Tags: recras, recreation, reservation, booking, voucher
    44Tested up to: 6.7
    5 Stable tag: 6.2.3
     5Stable tag: 6.3.0
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7777
    7878== Changelog ==
     79
     80= 6.3.0 =
     81* The plugin now hides certain blocks/editor buttons, when they're not available in your Recras instance
     82* Plugin now requires WP 6.5 or higher
    7983
    8084= 6.2.3 =
  • recras/trunk/recras-wordpress-plugin.php

    r3217607 r3221428  
    33Plugin Name: Recras WordPress Plugin
    44Plugin URI: https://www.recras.nl/
    5 Version: 6.2.3
     5Version: 6.3.0
    66Description: Easily integrate your Recras data into your own site
    7 Requires at least: 6.4
     7Requires at least: 6.5
    88Requires PHP: 7.4.0
    99Author: Recras
  • recras/trunk/src/Gutenberg.php

    r2915644 r3221428  
    6969            ],
    7070        ];
     71
     72        if (!Settings::allowOnlinePackageBooking()) {
     73            unset($gutenbergBlocks['onlinebooking']);
     74        }
     75        if (!Settings::allowOldVoucherSales()) {
     76            unset($gutenbergBlocks['voucher-sales']);
     77        }
     78
    7179        foreach ($gutenbergBlocks as $key => $block) {
    7280            $handle = 'recras-gutenberg-' . $key;
  • recras/trunk/src/OnlineBooking.php

    r3217607 r3221428  
    1313    public static function renderOnlineBooking($attributes): string
    1414    {
     15        if (!Settings::allowOnlinePackageBooking()) {
     16            error_log('Online booking of packages is integrated on your website, but is disabled in your Recras');
     17            return '';
     18        }
     19
    1520        if (is_string($attributes)) {
    1621            $attributes = [];
  • recras/trunk/src/Plugin.php

    r3217607 r3221428  
    1717        $this->setBaseUrl();
    1818        $this->transients = new Transient();
     19
     20        // Needs to run before: Gutenberg::addBlocks, self::loadAdminScripts
     21        $this->checkOldSettings();
    1922
    2023        // Init Localisation
     
    9093            'edit_pages',
    9194            Settings::PAGE_CACHE,
    92             ['\Recras\Settings', 'clearCache']
     95            ['\Recras\Settings', 'clearCachePage']
    9396        );
    9497        add_submenu_page(
     
    122125     * Register our shortcodes
    123126     */
    124     public function addShortcodes(): void
     127    private function addShortcodes(): void
    125128    {
    126129        add_shortcode(Availability::SHORTCODE, [Availability::class, 'renderAvailability']);
     
    134137    }
    135138
     139    private function checkOldSettings(): void
     140    {
     141        $subdomain = get_option('recras_subdomain');
     142        if (!$subdomain) {
     143            return;
     144        }
     145
     146        $setting = $this->transients->get($subdomain . '_show_old_online_booking');
     147        if ($setting === false) {
     148            try {
     149                $setting = Http::get($subdomain, 'instellingen/allow_online_package_booking');
     150            } catch (\Exception $e) {
     151                return;
     152            }
     153            if (is_object($setting) && property_exists($setting, 'waarde')) {
     154                $this->transients->set($subdomain . '_show_old_online_booking', $setting->waarde, DAY_IN_SECONDS);
     155            }
     156        }
     157
     158        $setting = $this->transients->get($subdomain . '_show_old_voucher_sales');
     159        if ($setting === false) {
     160            try {
     161                $setting = Http::get($subdomain, 'instellingen/allow_old_vouchers_sales');
     162            } catch (\Exception $e) {
     163                return;
     164            }
     165            if (is_object($setting) && property_exists($setting, 'waarde')) {
     166                $this->transients->set($subdomain . '_show_old_voucher_sales', $setting->waarde, DAY_IN_SECONDS);
     167            }
     168        }
     169    }
     170
    136171
    137172    //TODO: change to :never when we support only PHP 8.1+
     
    143178        $errors += ContactForm::clearCache();
    144179        $errors += Products::clearCache();
     180        $errors += Settings::clearCache();
    145181        $errors += Vouchers::clearCache();
    146182
     
    174210    public function loadAdminScripts(): void
    175211    {
    176         wp_register_script('recras-admin', $this->baseUrl . '/js/admin.js', [], '4.0.0', true);
    177         wp_localize_script('recras-admin', 'recras_l10n', [
     212        $l10n = [
    178213            'contact_form' => __('Contact form', $this::TEXT_DOMAIN),
    179214            'no_connection' => __('Could not connect to your Recras', $this::TEXT_DOMAIN),
     
    183218            'package_availability' => __('Package availability', $this::TEXT_DOMAIN),
    184219            'product' => __('Product', $this::TEXT_DOMAIN),
     220            'showOnlineBooking' => 'yes',
     221            'showVoucherSales' => 'yes',
    185222            'voucherInfo' => __('Voucher info', $this::TEXT_DOMAIN),
    186223            'voucherSales' => __('Voucher sales', $this::TEXT_DOMAIN),
    187         ]);
     224        ];
     225
     226        if (!Settings::allowOnlinePackageBooking()) {
     227            $l10n['showOnlineBooking'] = 'no';
     228        }
     229        if (!Settings::allowOldVoucherSales()) {
     230            $l10n['showVoucherSales'] = 'no';
     231        }
     232
     233        wp_register_script('recras-admin', $this->baseUrl . '/js/admin.js', [], '6.3.0', true);
     234        wp_localize_script('recras-admin', 'recras_l10n', $l10n);
    188235        wp_enqueue_script('recras-admin');
    189236        wp_enqueue_style('recras-admin-style', $this->baseUrl . '/css/admin-style.css', [], '6.0.7');
  • recras/trunk/src/Settings.php

    r2953659 r3221428  
    115115
    116116
    117     public static function clearCache(): void
     117    public static function allowOnlinePackageBooking(): bool
     118    {
     119        global $recrasPlugin;
     120
     121        $subdomain = get_option('recras_subdomain');
     122        if (!$subdomain) {
     123            return true;
     124        }
     125        $setting = $recrasPlugin->transients->get($subdomain . '_show_old_online_booking');
     126        // if getting the transient fails, we want to show the button to be sure, so comparing with 'no' is safest
     127        return ($setting === 'no') ? false : true;
     128    }
     129
     130
     131    public static function allowOldVoucherSales(): bool
     132    {
     133        global $recrasPlugin;
     134
     135        $subdomain = get_option('recras_subdomain');
     136        if (!$subdomain) {
     137            return true;
     138        }
     139        $setting = $recrasPlugin->transients->get($subdomain . '_show_old_voucher_sales');
     140        // if getting the transient fails, we want to show the button to be sure, so comparing with 'no' is safest
     141        return ($setting === 'no') ? false : true;
     142    }
     143
     144    /**
     145     * Clear voucher template cache (transients)
     146     */
     147    public static function clearCache(): int
     148    {
     149        global $recrasPlugin;
     150
     151        $subdomain = get_option('recras_subdomain');
     152        $errors = 0;
     153        if ($recrasPlugin->transients->get($subdomain . '_show_old_online_booking')) {
     154            $errors = $recrasPlugin->transients->delete($subdomain . '_show_old_online_booking');
     155        }
     156        if ($recrasPlugin->transients->get($subdomain . '_show_old_voucher_sales')) {
     157            $errors = $recrasPlugin->transients->delete($subdomain . '_show_old_voucher_sales');
     158        }
     159
     160        return $errors;
     161    }
     162
     163    /**
     164     * Admin page to clear the cache
     165     */
     166    public static function clearCachePage(): void
    118167    {
    119168        if (!current_user_can('edit_pages')) {
  • recras/trunk/src/Transient.php

    r3121563 r3221428  
    2525    }
    2626
    27     public function set(string $name, $value): bool
     27    // HOUR_IN_SECONDS is defined by WordPress
     28    public function set(string $name, $value, int $expiration = HOUR_IN_SECONDS): bool
    2829    {
    29         return set_transient(self::BASE . $name, $value, HOUR_IN_SECONDS);
     30        return set_transient(self::BASE . $name, $value, $expiration);
    3031    }
    3132}
  • recras/trunk/src/Vouchers.php

    r3217607 r3221428  
    6363    public static function renderVoucherSales($attributes): string
    6464    {
     65        if (!Settings::allowOldVoucherSales()) {
     66            error_log('The old method of selling vouchers is integrated on your website, but is disabled in your Recras');
     67            return '';
     68        }
     69
    6570        if (is_string($attributes)) {
    6671            $attributes = [];
Note: See TracChangeset for help on using the changeset viewer.