Plugin Directory

Changeset 3506160


Ignore:
Timestamp:
04/14/2026 02:58:08 PM (6 months ago)
Author:
gastrosite
Message:

Release 1.0.1: WordPress 6.9 compatibility, improved settings validation, extended shortcode attributes

Location:
gastro-site-table-reservation
Files:
43 added
4 edited

Legend:

Unmodified
Added
Removed
  • gastro-site-table-reservation/trunk/admin/settings.php

    r3267180 r3506160  
    11<?php
    22    if (!defined('ABSPATH')) exit;
     3
     4    function gastrosite_reservation_get_supported_languages() {
     5        return [
     6            'ar' => 'العربية',
     7            'bg' => 'Български',
     8            'cs' => 'Čeština',
     9            'da' => 'Dansk',
     10            'de' => 'Deutsch',
     11            'el' => 'Ελληνικά',
     12            'en' => 'English',
     13            'es' => 'Español',
     14            'et' => 'Eesti',
     15            'fi' => 'Suomi',
     16            'fr' => 'Français',
     17            'he' => 'עברית',
     18            'hi' => 'हिन्दी',
     19            'hr' => 'Hrvatski',
     20            'hu' => 'Magyar',
     21            'id' => 'Bahasa Indonesia',
     22            'it' => 'Italiano',
     23            'ja' => '日本語',
     24            'ko' => '한국어',
     25            'lt' => 'Lietuvių',
     26            'lv' => 'Latviešu',
     27            'ms' => 'Bahasa Melayu',
     28            'nl' => 'Nederlands',
     29            'no' => 'Norsk',
     30            'pl' => 'Polski',
     31            'pt' => 'Português',
     32            'ro' => 'Română',
     33            'ru' => 'Русский',
     34            'sk' => 'Slovenčina',
     35            'sl' => 'Slovenščina',
     36            'sv' => 'Svenska',
     37            'sw' => 'Kiswahili',
     38            'th' => 'ไทย',
     39            'tr' => 'Türkçe',
     40            'vi' => 'Tiếng Việt',
     41            'zh' => '中文',
     42        ];
     43    }
     44
     45    function gastrosite_reservation_sanitize_language($value) {
     46        $value = sanitize_text_field($value);
     47        $languages = gastrosite_reservation_get_supported_languages();
     48        return array_key_exists($value, $languages) ? $value : '';
     49    }
     50
     51    function gastrosite_reservation_sanitize_button_size($value) {
     52        $value = sanitize_text_field($value);
     53        return in_array($value, ['sm', 'lg'], true) ? $value : '';
     54    }
     55
     56    function gastrosite_reservation_sanitize_button_color($value) {
     57        $value = sanitize_text_field($value);
     58        return in_array($value, ['white', 'gray', 'primary'], true) ? $value : '';
     59    }
     60
     61    function gastrosite_reservation_sanitize_button_position($value) {
     62        $value = sanitize_text_field($value);
     63        return in_array($value, ['left', 'right'], true) ? $value : '';
     64    }
    365
    466    function gastrosite_reservation_add_admin_menu() {
    … …  
    1577    function gastrosite_reservation_register_settings() {
    1678        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_id', ['sanitize_callback' => 'sanitize_text_field']);
    17         register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_language', ['sanitize_callback' => 'sanitize_text_field']);
     79        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_language', ['sanitize_callback' => 'gastrosite_reservation_sanitize_language']);
    1880        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_show_header', ['sanitize_callback' => 'absint']);
    1981        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_color', ['sanitize_callback' => 'sanitize_hex_color']);
    2082        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_button_text', ['sanitize_callback' => 'sanitize_text_field']);
    21         register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_button_size', ['sanitize_callback' => 'sanitize_text_field']);
    22         register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_button_color', ['sanitize_callback' => 'sanitize_text_field']);
     83        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_button_size', ['sanitize_callback' => 'gastrosite_reservation_sanitize_button_size']);
     84        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_button_color', ['sanitize_callback' => 'gastrosite_reservation_sanitize_button_color']);
    2385        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_z_index', ['sanitize_callback' => 'absint']);
    24         register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_button_position', ['sanitize_callback' => 'sanitize_text_field']);
     86        register_setting('gastrosite_reservation_settings_group', 'gastrosite_reservation_button_position', ['sanitize_callback' => 'gastrosite_reservation_sanitize_button_position']);
    2587    }
    2688    add_action('admin_init', 'gastrosite_reservation_register_settings');
    … …  
    65127                                        <option value=""><?php esc_html_e('Use WordPress language', 'gastro-site-table-reservation'); ?></option>
    66128                                        <?php
    67                                         $languages = [
    68                                             'cs' => 'Čeština',
    69                                             'da' => 'Dansk',
    70                                             'de' => 'Deutsch',
    71                                             'el' => 'Ελληνικά',
    72                                             'en' => 'English',
    73                                             'es' => 'Español',
    74                                             'fi' => 'Suomi',
    75                                             'fr' => 'Français',
    76                                             'it' => 'Italiano',
    77                                             'nl' => 'Nederlands',
    78                                             'no' => 'Norsk',
    79                                             'pl' => 'Polski',
    80                                             'ro' => 'Română',
    81                                             'sk' => 'Slovenčina',
    82                                             'sv' => 'Svenska',
    83                                             'tr' => 'Türkçe',
    84                                         ];
     129                                        $languages = gastrosite_reservation_get_supported_languages();
    85130
    86131                                        $selected_lang = get_option('gastrosite_reservation_language', '');
    … …  
    170215                    <p><?php esc_html_e('You can also embed the widget manually using the following shortcode:', 'gastro-site-table-reservation'); ?></p>
    171216                    <code>[book_a_table]</code>
    172                     <p><?php esc_html_e('Optional attributes:', 'gastro-site-table-reservation'); ?> <code>lang</code>, <code>header</code>, <code>primary-color</code></p>
     217                    <p><?php esc_html_e('Optional attributes:', 'gastro-site-table-reservation'); ?> <code>lang</code>, <code>header</code>, <code>primary-color</code>, <code>render-method</code>, <code>button-label</code>, <code>button-size</code>, <code>button-color</code>, <code>button-position</code>, <code>z-index</code></p>
    173218                    <p><em><?php esc_html_e('The ID is always taken from the plugin settings.', 'gastro-site-table-reservation'); ?></em></p>
    174219                    <p><strong><?php esc_html_e('Example:', 'gastro-site-table-reservation'); ?></strong></p>
    175                     <code>[book_a_table lang="de" header="true" primary-color="#E74E60"]</code>
     220                    <code>[book_a_table lang="de" header="true" primary-color="#E74E60" render-method="button" button-label="Reserve table online" button-size="lg" button-color="primary" button-position="right" z-index="1000"]</code>
    176221                </div>
    177222            </div>
  • gastro-site-table-reservation/trunk/gastro-site-table-reservation.php

    r3267180 r3506160  
    33     * Plugin Name: Gastro.site Table Reservation
    44     * Description: Integrate the Gastro.site Table Reservation Tool in your Website.
    5      * Version:     1.0.0
     5     * Version:     1.0.1
    66     * Author:      Gastro.site
    77     * Author URI:  https://www.gastro.site
    … …  
    1717    define('GASTROSITE_RESERVATION_PLUGIN_DIR', plugin_dir_path(__FILE__));
    1818    define('GASTROSITE_RESERVATION_PLUGIN_URL', plugin_dir_url(__FILE__));
    19     define('GASTROSITE_RESERVATION_PLUGIN_VERSION', '1.0.0');
     19    define('GASTROSITE_RESERVATION_PLUGIN_VERSION', '1.0.1');
    2020   
    2121    function gastrosite_reservation_plugin_action_links($links) {
  • gastro-site-table-reservation/trunk/includes/frontend.php

    r3267180 r3506160  
    33
    44    $GLOBALS['gastrosite_reservation_shortcode_used'] = false;
     5
     6    function gastrosite_reservation_filter_attribute_value($value, $allowed_values) {
     7        $value = sanitize_text_field((string) $value);
     8        return in_array($value, $allowed_values, true) ? $value : null;
     9    }
     10
     11    function gastrosite_reservation_normalize_header_attribute($value) {
     12        if (is_bool($value)) {
     13            return $value ? 'true' : null;
     14        }
     15
     16        $value = strtolower(sanitize_text_field((string) $value));
     17        if (in_array($value, ['1', 'true', 'yes', 'on'], true)) {
     18            return 'true';
     19        }
     20
     21        return null;
     22    }
    523
    624    function gastrosite_reservation_enqueue_script() {
    … …  
    3048        $primary_color   = get_option('gastrosite_reservation_color');
    3149        $button_label    = get_option('gastrosite_reservation_button_text');
    32         $button_size     = get_option('gastrosite_reservation_button_size');
    33         $button_color    = get_option('gastrosite_reservation_button_color');
     50        $button_size     = gastrosite_reservation_filter_attribute_value(get_option('gastrosite_reservation_button_size'), ['sm', 'lg']);
     51        $button_color    = gastrosite_reservation_filter_attribute_value(get_option('gastrosite_reservation_button_color'), ['white', 'gray', 'primary']);
    3452        $z_index         = get_option('gastrosite_reservation_z_index');
    35         $button_position = get_option('gastrosite_reservation_button_position');
     53        $button_position = gastrosite_reservation_filter_attribute_value(get_option('gastrosite_reservation_button_position'), ['left', 'right']);
    3654   
    3755        $output = '<book-a-table id="BAT' . esc_attr($id) . '" render-method="button"';
    … …  
    7795        $settings_show_header   = get_option('gastrosite_reservation_show_header') ? 'true' : null;
    7896        $settings_primary_color = get_option('gastrosite_reservation_color');
     97        $settings_button_label  = get_option('gastrosite_reservation_button_text');
     98        $settings_button_size   = gastrosite_reservation_filter_attribute_value(get_option('gastrosite_reservation_button_size'), ['sm', 'lg']);
     99        $settings_button_color  = gastrosite_reservation_filter_attribute_value(get_option('gastrosite_reservation_button_color'), ['white', 'gray', 'primary']);
     100        $settings_z_index       = get_option('gastrosite_reservation_z_index');
     101        $settings_button_position = gastrosite_reservation_filter_attribute_value(get_option('gastrosite_reservation_button_position'), ['left', 'right']);
    79102   
    80103        if (empty($settings_lang)) {
    … …  
    87110            'header'         => $settings_show_header,
    88111            'primary-color'  => $settings_primary_color,
     112            'render-method'  => 'inline',
     113            'button-label'   => $settings_button_label,
     114            'button-size'    => $settings_button_size,
     115            'button-color'   => $settings_button_color,
     116            'button-position' => $settings_button_position,
     117            'z-index'        => $settings_z_index,
    89118        ], $atts, 'book_a_table');
     119
     120        $allowed_atts['lang'] = sanitize_text_field((string) $allowed_atts['lang']);
     121        $allowed_atts['header'] = gastrosite_reservation_normalize_header_attribute($allowed_atts['header']);
     122        $allowed_atts['primary-color'] = sanitize_hex_color((string) $allowed_atts['primary-color']);
     123        $allowed_atts['render-method'] = gastrosite_reservation_filter_attribute_value($allowed_atts['render-method'], ['inline', 'button']);
     124        $allowed_atts['button-label'] = sanitize_text_field((string) $allowed_atts['button-label']);
     125        $allowed_atts['button-size'] = gastrosite_reservation_filter_attribute_value($allowed_atts['button-size'], ['sm', 'lg']);
     126        $allowed_atts['button-color'] = gastrosite_reservation_filter_attribute_value($allowed_atts['button-color'], ['white', 'gray', 'primary']);
     127        $allowed_atts['button-position'] = gastrosite_reservation_filter_attribute_value($allowed_atts['button-position'], ['left', 'right']);
     128        $allowed_atts['z-index'] = absint($allowed_atts['z-index']);
    90129   
    91130        if (empty($settings_id)) {
  • gastro-site-table-reservation/trunk/readme.txt

    r3267180 r3506160  
    33Tags: table booking, reservations, restaurant, tischreservierung, gastro.site
    44Requires at least: 5.5
    5 Tested up to: 6.7
     5Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.0.0
     7Stable tag: 1.0.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    2424
    2525= Does this plugin work with all WordPress themes? =
    26 Yes, as long as your theme supports the `wp_head` hook.
     26Yes, as long as your theme supports either the `wp_body_open` or the `wp_footer` hook.
    2727
    2828= How do I embed the booking widget manually? =
    … …  
    3535- `header`: Show header above the widget (`true` or `false`). Defaults to plugin setting.
    3636- `primary-color`: Primary color for the widget in hex format (e.g. `#E74E60`). Defaults to plugin setting.
     37- `render-method`: Display mode (`inline` or `button`). Defaults to `inline`.
     38- `button-label`: Text shown on the booking button.
     39- `button-size`: Button size (`sm` or `lg`).
     40- `button-color`: Button color (`white`, `gray`, or `primary`).
     41- `button-position`: Button position (`left` or `right`).
     42- `z-index`: Numeric z-index value.
    3743
    3844Example:
    39 `[book_a_table lang="de" header="true" primary-color="#E74E60"]`
     45`[book_a_table lang="de" header="true" primary-color="#E74E60" render-method="button" button-label="Reserve table online" button-size="lg" button-color="primary" button-position="right" z-index="1000"]`
    4046
    4147The ID is always taken from the plugin settings and cannot be set via the shortcode.
    4248
    4349== Changelog ==
     50= 1.0.1 =
     51* Compatibility update for WordPress 6.9
     52* Extended shortcode attributes for advanced widget configuration
     53* Improved settings validation for integration options
     54
    4455= 1.0.0 =
    4556* Initial release
Note: See TracChangeset for help on using the changeset viewer.