Plugin Directory

Changeset 3835631


Ignore:
Timestamp:
11/30/2026 04:55:34 PM (less than one hour ago)
Author:
hibira
Message:

Release 0.2.0

Location:
hibira-waiting-room
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • hibira-waiting-room/tags/0.2.0/hibira-waiting-room.php

    r3808590 r3835631  
    44 * Plugin URI:           https://hibira.io/guides/woocommerce
    55 * Description:          A fair virtual queue for product drops and flash sales. Shoppers wait their turn on a Hibira waiting room, come back with a signed pass, and the pass is checked again at checkout.
    6  * Version:              0.1.1
     6 * Version:              0.2.0
    77 * Requires at least:    6.5
    88 * Requires PHP:         7.4
    … …  
    2121defined( 'ABSPATH' ) || exit;
    2222
    23 define( 'HIBIRA_WR_VERSION', '0.1.1' );
     23define( 'HIBIRA_WR_VERSION', '0.2.0' );
    2424define( 'HIBIRA_WR_FILE', __FILE__ );
    2525define( 'HIBIRA_WR_DIR', plugin_dir_path( __FILE__ ) );
  • hibira-waiting-room/tags/0.2.0/includes/class-hibira-wr-admin.php

    r3808590 r3835631  
    9292                register_setting( $group, $p . 'skip_bots', $yesno );
    9393                register_setting( $group, $p . 'once_per_pass', $yesno );
     94                register_setting( $group, $p . 'fail_open', $yesno );
    9495        }
    9596
    … …  
    352353                        'skip_staff'    => __( 'Shop managers skip the line', 'hibira-waiting-room' ),
    353354                        'skip_bots'     => __( 'Search engines can still read product pages (they cannot buy)', 'hibira-waiting-room' ),
     355                        'fail_open'     => __( 'Let shoppers in if the waiting room can\'t be reached', 'hibira-waiting-room' ),
    354356                );
    355357                foreach ( $rules as $name => $label ) {
  • hibira-waiting-room/tags/0.2.0/includes/class-hibira-wr-checkout.php

    r3808590 r3835631  
    5252                $pass = Hibira_WR::current_pass();
    5353                if ( ! $pass ) {
    54                         return self::queue_message();
     54                        return Hibira_WR::failed_open() ? '' : self::queue_message();
    5555                }
    5656                if ( Hibira_WR::on( 'once_per_pass' ) && '' !== $pass['ticket'] && self::ticket_used( $pass['ticket'], $order ? $order->get_id() : 0 ) ) {
    … …  
    7171                        return $passed;
    7272                }
    73                 if ( Hibira_WR::bypass( true ) || Hibira_WR::current_pass() ) {
     73                if ( Hibira_WR::bypass( true ) || Hibira_WR::current_pass() || Hibira_WR::failed_open() ) {
    7474                        return $passed;
    7575                }
    … …  
    8383                        return;
    8484                }
    85                 if ( Hibira_WR::bypass( true ) || Hibira_WR::current_pass() ) {
     85                if ( Hibira_WR::bypass( true ) || Hibira_WR::current_pass() || Hibira_WR::failed_open() ) {
    8686                        return;
    8787                }
  • hibira-waiting-room/tags/0.2.0/includes/class-hibira-wr-client.php

    r3808590 r3835631  
    3030                $this->base      = untrailingslashit( (string) $base );
    3131                $this->transport = $transport;
     32        }
     33
     34        /**
     35         * Whether the room's public status answers within $timeout seconds, the
     36         * way a shopper's browser would reach the waiting page. A network error,
     37         * a timeout or a 5xx is false.
     38         */
     39        public function reachable( $room, $timeout = 1.5 ) {
     40                $url = $this->base . '/waitroom/' . rawurlencode( $this->key ) . '/' . rawurlencode( $room );
     41                if ( $this->transport ) {
     42                        $out = call_user_func( $this->transport, 'GET', $url, '' );
     43                        if ( is_wp_error( $out ) ) {
     44                                return false;
     45                        }
     46                        $status = (int) $out[0];
     47                } else {
     48                        $res = wp_remote_get(
     49                                $url,
     50                                array(
     51                                        'timeout'     => $timeout,
     52                                        'redirection' => 0,
     53                                )
     54                        );
     55                        if ( is_wp_error( $res ) ) {
     56                                return false;
     57                        }
     58                        $status = (int) wp_remote_retrieve_response_code( $res );
     59                }
     60                return $status > 0 && $status < 500;
    3261        }
    3362
  • hibira-waiting-room/tags/0.2.0/includes/class-hibira-wr-gate.php

    r3808590 r3835631  
    4141                        return;
    4242                }
     43                if ( Hibira_WR::failed_open() ) {
     44                        /**
     45                         * Fires when a shopper is let in because the waiting page could not be reached.
     46                         *
     47                         * @param string $url The page the shopper asked for.
     48                         */
     49                        do_action( 'hibira_wr_fail_open', self::current_url() );
     50                        return;
     51                }
    4352                wp_redirect( Hibira_WR::waiting_page_url( self::current_url() ), 302, 'Hibira Waiting Room' ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- the waiting page is on the Hibira host.
    4453                exit;
  • hibira-waiting-room/tags/0.2.0/includes/class-hibira-wr.php

    r3808590 r3835631  
    2727                        'skip_bots'     => 'yes',
    2828                        'once_per_pass' => 'yes',
     29                        'fail_open'     => 'no',
    2930                );
    3031        }
    … …  
    7475                }
    7576                return 'https://' . preg_replace( '#^wss?://#', '', $host );
     77        }
     78
     79        /**
     80         * Whether shoppers can reach the waiting page right now, for the
     81         * "let shoppers in if the waiting room can't be reached" rule. One check
     82         * per room is kept for 15 seconds, so a busy store sends at most one
     83         * check every 15 seconds.
     84         */
     85        public static function queue_reachable() {
     86                $cache = self::PREFIX . 'up_' . md5( self::base_url() . '|' . self::get( 'key' ) . '|' . self::room() );
     87                $known = get_transient( $cache );
     88                if ( 'yes' === $known || 'no' === $known ) {
     89                        return 'yes' === $known;
     90                }
     91                /**
     92                 * Filters how long, in seconds, to wait for the waiting page before letting a shopper in.
     93                 *
     94                 * @param float $timeout
     95                 */
     96                $timeout = (float) apply_filters( 'hibira_wr_fail_open_timeout', 1.5 );
     97                $up      = self::client()->reachable( self::room(), $timeout );
     98                set_transient( $cache, $up ? 'yes' : 'no', 15 );
     99                return $up;
     100        }
     101
     102        /** True when the fail-open rule is on and the waiting page can't be reached right now. */
     103        public static function failed_open() {
     104                return self::on( 'fail_open' ) && ! self::queue_reachable();
    76105        }
    77106
  • hibira-waiting-room/tags/0.2.0/readme.txt

    r3808590 r3835631  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 0.1.1
     7Stable tag: 0.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    3232* From WooCommerce > Waiting room, your server sends the room's settings (title, rate, start time, pass lifetime, your store address and the waiting page look: logo address, colour, message and theme) to Hibira's HTTP API and reads the room's counters. No customer or order data is sent.
    3333* Passes are checked on your server with your app secret; checking a pass sends nothing to Hibira.
     34* With "Let shoppers in if the waiting room can't be reached" ticked, your server requests the room's public status from your Hibira app's host at most once every 15 seconds. The request carries only your app key and room name.
    3435
    3536Terms: https://hibira.io/legal/terms — Privacy policy: https://hibira.io/legal/privacy
    … …  
    5556A pass can be copied to another browser while it is valid, so the plugin records the place in line on the order and refuses a second paid order with the same place.
    5657
     58= What if the waiting room can't be reached? =
     59
     60By default shoppers without a pass are still sent to the waiting page. Tick "Let shoppers in if the waiting room can't be reached" to let them in instead when the waiting page doesn't answer within 1.5 seconds (or answers with a server error). The check runs at most once every 15 seconds per room.
     61
    5762= What happens to shoppers already in the cart when I turn it on? =
    5863
    … …  
    7176== Upgrade Notice ==
    7277
     78= 0.2.0 =
     79Adds an optional rule that lets shoppers in when the waiting room can't be reached.
     80
    7381= 0.1.1 =
    7482Adds logo, colour, message and theme settings for the waiting page.
    7583
    7684== Changelog ==
     85
     86= 0.2.0 =
     87* New option "Let shoppers in if the waiting room can't be reached" (off by default): if the room's status check times out or fails, shoppers go straight in, including at add to cart and checkout.
    7788
    7889= 0.1.1 =
  • hibira-waiting-room/tags/0.2.0/uninstall.php

    r3808590 r3835631  
    99defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
    1010
    11 foreach ( array( 'app_id', 'key', 'secret', 'host', 'enabled', 'room', 'scope', 'products', 'categories', 'skip_staff', 'skip_bots', 'once_per_pass' ) as $hibira_wr_name ) {
     11foreach ( array( 'app_id', 'key', 'secret', 'host', 'enabled', 'room', 'scope', 'products', 'categories', 'skip_staff', 'skip_bots', 'once_per_pass', 'fail_open' ) as $hibira_wr_name ) {
    1212        delete_option( 'hibira_wr_' . $hibira_wr_name );
    1313}
  • hibira-waiting-room/trunk/hibira-waiting-room.php

    r3808590 r3835631  
    44 * Plugin URI:           https://hibira.io/guides/woocommerce
    55 * Description:          A fair virtual queue for product drops and flash sales. Shoppers wait their turn on a Hibira waiting room, come back with a signed pass, and the pass is checked again at checkout.
    6  * Version:              0.1.1
     6 * Version:              0.2.0
    77 * Requires at least:    6.5
    88 * Requires PHP:         7.4
    … …  
    2121defined( 'ABSPATH' ) || exit;
    2222
    23 define( 'HIBIRA_WR_VERSION', '0.1.1' );
     23define( 'HIBIRA_WR_VERSION', '0.2.0' );
    2424define( 'HIBIRA_WR_FILE', __FILE__ );
    2525define( 'HIBIRA_WR_DIR', plugin_dir_path( __FILE__ ) );
  • hibira-waiting-room/trunk/includes/class-hibira-wr-admin.php

    r3808590 r3835631  
    9292                register_setting( $group, $p . 'skip_bots', $yesno );
    9393                register_setting( $group, $p . 'once_per_pass', $yesno );
     94                register_setting( $group, $p . 'fail_open', $yesno );
    9495        }
    9596
    … …  
    352353                        'skip_staff'    => __( 'Shop managers skip the line', 'hibira-waiting-room' ),
    353354                        'skip_bots'     => __( 'Search engines can still read product pages (they cannot buy)', 'hibira-waiting-room' ),
     355                        'fail_open'     => __( 'Let shoppers in if the waiting room can\'t be reached', 'hibira-waiting-room' ),
    354356                );
    355357                foreach ( $rules as $name => $label ) {
  • hibira-waiting-room/trunk/includes/class-hibira-wr-checkout.php

    r3808590 r3835631  
    5252                $pass = Hibira_WR::current_pass();
    5353                if ( ! $pass ) {
    54                         return self::queue_message();
     54                        return Hibira_WR::failed_open() ? '' : self::queue_message();
    5555                }
    5656                if ( Hibira_WR::on( 'once_per_pass' ) && '' !== $pass['ticket'] && self::ticket_used( $pass['ticket'], $order ? $order->get_id() : 0 ) ) {
    … …  
    7171                        return $passed;
    7272                }
    73                 if ( Hibira_WR::bypass( true ) || Hibira_WR::current_pass() ) {
     73                if ( Hibira_WR::bypass( true ) || Hibira_WR::current_pass() || Hibira_WR::failed_open() ) {
    7474                        return $passed;
    7575                }
    … …  
    8383                        return;
    8484                }
    85                 if ( Hibira_WR::bypass( true ) || Hibira_WR::current_pass() ) {
     85                if ( Hibira_WR::bypass( true ) || Hibira_WR::current_pass() || Hibira_WR::failed_open() ) {
    8686                        return;
    8787                }
  • hibira-waiting-room/trunk/includes/class-hibira-wr-client.php

    r3808590 r3835631  
    3030                $this->base      = untrailingslashit( (string) $base );
    3131                $this->transport = $transport;
     32        }
     33
     34        /**
     35         * Whether the room's public status answers within $timeout seconds, the
     36         * way a shopper's browser would reach the waiting page. A network error,
     37         * a timeout or a 5xx is false.
     38         */
     39        public function reachable( $room, $timeout = 1.5 ) {
     40                $url = $this->base . '/waitroom/' . rawurlencode( $this->key ) . '/' . rawurlencode( $room );
     41                if ( $this->transport ) {
     42                        $out = call_user_func( $this->transport, 'GET', $url, '' );
     43                        if ( is_wp_error( $out ) ) {
     44                                return false;
     45                        }
     46                        $status = (int) $out[0];
     47                } else {
     48                        $res = wp_remote_get(
     49                                $url,
     50                                array(
     51                                        'timeout'     => $timeout,
     52                                        'redirection' => 0,
     53                                )
     54                        );
     55                        if ( is_wp_error( $res ) ) {
     56                                return false;
     57                        }
     58                        $status = (int) wp_remote_retrieve_response_code( $res );
     59                }
     60                return $status > 0 && $status < 500;
    3261        }
    3362
  • hibira-waiting-room/trunk/includes/class-hibira-wr-gate.php

    r3808590 r3835631  
    4141                        return;
    4242                }
     43                if ( Hibira_WR::failed_open() ) {
     44                        /**
     45                         * Fires when a shopper is let in because the waiting page could not be reached.
     46                         *
     47                         * @param string $url The page the shopper asked for.
     48                         */
     49                        do_action( 'hibira_wr_fail_open', self::current_url() );
     50                        return;
     51                }
    4352                wp_redirect( Hibira_WR::waiting_page_url( self::current_url() ), 302, 'Hibira Waiting Room' ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- the waiting page is on the Hibira host.
    4453                exit;
  • hibira-waiting-room/trunk/includes/class-hibira-wr.php

    r3808590 r3835631  
    2727                        'skip_bots'     => 'yes',
    2828                        'once_per_pass' => 'yes',
     29                        'fail_open'     => 'no',
    2930                );
    3031        }
    … …  
    7475                }
    7576                return 'https://' . preg_replace( '#^wss?://#', '', $host );
     77        }
     78
     79        /**
     80         * Whether shoppers can reach the waiting page right now, for the
     81         * "let shoppers in if the waiting room can't be reached" rule. One check
     82         * per room is kept for 15 seconds, so a busy store sends at most one
     83         * check every 15 seconds.
     84         */
     85        public static function queue_reachable() {
     86                $cache = self::PREFIX . 'up_' . md5( self::base_url() . '|' . self::get( 'key' ) . '|' . self::room() );
     87                $known = get_transient( $cache );
     88                if ( 'yes' === $known || 'no' === $known ) {
     89                        return 'yes' === $known;
     90                }
     91                /**
     92                 * Filters how long, in seconds, to wait for the waiting page before letting a shopper in.
     93                 *
     94                 * @param float $timeout
     95                 */
     96                $timeout = (float) apply_filters( 'hibira_wr_fail_open_timeout', 1.5 );
     97                $up      = self::client()->reachable( self::room(), $timeout );
     98                set_transient( $cache, $up ? 'yes' : 'no', 15 );
     99                return $up;
     100        }
     101
     102        /** True when the fail-open rule is on and the waiting page can't be reached right now. */
     103        public static function failed_open() {
     104                return self::on( 'fail_open' ) && ! self::queue_reachable();
    76105        }
    77106
  • hibira-waiting-room/trunk/readme.txt

    r3808590 r3835631  
    55Tested up to: 7.1
    66Requires PHP: 7.4
    7 Stable tag: 0.1.1
     7Stable tag: 0.2.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    3232* From WooCommerce > Waiting room, your server sends the room's settings (title, rate, start time, pass lifetime, your store address and the waiting page look: logo address, colour, message and theme) to Hibira's HTTP API and reads the room's counters. No customer or order data is sent.
    3333* Passes are checked on your server with your app secret; checking a pass sends nothing to Hibira.
     34* With "Let shoppers in if the waiting room can't be reached" ticked, your server requests the room's public status from your Hibira app's host at most once every 15 seconds. The request carries only your app key and room name.
    3435
    3536Terms: https://hibira.io/legal/terms — Privacy policy: https://hibira.io/legal/privacy
    … …  
    5556A pass can be copied to another browser while it is valid, so the plugin records the place in line on the order and refuses a second paid order with the same place.
    5657
     58= What if the waiting room can't be reached? =
     59
     60By default shoppers without a pass are still sent to the waiting page. Tick "Let shoppers in if the waiting room can't be reached" to let them in instead when the waiting page doesn't answer within 1.5 seconds (or answers with a server error). The check runs at most once every 15 seconds per room.
     61
    5762= What happens to shoppers already in the cart when I turn it on? =
    5863
    … …  
    7176== Upgrade Notice ==
    7277
     78= 0.2.0 =
     79Adds an optional rule that lets shoppers in when the waiting room can't be reached.
     80
    7381= 0.1.1 =
    7482Adds logo, colour, message and theme settings for the waiting page.
    7583
    7684== Changelog ==
     85
     86= 0.2.0 =
     87* New option "Let shoppers in if the waiting room can't be reached" (off by default): if the room's status check times out or fails, shoppers go straight in, including at add to cart and checkout.
    7788
    7889= 0.1.1 =
  • hibira-waiting-room/trunk/uninstall.php

    r3808590 r3835631  
    99defined( 'WP_UNINSTALL_PLUGIN' ) || exit;
    1010
    11 foreach ( array( 'app_id', 'key', 'secret', 'host', 'enabled', 'room', 'scope', 'products', 'categories', 'skip_staff', 'skip_bots', 'once_per_pass' ) as $hibira_wr_name ) {
     11foreach ( array( 'app_id', 'key', 'secret', 'host', 'enabled', 'room', 'scope', 'products', 'categories', 'skip_staff', 'skip_bots', 'once_per_pass', 'fail_open' ) as $hibira_wr_name ) {
    1212        delete_option( 'hibira_wr_' . $hibira_wr_name );
    1313}
Note: See TracChangeset for help on using the changeset viewer.