Plugin Directory

Changeset 3841382


Ignore:
Timestamp:
12/03/2026 12:31:58 AM (less than one hour ago)
Author:
reachzone
Message:

Release 0.3.0

Location:
reachzone
Files:
22 added
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • reachzone/tags/0.3.0/assets/css/checker.css

    r3785752 r3841382  
    1313.reachzone-result--out p { border-color: #b32d2e; }
    1414.reachzone-result--unknown p, .reachzone-result--error p { border-color: #996800; }
     15/* Optional accent colour (block / shortcode "accent"): only set when the shop chose one. */
     16.reachzone-checker--accent .reachzone-button { background: var(--reachzone-accent); border-color: var(--reachzone-accent); color: var(--reachzone-accent-text); }
     17.reachzone-checker--accent .reachzone-input:focus { border-color: var(--reachzone-accent); outline-color: var(--reachzone-accent); }
  • reachzone/tags/0.3.0/blocks/checker/block.json

    r3785752 r3841382  
    1111        "textdomain": "reachzone",
    1212        "attributes": {
    13                 "title": { "type": "string", "default": "" }
     13                "title": { "type": "string", "default": "" },
     14                "buttonText": { "type": "string", "default": "" },
     15                "accentColor": { "type": "string", "default": "" }
    1416        },
    1517        "supports": { "html": false, "align": [ "wide", "full" ] },
  • reachzone/tags/0.3.0/blocks/checker/editor.js

    r3785752 r3841382  
    77        var PanelBody = wp.components.PanelBody;
    88        var TextControl = wp.components.TextControl;
     9        var BaseControl = wp.components.BaseControl;
     10        var ColorPalette = wp.components.ColorPalette;
     11        // A few neutral choices; the picker also takes any colour. The shortcode attribute "accent" takes the same #rrggbb value.
     12        var ACCENT_COLORS = [
     13                { name: 'Navy', color: '#2b4c7e' },
     14                { name: 'Green', color: '#1a7f37' },
     15                { name: 'Red', color: '#b32d2e' },
     16                { name: 'Marigold', color: '#f4b942' },
     17                { name: 'Ink', color: '#1e1e1e' }
     18        ];
    919
    1020        wp.blocks.registerBlockType( 'reachzone/checker', {
    … …  
    1222                        var blockProps = useBlockProps( { className: 'reachzone-checker-preview' } );
    1323                        var title = props.attributes.title;
     24                        var buttonText = props.attributes.buttonText;
     25                        var accent = props.attributes.accentColor;
    1426                        return el(
    1527                                'div',
    … …  
    2335                                                                props.setAttributes( { title: v } );
    2436                                                        }
    25                                                 } )
     37                                                } ),
     38                                                el( TextControl, {
     39                                                        label: __( 'Button text (optional)', 'reachzone' ),
     40                                                        help: __( 'Leave empty for "Check".', 'reachzone' ),
     41                                                        value: buttonText,
     42                                                        maxLength: 40,
     43                                                        onChange: function ( v ) {
     44                                                                props.setAttributes( { buttonText: v } );
     45                                                        }
     46                                                } ),
     47                                                el( BaseControl, { label: __( 'Button colour (optional)', 'reachzone' ), __nextHasNoMarginBottom: true },
     48                                                        el( ColorPalette, {
     49                                                                colors: ACCENT_COLORS,
     50                                                                value: accent || undefined,
     51                                                                clearable: true,
     52                                                                onChange: function ( v ) {
     53                                                                        props.setAttributes( { accentColor: v || '' } );
     54                                                                }
     55                                                        } )
     56                                                )
    2657                                        )
    2758                                ),
  • reachzone/tags/0.3.0/includes/class-checker.php

    r3816841 r3841382  
    6868         */
    6969        public static function render_block( $attributes ) {
    70                 return self::render( isset( $attributes['title'] ) ? (string) $attributes['title'] : '' );
    71         }
    72 
    73         /**
    74          * Shortcode handler.
     70                return self::render(
     71                        isset( $attributes['title'] ) ? (string) $attributes['title'] : '',
     72                        isset( $attributes['buttonText'] ) ? (string) $attributes['buttonText'] : '',
     73                        isset( $attributes['accentColor'] ) ? (string) $attributes['accentColor'] : ''
     74                );
     75        }
     76
     77        /**
     78         * Shortcode handler: [reachzone_checker title="Do we deliver?" button="Check" accent="#2b4c7e"].
    7579         *
    7680         * @param array|string $atts Attributes.
    … …  
    7882         */
    7983        public static function shortcode( $atts ) {
    80                 $atts = shortcode_atts( array( 'title' => '' ), (array) $atts, self::SHORTCODE );
    81                 return self::render( $atts['title'] );
     84                $atts = shortcode_atts(
     85                        array(
     86                                'title'  => '',
     87                                'button' => '',
     88                                'accent' => '',
     89                        ),
     90                        (array) $atts,
     91                        self::SHORTCODE
     92                );
     93                return self::render( $atts['title'], $atts['button'], $atts['accent'] );
     94        }
     95
     96        /**
     97         * Button label from the block or shortcode: plain text, at most 40 characters. Empty means the default "Check".
     98         *
     99         * @param mixed $value Raw value.
     100         * @return string
     101         */
     102        public static function button_text( $value ) {
     103                $text = is_string( $value ) ? trim( sanitize_text_field( $value ) ) : '';
     104                return function_exists( 'mb_substr' ) ? mb_substr( $text, 0, 40 ) : substr( $text, 0, 40 );
     105        }
     106
     107        /**
     108         * Accent colour from the block or shortcode: a #rgb or #rrggbb value, lower-cased and expanded to six digits.
     109         * Anything else (names, functions, injected CSS) is refused, so the value is safe in a style attribute.
     110         *
     111         * @param mixed $value Raw value.
     112         * @return string The colour, or '' when absent or invalid.
     113         */
     114        public static function accent_color( $value ) {
     115                if ( ! is_string( $value ) || ! preg_match( '/^#([0-9a-f]{3}|[0-9a-f]{6})$/i', trim( $value ), $m ) ) {
     116                        return '';
     117                }
     118                $hex = strtolower( $m[1] );
     119                if ( 3 === strlen( $hex ) ) {
     120                        $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
     121                }
     122                return '#' . $hex;
     123        }
     124
     125        /**
     126         * Readable text colour (black or white) on top of an accent colour, by WCAG relative luminance.
     127         *
     128         * @param string $hex Colour from accent_color().
     129         * @return string #000000 or #ffffff.
     130         */
     131        public static function accent_text_color( $hex ) {
     132                $lum = 0.0;
     133                foreach ( array( array( 1, 0.2126 ), array( 3, 0.7152 ), array( 5, 0.0722 ) ) as $channel ) {
     134                        $c    = hexdec( substr( $hex, $channel[0], 2 ) ) / 255;
     135                        $lum += $channel[1] * ( $c <= 0.03928 ? $c / 12.92 : pow( ( $c + 0.055 ) / 1.055, 2.4 ) );
     136                }
     137                return $lum > 0.179 ? '#000000' : '#ffffff';
    82138        }
    83139
    … …  
    102158         * Markup of the checker.
    103159         *
    104          * @param string $title Optional heading.
    105          * @return string
    106          */
    107         public static function render( $title = '' ) {
     160         * @param string $title  Optional heading.
     161         * @param string $button Optional button label (default "Check").
     162         * @param string $accent Optional accent colour for the button, #rgb or #rrggbb.
     163         * @return string
     164         */
     165        public static function render( $title = '', $button = '', $accent = '' ) {
    108166                if ( ! Settings::has_zones() ) {
    109167                        return current_user_can( 'manage_woocommerce' )
    … …  
    121179                $uid   = wp_unique_id( 'reachzone-input-' );
    122180                $label = 'address' === $mode ? __( 'Your delivery address', 'reachzone' ) : __( 'Your postcode', 'reachzone' );
     181                $check = self::button_text( $button );
     182                $check = '' !== $check ? $check : __( 'Check', 'reachzone' );
     183                $color = self::accent_color( $accent );
     184                $class = 'reachzone-checker';
     185                $style = '';
     186                if ( '' !== $color ) {
     187                        $class .= ' reachzone-checker--accent';
     188                        $style  = ' style="--reachzone-accent:' . esc_attr( $color ) . ';--reachzone-accent-text:' . esc_attr( self::accent_text_color( $color ) ) . '"';
     189                }
    123190                ob_start();
    124191                ?>
    125                 <div class="reachzone-checker" data-reachzone-checker data-mode="<?php echo esc_attr( $mode ); ?>">
     192                <div class="<?php echo esc_attr( $class ); ?>" data-reachzone-checker data-mode="<?php echo esc_attr( $mode ); ?>"<?php echo $style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from esc_attr() values above. ?>>
    126193                        <?php if ( '' !== $title ) : ?>
    127194                                <h3 class="reachzone-title"><?php echo esc_html( $title ); ?></h3>
    … …  
    132199                                        <div class="reachzone-row">
    133200                                                <input class="reachzone-input" id="<?php echo esc_attr( $uid ); ?>" type="text" name="reachzone_query" autocomplete="<?php echo 'address' === $mode ? 'street-address' : 'postal-code'; ?>" maxlength="300" required />
    134                                                 <button type="submit" class="reachzone-button wp-element-button"><?php esc_html_e( 'Check', 'reachzone' ); ?></button>
     201                                                <button type="submit" class="reachzone-button wp-element-button"><?php echo esc_html( $check ); ?></button>
    135202                                        </div>
    136203                                <?php endif; ?>
  • reachzone/tags/0.3.0/languages/reachzone.pot

    r3816841 r3841382  
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2026-11-22T16:01:04+00:00\n"
     12"POT-Creation-Date: 2026-12-03T00:21:55+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.12.0\n"
    … …  
    497497msgstr ""
    498498
    499 #: includes/class-checker.php:110
     499#: includes/class-checker.php:168
    500500msgid "ReachZone: add a delivery zone under WooCommerce > ReachZone to show the checker."
    501501msgstr ""
    502502
    503 #: includes/class-checker.php:122
     503#: includes/class-checker.php:180
    504504msgid "Your delivery address"
    505505msgstr ""
    506506
    507 #: includes/class-checker.php:122
     507#: includes/class-checker.php:180
    508508msgid "Your postcode"
    509509msgstr ""
    510510
    511 #: includes/class-checker.php:134
     511#: includes/class-checker.php:182
    512512msgid "Check"
    513513msgstr ""
    514514
    515 #: includes/class-checker.php:139
     515#: includes/class-checker.php:206
    516516msgid "Use my current location"
    517517msgstr ""
    518518
    519 #: includes/class-checker.php:140
     519#: includes/class-checker.php:207
    520520msgid "Optional. Your browser will ask for permission. The position is used only to check our delivery area."
    521521msgstr ""
    522522
    523 #: includes/class-checker.php:183
     523#: includes/class-checker.php:250
    524524msgid "free delivery"
    525525msgstr ""
    526526
    527527#. translators: %s: delivery fee, for example $4.99
    528 #: includes/class-checker.php:186
     528#: includes/class-checker.php:253
    529529#, php-format
    530530msgid "%s delivery fee"
    531531msgstr ""
    532532
    533 #: includes/class-checker.php:221
    534 #: includes/class-checker.php:395
     533#: includes/class-checker.php:288
     534#: includes/class-checker.php:462
    535535msgid "Please enter your postcode or use your current location so we can check our delivery area."
    536536msgstr ""
    537537
    538 #: includes/class-checker.php:222
    539 #: includes/class-checker.php:306
     538#: includes/class-checker.php:289
     539#: includes/class-checker.php:373
    540540msgid "We could not find that address. Please check it and try again."
    541541msgstr ""
    542542
    543 #: includes/class-checker.php:223
    544 #: includes/class-checker.php:307
     543#: includes/class-checker.php:290
     544#: includes/class-checker.php:374
    545545msgid "Sorry, the check did not work. Please try again in a moment."
    546546msgstr ""
    547547
    548 #: includes/class-checker.php:224
     548#: includes/class-checker.php:291
    549549msgid "Checking..."
    550550msgstr ""
    551551
    552 #: includes/class-checker.php:225
     552#: includes/class-checker.php:292
    553553msgid "We could not get your location. You can type your address or postcode instead."
    554554msgstr ""
    555555
    556 #: includes/class-checker.php:226
     556#: includes/class-checker.php:293
    557557msgid "Your browser does not support location sharing."
    558558msgstr ""
    559559
    560 #: includes/class-checker.php:227
     560#: includes/class-checker.php:294
    561561msgid "Please enter an address or postcode first."
    562562msgstr ""
    563563
    564 #: includes/class-checker.php:281
     564#: includes/class-checker.php:348
    565565msgid "Too many checks. Please wait a few minutes."
    566566msgstr ""
    567567
    568 #: includes/class-checker.php:285
     568#: includes/class-checker.php:352
    569569msgid "Invalid input."
    570570msgstr ""
    571571
    572 #: includes/class-checker.php:297
     572#: includes/class-checker.php:364
    573573msgid "Address lookup is not available in this shop."
    574574msgstr ""
    575575
    576 #: includes/class-checker.php:301
     576#: includes/class-checker.php:368
    577577msgid "Please enter an address."
    578578msgstr ""
    579579
    580 #: includes/class-checker.php:315
     580#: includes/class-checker.php:382
    581581msgid "Invalid position."
    582582msgstr ""
    … …  
    707707msgstr ""
    708708
    709 #: reachzone.php:64
     709#: reachzone.php:67
    710710msgid "ReachZone needs WooCommerce to be installed and active."
    711711msgstr ""
    712712
    713 #: blocks/checker/editor.js:18
     713#: blocks/checker/editor.js:30
    714714msgid "Delivery checker"
    715715msgstr ""
    716716
    717 #: blocks/checker/editor.js:20
     717#: blocks/checker/editor.js:32
    718718msgid "Heading (optional)"
    719719msgstr ""
    720720
    721 #: blocks/checker/editor.js:29
     721#: blocks/checker/editor.js:39
     722msgid "Button text (optional)"
     723msgstr ""
     724
     725#: blocks/checker/editor.js:40
     726msgid "Leave empty for \"Check\"."
     727msgstr ""
     728
     729#: blocks/checker/editor.js:47
     730msgid "Button colour (optional)"
     731msgstr ""
     732
     733#: blocks/checker/editor.js:60
    722734msgid "Delivery checker: shoppers enter their address or postcode, or share their location. Zones are set under WooCommerce > ReachZone."
    723735msgstr ""
  • reachzone/tags/0.3.0/reachzone.php

    r3816841 r3841382  
    44 * Plugin URI:        https://reachzone.app
    55 * Description:       Let shoppers check if you deliver to them, and enforce delivery zones, fees and minimum orders at checkout. Radius, drawn-area, postcode and drive-time zones.
    6  * Version:           0.2.0
     6 * Version:           0.3.0
    77 * Requires at least: 6.2
    88 * Requires PHP:      7.4
    … …  
    1919defined( 'ABSPATH' ) || exit;
    2020
    21 define( 'REACHZONE_VERSION', '0.2.0' );
     21define( 'REACHZONE_VERSION', '0.3.0' );
    2222define( 'REACHZONE_FILE', __FILE__ );
    2323define( 'REACHZONE_DIR', plugin_dir_path( __FILE__ ) );
    2424define( 'REACHZONE_URL', plugin_dir_url( __FILE__ ) );
    2525
     26require_once REACHZONE_DIR . 'includes/class-i18n.php';
    2627require_once REACHZONE_DIR . 'includes/class-geometry.php';
    2728require_once REACHZONE_DIR . 'includes/class-zones.php';
    … …  
    3940require_once REACHZONE_DIR . 'includes/class-addon-promo.php';
    4041require_once REACHZONE_DIR . 'includes/class-admin.php';
     42
     43ReachZone\I18n::init();
    4144
    4245register_activation_hook( __FILE__, array( 'ReachZone\Demand', 'install' ) );
  • reachzone/tags/0.3.0/readme.txt

    r3826550 r3841382  
    66Requires PHP: 7.4
    77Requires Plugins: woocommerce
    8 Stable tag: 0.2.0
     8Stable tag: 0.3.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    2020* **Zones on a map.** Unlimited locations, each with radius zones (km or miles), areas you draw on the map, or lists of postcodes or ZIP codes (exact, prefix such as `606*`, ranges such as `60601-60610`, UK outward codes and Canadian FSAs).
    2121* **Per-zone rules.** Delivery fee, minimum order, delivery time text and which WooCommerce shipping methods are allowed.
    22 * **Delivery checker.** A block and a `[reachzone_checker]` shortcode. Shoppers see "We deliver here: 30 min, $4.99" or "Outside our delivery area" before they fill a cart.
     22* **Delivery checker.** A block and a `[reachzone_checker]` shortcode. Shoppers see "We deliver here: 30 min, $4.99" or "Outside our delivery area" before they fill a cart. Set your own heading, button text and button colour (`[reachzone_checker title="Do we deliver?" button="Check" accent="#2b4c7e"]`).
     23* **Shoppers in their language.** The checker and the checkout messages ship in German, French, Italian, Dutch and Spanish, and follow your site language.
    2324* **Checkout rules.** The matching zone filters shipping methods, adds its fee, enforces its minimum order, and blocks checkout outside every zone. Works with the classic checkout and the block checkout.
    2425* **Shoppers outside your zones.** The settings page shows how many shoppers were turned away this month because their address is outside every zone, so you can see what a bigger area would bring.
    … …  
    143144Out-of-zone orders are blocked and the Store API rejects them. Fee and minimum order are applied through the cart, and shipping methods are filtered in the same way as in classic checkout. The delivery option shows the zone's delivery time, for example "Delivery (30 min)". The unserved-demand map (Business and Agency plans, opt-in) is fed from the block checkout too, once per shopper and rounded spot per hour.
    144145
     146= Is the checker translated? =
     147
     148Yes. The delivery checker and the checkout messages ship in German, French, Italian, Dutch and Spanish, and follow your site language (regional variants such as de_CH or es_MX use the main translation). Messages you write yourself in the settings are shown as you wrote them. Translations from translate.wordpress.org are welcome and take priority.
     149
    145150= Does it work with Indian PIN codes (pincodes)? =
    146151
    … …  
    164169== Changelog ==
    165170
     171= 0.3.0 =
     172* The delivery checker and the checkout messages are translated into German, French, Italian, Dutch and Spanish (bundled; a WordPress.org language pack, when there is one, comes first).
     173* Checker block and shortcode: your own button text and button colour (shortcode attributes `button` and `accent`).
     174
    166175= 0.2.0 =
    167176* The settings page shows how many shoppers were outside your zones this month (counted once per shopper; no address is kept).
    … …  
    181190== Upgrade Notice ==
    182191
     192= 0.3.0 =
     193The checker and checkout messages now speak German, French, Italian, Dutch and Spanish. New button text and colour options for the checker.
     194
    183195= 0.2.0 =
    184196Adds a "Shoppers outside your zones this month" count to the settings page, and the hooks the Delivery Slots add-on needs for delivery hours.
  • reachzone/trunk/assets/css/checker.css

    r3785752 r3841382  
    1313.reachzone-result--out p { border-color: #b32d2e; }
    1414.reachzone-result--unknown p, .reachzone-result--error p { border-color: #996800; }
     15/* Optional accent colour (block / shortcode "accent"): only set when the shop chose one. */
     16.reachzone-checker--accent .reachzone-button { background: var(--reachzone-accent); border-color: var(--reachzone-accent); color: var(--reachzone-accent-text); }
     17.reachzone-checker--accent .reachzone-input:focus { border-color: var(--reachzone-accent); outline-color: var(--reachzone-accent); }
  • reachzone/trunk/blocks/checker/block.json

    r3785752 r3841382  
    1111        "textdomain": "reachzone",
    1212        "attributes": {
    13                 "title": { "type": "string", "default": "" }
     13                "title": { "type": "string", "default": "" },
     14                "buttonText": { "type": "string", "default": "" },
     15                "accentColor": { "type": "string", "default": "" }
    1416        },
    1517        "supports": { "html": false, "align": [ "wide", "full" ] },
  • reachzone/trunk/blocks/checker/editor.js

    r3785752 r3841382  
    77        var PanelBody = wp.components.PanelBody;
    88        var TextControl = wp.components.TextControl;
     9        var BaseControl = wp.components.BaseControl;
     10        var ColorPalette = wp.components.ColorPalette;
     11        // A few neutral choices; the picker also takes any colour. The shortcode attribute "accent" takes the same #rrggbb value.
     12        var ACCENT_COLORS = [
     13                { name: 'Navy', color: '#2b4c7e' },
     14                { name: 'Green', color: '#1a7f37' },
     15                { name: 'Red', color: '#b32d2e' },
     16                { name: 'Marigold', color: '#f4b942' },
     17                { name: 'Ink', color: '#1e1e1e' }
     18        ];
    919
    1020        wp.blocks.registerBlockType( 'reachzone/checker', {
    … …  
    1222                        var blockProps = useBlockProps( { className: 'reachzone-checker-preview' } );
    1323                        var title = props.attributes.title;
     24                        var buttonText = props.attributes.buttonText;
     25                        var accent = props.attributes.accentColor;
    1426                        return el(
    1527                                'div',
    … …  
    2335                                                                props.setAttributes( { title: v } );
    2436                                                        }
    25                                                 } )
     37                                                } ),
     38                                                el( TextControl, {
     39                                                        label: __( 'Button text (optional)', 'reachzone' ),
     40                                                        help: __( 'Leave empty for "Check".', 'reachzone' ),
     41                                                        value: buttonText,
     42                                                        maxLength: 40,
     43                                                        onChange: function ( v ) {
     44                                                                props.setAttributes( { buttonText: v } );
     45                                                        }
     46                                                } ),
     47                                                el( BaseControl, { label: __( 'Button colour (optional)', 'reachzone' ), __nextHasNoMarginBottom: true },
     48                                                        el( ColorPalette, {
     49                                                                colors: ACCENT_COLORS,
     50                                                                value: accent || undefined,
     51                                                                clearable: true,
     52                                                                onChange: function ( v ) {
     53                                                                        props.setAttributes( { accentColor: v || '' } );
     54                                                                }
     55                                                        } )
     56                                                )
    2657                                        )
    2758                                ),
  • reachzone/trunk/includes/class-checker.php

    r3816841 r3841382  
    6868         */
    6969        public static function render_block( $attributes ) {
    70                 return self::render( isset( $attributes['title'] ) ? (string) $attributes['title'] : '' );
    71         }
    72 
    73         /**
    74          * Shortcode handler.
     70                return self::render(
     71                        isset( $attributes['title'] ) ? (string) $attributes['title'] : '',
     72                        isset( $attributes['buttonText'] ) ? (string) $attributes['buttonText'] : '',
     73                        isset( $attributes['accentColor'] ) ? (string) $attributes['accentColor'] : ''
     74                );
     75        }
     76
     77        /**
     78         * Shortcode handler: [reachzone_checker title="Do we deliver?" button="Check" accent="#2b4c7e"].
    7579         *
    7680         * @param array|string $atts Attributes.
    … …  
    7882         */
    7983        public static function shortcode( $atts ) {
    80                 $atts = shortcode_atts( array( 'title' => '' ), (array) $atts, self::SHORTCODE );
    81                 return self::render( $atts['title'] );
     84                $atts = shortcode_atts(
     85                        array(
     86                                'title'  => '',
     87                                'button' => '',
     88                                'accent' => '',
     89                        ),
     90                        (array) $atts,
     91                        self::SHORTCODE
     92                );
     93                return self::render( $atts['title'], $atts['button'], $atts['accent'] );
     94        }
     95
     96        /**
     97         * Button label from the block or shortcode: plain text, at most 40 characters. Empty means the default "Check".
     98         *
     99         * @param mixed $value Raw value.
     100         * @return string
     101         */
     102        public static function button_text( $value ) {
     103                $text = is_string( $value ) ? trim( sanitize_text_field( $value ) ) : '';
     104                return function_exists( 'mb_substr' ) ? mb_substr( $text, 0, 40 ) : substr( $text, 0, 40 );
     105        }
     106
     107        /**
     108         * Accent colour from the block or shortcode: a #rgb or #rrggbb value, lower-cased and expanded to six digits.
     109         * Anything else (names, functions, injected CSS) is refused, so the value is safe in a style attribute.
     110         *
     111         * @param mixed $value Raw value.
     112         * @return string The colour, or '' when absent or invalid.
     113         */
     114        public static function accent_color( $value ) {
     115                if ( ! is_string( $value ) || ! preg_match( '/^#([0-9a-f]{3}|[0-9a-f]{6})$/i', trim( $value ), $m ) ) {
     116                        return '';
     117                }
     118                $hex = strtolower( $m[1] );
     119                if ( 3 === strlen( $hex ) ) {
     120                        $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
     121                }
     122                return '#' . $hex;
     123        }
     124
     125        /**
     126         * Readable text colour (black or white) on top of an accent colour, by WCAG relative luminance.
     127         *
     128         * @param string $hex Colour from accent_color().
     129         * @return string #000000 or #ffffff.
     130         */
     131        public static function accent_text_color( $hex ) {
     132                $lum = 0.0;
     133                foreach ( array( array( 1, 0.2126 ), array( 3, 0.7152 ), array( 5, 0.0722 ) ) as $channel ) {
     134                        $c    = hexdec( substr( $hex, $channel[0], 2 ) ) / 255;
     135                        $lum += $channel[1] * ( $c <= 0.03928 ? $c / 12.92 : pow( ( $c + 0.055 ) / 1.055, 2.4 ) );
     136                }
     137                return $lum > 0.179 ? '#000000' : '#ffffff';
    82138        }
    83139
    … …  
    102158         * Markup of the checker.
    103159         *
    104          * @param string $title Optional heading.
    105          * @return string
    106          */
    107         public static function render( $title = '' ) {
     160         * @param string $title  Optional heading.
     161         * @param string $button Optional button label (default "Check").
     162         * @param string $accent Optional accent colour for the button, #rgb or #rrggbb.
     163         * @return string
     164         */
     165        public static function render( $title = '', $button = '', $accent = '' ) {
    108166                if ( ! Settings::has_zones() ) {
    109167                        return current_user_can( 'manage_woocommerce' )
    … …  
    121179                $uid   = wp_unique_id( 'reachzone-input-' );
    122180                $label = 'address' === $mode ? __( 'Your delivery address', 'reachzone' ) : __( 'Your postcode', 'reachzone' );
     181                $check = self::button_text( $button );
     182                $check = '' !== $check ? $check : __( 'Check', 'reachzone' );
     183                $color = self::accent_color( $accent );
     184                $class = 'reachzone-checker';
     185                $style = '';
     186                if ( '' !== $color ) {
     187                        $class .= ' reachzone-checker--accent';
     188                        $style  = ' style="--reachzone-accent:' . esc_attr( $color ) . ';--reachzone-accent-text:' . esc_attr( self::accent_text_color( $color ) ) . '"';
     189                }
    123190                ob_start();
    124191                ?>
    125                 <div class="reachzone-checker" data-reachzone-checker data-mode="<?php echo esc_attr( $mode ); ?>">
     192                <div class="<?php echo esc_attr( $class ); ?>" data-reachzone-checker data-mode="<?php echo esc_attr( $mode ); ?>"<?php echo $style; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from esc_attr() values above. ?>>
    126193                        <?php if ( '' !== $title ) : ?>
    127194                                <h3 class="reachzone-title"><?php echo esc_html( $title ); ?></h3>
    … …  
    132199                                        <div class="reachzone-row">
    133200                                                <input class="reachzone-input" id="<?php echo esc_attr( $uid ); ?>" type="text" name="reachzone_query" autocomplete="<?php echo 'address' === $mode ? 'street-address' : 'postal-code'; ?>" maxlength="300" required />
    134                                                 <button type="submit" class="reachzone-button wp-element-button"><?php esc_html_e( 'Check', 'reachzone' ); ?></button>
     201                                                <button type="submit" class="reachzone-button wp-element-button"><?php echo esc_html( $check ); ?></button>
    135202                                        </div>
    136203                                <?php endif; ?>
  • reachzone/trunk/languages/reachzone.pot

    r3816841 r3841382  
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2026-11-22T16:01:04+00:00\n"
     12"POT-Creation-Date: 2026-12-03T00:21:55+00:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.12.0\n"
    … …  
    497497msgstr ""
    498498
    499 #: includes/class-checker.php:110
     499#: includes/class-checker.php:168
    500500msgid "ReachZone: add a delivery zone under WooCommerce > ReachZone to show the checker."
    501501msgstr ""
    502502
    503 #: includes/class-checker.php:122
     503#: includes/class-checker.php:180
    504504msgid "Your delivery address"
    505505msgstr ""
    506506
    507 #: includes/class-checker.php:122
     507#: includes/class-checker.php:180
    508508msgid "Your postcode"
    509509msgstr ""
    510510
    511 #: includes/class-checker.php:134
     511#: includes/class-checker.php:182
    512512msgid "Check"
    513513msgstr ""
    514514
    515 #: includes/class-checker.php:139
     515#: includes/class-checker.php:206
    516516msgid "Use my current location"
    517517msgstr ""
    518518
    519 #: includes/class-checker.php:140
     519#: includes/class-checker.php:207
    520520msgid "Optional. Your browser will ask for permission. The position is used only to check our delivery area."
    521521msgstr ""
    522522
    523 #: includes/class-checker.php:183
     523#: includes/class-checker.php:250
    524524msgid "free delivery"
    525525msgstr ""
    526526
    527527#. translators: %s: delivery fee, for example $4.99
    528 #: includes/class-checker.php:186
     528#: includes/class-checker.php:253
    529529#, php-format
    530530msgid "%s delivery fee"
    531531msgstr ""
    532532
    533 #: includes/class-checker.php:221
    534 #: includes/class-checker.php:395
     533#: includes/class-checker.php:288
     534#: includes/class-checker.php:462
    535535msgid "Please enter your postcode or use your current location so we can check our delivery area."
    536536msgstr ""
    537537
    538 #: includes/class-checker.php:222
    539 #: includes/class-checker.php:306
     538#: includes/class-checker.php:289
     539#: includes/class-checker.php:373
    540540msgid "We could not find that address. Please check it and try again."
    541541msgstr ""
    542542
    543 #: includes/class-checker.php:223
    544 #: includes/class-checker.php:307
     543#: includes/class-checker.php:290
     544#: includes/class-checker.php:374
    545545msgid "Sorry, the check did not work. Please try again in a moment."
    546546msgstr ""
    547547
    548 #: includes/class-checker.php:224
     548#: includes/class-checker.php:291
    549549msgid "Checking..."
    550550msgstr ""
    551551
    552 #: includes/class-checker.php:225
     552#: includes/class-checker.php:292
    553553msgid "We could not get your location. You can type your address or postcode instead."
    554554msgstr ""
    555555
    556 #: includes/class-checker.php:226
     556#: includes/class-checker.php:293
    557557msgid "Your browser does not support location sharing."
    558558msgstr ""
    559559
    560 #: includes/class-checker.php:227
     560#: includes/class-checker.php:294
    561561msgid "Please enter an address or postcode first."
    562562msgstr ""
    563563
    564 #: includes/class-checker.php:281
     564#: includes/class-checker.php:348
    565565msgid "Too many checks. Please wait a few minutes."
    566566msgstr ""
    567567
    568 #: includes/class-checker.php:285
     568#: includes/class-checker.php:352
    569569msgid "Invalid input."
    570570msgstr ""
    571571
    572 #: includes/class-checker.php:297
     572#: includes/class-checker.php:364
    573573msgid "Address lookup is not available in this shop."
    574574msgstr ""
    575575
    576 #: includes/class-checker.php:301
     576#: includes/class-checker.php:368
    577577msgid "Please enter an address."
    578578msgstr ""
    579579
    580 #: includes/class-checker.php:315
     580#: includes/class-checker.php:382
    581581msgid "Invalid position."
    582582msgstr ""
    … …  
    707707msgstr ""
    708708
    709 #: reachzone.php:64
     709#: reachzone.php:67
    710710msgid "ReachZone needs WooCommerce to be installed and active."
    711711msgstr ""
    712712
    713 #: blocks/checker/editor.js:18
     713#: blocks/checker/editor.js:30
    714714msgid "Delivery checker"
    715715msgstr ""
    716716
    717 #: blocks/checker/editor.js:20
     717#: blocks/checker/editor.js:32
    718718msgid "Heading (optional)"
    719719msgstr ""
    720720
    721 #: blocks/checker/editor.js:29
     721#: blocks/checker/editor.js:39
     722msgid "Button text (optional)"
     723msgstr ""
     724
     725#: blocks/checker/editor.js:40
     726msgid "Leave empty for \"Check\"."
     727msgstr ""
     728
     729#: blocks/checker/editor.js:47
     730msgid "Button colour (optional)"
     731msgstr ""
     732
     733#: blocks/checker/editor.js:60
    722734msgid "Delivery checker: shoppers enter their address or postcode, or share their location. Zones are set under WooCommerce > ReachZone."
    723735msgstr ""
  • reachzone/trunk/reachzone.php

    r3816841 r3841382  
    44 * Plugin URI:        https://reachzone.app
    55 * Description:       Let shoppers check if you deliver to them, and enforce delivery zones, fees and minimum orders at checkout. Radius, drawn-area, postcode and drive-time zones.
    6  * Version:           0.2.0
     6 * Version:           0.3.0
    77 * Requires at least: 6.2
    88 * Requires PHP:      7.4
    … …  
    1919defined( 'ABSPATH' ) || exit;
    2020
    21 define( 'REACHZONE_VERSION', '0.2.0' );
     21define( 'REACHZONE_VERSION', '0.3.0' );
    2222define( 'REACHZONE_FILE', __FILE__ );
    2323define( 'REACHZONE_DIR', plugin_dir_path( __FILE__ ) );
    2424define( 'REACHZONE_URL', plugin_dir_url( __FILE__ ) );
    2525
     26require_once REACHZONE_DIR . 'includes/class-i18n.php';
    2627require_once REACHZONE_DIR . 'includes/class-geometry.php';
    2728require_once REACHZONE_DIR . 'includes/class-zones.php';
    … …  
    3940require_once REACHZONE_DIR . 'includes/class-addon-promo.php';
    4041require_once REACHZONE_DIR . 'includes/class-admin.php';
     42
     43ReachZone\I18n::init();
    4144
    4245register_activation_hook( __FILE__, array( 'ReachZone\Demand', 'install' ) );
  • reachzone/trunk/readme.txt

    r3826550 r3841382  
    66Requires PHP: 7.4
    77Requires Plugins: woocommerce
    8 Stable tag: 0.2.0
     8Stable tag: 0.3.0
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    2020* **Zones on a map.** Unlimited locations, each with radius zones (km or miles), areas you draw on the map, or lists of postcodes or ZIP codes (exact, prefix such as `606*`, ranges such as `60601-60610`, UK outward codes and Canadian FSAs).
    2121* **Per-zone rules.** Delivery fee, minimum order, delivery time text and which WooCommerce shipping methods are allowed.
    22 * **Delivery checker.** A block and a `[reachzone_checker]` shortcode. Shoppers see "We deliver here: 30 min, $4.99" or "Outside our delivery area" before they fill a cart.
     22* **Delivery checker.** A block and a `[reachzone_checker]` shortcode. Shoppers see "We deliver here: 30 min, $4.99" or "Outside our delivery area" before they fill a cart. Set your own heading, button text and button colour (`[reachzone_checker title="Do we deliver?" button="Check" accent="#2b4c7e"]`).
     23* **Shoppers in their language.** The checker and the checkout messages ship in German, French, Italian, Dutch and Spanish, and follow your site language.
    2324* **Checkout rules.** The matching zone filters shipping methods, adds its fee, enforces its minimum order, and blocks checkout outside every zone. Works with the classic checkout and the block checkout.
    2425* **Shoppers outside your zones.** The settings page shows how many shoppers were turned away this month because their address is outside every zone, so you can see what a bigger area would bring.
    … …  
    143144Out-of-zone orders are blocked and the Store API rejects them. Fee and minimum order are applied through the cart, and shipping methods are filtered in the same way as in classic checkout. The delivery option shows the zone's delivery time, for example "Delivery (30 min)". The unserved-demand map (Business and Agency plans, opt-in) is fed from the block checkout too, once per shopper and rounded spot per hour.
    144145
     146= Is the checker translated? =
     147
     148Yes. The delivery checker and the checkout messages ship in German, French, Italian, Dutch and Spanish, and follow your site language (regional variants such as de_CH or es_MX use the main translation). Messages you write yourself in the settings are shown as you wrote them. Translations from translate.wordpress.org are welcome and take priority.
     149
    145150= Does it work with Indian PIN codes (pincodes)? =
    146151
    … …  
    164169== Changelog ==
    165170
     171= 0.3.0 =
     172* The delivery checker and the checkout messages are translated into German, French, Italian, Dutch and Spanish (bundled; a WordPress.org language pack, when there is one, comes first).
     173* Checker block and shortcode: your own button text and button colour (shortcode attributes `button` and `accent`).
     174
    166175= 0.2.0 =
    167176* The settings page shows how many shoppers were outside your zones this month (counted once per shopper; no address is kept).
    … …  
    181190== Upgrade Notice ==
    182191
     192= 0.3.0 =
     193The checker and checkout messages now speak German, French, Italian, Dutch and Spanish. New button text and colour options for the checker.
     194
    183195= 0.2.0 =
    184196Adds a "Shoppers outside your zones this month" count to the settings page, and the hooks the Delivery Slots add-on needs for delivery hours.
Note: See TracChangeset for help on using the changeset viewer.