Plugin Directory

Changeset 3685965


Ignore:
Timestamp:
09/08/2026 05:41:49 AM (3 months ago)
Author:
ghera74
Message:

Release version 1.3.0

Location:
wp-restaurant-booking
Files:
21 added
2 deleted
35 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-restaurant-booking/tags/1.3.0/admin/class-wprb-admin.php

    r3650036 r3685965  
    2929
    3030                        add_action( 'admin_init', array( $this, 'save_reservations_settings' ) );
    31                         add_action( 'admin_init', array( $this, 'save_last_minute_settings' ) );
     31                        add_action( 'admin_init', array( $this, 'save_closing_days_settings' ) );
    3232                        add_action( 'admin_init', array( $this, 'save_rooms_tables_settings' ) );
    3333                        add_action( 'admin_init', array( $this, 'save_notifications_settings' ) );
    … …  
    3535                        add_action( 'admin_menu', array( $this, 'register_wprb_admin' ) );
    3636                        add_action( 'wp_ajax_wprb-add-hours', array( $this, 'hours_element_callback' ) );
    37                         add_action( 'wp_ajax_wprb-add-last-minute', array( $this, 'last_minute_element_callback' ) );
    3837                        add_action( 'wp_ajax_wprb-add-closing-period', array( $this, 'closing_period_element_callback' ) );
    3938                        add_action( 'wp_ajax_wprb-add-room-tables', array( $this, 'room_tables_element_callback' ) );
    40 
    41                         add_action(
    42                                 'in_plugin_update_message-' . basename( WPRB_DIR ) . '/wp-restaurant-booking.php',
    43                                 array(
    44                                         $this,
    45                                         'wprb_update_message',
    46                                 ),
    47                                 10,
    48                                 2
    49                         );
    5039
    5140                }
    … …  
    7766                        /*Nonce*/
    7867                        $add_hours_nonce          = wp_create_nonce( 'wprb-add-hours' );
    79                         $add_last_minute_nonce    = wp_create_nonce( 'wprb-add-last-minute' );
    8068                        $add_closing_period_nonce = wp_create_nonce( 'wprb-add-closing-period' );
    8169                        $add_room_tables_nonce    = wp_create_nonce( 'wprb-add-room-tables' );
    … …  
    8876                        wp_enqueue_style( 'wprb-admin-style', WPRB_URI . 'css/wprb-admin.css' );
    8977                        wp_enqueue_style( 'tzcheckbox-style', WPRB_URI . 'js/tzCheckbox/jquery.tzCheckbox/jquery.tzCheckbox.css' );
     78                        wp_enqueue_style( 'wp-color-picker' );
    9079
    9180                        /*js*/
    9281                        wp_enqueue_script( 'wprb-admin-js', WPRB_URI . 'js/wprb-admin.js', array( 'jquery' ), '1.0', true );
    9382                        wp_enqueue_script( 'tzcheckbox', WPRB_URI . 'js/tzCheckbox/jquery.tzCheckbox/jquery.tzCheckbox.js', array( 'jquery' ) );
     83                        wp_enqueue_script( 'wp-color-picker' );
    9484
    9585                        /*Pass data to the script file*/
    … …  
    9989                                array(
    10090                                        'addHoursNonce'         => $add_hours_nonce,
    101                                         'addLastMinuteNonce'    => $add_last_minute_nonce,
    10291                                        'addClosingPeriodNonce' => $add_closing_period_nonce,
    10392                                        'addRoomTablesNonce'    => $add_room_tables_nonce,
    … …  
    244233
    245234        /**
    246          * Go premium button
    247          */
    248         public function go_premium() {
    249 
    250                 $title = __( 'This is a premium functionality, click here for more information', 'wp-restaurant-booking' );
    251                 $output = '<span class="wprb label label-warning premium">';
    252                         $output .= '<a href="https://www.ilghera.com/product/wp-restaurant-booking-premium" target="_blank" title="' . esc_attr( $title ) . '">Premium</a>';
    253                 $output .= '</span>';
    254 
    255                 $allowed = array(
    256                         'span' => array(
    257                                 'class' => [],
    258                         ),
    259                         'a'    => array(
    260                                 'target' => [],
    261                                 'title'  => [],
    262                                 'href'   => [],
    263                         ),
    264                 );
    265 
    266                 echo wp_kses( $output, $allowed );
    267 
    268         }
    269 
    270         /**
    271235         * Return a single hours element as ajax callback
    272236         */
    … …  
    298262                $to    = isset( $data['to'] ) ? $data['to'] : '';
    299263                $every = isset( $data['every'] ) ? $data['every'] : '';
    300                 $disabled = 1 !== $number ? ' disabled' : '';
    301264
    302265                echo '<div class="wprb-hours-element-' . esc_attr( $number ) . ' hours-element">';
    303266
    304267                        echo '<label for="wprb-bookable-hours-from">' . esc_html__( 'From', 'wp-restaurant-booking' ) . '</label>';
    305                         echo '<input type="time" name="wprb-' . esc_attr( $day ) . '-bookable-hours-from-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-from" class="wprb-bookable-hours-from" max="23:59" value="' . esc_attr( $from ) . '" required' . $disabled . '>';
     268                        echo '<input type="time" name="wprb-' . esc_attr( $day ) . '-bookable-hours-from-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-from" class="wprb-bookable-hours-from" max="23:59" value="' . esc_attr( $from ) . '">';
    306269
    307270                        echo '<label for="wprb-bookable-hours-to">' . esc_html__( 'to', 'wp-restaurant-booking' ) . '</label>';
    308                         echo '<input type="time" name="wprb-' . esc_attr( $day ) . '-bookable-hours-to-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-to" class="wprb-bookable-hours-to" max="23:59" value="' . esc_attr( $to ) . '" required' . $disabled . '>';
     271                        echo '<input type="time" name="wprb-' . esc_attr( $day ) . '-bookable-hours-to-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-to" class="wprb-bookable-hours-to" max="23:59" value="' . esc_attr( $to ) . '">';
    309272
    310273                        echo '<label for="wprb-bookable-hours-every">' . esc_html__( 'every (minutes)', 'wp-restaurant-booking' ) . '</label>';
    311                         echo '<input type="number" name="wprb-' . esc_attr( $day ) . '-bookable-hours-every-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-every" class="wprb-bookable-hours-every" min="5" max="60" step="5" placeholder="15" value="' . esc_attr( $every ) . '" required' . $disabled . '>';
     274                        echo '<input type="number" name="wprb-' . esc_attr( $day ) . '-bookable-hours-every-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-every" class="wprb-bookable-hours-every" min="5" max="60" step="5" placeholder="15" value="' . esc_attr( $every ) . '">';
    312275
    313276                        if ( 1 === $number ) {
    … …  
    342305                        if ( $this->saved_hours && isset( $this->saved_hours[ $day ] )) {
    343306
    344                                 $this->hours_element( $day, 1, $this->saved_hours[ $day ][1] );
     307                                $count = count( $this->saved_hours[ $day ] );
     308
     309                                for ( $i = 1; $i <= $count; $i++ ) {
     310
     311                                        $this->hours_element( $day, $i, $this->saved_hours[ $day ][ $i ] );
     312
     313                                }
    345314
    346315                        } else {
    … …  
    350319                        }
    351320
    352                         echo '<div class="go-premium">';
    353 
    354                                 $this->go_premium();
    355                        
    356                         echo '</div>';
    357        
    358321                echo '</div>';
    359 
    360         }
    361 
    362         /**
    363          * Return a single last minute element as ajax callback
    364          */
    365         public function last_minute_element_callback() {
    366 
    367                 if ( isset( $_POST['number'], $_POST['wprb-add-last-minute-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['wprb-add-last-minute-nonce'] ), 'wprb-add-last-minute' ) ) {
    368 
    369                         $number = sanitize_text_field( wp_unslash( $_POST['number'] ) );
    370 
    371                         $this->last_minute( $number );
    372 
    373                 }
    374 
    375                 exit;
    376 
    377         }
    378 
    379         /**
    380          * Display a single last minute
    381          *
    382          * @param int   $number the number of hours element.
    383          * @param array $data single element data coming from the db.
    384          */
    385         public function last_minute( $number = 0, $data = array() ) {
    386 
    387                 $date   = null;
    388                 $from   = null;
    389                 $to     = null;
    390                 $people = null;
    391 
    392                 echo '<div class="wprb-last-minute-element-' . esc_attr( $number ) . ' last-minute-element">';
    393 
    394                         echo '<label for="wprb-last-minute-date">' . esc_html__( 'On', 'wp-restaurant-booking' ) . '</label>';
    395                         echo '<input type="date" name="wprb-last-minute-date-' . esc_attr( $number ) . '" id="wprb-last-minute-date" class="wprb-last-minute-date" min="' . esc_html( date( 'Y-m-d' ) ) . '" value="' . esc_attr( $date ) . '" disabled>';
    396 
    397                         echo '<label for="wprb-last-minute-from">' . esc_html__( 'from', 'wp-restaurant-booking' ) . '</label>';
    398                         echo '<input type="time" name="wprb-last-minute-from-' . esc_attr( $number ) . '" id="wprb-last-minute-from" class="wprb-last-minute-from" min="12:00" max="23:00" value="' . esc_attr( $from ) . '" required disabled>';
    399 
    400                         echo '<label for="wprb-last-minute-to">' . esc_html__( 'to', 'wp-restaurant-booking' ) . '</label>';
    401                         echo '<input type="time" name="wprb-last-minute-to-' . esc_attr( $number ) . '" id="wprb-last-minute-to" class="wprb-last-minute-to" min="12:00" max="23:00" value="' . esc_attr( $to ) . '" required disabled>';
    402 
    403                         echo '<label for="wprb-last-minute-people">' . esc_html__( 'people', 'wp-restaurant-booking' ) . '</label>';
    404                         echo '<input type="number" name="wprb-last-minute-people-' . esc_attr( $number ) . '" id="wprb-last-minute-people" class="wprb-last-minute-people" step="1" placeholder="0" value="' . esc_attr( $people ) . '" required disabled>';
    405 
    406                         if ( 0 === $number ) {
    407 
    408                                 echo '<div class="wprb-add-last-minute-container">';
    409                                         echo '<img class="add-last-minute" src="' . esc_url( WPRB_URI . 'images/add-icon.png' ) . '">';
    410                                         echo '<img class="add-last-minute-hover" src="' . esc_url( WPRB_URI . 'images/add-icon-hover.png' ) . '">';
    411                                 echo '</div>';
    412 
    413                         } else {
    414 
    415                                 echo '<div class="wprb-remove-last-minute-container">';
    416                                         echo '<img class="remove-last-minute" src="' . esc_url( WPRB_URI . 'images/remove-icon.png' ) . '">';
    417                                         echo '<img class="remove-last-minute-hover" src="' . esc_url( WPRB_URI . 'images/remove-icon-hover.png' ) . '">';
    418                                 echo '</div>';
    419 
    420                         }
    421                                                
    422                 echo '</div>';
    423 
    424         }
    425 
    426         /**
    427          * Display the last minute element in the plugin admin area
    428          */
    429         public function display_last_minute_elements() {
    430 
    431                 $this->last_minute();
    432322
    433323        }
    … …  
    441331        public function room_tables( $number = 0, $data = array() ) {
    442332
    443                 $name     = isset( $data['name'] ) ? $data['name'] : '';
    444                 $tables   = isset( $data['tables'] ) ? $data['tables'] : 0;
    445                 $disabled = 0 !== $number ? ' disabled' : '';
     333                $name   = isset( $data['name'] ) ? $data['name'] : '';
     334                $tables = isset( $data['tables'] ) ? $data['tables'] : 0;
    446335
    447336                echo '<tr class="wprb-room-tables-element-' . esc_attr( $number ) . ' room-tables-element">';
    … …  
    452341
    453342                                echo '<label>' . esc_html__( 'Name', 'wp-restaurant-booking' ) . '</label>';
    454                                 echo '<input type="text" name="room-name-' . esc_attr( $number ) . '" value="' . esc_attr( $name ) . '" placeholder="' . sprintf( esc_attr( 'Room %d', 'wp-restaurant-booking' ), esc_attr( $number + 1 ) ) . '"' . $disabled . '>';
     343                                echo '<input type="text" name="room-name-' . esc_attr( $number ) . '" value="' . esc_attr( $name ) . '" placeholder="' . sprintf( esc_attr( 'Room %d', 'wp-restaurant-booking' ), esc_attr( $number + 1 ) ) . '">';
    455344
    456345                                echo '<label>' . esc_html__( 'Tables', 'wp-restaurant-booking' ) . '</label>';
    457                                 echo '<input type="number" name="tables-number-' . esc_attr( $number ) . '" min="1" value="' . esc_attr( $tables ) . '"' . $disabled . '>';
    458 
    459                                 if ( 0 === $number ) {
    460 
    461                                         echo '<div class="wprb-add-room-tables-container">';
    462                                                 echo '<img class="add-room-tables" src="' . esc_url( WPRB_URI . 'images/add-icon.png' ) . '">';
    463                                                 echo '<img class="add-room-tables-hover" src="' . esc_url( WPRB_URI . 'images/add-icon-hover.png' ) . '">';
    464                                         echo '</div>';
    465 
    466                                 } else {
    467 
    468                                         echo '<div class="wprb-remove-room-tables-container">';
    469                                                 echo '<img class="remove-room-tables" src="' . esc_url( WPRB_URI . 'images/remove-icon.png' ) . '">';
    470                                                 echo '<img class="remove-room-tables-hover" src="' . esc_url( WPRB_URI . 'images/remove-icon-hover.png' ) . '">';
    471                                         echo '</div>';
    472 
    473                                 }
    474                                
     346                                echo '<input type="number" name="tables-number-' . esc_attr( $number ) . '" min="1" value="' . esc_attr( $tables ) . '">';
     347
    475348                                echo '<p class="description">' . esc_html__( 'Add a name and the number of tables to this restaurant room', 'wp-restaurant-booking' ) . '</p>';
    476349
    … …  
    531404        public function closing_period( $number = 0, $data = array() ) {
    532405
    533                 $from   = null;
    534                 $to     = null;
     406                $from = isset( $data['from'] ) ? $data['from'] : '';
     407                $to   = isset( $data['to'] ) ? $data['to'] : '';
    535408
    536409                echo '<div class="wprb-closing-period-element-' . esc_attr( $number ) . ' closing-period-element">';
    … …  
    563436
    564437        /**
    565          * Display the last minute element in the plugin admin area
     438         * Return a single closing period element as ajax callback
     439         */
     440        public function closing_period_element_callback() {
     441
     442                if ( isset( $_POST['number'], $_POST['wprb-add-closing-period-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['wprb-add-closing-period-nonce'] ), 'wprb-add-closing-period' ) ) {
     443
     444                        $number = sanitize_text_field( wp_unslash( $_POST['number'] ) );
     445
     446                        $this->closing_period( $number );
     447
     448                }
     449
     450                exit;
     451
     452        }
     453
     454        /**
     455         * Auto-delete the closing periods out of date
     456         */
     457        public function get_filtered_closing_periods() {
     458
     459                $output = null;
     460
     461                $closing_periods = get_option( 'wprb-closing-periods' );
     462
     463                if ( $closing_periods ) {
     464
     465                        $count = count( $closing_periods );
     466
     467                        for ( $i = 0; $i < $count; $i++ ) {
     468
     469                                $to = isset( $closing_periods[ $i ]['to'] ) ? $closing_periods[ $i ]['to'] : '';
     470
     471                                /*Check for expired elements*/
     472                                if ( $to ) {
     473
     474                                        $to  = strtotime( $to );
     475                                        $now = strtotime( 'now' );
     476
     477                                        if ( $now > $to ) {
     478
     479                                                unset( $closing_periods[ $i ] );
     480
     481                                        }
     482
     483                                }
     484
     485                        }
     486
     487                        $output = array_values( $closing_periods );
     488
     489                        update_option( 'wprb-closing-periods', $output );
     490
     491                        return $output;
     492
     493                }
     494
     495        }
     496
     497        /**
     498         * Display the closing period elements in the plugin admin area
    566499         */
    567500        public function display_closing_period_elements() {
    568501
    569                 $this->closing_period();
     502                $closing_periods = $this->get_filtered_closing_periods();
     503
     504                if ( $closing_periods ) {
     505
     506                        $count = count( $closing_periods );
     507
     508                        for ( $i = 0; $i < $count; $i++ ) {
     509
     510                                $this->closing_period( $i, $closing_periods[ $i ] );
     511
     512                        }
     513
     514                } else {
     515
     516                        $this->closing_period();
     517
     518                }
    570519
    571520        }
    … …  
    607556                        update_option( 'wprb-expiration-time', $expiration_time );
    608557
     558                        /*Widget color*/
     559                        $widget_color = isset( $_POST['wprb-widget-color'] ) ? sanitize_hex_color( wp_unslash( $_POST['wprb-widget-color'] ) ) : '';
     560                        update_option( 'wprb-widget-color', $widget_color );
     561
     562                        /*Widget text color*/
     563                        $widget_text_color = isset( $_POST['wprb-widget-text-color'] ) ? sanitize_hex_color( wp_unslash( $_POST['wprb-widget-text-color'] ) ) : '';
     564                        update_option( 'wprb-widget-text-color', $widget_text_color );
     565
    609566                }
    610567
    … …  
    660617                        foreach ( self::week() as $key => $value ) {
    661618
    662                                 $from = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-from-1' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-from-1' ] ) ) : null;
    663 
    664                                 $to = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-to-1' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-to-1' ] ) ) : null;
    665 
    666                                 $every = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-every-1' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-every-1' ] ) ) : null;
    667 
    668                                 if ( $from && $to && $every ) {
    669 
    670                                         $save_hours[ $key ][1] = array(
    671                                                 'from'  => $from,
    672                                                 'to'    => $to,
    673                                                 'every' => $every,
    674                                         );
     619                                /*10 is the current limit*/
     620                                for ( $i = 1; $i <= 10; $i++ ) {
     621
     622                                        $from = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-from-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-from-' . $i ] ) ) : null;
     623
     624                                        $to = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-to-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-to-' . $i ] ) ) : null;
     625
     626                                        $every = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-every-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-every-' . $i ] ) ) : null;
     627
     628                                        if ( $from && $to && $every ) {
     629
     630                                                $save_hours[ $key ][ $i ] = array(
     631                                                        'from'  => $from,
     632                                                        'to'    => $to,
     633                                                        'every' => $every,
     634                                                );
     635
     636                                        } else {
     637
     638                                                break;
     639
     640                                        }
    675641
    676642                                }
    … …  
    685651
    686652        /**
    687          * Save last minute
    688          */
    689         public function save_last_minute_settings() {
    690 
    691                 if ( isset( $_POST['wprb-set-last-minute-sent'], $_POST['wprb-set-last-minute-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['wprb-set-last-minute-nonce'] ), 'wprb-set-last-minute' ) ) {
    692 
    693                         /*Last minute activate*/
    694                         $activate = isset( $_POST['wprb-activate-last-minute'] ) ? sanitize_text_field( wp_unslash( $_POST['wprb-activate-last-minute'] ) ) : 0;
    695                         update_option( 'wprb-activate-last-minute', $activate );
    696 
    697                         /*Last minute description*/
    698                         $description = isset( $_POST['wprb-last-minute-description'] ) ? sanitize_text_field( wp_unslash( $_POST['wprb-last-minute-description'] ) ) : '';
    699                         update_option( 'wprb-last-minute-description', $description );
    700 
    701                         /*Set last minute*/
    702                         $last_minute = array();
     653         * Save closing days
     654         */
     655        public function save_closing_days_settings() {
     656
     657                if ( isset( $_POST['wprb-set-closing-days-sent'], $_POST['wprb-set-closing-days-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['wprb-set-closing-days-nonce'] ), 'wprb-set-closing-days' ) ) {
     658
     659                        /*Closing days*/
     660                        $closing_days = isset( $_POST['wprb-closing-days'] ) ? $_POST['wprb-closing-days'] : '';
     661                        update_option( 'wprb-closing-days', $closing_days );
     662
     663                        /*Closing periods*/
     664                        $closing_periods = array();
    703665
    704666                        /*20 is the current limit*/
    705667                        for ( $i = 0; $i <= 20; $i++ ) {
    706668
    707                                 $date = isset( $_POST[ 'wprb-last-minute-date-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-last-minute-date-' . $i ] ) ) : null;
    708                                 $from = isset( $_POST[ 'wprb-last-minute-from-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-last-minute-from-' . $i ] ) ) : null;
    709                                 $to = isset( $_POST[ 'wprb-last-minute-to-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-last-minute-to-' . $i ] ) ) : null;
    710                                 $people = isset( $_POST[ 'wprb-last-minute-people-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-last-minute-people-' . $i ] ) ) : null;
    711                                 if ( $date && $from && $to && $people ) {
    712 
    713                                         $last_minute[ $i ] = array(
    714                                                 'date'   => $date,
     669                                $from = isset( $_POST[ 'wprb-closing-period-from-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-closing-period-from-' . $i ] ) ) : null;
     670                                $to   = isset( $_POST[ 'wprb-closing-period-to-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-closing-period-to-' . $i ] ) ) : null;
     671
     672                                if ( $from && $to ) {
     673
     674                                        $closing_periods[ $i ] = array(
    715675                                                'from'   => $from,
    716676                                                'to'     => $to,
    717                                                 'people' => $people,
    718677                                        );
    719678
    … …  
    726685                        }
    727686
    728                         update_option( 'wprb-last-minute', $last_minute );
     687                        update_option( 'wprb-closing-periods', $closing_periods );
    729688
    730689                }
    … …  
    781740                        $admin_recipients = isset( $_POST['wprb-admin-recipients'] ) && '' !== $_POST['wprb-admin-recipients'] ? explode( ' ', sanitize_text_field( wp_unslash( $_POST['wprb-admin-recipients'] ) ) ) : '';
    782741                        update_option( 'wprb-admin-recipients', $admin_recipients );
     742
     743                        $user_activate = isset( $_POST['wprb-activate-user-notification'] ) ? sanitize_text_field( wp_unslash( $_POST['wprb-activate-user-notification'] ) ) : '';
     744                        update_option( 'wprb-activate-user-notification', $user_activate );
    783745
    784746                }
    … …  
    811773                                        echo '<a href="#" data-link="wprb-set-hours" class="nav-tab" onclick="return false;">' . esc_html( __( 'Hours', 'wp-restaurant-booking' ) ) . '</a>';
    812774                                        echo '<a href="#" data-link="wprb-set-closing-days" class="nav-tab" onclick="return false;">' . esc_html( __( 'Closing days', 'wp-restaurant-booking' ) ) . '</a>';
    813                                         echo '<a href="#" data-link="wprb-set-last-minute" class="nav-tab" onclick="return false;">' . esc_html( __( 'Last minute', 'wp-restaurant-booking' ) ) . '</a>';
    814775                                        echo '<a href="#" data-link="wprb-set-notifications" class="nav-tab" onclick="return false;">' . esc_html( __( 'Notifications', 'wp-restaurant-booking' ) ) . '</a>';
     776                                        echo '<a href="#" data-link="wprb-set-premium" class="nav-tab nav-tab-premium" onclick="return false;"><span class="dashicons dashicons-star-filled"></span> ' . esc_html( __( 'Premium', 'wp-restaurant-booking' ) ) . '</a>';
    815777                                echo '</h2>';
    816778
    … …  
    850812                                echo '</div>';
    851813
    852                                 /*Set last minute*/
    853                                 echo '<div id="wprb-set-last-minute" class="wprb-admin">';
    854 
    855                                         include( WPRB_ADMIN . 'wprb-set-last-minute-template.php' );
    856 
    857                                 echo '</div>';
    858 
    859814                                /*Set notifications*/
    860815                                echo '<div id="wprb-set-notifications" class="wprb-admin">';
    861816
    862817                                        include( WPRB_ADMIN . 'wprb-set-notifications-template.php' );
     818
     819                                echo '</div>';
     820
     821                                /*Premium features*/
     822                                echo '<div id="wprb-set-premium" class="wprb-admin">';
     823
     824                                        include( WPRB_ADMIN . 'wprb-set-premium-template.php' );
    863825
    864826                                echo '</div>';
  • wp-restaurant-booking/tags/1.3.0/admin/wprb-set-bookables-template.php

    r3650036 r3685965  
    1515
    1616        <table class="form-table">
    17                 <tr class="wprb-activate-external-seats-field">
    18                         <th scope="row"><?php esc_html_e( 'External seats', 'wp-restaurant-booking' ); ?></th>
    19                         <td>
    20                                 <input type="checkbox" name="wprb-activate-external-seats" id="wprb-activate-external-seats" value="1">
    21                                 <p class="description"><?php esc_html_e( 'Activate if external seats are available in your restaurant in this season.', 'wp-restaurant-booking' ); ?></p>
    22                                 <?php $admin->go_premium(); ?>
    23                         </td>
    24                 </tr>
    2517                <tr>
    2618                        <th scope="row"><?php esc_html_e( 'Bookable seats', 'wp-restaurant-booking' ); ?></th>
    … …  
    3325                                                if ( 'mon' === $key ) {
    3426                                                        echo '<div class="wprb-col"><h4>' . esc_html__( 'Internal seats', 'wp-restaurant-booking' ) . '</h4></div>';
    35                                                         echo '<div class="wprb-col external"><h4>' . esc_html__( 'External seats', 'wp-restaurant-booking' ) . '</h4></div>';
    3627                                                        echo '<div class="wprb-col min-bookable"><h4>' . esc_html__( 'Minimum bookable number', 'wp-restaurant-booking' ) . '</h4></div>';
    3728                                                        echo '<div class="wprb-col max-bookable"><h4>' . esc_html__( 'Maximum bookable number', 'wp-restaurant-booking' ) . '</h4></div>';
    … …  
    4839
    4940                                                        echo '<input type="number" name="wprb-bookable-seats-' . esc_attr( $key ) . '" id="wprb-bookable-seats" class="' . esc_attr( $key ) . '" placeholder="0" value="' . esc_attr( $bookable_value ) . '">';
    50                                                 echo '</div>';
    51 
    52                                                 echo '<div class="wprb-col external">';
    53 
    54                                                         echo '<input type="number" name="wprb-external-seats-' . esc_attr( $key ) . '" id="wprb-external-seats" class="' . esc_attr( $key ) . '" placeholder="0" value="0" disabled>';
    55 
    5641                                                echo '</div>';
    5742
  • wp-restaurant-booking/tags/1.3.0/admin/wprb-set-closing-days-template.php

    r3650036 r3685965  
    55 * @author ilGhera
    66 * @package wp-restaurant-booking/admin
    7  * @since 1.1.7
     7 * @since 1.1.8
    88 */
    99
     10$closing_days = get_option( 'wprb-closing-days' );
    1011?>
    1112<!-- Form -->
    … …  
    2021                                        foreach ( WPRB_Admin::week() as $key => $value ) {
    2122                                               
    22                                                 echo '<option value="' . esc_attr( $key ) . '">' . esc_html( ucfirst( $value ) ) . '</option>';
     23                                                echo '<option value="' . esc_attr( $key ) . '"' . ( is_array( $closing_days ) && in_array( $key , $closing_days) ? ' selected="selected"' : '' ) . '>' . esc_html( ucfirst( $value ) ) . '</option>';
    2324
    2425                                        }
    … …  
    3738                        </td>
    3839                </tr>
    39                 <tr>
    40                         <th></th>
    41                 <td><?php $admin->go_premium(); ?></td>
    42                 </tr>
    4340        </table>
    4441
    … …  
    4643
    4744        <input type="hidden" name="wprb-set-closing-days-sent" value="1">
    48         <input type="submit" class="button-primary wprb" value="<?php esc_html_e( 'Save settings', 'wp-restaurant-booking' ); ?>" disabled>
     45        <input type="submit" class="button-primary wprb" value="<?php esc_html_e( 'Save settings', 'wp-restaurant-booking' ); ?>">
    4946
    5047</form>
  • wp-restaurant-booking/tags/1.3.0/admin/wprb-set-general-template.php

    r3650036 r3685965  
    1717$expiration_time           = get_option( 'wprb-expiration-time' );
    1818$policy_page               = get_option( 'wprb-policy-page' );
     19$widget_color              = get_option( 'wprb-widget-color' );
     20$widget_text_color         = get_option( 'wprb-widget-text-color' );
    1921?>
    2022<!-- Form -->
    … …  
    9799                        </td>
    98100                </tr>
     101                <tr>
     102                        <th scope="row"><?php esc_html_e( 'Widget color', 'wp-restaurant-booking' ); ?></th>
     103                        <td>
     104                                <input type="text" class="wprb-color-field" name="wprb-widget-color" value="<?php echo esc_attr( $widget_color ); ?>">
     105                                <p class="description"><?php esc_html_e( 'Main color of the booking widget. Leave empty to use the default yellow.', 'wp-restaurant-booking' ); ?></p>
     106                        </td>
     107                </tr>
     108                <tr>
     109                        <th scope="row"><?php esc_html_e( 'Widget text color', 'wp-restaurant-booking' ); ?></th>
     110                        <td>
     111                                <input type="text" class="wprb-color-field" name="wprb-widget-text-color" value="<?php echo esc_attr( $widget_text_color ); ?>">
     112                                <p class="description"><?php esc_html_e( 'Text color used on top of the widget main color, for contrast. Leave empty to use the default white.', 'wp-restaurant-booking' ); ?></p>
     113                        </td>
     114                </tr>
    99115        </table>
    100116
  • wp-restaurant-booking/tags/1.3.0/admin/wprb-set-notifications-template.php

    r3650036 r3685965  
    1111$admin_activate       = get_option( 'wprb-activate-admin-notification' );
    1212$admin_recipients     = get_option( 'wprb-admin-recipients' ) ? get_option( 'wprb-admin-recipients' ) : array( get_option( 'admin_email' ) );
    13 
    14 /*Define the user object*/
    15 $default_user_object  = WPRB_Notifications::default_user_object();
    16 $user_object          = null;
    17 
    18 /*Define the admin object*/
    19 $default_user_message = WPRB_Notifications::default_user_message();
    20 $user_message         = null;
     13$user_activate        = get_option( 'wprb-activate-user-notification' );
    2114?>
    2215
    … …  
    5346                        <th scope="row"><?php esc_html_e( 'User notifications', 'wp-restaurant-booking' ); ?></th>
    5447                        <td>
    55                                 <input type="checkbox" name="wprb-activate-user-notification" id="wprb-activate-user-notification" value="1">
     48                                <input type="checkbox" name="wprb-activate-user-notification" id="wprb-activate-user-notification" value="1"<?php echo ( 1 == $user_activate ? ' checked="checked"' : '' ); ?>>
    5649                                <p class="description"><?php esc_html_e( 'Activate email notifications for the user.', 'wp-restaurant-booking' ); ?></p>
    57                         </td>
    58                 </tr>
    59                 <tr class="wprb-user-notification-field" style="display: none;">
    60                         <th scope="row"><?php esc_html_e( 'Object', 'wp-restaurant-booking' ); ?></th>
    61                         <td>
    62                                 <input type="text" name="wprb-user-notification-object" class="wprb-user-notification-object regular-text" placeholder="<?php echo esc_attr( $default_user_object ); ?>" value="<?php echo esc_attr( $user_object ); ?>" disabled>
    63                                 <p class="description"><?php esc_html_e( 'Specify a different email object.', 'wp-restaurant-booking' ); ?></p>
    64                         </td>
    65                 </tr>
    66                 <tr class="wprb-user-notification-field" style="display: none;">
    67                         <th scope="row"><?php esc_html_e( 'Message', 'wp-restaurant-booking' ); ?></th>
    68                         <td>
    69                                 <textarea type="text" name="wprb-user-notification-message" class="wprb-user-notification-message regular-text" rows="6" placeholder="<?php echo esc_attr( $default_user_message ); ?>" disabled><?php echo esc_html( $user_message ); ?></textarea>
    70                                 <p class="description">
    71                                         <?php
    72                                         echo '<span class="shortcodes">';
    73                                                 echo '<code>[first-name]</code> <code>[last-name]</code> <code>[email]</code> <code>[phone]</code>';
    74                                                 echo '<code>[people]</code> <code>[in-outdoor]</code> <code>[date]</code> <code>[time]</code> <code>[until]</code> <code>[notes]</code>';
    75                                         echo '</span>';
    76                                         esc_html_e( 'Specify a different email message.', 'wp-restaurant-booking' );
    77                                         ?>
    78                                 </p>
    79                                 <?php $admin->go_premium(); ?>
    8050                        </td>
    8151                </tr>
  • wp-restaurant-booking/tags/1.3.0/admin/wprb-set-tables-template.php

    r3650036 r3685965  
    1414
    1515                <?php $admin->display_rooms_tables_elements(); ?>
    16 
    17                 <tr class="go-premium">
    18                         <th></th>
    19                 <td><?php $admin->go_premium(); ?></td>
    20                 </tr>
    2116       
    2217        </table>
  • wp-restaurant-booking/tags/1.3.0/css/wprb-admin.css

    r3650036 r3685965  
    6868#submit-key:active {
    6969        top: 2px;
    70 }
    71 
    72 .nav-tab.not-available, .nav-tab.not-available:hover {
    73         border-width: 1px 1px medium;
    74     border-style: solid solid none;
    75     border-color: #CCC #CCC -moz-use-text-color;
    76     -moz-border-top-colors: none;
    77     -moz-border-right-colors: none;
    78     -moz-border-bottom-colors: none;
    79     -moz-border-left-colors: none;
    80     border-image: none;
    81     background: #E4E4E4 none repeat scroll 0% 0%;
    82     display: inline-block;
    83     text-decoration: none;
    84     opacity:0.4;
    8570}
    8671
    … …  
    544529}
    545530
    546 .wprb.label-warning.premium {
    547     display: inline-block;
    548     margin: 10px 0 0;
    549         padding: 7px 14px;
    550         font-size: 12px;
    551         font-weight: bold;
    552         line-height: 1;
    553         text-align: center;
    554         white-space: nowrap;
    555         vertical-align: baseline;
    556         border-radius: .25em;
    557         background-color: #f0ad4e;
    558         cursor: pointer;
    559 }
    560 
    561 .label-warning a {
    562         color: #ffffff;
    563         text-decoration: none;
    564 }
    565 
    566 .label-warning a:hover {
    567         color: #0073aa;
    568 }
    569 
    570 .go-premium {
    571         display: none;
    572 }
    573 
    574531.old-table {
    575532        display: block;
    … …  
    590547
    591548        .wrap-right {
    592                 float: none; 
    593                 width: 100%; 
    594                 text-align: center; 
     549                float: none;
     550                width: 100%;
     551                text-align: center;
    595552                padding-top: 3rem;
    596553        }
    … …  
    598555
    599556}
     557
     558.nav-tab-premium {
     559        color: #b8860b !important;
     560        font-weight: 600;
     561}
     562
     563.nav-tab-premium:hover,
     564.nav-tab-premium:focus {
     565        color: #8b6508 !important;
     566}
     567
     568.nav-tab-premium .dashicons {
     569        font-size: 14px;
     570        width: 14px;
     571        height: 14px;
     572        vertical-align: text-bottom;
     573        margin-right: 2px;
     574}
     575
     576.nav-tab-premium.nav-tab-active {
     577        color: #f0b90b !important;
     578        border-bottom-color: #f0b90b !important;
     579}
     580
     581.wprb-premium-upsell {
     582        max-width: 860px;
     583        margin-top: 1.5rem;
     584}
     585
     586.wprb-premium-header {
     587        text-align: center;
     588        padding: 2rem 1rem;
     589        background: #fff;
     590        border: 1px solid #e0e0e0;
     591        border-radius: 4px;
     592        margin-bottom: 1.5rem;
     593}
     594
     595.wprb-premium-header .dashicons {
     596        font-size: 2.5rem;
     597        width: 2.5rem;
     598        height: 2.5rem;
     599        color: #f0b90b;
     600}
     601
     602.wprb-premium-header h2 {
     603        font-size: 1.6rem;
     604        margin: 0.5rem 0;
     605        color: #23282d;
     606}
     607
     608.wprb-premium-header .description {
     609        font-size: 1rem;
     610        color: #666;
     611}
     612
     613.wprb-premium-features {
     614        display: grid;
     615        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
     616        gap: 1rem;
     617        margin-bottom: 1.5rem;
     618}
     619
     620.wprb-feature {
     621        background: #fff;
     622        border: 1px solid #e0e0e0;
     623        border-radius: 4px;
     624        padding: 1.5rem;
     625        transition: box-shadow 0.2s ease;
     626}
     627
     628.wprb-feature:hover {
     629        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
     630}
     631
     632.wprb-feature .dashicons {
     633        font-size: 2rem;
     634        width: 2rem;
     635        height: 2rem;
     636        color: #f0b90b;
     637}
     638
     639.wprb-feature h3 {
     640        margin: 0.5rem 0;
     641        font-size: 1rem;
     642        color: #23282d;
     643}
     644
     645.wprb-feature p {
     646        margin: 0;
     647        color: #666;
     648        font-size: 0.9rem;
     649}
     650
     651.wprb-premium-cta {
     652        text-align: center;
     653        padding: 2rem;
     654        background: #fff;
     655        border: 1px solid #e0e0e0;
     656        border-radius: 4px;
     657}
     658
     659.wprb-premium-cta .button-hero {
     660        background: #f0b90b;
     661        border-color: #d4a009;
     662        color: #fff;
     663        font-size: 1.1rem;
     664        padding: 0.6rem 2rem;
     665}
     666
     667.wprb-premium-cta .button-hero:hover {
     668        background: #d4a009;
     669        border-color: #b8860b;
     670        color: #fff;
     671}
     672
     673.wprb-premium-cta .description {
     674        margin-top: 0.75rem;
     675        color: #666;
     676}
  • wp-restaurant-booking/tags/1.3.0/css/wprb.css

    r3650036 r3685965  
    1616        display: inline-block;
    1717        padding: 2px 20px;
    18         background: #f5b016;
     18        background: var(--wprb-widget-color, #f5b016);
    1919        border-radius: 5px;
    2020        cursor: pointer;
    … …  
    4848.wprb-booking-button a,
    4949.wprb-booking-button a:hover {
    50         color: #fff !important;
     50        color: var(--wprb-widget-text-color, #fff) !important;
    5151        text-decoration: none;
    5252        font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    … …  
    8080#wprb-booking-modal h2 {
    8181        text-align: center;
    82         background: #f5b016;
     82        background: var(--wprb-widget-color, #f5b016);
    8383        margin: 0;
    8484        padding: 40px 0 20px;
    85         color: #fff;
     85        color: var(--wprb-widget-text-color, #fff);
    8686    font-size: 2em;
    8787        -webkit-border-radius: 8px 8px 0 0;
    … …  
    105105#wprb-booking-modal .header-bar {
    106106        display: block;
    107         background: #f5b016;
     107        background: var(--wprb-widget-color, #f5b016);
    108108        min-height: 100px;
    109109}
    … …  
    121121        position: relative;
    122122    margin: 0;
     123}
     124
     125.header-bar_steps li {
     126        color: var(--wprb-widget-text-color, #333);
     127}
     128
     129.header-bar_steps li.active span i {
     130        color: var(--wprb-widget-color, #333);
    123131}
    124132
    … …  
    141149#wprb-booking-modal ul li span {
    142150        text-align: center;
    143         background-color: #f5b016;
     151        background-color: var(--wprb-widget-color, #f5b016);
    144152        width: 44px;
    145153        height: 44px;
    … …  
    153161        opacity: 1;
    154162        background-color: #fff;
    155         border: 2px solid #f0a417;
     163        border: 2px solid var(--wprb-widget-accent-color, #f0a417);
    156164        cursor: pointer;
    157165}
    … …  
    226234.booking-people_numbers__number input[type="button"]:hover,
    227235.booking-people_numbers__number input[type="button"].active {
    228         background: #f5b016 !important;
     236        background: var(--wprb-widget-color, #f5b016) !important;
    229237    text-decoration: none;
    230         color: #fff;   
     238        color: var(--wprb-widget-text-color, #fff);     
    231239}
    232240
    … …  
    277285
    278286.booking-people_numbers__number.active select {
    279         background: #f5b016;
    280         color: #fff;
     287        background: var(--wprb-widget-color, #f5b016);
     288        color: var(--wprb-widget-text-color, #fff);
    281289}
    282290
    … …  
    403411.booking-hours ul li input:hover,
    404412.booking-hours ul li input.active {
    405         color: #fff;
     413        color: var(--wprb-widget-text-color, #fff);
    406414    text-decoration: none;
    407         background: #f5b016;
     415        background: var(--wprb-widget-color, #f5b016);
    408416}
    409417
    … …  
    474482
    475483#wprb-reservation input[type="checkbox"]:checked {
    476     background-color: #f5b016;
     484    background-color: var(--wprb-widget-color, #f5b016);
    477485}
    478486
    479487#wprb-reservation input[type="checkbox"]:checked:after {
    480488    content: '✔';
    481     color: white;
     489    color: var(--wprb-widget-text-color, white);
    482490    position: relative;
    483491    top: -3px;
    … …  
    555563.booking-end .fa-check-circle {
    556564        font-size: 400%;
    557         color: #f5b016; /*temp*/
     565        color: var(--wprb-widget-color, #f5b016);
    558566        margin-bottom: 1.5rem;
    559567}
    560568
     569/*
     570 * Override the air-datepicker library's own default theme (#ff9a19)
     571 * so the calendar follows the widget color too. Needs !important:
     572 * the library's stylesheet is enqueued after wprb.css and its own
     573 * rules don't use !important, so source order alone isn't enough.
     574 */
     575.datepicker--day-name {
     576        color: var(--wprb-widget-color, #ff9a19) !important;
     577}
     578
     579.-current-,
     580.-selected-,
     581.datepicker--cell.-selected-.-current- {
     582        background: var(--wprb-widget-color, #ff9a19) !important;
     583        color: var(--wprb-widget-text-color, #fff) !important;
     584}
     585
     586.-focus-,
     587.-selected-.-focus- {
     588        background: var(--wprb-widget-color, #ff9a19) !important;
     589}
     590
    561591@media screen and (max-width: 1000px) {
    562592
  • wp-restaurant-booking/tags/1.3.0/includes/class-wprb-notifications.php

    r3650036 r3685965  
    4848                $this->define_shortcodes();
    4949                $this->send_admin_notification();
     50                $this->send_user_notification();
    5051
    5152        }
    … …  
    263264
    264265        }
     266
     267
     268        /**
     269         * Send user notification if activated
     270         */
     271        public function send_user_notification() {
     272
     273                if ( get_option( 'wprb-activate-user-notification' ) ) {
     274
     275                        $to = $this->email;
     276
     277                        $subject = do_shortcode( self::default_user_object() );
     278
     279                        $message = do_shortcode( self::default_user_message( $this->until, $this->notes ) );
     280
     281                        $this->mail_from_filters();
     282
     283                        $sent = wp_mail( $to, $subject, $message );
     284
     285                }
     286
     287        }
    265288}
    266289
  • wp-restaurant-booking/tags/1.3.0/includes/class-wprb-reservation-widget.php

    r3650036 r3685965  
    108108
    109109        /**
     110         * Darken a hex color by the given percentage
     111         *
     112         * @param string $hex     the hex color (with or without #).
     113         * @param int    $percent darken percentage.
     114         * @return string the darkened hex color, empty string if invalid input.
     115         */
     116        private function darken_color( $hex, $percent = 12 ) {
     117
     118                $hex = ltrim( $hex, '#' );
     119
     120                if ( 3 === strlen( $hex ) ) {
     121                        $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
     122                }
     123
     124                if ( 6 !== strlen( $hex ) || ! ctype_xdigit( $hex ) ) {
     125                        return '';
     126                }
     127
     128                list( $r, $g, $b ) = array_map( 'hexdec', str_split( $hex, 2 ) );
     129
     130                $r = max( 0, round( $r * ( 1 - $percent / 100 ) ) );
     131                $g = max( 0, round( $g * ( 1 - $percent / 100 ) ) );
     132                $b = max( 0, round( $b * ( 1 - $percent / 100 ) ) );
     133
     134                return sprintf( '#%02x%02x%02x', $r, $g, $b );
     135
     136        }
     137
     138
     139        /**
     140         * Build the CSS custom properties for the widget colors, if set
     141         *
     142         * @param string $color      the main widget color.
     143         * @param string $text_color the widget text color.
     144         * @return string the CSS, empty string if no color is set.
     145         */
     146        private function widget_color_css( $color, $text_color ) {
     147
     148                $vars = array();
     149
     150                if ( $color ) {
     151
     152                        $vars[] = '--wprb-widget-color: ' . $color . ';';
     153
     154                        $accent = $this->darken_color( $color );
     155
     156                        if ( $accent ) {
     157                                $vars[] = '--wprb-widget-accent-color: ' . $accent . ';';
     158                        }
     159                }
     160
     161                if ( $text_color ) {
     162                        $vars[] = '--wprb-widget-text-color: ' . $text_color . ';';
     163                }
     164
     165                if ( empty( $vars ) ) {
     166                        return '';
     167                }
     168
     169                return ':root{' . implode( ' ', $vars ) . '}';
     170
     171        }
     172
     173
     174        /**
    110175         * Scripts and style
    111176         */
    … …  
    114179                /*css*/
    115180                wp_enqueue_style( 'wprb-style', WPRB_URI . 'css/wprb.css' );
     181
     182                $widget_color      = get_option( 'wprb-widget-color' );
     183                $widget_text_color = get_option( 'wprb-widget-text-color' );
     184                $widget_color_css  = $this->widget_color_css( $widget_color, $widget_text_color );
     185
     186                if ( $widget_color_css ) {
     187                        wp_add_inline_style( 'wprb-style', $widget_color_css );
     188                }
     189
    116190                wp_enqueue_style( 'modal-style', WPRB_URI . 'css/jquery.modal.min.css' );
    117191                wp_enqueue_style( 'font-awesome', WPRB_URI . 'css/fontawesome/all.min.css' );
  • wp-restaurant-booking/tags/1.3.0/js/wprb-admin.js

    r3650036 r3685965  
    1717                self.chosen();
    1818                self.tzCheckbox();
    19                 self.externalSeats();
    2019                self.addHours();
    2120                self.removeHours();
    22                 self.addLastMinute();
    23                 self.removeLastMinute();
    2421                self.addclosingPeriod();
    2522                self.removeClosingPeriod();
    … …  
    2825                self.minDateClosingPeriodTo();
    2926                self.autoCompleteFields('internal');
    30                 self.autoCompleteFields('external');
    3127                self.autoCompleteFields('min');
    3228                self.autoCompleteFields('max');
    33                 self.lastMinuteElement();
    3429                self.notificationsElement();
    35                 self.notificationsShortcodes();
     30                self.widgetColorPicker();
    3631        }
    3732
    … …  
    129124
    130125        /**
    131          *External seats option
    132          */
    133         self.externalSeats = function() {
    134 
    135                 jQuery(function($){
    136 
    137                         var col             = $('.wprb-col.external');
    138                         var fieldContainer  = $('.wprb-activate-external-seats-field');
    139                         var field           = $('input', fieldContainer);
    140 
    141                         var fieldCheck = function() {
    142 
    143                                 if ( 'checked' == field.attr('checked') ) {
    144 
    145                                         col.show();
    146 
    147                                 } else {
    148 
    149                                         col.hide();
    150 
    151                                 }
    152                        
    153                         }
    154                         fieldCheck();
    155 
    156                         $('span.tzCheckBox', fieldContainer).on('click', function(){
    157 
    158                                 fieldCheck();
    159 
    160                         })     
    161 
    162                 })
    163 
    164         }
    165 
    166 
    167         /**
    168126         * Add a new hours element
    169127         */
    … …  
    190148                                        $(prev).after(response);
    191149
    192                                         /*Display go premium*/
    193                                         $('.go-premium', container).show('slow');
    194 
    195150                                })
    196151
    … …  
    216171                                $(element).remove();
    217172
    218                                 /*Hide go premium*/
    219                                 if ( $('.wprb-hours-element-2', container).length == 0 ) {
    220 
    221                                         $('.go-premium', container).hide();
    222 
    223                                 }
    224 
    225                         })
    226 
    227                 })
    228 
    229         }
    230 
    231 
    232         /**
    233          * Auto-complete the bookable and external fields of every day, copying the values from the firsts setted
     173                        })
     174
     175                })
     176
     177        }
     178
     179
     180        /**
     181         * Auto-complete the bookable fields of every day, copying the values from the firsts setted
    234182         *
    235          * @param  {Boolean} external true for external field, default for bookable.
     183         * @param  {string} type field type.
    236184         */
    237185        self.autoCompleteFields = function( type = 'internal' ) {
    … …  
    244192                        switch (type) {
    245193
    246                                 case 'internal':
    247                                 element = '#wprb-bookable-seats';
    248 
    249                                 break;
    250 
    251                                 case 'external':
    252                                 element = '#wprb-external-seats';
    253 
    254                                 break;
    255 
    256                                 case 'min':
     194                        case 'internal':
     195                        element = '#wprb-bookable-seats';
     196
     197                        break;
     198
     199                        case 'min':
    257200                                element = '#wprb-min-bookable';
    258201
    … …  
    279222
    280223                                })
    281 
    282                         })
    283 
    284                 })
    285 
    286         }
    287 
    288 
    289         /**
    290          * Handles the visibility of the last minute fields
    291          */
    292         self.lastMinuteElement = function() {
    293 
    294                 jQuery(function($){
    295 
    296                         var toggle      = $('.wprb-activate-last-minute-field .tzCheckBox');
    297                         var lastMinute  = $('.wprb-add-last-minute-field');
    298 
    299                         if ($(toggle).hasClass('checked')) {
    300 
    301                                 lastMinute.show();
    302 
    303                         }
    304 
    305                         $(toggle).on('click', function(){
    306                                
    307                                 if ($(this).hasClass('checked')) {
    308 
    309                                         lastMinute.show('slow');
    310 
    311                                 } else {
    312 
    313                                         lastMinute.hide();
    314 
    315                                 }
    316                        
    317                         })
    318 
    319                 })
    320 
    321         }
    322 
    323 
    324         /**
    325          * Add a new last minute
    326          */
    327         self.addLastMinute = function() {
    328 
    329                 jQuery(function($){
    330 
    331                         $(document).on('click', '.add-last-minute-hover', function(){
    332 
    333 
    334                                 var count = $('.last-minute-element').length;
    335                                 var prev  = $('.wprb-last-minute-element-' + ( count - 1 ) );
    336                                 var next  = count;
    337                                 var data  = {
    338                                         'action': 'wprb-add-last-minute',
    339                                         'wprb-add-last-minute-nonce': wprbSettings.addLastMinuteNonce,
    340                                         'number': next
    341                                 }
    342 
    343                                 $.post(ajaxurl, data, function(response){
    344 
    345                                         $(prev).after(response);
    346 
    347                                 })
    348 
    349                         })
    350 
    351                 })
    352 
    353         }
    354 
    355        
    356         /**
    357          * Remove a last minute
    358          */
    359         self.removeLastMinute = function() {
    360 
    361                 jQuery(function($){
    362 
    363                         $(document).on('click', '.remove-last-minute-hover', function(){
    364 
    365                                 var element = $(this).closest('.last-minute-element');
    366 
    367                                 $(element).remove();
    368224
    369225                        })
    … …  
    463319                                $.post(ajaxurl, data, function(response){
    464320
    465                                         /*Display go premium*/
    466                                         $('.wprb-set-rooms-tables .go-premium').show('slow');
    467                                        
    468321                                        $(prev).after(response);
    469322
    … …  
    489342
    490343                                $(element).remove();
    491 
    492                                 /*Hide go premium*/
    493                                 if ( $('.wprb-room-tables-element-1').length == 0 ) {
    494 
    495                                         $('.wprb-set-rooms-tables .go-premium').hide();
    496 
    497                                 }
    498344
    499345                        })
    … …  
    564410
    565411        /**
    566          * Copy shortcodes to use in user notification
    567          */
    568         self.notificationsShortcodes = function() {
    569 
    570                 jQuery(function($){
    571 
    572                         var $temp;
    573                         var shortcode;
    574 
    575                         /*Add title*/
    576                         $('.shortcodes code').each( function(){
    577 
    578                                 $(this).attr('title', 'Click to copy');
    579 
    580                         })
    581 
    582                         /*Copy shortcode*/
    583                         $('.shortcodes code').on( 'click', function(){
    584 
    585                                 $temp     = $('<input>');
    586                                 shortcode = $(this);
    587                                
    588                                 $('body').append($temp);
    589                                 $temp.val($(shortcode).text()).select();
    590                                 document.execCommand('copy');
    591                                 $temp.remove();
    592 
    593                         })
    594 
    595                 })
    596 
    597         }
     412         * Widget colors picker
     413         */
     414        self.widgetColorPicker = function() {
     415
     416                jQuery(function($){
     417
     418                        if ( typeof $.fn.wpColorPicker === 'function' ) {
     419
     420                                $('.wprb-color-field').wpColorPicker();
     421
     422                        }
     423
     424                })
     425
     426        }
     427
    598428
    599429}
  • wp-restaurant-booking/tags/1.3.0/readme.txt

    r3658642 r3685965  
    22Contributors: ghera74
    33Tags: booking, ticket, reservation, restaurant, bar
    4 Version: 1.2.4
    5 Stable tag: 1.2.4
     4Version: 1.3.0
     5Stable tag: 1.3.0
    66Requires at least: 5.0
    77Tested up to: 7.1
    … …  
    1616**AVAILABLE FUNCTIONALITIES**
    1717
    18 * Activate/ deactivate the booking functionlity in a click.
     18* Activate/deactivate the booking function in a click.
    1919* Booking widget position, even using the shortcode *[booking-button]*.
    20 * Set a number of bookable seats for each day of the week.
    21 * Define the time slots that can be booked every day
    22 * Outdoor tables option (Premium).
    23 * Last minute table option (Premium).
    24 * Set time limit within which to book a table.
     20* Customizable widget colors (background and text color).
     21* Set a number of bookable seats for each day of the week, with a minimum and a maximum bookable.
     22* Multiple bookable time slots for each day (for example lunch and dinner), with the interval between one time and the next.
     23* Closing days: days of the week and closing periods on specific dates (holidays).
     24* Set a time limit within which to book a table.
    2525* Set an average time of the customer at the table, useful for calculating availability.
    2626* Assign a table to each reservation.
    … …  
    2929* Admin and user email notifications.
    3030
     31**PREMIUM VERSION**
     32
     33The premium version of **ilGhera Restaurant Booking for WordPress** adds the following functionalities:
     34
     35* Outdoor seats, with availability calculated separately.
     36* Last minute tables.
     37* Multiple rooms, each with its own number of tables.
     38* HTML email templates with custom header and footer.
     39* Inline booking form using the shortcode *[booking-form]*.
     40
     41https://www.ilghera.com/product/wp-restaurant-booking-premium/
     42
    3143https://youtu.be/fAk2Hzm2E7k
    3244
    … …  
    4759== Screenshots ==
    4860
    49 1. Select date and number of people
     611. Select the date and the number of people
    50622. Select the booking time
    51633. Add your data
    52644. The reservation was completed
    53 5. General settings
    54 6. Last minute settings (Premium)
    55 7. Admin and user email settings
    56 8. Admin reservations
    57 9. Edit single reservation
     655. General settings, with the booking widget colors
     666. Bookable seats for each day of the week
     677. Bookable time slots, more than one for each day
     688. Closing days and closing periods
     699. Admin and user email notifications
     7010. Admin reservations
     7111. Edit single reservation
     7212. The functionalities available in the premium version
    5873
    5974
    6075== Changelog ==
     76
     77= 1.3.0 =
     78Release Date: 7 September 2026
     79
     80    * New: multiple bookable time slots for each day, now included in the free version.
     81    * New: closing days, both weekdays and closing periods on specific dates, now included in the free version.
     82    * New: customizable booking widget colors (background and text color).
     83    * New: Premium tab with the list of the features available in the premium version.
     84    * Tweak: settings pages cleaned up, the options reserved to the premium version are no longer shown as disabled fields.
     85    * Fix: the confirmation email was never sent to the customer, and the User notifications switch was not saved.
     86    * Fix: the Chosen library used by the multiple selects was enqueued but not included in the package, so both files returned a 404.
     87    * Fix: the link to the premium version pointed to a page that no longer exists.
     88
    6189
    6290= 1.2.4 =
  • wp-restaurant-booking/tags/1.3.0/wp-restaurant-booking.php

    r3660604 r3685965  
    22/**
    33 * Plugin Name: ilGhera Restaurant Booking for WordPress
    4  * Plugin URI: https://www.ilghera.com/product/wordpress-restaurant-booking-premium
     4 * Plugin URI: https://www.ilghera.com/product/wp-restaurant-booking-premium
    55 * Description: A feature-rich and easy to use reservation system for bars and restaurants.
    66 * Author: ilGhera
    7  * Version: 1.2.4
     7 * Version: 1.3.0
    88 * Author URI: https://ilghera.com
    99 * Requires at least: 5.0
  • wp-restaurant-booking/trunk/admin/class-wprb-admin.php

    r3650036 r3685965  
    2929
    3030                        add_action( 'admin_init', array( $this, 'save_reservations_settings' ) );
    31                         add_action( 'admin_init', array( $this, 'save_last_minute_settings' ) );
     31                        add_action( 'admin_init', array( $this, 'save_closing_days_settings' ) );
    3232                        add_action( 'admin_init', array( $this, 'save_rooms_tables_settings' ) );
    3333                        add_action( 'admin_init', array( $this, 'save_notifications_settings' ) );
    … …  
    3535                        add_action( 'admin_menu', array( $this, 'register_wprb_admin' ) );
    3636                        add_action( 'wp_ajax_wprb-add-hours', array( $this, 'hours_element_callback' ) );
    37                         add_action( 'wp_ajax_wprb-add-last-minute', array( $this, 'last_minute_element_callback' ) );
    3837                        add_action( 'wp_ajax_wprb-add-closing-period', array( $this, 'closing_period_element_callback' ) );
    3938                        add_action( 'wp_ajax_wprb-add-room-tables', array( $this, 'room_tables_element_callback' ) );
    40 
    41                         add_action(
    42                                 'in_plugin_update_message-' . basename( WPRB_DIR ) . '/wp-restaurant-booking.php',
    43                                 array(
    44                                         $this,
    45                                         'wprb_update_message',
    46                                 ),
    47                                 10,
    48                                 2
    49                         );
    5039
    5140                }
    … …  
    7766                        /*Nonce*/
    7867                        $add_hours_nonce          = wp_create_nonce( 'wprb-add-hours' );
    79                         $add_last_minute_nonce    = wp_create_nonce( 'wprb-add-last-minute' );
    8068                        $add_closing_period_nonce = wp_create_nonce( 'wprb-add-closing-period' );
    8169                        $add_room_tables_nonce    = wp_create_nonce( 'wprb-add-room-tables' );
    … …  
    8876                        wp_enqueue_style( 'wprb-admin-style', WPRB_URI . 'css/wprb-admin.css' );
    8977                        wp_enqueue_style( 'tzcheckbox-style', WPRB_URI . 'js/tzCheckbox/jquery.tzCheckbox/jquery.tzCheckbox.css' );
     78                        wp_enqueue_style( 'wp-color-picker' );
    9079
    9180                        /*js*/
    9281                        wp_enqueue_script( 'wprb-admin-js', WPRB_URI . 'js/wprb-admin.js', array( 'jquery' ), '1.0', true );
    9382                        wp_enqueue_script( 'tzcheckbox', WPRB_URI . 'js/tzCheckbox/jquery.tzCheckbox/jquery.tzCheckbox.js', array( 'jquery' ) );
     83                        wp_enqueue_script( 'wp-color-picker' );
    9484
    9585                        /*Pass data to the script file*/
    … …  
    9989                                array(
    10090                                        'addHoursNonce'         => $add_hours_nonce,
    101                                         'addLastMinuteNonce'    => $add_last_minute_nonce,
    10291                                        'addClosingPeriodNonce' => $add_closing_period_nonce,
    10392                                        'addRoomTablesNonce'    => $add_room_tables_nonce,
    … …  
    244233
    245234        /**
    246          * Go premium button
    247          */
    248         public function go_premium() {
    249 
    250                 $title = __( 'This is a premium functionality, click here for more information', 'wp-restaurant-booking' );
    251                 $output = '<span class="wprb label label-warning premium">';
    252                         $output .= '<a href="https://www.ilghera.com/product/wp-restaurant-booking-premium" target="_blank" title="' . esc_attr( $title ) . '">Premium</a>';
    253                 $output .= '</span>';
    254 
    255                 $allowed = array(
    256                         'span' => array(
    257                                 'class' => [],
    258                         ),
    259                         'a'    => array(
    260                                 'target' => [],
    261                                 'title'  => [],
    262                                 'href'   => [],
    263                         ),
    264                 );
    265 
    266                 echo wp_kses( $output, $allowed );
    267 
    268         }
    269 
    270         /**
    271235         * Return a single hours element as ajax callback
    272236         */
    … …  
    298262                $to    = isset( $data['to'] ) ? $data['to'] : '';
    299263                $every = isset( $data['every'] ) ? $data['every'] : '';
    300                 $disabled = 1 !== $number ? ' disabled' : '';
    301264
    302265                echo '<div class="wprb-hours-element-' . esc_attr( $number ) . ' hours-element">';
    303266
    304267                        echo '<label for="wprb-bookable-hours-from">' . esc_html__( 'From', 'wp-restaurant-booking' ) . '</label>';
    305                         echo '<input type="time" name="wprb-' . esc_attr( $day ) . '-bookable-hours-from-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-from" class="wprb-bookable-hours-from" max="23:59" value="' . esc_attr( $from ) . '" required' . $disabled . '>';
     268                        echo '<input type="time" name="wprb-' . esc_attr( $day ) . '-bookable-hours-from-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-from" class="wprb-bookable-hours-from" max="23:59" value="' . esc_attr( $from ) . '">';
    306269
    307270                        echo '<label for="wprb-bookable-hours-to">' . esc_html__( 'to', 'wp-restaurant-booking' ) . '</label>';
    308                         echo '<input type="time" name="wprb-' . esc_attr( $day ) . '-bookable-hours-to-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-to" class="wprb-bookable-hours-to" max="23:59" value="' . esc_attr( $to ) . '" required' . $disabled . '>';
     271                        echo '<input type="time" name="wprb-' . esc_attr( $day ) . '-bookable-hours-to-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-to" class="wprb-bookable-hours-to" max="23:59" value="' . esc_attr( $to ) . '">';
    309272
    310273                        echo '<label for="wprb-bookable-hours-every">' . esc_html__( 'every (minutes)', 'wp-restaurant-booking' ) . '</label>';
    311                         echo '<input type="number" name="wprb-' . esc_attr( $day ) . '-bookable-hours-every-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-every" class="wprb-bookable-hours-every" min="5" max="60" step="5" placeholder="15" value="' . esc_attr( $every ) . '" required' . $disabled . '>';
     274                        echo '<input type="number" name="wprb-' . esc_attr( $day ) . '-bookable-hours-every-' . esc_attr( $number ) . '" id="wprb-' . esc_attr( $day ) . '-bookable-hours-every" class="wprb-bookable-hours-every" min="5" max="60" step="5" placeholder="15" value="' . esc_attr( $every ) . '">';
    312275
    313276                        if ( 1 === $number ) {
    … …  
    342305                        if ( $this->saved_hours && isset( $this->saved_hours[ $day ] )) {
    343306
    344                                 $this->hours_element( $day, 1, $this->saved_hours[ $day ][1] );
     307                                $count = count( $this->saved_hours[ $day ] );
     308
     309                                for ( $i = 1; $i <= $count; $i++ ) {
     310
     311                                        $this->hours_element( $day, $i, $this->saved_hours[ $day ][ $i ] );
     312
     313                                }
    345314
    346315                        } else {
    … …  
    350319                        }
    351320
    352                         echo '<div class="go-premium">';
    353 
    354                                 $this->go_premium();
    355                        
    356                         echo '</div>';
    357        
    358321                echo '</div>';
    359 
    360         }
    361 
    362         /**
    363          * Return a single last minute element as ajax callback
    364          */
    365         public function last_minute_element_callback() {
    366 
    367                 if ( isset( $_POST['number'], $_POST['wprb-add-last-minute-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['wprb-add-last-minute-nonce'] ), 'wprb-add-last-minute' ) ) {
    368 
    369                         $number = sanitize_text_field( wp_unslash( $_POST['number'] ) );
    370 
    371                         $this->last_minute( $number );
    372 
    373                 }
    374 
    375                 exit;
    376 
    377         }
    378 
    379         /**
    380          * Display a single last minute
    381          *
    382          * @param int   $number the number of hours element.
    383          * @param array $data single element data coming from the db.
    384          */
    385         public function last_minute( $number = 0, $data = array() ) {
    386 
    387                 $date   = null;
    388                 $from   = null;
    389                 $to     = null;
    390                 $people = null;
    391 
    392                 echo '<div class="wprb-last-minute-element-' . esc_attr( $number ) . ' last-minute-element">';
    393 
    394                         echo '<label for="wprb-last-minute-date">' . esc_html__( 'On', 'wp-restaurant-booking' ) . '</label>';
    395                         echo '<input type="date" name="wprb-last-minute-date-' . esc_attr( $number ) . '" id="wprb-last-minute-date" class="wprb-last-minute-date" min="' . esc_html( date( 'Y-m-d' ) ) . '" value="' . esc_attr( $date ) . '" disabled>';
    396 
    397                         echo '<label for="wprb-last-minute-from">' . esc_html__( 'from', 'wp-restaurant-booking' ) . '</label>';
    398                         echo '<input type="time" name="wprb-last-minute-from-' . esc_attr( $number ) . '" id="wprb-last-minute-from" class="wprb-last-minute-from" min="12:00" max="23:00" value="' . esc_attr( $from ) . '" required disabled>';
    399 
    400                         echo '<label for="wprb-last-minute-to">' . esc_html__( 'to', 'wp-restaurant-booking' ) . '</label>';
    401                         echo '<input type="time" name="wprb-last-minute-to-' . esc_attr( $number ) . '" id="wprb-last-minute-to" class="wprb-last-minute-to" min="12:00" max="23:00" value="' . esc_attr( $to ) . '" required disabled>';
    402 
    403                         echo '<label for="wprb-last-minute-people">' . esc_html__( 'people', 'wp-restaurant-booking' ) . '</label>';
    404                         echo '<input type="number" name="wprb-last-minute-people-' . esc_attr( $number ) . '" id="wprb-last-minute-people" class="wprb-last-minute-people" step="1" placeholder="0" value="' . esc_attr( $people ) . '" required disabled>';
    405 
    406                         if ( 0 === $number ) {
    407 
    408                                 echo '<div class="wprb-add-last-minute-container">';
    409                                         echo '<img class="add-last-minute" src="' . esc_url( WPRB_URI . 'images/add-icon.png' ) . '">';
    410                                         echo '<img class="add-last-minute-hover" src="' . esc_url( WPRB_URI . 'images/add-icon-hover.png' ) . '">';
    411                                 echo '</div>';
    412 
    413                         } else {
    414 
    415                                 echo '<div class="wprb-remove-last-minute-container">';
    416                                         echo '<img class="remove-last-minute" src="' . esc_url( WPRB_URI . 'images/remove-icon.png' ) . '">';
    417                                         echo '<img class="remove-last-minute-hover" src="' . esc_url( WPRB_URI . 'images/remove-icon-hover.png' ) . '">';
    418                                 echo '</div>';
    419 
    420                         }
    421                                                
    422                 echo '</div>';
    423 
    424         }
    425 
    426         /**
    427          * Display the last minute element in the plugin admin area
    428          */
    429         public function display_last_minute_elements() {
    430 
    431                 $this->last_minute();
    432322
    433323        }
    … …  
    441331        public function room_tables( $number = 0, $data = array() ) {
    442332
    443                 $name     = isset( $data['name'] ) ? $data['name'] : '';
    444                 $tables   = isset( $data['tables'] ) ? $data['tables'] : 0;
    445                 $disabled = 0 !== $number ? ' disabled' : '';
     333                $name   = isset( $data['name'] ) ? $data['name'] : '';
     334                $tables = isset( $data['tables'] ) ? $data['tables'] : 0;
    446335
    447336                echo '<tr class="wprb-room-tables-element-' . esc_attr( $number ) . ' room-tables-element">';
    … …  
    452341
    453342                                echo '<label>' . esc_html__( 'Name', 'wp-restaurant-booking' ) . '</label>';
    454                                 echo '<input type="text" name="room-name-' . esc_attr( $number ) . '" value="' . esc_attr( $name ) . '" placeholder="' . sprintf( esc_attr( 'Room %d', 'wp-restaurant-booking' ), esc_attr( $number + 1 ) ) . '"' . $disabled . '>';
     343                                echo '<input type="text" name="room-name-' . esc_attr( $number ) . '" value="' . esc_attr( $name ) . '" placeholder="' . sprintf( esc_attr( 'Room %d', 'wp-restaurant-booking' ), esc_attr( $number + 1 ) ) . '">';
    455344
    456345                                echo '<label>' . esc_html__( 'Tables', 'wp-restaurant-booking' ) . '</label>';
    457                                 echo '<input type="number" name="tables-number-' . esc_attr( $number ) . '" min="1" value="' . esc_attr( $tables ) . '"' . $disabled . '>';
    458 
    459                                 if ( 0 === $number ) {
    460 
    461                                         echo '<div class="wprb-add-room-tables-container">';
    462                                                 echo '<img class="add-room-tables" src="' . esc_url( WPRB_URI . 'images/add-icon.png' ) . '">';
    463                                                 echo '<img class="add-room-tables-hover" src="' . esc_url( WPRB_URI . 'images/add-icon-hover.png' ) . '">';
    464                                         echo '</div>';
    465 
    466                                 } else {
    467 
    468                                         echo '<div class="wprb-remove-room-tables-container">';
    469                                                 echo '<img class="remove-room-tables" src="' . esc_url( WPRB_URI . 'images/remove-icon.png' ) . '">';
    470                                                 echo '<img class="remove-room-tables-hover" src="' . esc_url( WPRB_URI . 'images/remove-icon-hover.png' ) . '">';
    471                                         echo '</div>';
    472 
    473                                 }
    474                                
     346                                echo '<input type="number" name="tables-number-' . esc_attr( $number ) . '" min="1" value="' . esc_attr( $tables ) . '">';
     347
    475348                                echo '<p class="description">' . esc_html__( 'Add a name and the number of tables to this restaurant room', 'wp-restaurant-booking' ) . '</p>';
    476349
    … …  
    531404        public function closing_period( $number = 0, $data = array() ) {
    532405
    533                 $from   = null;
    534                 $to     = null;
     406                $from = isset( $data['from'] ) ? $data['from'] : '';
     407                $to   = isset( $data['to'] ) ? $data['to'] : '';
    535408
    536409                echo '<div class="wprb-closing-period-element-' . esc_attr( $number ) . ' closing-period-element">';
    … …  
    563436
    564437        /**
    565          * Display the last minute element in the plugin admin area
     438         * Return a single closing period element as ajax callback
     439         */
     440        public function closing_period_element_callback() {
     441
     442                if ( isset( $_POST['number'], $_POST['wprb-add-closing-period-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['wprb-add-closing-period-nonce'] ), 'wprb-add-closing-period' ) ) {
     443
     444                        $number = sanitize_text_field( wp_unslash( $_POST['number'] ) );
     445
     446                        $this->closing_period( $number );
     447
     448                }
     449
     450                exit;
     451
     452        }
     453
     454        /**
     455         * Auto-delete the closing periods out of date
     456         */
     457        public function get_filtered_closing_periods() {
     458
     459                $output = null;
     460
     461                $closing_periods = get_option( 'wprb-closing-periods' );
     462
     463                if ( $closing_periods ) {
     464
     465                        $count = count( $closing_periods );
     466
     467                        for ( $i = 0; $i < $count; $i++ ) {
     468
     469                                $to = isset( $closing_periods[ $i ]['to'] ) ? $closing_periods[ $i ]['to'] : '';
     470
     471                                /*Check for expired elements*/
     472                                if ( $to ) {
     473
     474                                        $to  = strtotime( $to );
     475                                        $now = strtotime( 'now' );
     476
     477                                        if ( $now > $to ) {
     478
     479                                                unset( $closing_periods[ $i ] );
     480
     481                                        }
     482
     483                                }
     484
     485                        }
     486
     487                        $output = array_values( $closing_periods );
     488
     489                        update_option( 'wprb-closing-periods', $output );
     490
     491                        return $output;
     492
     493                }
     494
     495        }
     496
     497        /**
     498         * Display the closing period elements in the plugin admin area
    566499         */
    567500        public function display_closing_period_elements() {
    568501
    569                 $this->closing_period();
     502                $closing_periods = $this->get_filtered_closing_periods();
     503
     504                if ( $closing_periods ) {
     505
     506                        $count = count( $closing_periods );
     507
     508                        for ( $i = 0; $i < $count; $i++ ) {
     509
     510                                $this->closing_period( $i, $closing_periods[ $i ] );
     511
     512                        }
     513
     514                } else {
     515
     516                        $this->closing_period();
     517
     518                }
    570519
    571520        }
    … …  
    607556                        update_option( 'wprb-expiration-time', $expiration_time );
    608557
     558                        /*Widget color*/
     559                        $widget_color = isset( $_POST['wprb-widget-color'] ) ? sanitize_hex_color( wp_unslash( $_POST['wprb-widget-color'] ) ) : '';
     560                        update_option( 'wprb-widget-color', $widget_color );
     561
     562                        /*Widget text color*/
     563                        $widget_text_color = isset( $_POST['wprb-widget-text-color'] ) ? sanitize_hex_color( wp_unslash( $_POST['wprb-widget-text-color'] ) ) : '';
     564                        update_option( 'wprb-widget-text-color', $widget_text_color );
     565
    609566                }
    610567
    … …  
    660617                        foreach ( self::week() as $key => $value ) {
    661618
    662                                 $from = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-from-1' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-from-1' ] ) ) : null;
    663 
    664                                 $to = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-to-1' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-to-1' ] ) ) : null;
    665 
    666                                 $every = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-every-1' ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-every-1' ] ) ) : null;
    667 
    668                                 if ( $from && $to && $every ) {
    669 
    670                                         $save_hours[ $key ][1] = array(
    671                                                 'from'  => $from,
    672                                                 'to'    => $to,
    673                                                 'every' => $every,
    674                                         );
     619                                /*10 is the current limit*/
     620                                for ( $i = 1; $i <= 10; $i++ ) {
     621
     622                                        $from = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-from-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-from-' . $i ] ) ) : null;
     623
     624                                        $to = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-to-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-to-' . $i ] ) ) : null;
     625
     626                                        $every = isset( $_POST[ 'wprb-' . $key . '-bookable-hours-every-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-' . $key . '-bookable-hours-every-' . $i ] ) ) : null;
     627
     628                                        if ( $from && $to && $every ) {
     629
     630                                                $save_hours[ $key ][ $i ] = array(
     631                                                        'from'  => $from,
     632                                                        'to'    => $to,
     633                                                        'every' => $every,
     634                                                );
     635
     636                                        } else {
     637
     638                                                break;
     639
     640                                        }
    675641
    676642                                }
    … …  
    685651
    686652        /**
    687          * Save last minute
    688          */
    689         public function save_last_minute_settings() {
    690 
    691                 if ( isset( $_POST['wprb-set-last-minute-sent'], $_POST['wprb-set-last-minute-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['wprb-set-last-minute-nonce'] ), 'wprb-set-last-minute' ) ) {
    692 
    693                         /*Last minute activate*/
    694                         $activate = isset( $_POST['wprb-activate-last-minute'] ) ? sanitize_text_field( wp_unslash( $_POST['wprb-activate-last-minute'] ) ) : 0;
    695                         update_option( 'wprb-activate-last-minute', $activate );
    696 
    697                         /*Last minute description*/
    698                         $description = isset( $_POST['wprb-last-minute-description'] ) ? sanitize_text_field( wp_unslash( $_POST['wprb-last-minute-description'] ) ) : '';
    699                         update_option( 'wprb-last-minute-description', $description );
    700 
    701                         /*Set last minute*/
    702                         $last_minute = array();
     653         * Save closing days
     654         */
     655        public function save_closing_days_settings() {
     656
     657                if ( isset( $_POST['wprb-set-closing-days-sent'], $_POST['wprb-set-closing-days-nonce'] ) && wp_verify_nonce( wp_unslash( $_POST['wprb-set-closing-days-nonce'] ), 'wprb-set-closing-days' ) ) {
     658
     659                        /*Closing days*/
     660                        $closing_days = isset( $_POST['wprb-closing-days'] ) ? $_POST['wprb-closing-days'] : '';
     661                        update_option( 'wprb-closing-days', $closing_days );
     662
     663                        /*Closing periods*/
     664                        $closing_periods = array();
    703665
    704666                        /*20 is the current limit*/
    705667                        for ( $i = 0; $i <= 20; $i++ ) {
    706668
    707                                 $date = isset( $_POST[ 'wprb-last-minute-date-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-last-minute-date-' . $i ] ) ) : null;
    708                                 $from = isset( $_POST[ 'wprb-last-minute-from-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-last-minute-from-' . $i ] ) ) : null;
    709                                 $to = isset( $_POST[ 'wprb-last-minute-to-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-last-minute-to-' . $i ] ) ) : null;
    710                                 $people = isset( $_POST[ 'wprb-last-minute-people-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-last-minute-people-' . $i ] ) ) : null;
    711                                 if ( $date && $from && $to && $people ) {
    712 
    713                                         $last_minute[ $i ] = array(
    714                                                 'date'   => $date,
     669                                $from = isset( $_POST[ 'wprb-closing-period-from-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-closing-period-from-' . $i ] ) ) : null;
     670                                $to   = isset( $_POST[ 'wprb-closing-period-to-' . $i ] ) ? sanitize_text_field( wp_unslash( $_POST[ 'wprb-closing-period-to-' . $i ] ) ) : null;
     671
     672                                if ( $from && $to ) {
     673
     674                                        $closing_periods[ $i ] = array(
    715675                                                'from'   => $from,
    716676                                                'to'     => $to,
    717                                                 'people' => $people,
    718677                                        );
    719678
    … …  
    726685                        }
    727686
    728                         update_option( 'wprb-last-minute', $last_minute );
     687                        update_option( 'wprb-closing-periods', $closing_periods );
    729688
    730689                }
    … …  
    781740                        $admin_recipients = isset( $_POST['wprb-admin-recipients'] ) && '' !== $_POST['wprb-admin-recipients'] ? explode( ' ', sanitize_text_field( wp_unslash( $_POST['wprb-admin-recipients'] ) ) ) : '';
    782741                        update_option( 'wprb-admin-recipients', $admin_recipients );
     742
     743                        $user_activate = isset( $_POST['wprb-activate-user-notification'] ) ? sanitize_text_field( wp_unslash( $_POST['wprb-activate-user-notification'] ) ) : '';
     744                        update_option( 'wprb-activate-user-notification', $user_activate );
    783745
    784746                }
    … …  
    811773                                        echo '<a href="#" data-link="wprb-set-hours" class="nav-tab" onclick="return false;">' . esc_html( __( 'Hours', 'wp-restaurant-booking' ) ) . '</a>';
    812774                                        echo '<a href="#" data-link="wprb-set-closing-days" class="nav-tab" onclick="return false;">' . esc_html( __( 'Closing days', 'wp-restaurant-booking' ) ) . '</a>';
    813                                         echo '<a href="#" data-link="wprb-set-last-minute" class="nav-tab" onclick="return false;">' . esc_html( __( 'Last minute', 'wp-restaurant-booking' ) ) . '</a>';
    814775                                        echo '<a href="#" data-link="wprb-set-notifications" class="nav-tab" onclick="return false;">' . esc_html( __( 'Notifications', 'wp-restaurant-booking' ) ) . '</a>';
     776                                        echo '<a href="#" data-link="wprb-set-premium" class="nav-tab nav-tab-premium" onclick="return false;"><span class="dashicons dashicons-star-filled"></span> ' . esc_html( __( 'Premium', 'wp-restaurant-booking' ) ) . '</a>';
    815777                                echo '</h2>';
    816778
    … …  
    850812                                echo '</div>';
    851813
    852                                 /*Set last minute*/
    853                                 echo '<div id="wprb-set-last-minute" class="wprb-admin">';
    854 
    855                                         include( WPRB_ADMIN . 'wprb-set-last-minute-template.php' );
    856 
    857                                 echo '</div>';
    858 
    859814                                /*Set notifications*/
    860815                                echo '<div id="wprb-set-notifications" class="wprb-admin">';
    861816
    862817                                        include( WPRB_ADMIN . 'wprb-set-notifications-template.php' );
     818
     819                                echo '</div>';
     820
     821                                /*Premium features*/
     822                                echo '<div id="wprb-set-premium" class="wprb-admin">';
     823
     824                                        include( WPRB_ADMIN . 'wprb-set-premium-template.php' );
    863825
    864826                                echo '</div>';
  • wp-restaurant-booking/trunk/admin/wprb-set-bookables-template.php

    r3650036 r3685965  
    1515
    1616        <table class="form-table">
    17                 <tr class="wprb-activate-external-seats-field">
    18                         <th scope="row"><?php esc_html_e( 'External seats', 'wp-restaurant-booking' ); ?></th>
    19                         <td>
    20                                 <input type="checkbox" name="wprb-activate-external-seats" id="wprb-activate-external-seats" value="1">
    21                                 <p class="description"><?php esc_html_e( 'Activate if external seats are available in your restaurant in this season.', 'wp-restaurant-booking' ); ?></p>
    22                                 <?php $admin->go_premium(); ?>
    23                         </td>
    24                 </tr>
    2517                <tr>
    2618                        <th scope="row"><?php esc_html_e( 'Bookable seats', 'wp-restaurant-booking' ); ?></th>
    … …  
    3325                                                if ( 'mon' === $key ) {
    3426                                                        echo '<div class="wprb-col"><h4>' . esc_html__( 'Internal seats', 'wp-restaurant-booking' ) . '</h4></div>';
    35                                                         echo '<div class="wprb-col external"><h4>' . esc_html__( 'External seats', 'wp-restaurant-booking' ) . '</h4></div>';
    3627                                                        echo '<div class="wprb-col min-bookable"><h4>' . esc_html__( 'Minimum bookable number', 'wp-restaurant-booking' ) . '</h4></div>';
    3728                                                        echo '<div class="wprb-col max-bookable"><h4>' . esc_html__( 'Maximum bookable number', 'wp-restaurant-booking' ) . '</h4></div>';
    … …  
    4839
    4940                                                        echo '<input type="number" name="wprb-bookable-seats-' . esc_attr( $key ) . '" id="wprb-bookable-seats" class="' . esc_attr( $key ) . '" placeholder="0" value="' . esc_attr( $bookable_value ) . '">';
    50                                                 echo '</div>';
    51 
    52                                                 echo '<div class="wprb-col external">';
    53 
    54                                                         echo '<input type="number" name="wprb-external-seats-' . esc_attr( $key ) . '" id="wprb-external-seats" class="' . esc_attr( $key ) . '" placeholder="0" value="0" disabled>';
    55 
    5641                                                echo '</div>';
    5742
  • wp-restaurant-booking/trunk/admin/wprb-set-closing-days-template.php

    r3650036 r3685965  
    55 * @author ilGhera
    66 * @package wp-restaurant-booking/admin
    7  * @since 1.1.7
     7 * @since 1.1.8
    88 */
    99
     10$closing_days = get_option( 'wprb-closing-days' );
    1011?>
    1112<!-- Form -->
    … …  
    2021                                        foreach ( WPRB_Admin::week() as $key => $value ) {
    2122                                               
    22                                                 echo '<option value="' . esc_attr( $key ) . '">' . esc_html( ucfirst( $value ) ) . '</option>';
     23                                                echo '<option value="' . esc_attr( $key ) . '"' . ( is_array( $closing_days ) && in_array( $key , $closing_days) ? ' selected="selected"' : '' ) . '>' . esc_html( ucfirst( $value ) ) . '</option>';
    2324
    2425                                        }
    … …  
    3738                        </td>
    3839                </tr>
    39                 <tr>
    40                         <th></th>
    41                 <td><?php $admin->go_premium(); ?></td>
    42                 </tr>
    4340        </table>
    4441
    … …  
    4643
    4744        <input type="hidden" name="wprb-set-closing-days-sent" value="1">
    48         <input type="submit" class="button-primary wprb" value="<?php esc_html_e( 'Save settings', 'wp-restaurant-booking' ); ?>" disabled>
     45        <input type="submit" class="button-primary wprb" value="<?php esc_html_e( 'Save settings', 'wp-restaurant-booking' ); ?>">
    4946
    5047</form>
  • wp-restaurant-booking/trunk/admin/wprb-set-general-template.php

    r3650036 r3685965  
    1717$expiration_time           = get_option( 'wprb-expiration-time' );
    1818$policy_page               = get_option( 'wprb-policy-page' );
     19$widget_color              = get_option( 'wprb-widget-color' );
     20$widget_text_color         = get_option( 'wprb-widget-text-color' );
    1921?>
    2022<!-- Form -->
    … …  
    9799                        </td>
    98100                </tr>
     101                <tr>
     102                        <th scope="row"><?php esc_html_e( 'Widget color', 'wp-restaurant-booking' ); ?></th>
     103                        <td>
     104                                <input type="text" class="wprb-color-field" name="wprb-widget-color" value="<?php echo esc_attr( $widget_color ); ?>">
     105                                <p class="description"><?php esc_html_e( 'Main color of the booking widget. Leave empty to use the default yellow.', 'wp-restaurant-booking' ); ?></p>
     106                        </td>
     107                </tr>
     108                <tr>
     109                        <th scope="row"><?php esc_html_e( 'Widget text color', 'wp-restaurant-booking' ); ?></th>
     110                        <td>
     111                                <input type="text" class="wprb-color-field" name="wprb-widget-text-color" value="<?php echo esc_attr( $widget_text_color ); ?>">
     112                                <p class="description"><?php esc_html_e( 'Text color used on top of the widget main color, for contrast. Leave empty to use the default white.', 'wp-restaurant-booking' ); ?></p>
     113                        </td>
     114                </tr>
    99115        </table>
    100116
  • wp-restaurant-booking/trunk/admin/wprb-set-notifications-template.php

    r3650036 r3685965  
    1111$admin_activate       = get_option( 'wprb-activate-admin-notification' );
    1212$admin_recipients     = get_option( 'wprb-admin-recipients' ) ? get_option( 'wprb-admin-recipients' ) : array( get_option( 'admin_email' ) );
    13 
    14 /*Define the user object*/
    15 $default_user_object  = WPRB_Notifications::default_user_object();
    16 $user_object          = null;
    17 
    18 /*Define the admin object*/
    19 $default_user_message = WPRB_Notifications::default_user_message();
    20 $user_message         = null;
     13$user_activate        = get_option( 'wprb-activate-user-notification' );
    2114?>
    2215
    … …  
    5346                        <th scope="row"><?php esc_html_e( 'User notifications', 'wp-restaurant-booking' ); ?></th>
    5447                        <td>
    55                                 <input type="checkbox" name="wprb-activate-user-notification" id="wprb-activate-user-notification" value="1">
     48                                <input type="checkbox" name="wprb-activate-user-notification" id="wprb-activate-user-notification" value="1"<?php echo ( 1 == $user_activate ? ' checked="checked"' : '' ); ?>>
    5649                                <p class="description"><?php esc_html_e( 'Activate email notifications for the user.', 'wp-restaurant-booking' ); ?></p>
    57                         </td>
    58                 </tr>
    59                 <tr class="wprb-user-notification-field" style="display: none;">
    60                         <th scope="row"><?php esc_html_e( 'Object', 'wp-restaurant-booking' ); ?></th>
    61                         <td>
    62                                 <input type="text" name="wprb-user-notification-object" class="wprb-user-notification-object regular-text" placeholder="<?php echo esc_attr( $default_user_object ); ?>" value="<?php echo esc_attr( $user_object ); ?>" disabled>
    63                                 <p class="description"><?php esc_html_e( 'Specify a different email object.', 'wp-restaurant-booking' ); ?></p>
    64                         </td>
    65                 </tr>
    66                 <tr class="wprb-user-notification-field" style="display: none;">
    67                         <th scope="row"><?php esc_html_e( 'Message', 'wp-restaurant-booking' ); ?></th>
    68                         <td>
    69                                 <textarea type="text" name="wprb-user-notification-message" class="wprb-user-notification-message regular-text" rows="6" placeholder="<?php echo esc_attr( $default_user_message ); ?>" disabled><?php echo esc_html( $user_message ); ?></textarea>
    70                                 <p class="description">
    71                                         <?php
    72                                         echo '<span class="shortcodes">';
    73                                                 echo '<code>[first-name]</code> <code>[last-name]</code> <code>[email]</code> <code>[phone]</code>';
    74                                                 echo '<code>[people]</code> <code>[in-outdoor]</code> <code>[date]</code> <code>[time]</code> <code>[until]</code> <code>[notes]</code>';
    75                                         echo '</span>';
    76                                         esc_html_e( 'Specify a different email message.', 'wp-restaurant-booking' );
    77                                         ?>
    78                                 </p>
    79                                 <?php $admin->go_premium(); ?>
    8050                        </td>
    8151                </tr>
  • wp-restaurant-booking/trunk/admin/wprb-set-tables-template.php

    r3650036 r3685965  
    1414
    1515                <?php $admin->display_rooms_tables_elements(); ?>
    16 
    17                 <tr class="go-premium">
    18                         <th></th>
    19                 <td><?php $admin->go_premium(); ?></td>
    20                 </tr>
    2116       
    2217        </table>
  • wp-restaurant-booking/trunk/css/wprb-admin.css

    r3650036 r3685965  
    6868#submit-key:active {
    6969        top: 2px;
    70 }
    71 
    72 .nav-tab.not-available, .nav-tab.not-available:hover {
    73         border-width: 1px 1px medium;
    74     border-style: solid solid none;
    75     border-color: #CCC #CCC -moz-use-text-color;
    76     -moz-border-top-colors: none;
    77     -moz-border-right-colors: none;
    78     -moz-border-bottom-colors: none;
    79     -moz-border-left-colors: none;
    80     border-image: none;
    81     background: #E4E4E4 none repeat scroll 0% 0%;
    82     display: inline-block;
    83     text-decoration: none;
    84     opacity:0.4;
    8570}
    8671
    … …  
    544529}
    545530
    546 .wprb.label-warning.premium {
    547     display: inline-block;
    548     margin: 10px 0 0;
    549         padding: 7px 14px;
    550         font-size: 12px;
    551         font-weight: bold;
    552         line-height: 1;
    553         text-align: center;
    554         white-space: nowrap;
    555         vertical-align: baseline;
    556         border-radius: .25em;
    557         background-color: #f0ad4e;
    558         cursor: pointer;
    559 }
    560 
    561 .label-warning a {
    562         color: #ffffff;
    563         text-decoration: none;
    564 }
    565 
    566 .label-warning a:hover {
    567         color: #0073aa;
    568 }
    569 
    570 .go-premium {
    571         display: none;
    572 }
    573 
    574531.old-table {
    575532        display: block;
    … …  
    590547
    591548        .wrap-right {
    592                 float: none; 
    593                 width: 100%; 
    594                 text-align: center; 
     549                float: none;
     550                width: 100%;
     551                text-align: center;
    595552                padding-top: 3rem;
    596553        }
    … …  
    598555
    599556}
     557
     558.nav-tab-premium {
     559        color: #b8860b !important;
     560        font-weight: 600;
     561}
     562
     563.nav-tab-premium:hover,
     564.nav-tab-premium:focus {
     565        color: #8b6508 !important;
     566}
     567
     568.nav-tab-premium .dashicons {
     569        font-size: 14px;
     570        width: 14px;
     571        height: 14px;
     572        vertical-align: text-bottom;
     573        margin-right: 2px;
     574}
     575
     576.nav-tab-premium.nav-tab-active {
     577        color: #f0b90b !important;
     578        border-bottom-color: #f0b90b !important;
     579}
     580
     581.wprb-premium-upsell {
     582        max-width: 860px;
     583        margin-top: 1.5rem;
     584}
     585
     586.wprb-premium-header {
     587        text-align: center;
     588        padding: 2rem 1rem;
     589        background: #fff;
     590        border: 1px solid #e0e0e0;
     591        border-radius: 4px;
     592        margin-bottom: 1.5rem;
     593}
     594
     595.wprb-premium-header .dashicons {
     596        font-size: 2.5rem;
     597        width: 2.5rem;
     598        height: 2.5rem;
     599        color: #f0b90b;
     600}
     601
     602.wprb-premium-header h2 {
     603        font-size: 1.6rem;
     604        margin: 0.5rem 0;
     605        color: #23282d;
     606}
     607
     608.wprb-premium-header .description {
     609        font-size: 1rem;
     610        color: #666;
     611}
     612
     613.wprb-premium-features {
     614        display: grid;
     615        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
     616        gap: 1rem;
     617        margin-bottom: 1.5rem;
     618}
     619
     620.wprb-feature {
     621        background: #fff;
     622        border: 1px solid #e0e0e0;
     623        border-radius: 4px;
     624        padding: 1.5rem;
     625        transition: box-shadow 0.2s ease;
     626}
     627
     628.wprb-feature:hover {
     629        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
     630}
     631
     632.wprb-feature .dashicons {
     633        font-size: 2rem;
     634        width: 2rem;
     635        height: 2rem;
     636        color: #f0b90b;
     637}
     638
     639.wprb-feature h3 {
     640        margin: 0.5rem 0;
     641        font-size: 1rem;
     642        color: #23282d;
     643}
     644
     645.wprb-feature p {
     646        margin: 0;
     647        color: #666;
     648        font-size: 0.9rem;
     649}
     650
     651.wprb-premium-cta {
     652        text-align: center;
     653        padding: 2rem;
     654        background: #fff;
     655        border: 1px solid #e0e0e0;
     656        border-radius: 4px;
     657}
     658
     659.wprb-premium-cta .button-hero {
     660        background: #f0b90b;
     661        border-color: #d4a009;
     662        color: #fff;
     663        font-size: 1.1rem;
     664        padding: 0.6rem 2rem;
     665}
     666
     667.wprb-premium-cta .button-hero:hover {
     668        background: #d4a009;
     669        border-color: #b8860b;
     670        color: #fff;
     671}
     672
     673.wprb-premium-cta .description {
     674        margin-top: 0.75rem;
     675        color: #666;
     676}
  • wp-restaurant-booking/trunk/css/wprb.css

    r3650036 r3685965  
    1616        display: inline-block;
    1717        padding: 2px 20px;
    18         background: #f5b016;
     18        background: var(--wprb-widget-color, #f5b016);
    1919        border-radius: 5px;
    2020        cursor: pointer;
    … …  
    4848.wprb-booking-button a,
    4949.wprb-booking-button a:hover {
    50         color: #fff !important;
     50        color: var(--wprb-widget-text-color, #fff) !important;
    5151        text-decoration: none;
    5252        font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    … …  
    8080#wprb-booking-modal h2 {
    8181        text-align: center;
    82         background: #f5b016;
     82        background: var(--wprb-widget-color, #f5b016);
    8383        margin: 0;
    8484        padding: 40px 0 20px;
    85         color: #fff;
     85        color: var(--wprb-widget-text-color, #fff);
    8686    font-size: 2em;
    8787        -webkit-border-radius: 8px 8px 0 0;
    … …  
    105105#wprb-booking-modal .header-bar {
    106106        display: block;
    107         background: #f5b016;
     107        background: var(--wprb-widget-color, #f5b016);
    108108        min-height: 100px;
    109109}
    … …  
    121121        position: relative;
    122122    margin: 0;
     123}
     124
     125.header-bar_steps li {
     126        color: var(--wprb-widget-text-color, #333);
     127}
     128
     129.header-bar_steps li.active span i {
     130        color: var(--wprb-widget-color, #333);
    123131}
    124132
    … …  
    141149#wprb-booking-modal ul li span {
    142150        text-align: center;
    143         background-color: #f5b016;
     151        background-color: var(--wprb-widget-color, #f5b016);
    144152        width: 44px;
    145153        height: 44px;
    … …  
    153161        opacity: 1;
    154162        background-color: #fff;
    155         border: 2px solid #f0a417;
     163        border: 2px solid var(--wprb-widget-accent-color, #f0a417);
    156164        cursor: pointer;
    157165}
    … …  
    226234.booking-people_numbers__number input[type="button"]:hover,
    227235.booking-people_numbers__number input[type="button"].active {
    228         background: #f5b016 !important;
     236        background: var(--wprb-widget-color, #f5b016) !important;
    229237    text-decoration: none;
    230         color: #fff;   
     238        color: var(--wprb-widget-text-color, #fff);     
    231239}
    232240
    … …  
    277285
    278286.booking-people_numbers__number.active select {
    279         background: #f5b016;
    280         color: #fff;
     287        background: var(--wprb-widget-color, #f5b016);
     288        color: var(--wprb-widget-text-color, #fff);
    281289}
    282290
    … …  
    403411.booking-hours ul li input:hover,
    404412.booking-hours ul li input.active {
    405         color: #fff;
     413        color: var(--wprb-widget-text-color, #fff);
    406414    text-decoration: none;
    407         background: #f5b016;
     415        background: var(--wprb-widget-color, #f5b016);
    408416}
    409417
    … …  
    474482
    475483#wprb-reservation input[type="checkbox"]:checked {
    476     background-color: #f5b016;
     484    background-color: var(--wprb-widget-color, #f5b016);
    477485}
    478486
    479487#wprb-reservation input[type="checkbox"]:checked:after {
    480488    content: '✔';
    481     color: white;
     489    color: var(--wprb-widget-text-color, white);
    482490    position: relative;
    483491    top: -3px;
    … …  
    555563.booking-end .fa-check-circle {
    556564        font-size: 400%;
    557         color: #f5b016; /*temp*/
     565        color: var(--wprb-widget-color, #f5b016);
    558566        margin-bottom: 1.5rem;
    559567}
    560568
     569/*
     570 * Override the air-datepicker library's own default theme (#ff9a19)
     571 * so the calendar follows the widget color too. Needs !important:
     572 * the library's stylesheet is enqueued after wprb.css and its own
     573 * rules don't use !important, so source order alone isn't enough.
     574 */
     575.datepicker--day-name {
     576        color: var(--wprb-widget-color, #ff9a19) !important;
     577}
     578
     579.-current-,
     580.-selected-,
     581.datepicker--cell.-selected-.-current- {
     582        background: var(--wprb-widget-color, #ff9a19) !important;
     583        color: var(--wprb-widget-text-color, #fff) !important;
     584}
     585
     586.-focus-,
     587.-selected-.-focus- {
     588        background: var(--wprb-widget-color, #ff9a19) !important;
     589}
     590
    561591@media screen and (max-width: 1000px) {
    562592
  • wp-restaurant-booking/trunk/includes/class-wprb-notifications.php

    r3650036 r3685965  
    4848                $this->define_shortcodes();
    4949                $this->send_admin_notification();
     50                $this->send_user_notification();
    5051
    5152        }
    … …  
    263264
    264265        }
     266
     267
     268        /**
     269         * Send user notification if activated
     270         */
     271        public function send_user_notification() {
     272
     273                if ( get_option( 'wprb-activate-user-notification' ) ) {
     274
     275                        $to = $this->email;
     276
     277                        $subject = do_shortcode( self::default_user_object() );
     278
     279                        $message = do_shortcode( self::default_user_message( $this->until, $this->notes ) );
     280
     281                        $this->mail_from_filters();
     282
     283                        $sent = wp_mail( $to, $subject, $message );
     284
     285                }
     286
     287        }
    265288}
    266289
  • wp-restaurant-booking/trunk/includes/class-wprb-reservation-widget.php

    r3650036 r3685965  
    108108
    109109        /**
     110         * Darken a hex color by the given percentage
     111         *
     112         * @param string $hex     the hex color (with or without #).
     113         * @param int    $percent darken percentage.
     114         * @return string the darkened hex color, empty string if invalid input.
     115         */
     116        private function darken_color( $hex, $percent = 12 ) {
     117
     118                $hex = ltrim( $hex, '#' );
     119
     120                if ( 3 === strlen( $hex ) ) {
     121                        $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
     122                }
     123
     124                if ( 6 !== strlen( $hex ) || ! ctype_xdigit( $hex ) ) {
     125                        return '';
     126                }
     127
     128                list( $r, $g, $b ) = array_map( 'hexdec', str_split( $hex, 2 ) );
     129
     130                $r = max( 0, round( $r * ( 1 - $percent / 100 ) ) );
     131                $g = max( 0, round( $g * ( 1 - $percent / 100 ) ) );
     132                $b = max( 0, round( $b * ( 1 - $percent / 100 ) ) );
     133
     134                return sprintf( '#%02x%02x%02x', $r, $g, $b );
     135
     136        }
     137
     138
     139        /**
     140         * Build the CSS custom properties for the widget colors, if set
     141         *
     142         * @param string $color      the main widget color.
     143         * @param string $text_color the widget text color.
     144         * @return string the CSS, empty string if no color is set.
     145         */
     146        private function widget_color_css( $color, $text_color ) {
     147
     148                $vars = array();
     149
     150                if ( $color ) {
     151
     152                        $vars[] = '--wprb-widget-color: ' . $color . ';';
     153
     154                        $accent = $this->darken_color( $color );
     155
     156                        if ( $accent ) {
     157                                $vars[] = '--wprb-widget-accent-color: ' . $accent . ';';
     158                        }
     159                }
     160
     161                if ( $text_color ) {
     162                        $vars[] = '--wprb-widget-text-color: ' . $text_color . ';';
     163                }
     164
     165                if ( empty( $vars ) ) {
     166                        return '';
     167                }
     168
     169                return ':root{' . implode( ' ', $vars ) . '}';
     170
     171        }
     172
     173
     174        /**
    110175         * Scripts and style
    111176         */
    … …  
    114179                /*css*/
    115180                wp_enqueue_style( 'wprb-style', WPRB_URI . 'css/wprb.css' );
     181
     182                $widget_color      = get_option( 'wprb-widget-color' );
     183                $widget_text_color = get_option( 'wprb-widget-text-color' );
     184                $widget_color_css  = $this->widget_color_css( $widget_color, $widget_text_color );
     185
     186                if ( $widget_color_css ) {
     187                        wp_add_inline_style( 'wprb-style', $widget_color_css );
     188                }
     189
    116190                wp_enqueue_style( 'modal-style', WPRB_URI . 'css/jquery.modal.min.css' );
    117191                wp_enqueue_style( 'font-awesome', WPRB_URI . 'css/fontawesome/all.min.css' );
  • wp-restaurant-booking/trunk/js/wprb-admin.js

    r3650036 r3685965  
    1717                self.chosen();
    1818                self.tzCheckbox();
    19                 self.externalSeats();
    2019                self.addHours();
    2120                self.removeHours();
    22                 self.addLastMinute();
    23                 self.removeLastMinute();
    2421                self.addclosingPeriod();
    2522                self.removeClosingPeriod();
    … …  
    2825                self.minDateClosingPeriodTo();
    2926                self.autoCompleteFields('internal');
    30                 self.autoCompleteFields('external');
    3127                self.autoCompleteFields('min');
    3228                self.autoCompleteFields('max');
    33                 self.lastMinuteElement();
    3429                self.notificationsElement();
    35                 self.notificationsShortcodes();
     30                self.widgetColorPicker();
    3631        }
    3732
    … …  
    129124
    130125        /**
    131          *External seats option
    132          */
    133         self.externalSeats = function() {
    134 
    135                 jQuery(function($){
    136 
    137                         var col             = $('.wprb-col.external');
    138                         var fieldContainer  = $('.wprb-activate-external-seats-field');
    139                         var field           = $('input', fieldContainer);
    140 
    141                         var fieldCheck = function() {
    142 
    143                                 if ( 'checked' == field.attr('checked') ) {
    144 
    145                                         col.show();
    146 
    147                                 } else {
    148 
    149                                         col.hide();
    150 
    151                                 }
    152                        
    153                         }
    154                         fieldCheck();
    155 
    156                         $('span.tzCheckBox', fieldContainer).on('click', function(){
    157 
    158                                 fieldCheck();
    159 
    160                         })     
    161 
    162                 })
    163 
    164         }
    165 
    166 
    167         /**
    168126         * Add a new hours element
    169127         */
    … …  
    190148                                        $(prev).after(response);
    191149
    192                                         /*Display go premium*/
    193                                         $('.go-premium', container).show('slow');
    194 
    195150                                })
    196151
    … …  
    216171                                $(element).remove();
    217172
    218                                 /*Hide go premium*/
    219                                 if ( $('.wprb-hours-element-2', container).length == 0 ) {
    220 
    221                                         $('.go-premium', container).hide();
    222 
    223                                 }
    224 
    225                         })
    226 
    227                 })
    228 
    229         }
    230 
    231 
    232         /**
    233          * Auto-complete the bookable and external fields of every day, copying the values from the firsts setted
     173                        })
     174
     175                })
     176
     177        }
     178
     179
     180        /**
     181         * Auto-complete the bookable fields of every day, copying the values from the firsts setted
    234182         *
    235          * @param  {Boolean} external true for external field, default for bookable.
     183         * @param  {string} type field type.
    236184         */
    237185        self.autoCompleteFields = function( type = 'internal' ) {
    … …  
    244192                        switch (type) {
    245193
    246                                 case 'internal':
    247                                 element = '#wprb-bookable-seats';
    248 
    249                                 break;
    250 
    251                                 case 'external':
    252                                 element = '#wprb-external-seats';
    253 
    254                                 break;
    255 
    256                                 case 'min':
     194                        case 'internal':
     195                        element = '#wprb-bookable-seats';
     196
     197                        break;
     198
     199                        case 'min':
    257200                                element = '#wprb-min-bookable';
    258201
    … …  
    279222
    280223                                })
    281 
    282                         })
    283 
    284                 })
    285 
    286         }
    287 
    288 
    289         /**
    290          * Handles the visibility of the last minute fields
    291          */
    292         self.lastMinuteElement = function() {
    293 
    294                 jQuery(function($){
    295 
    296                         var toggle      = $('.wprb-activate-last-minute-field .tzCheckBox');
    297                         var lastMinute  = $('.wprb-add-last-minute-field');
    298 
    299                         if ($(toggle).hasClass('checked')) {
    300 
    301                                 lastMinute.show();
    302 
    303                         }
    304 
    305                         $(toggle).on('click', function(){
    306                                
    307                                 if ($(this).hasClass('checked')) {
    308 
    309                                         lastMinute.show('slow');
    310 
    311                                 } else {
    312 
    313                                         lastMinute.hide();
    314 
    315                                 }
    316                        
    317                         })
    318 
    319                 })
    320 
    321         }
    322 
    323 
    324         /**
    325          * Add a new last minute
    326          */
    327         self.addLastMinute = function() {
    328 
    329                 jQuery(function($){
    330 
    331                         $(document).on('click', '.add-last-minute-hover', function(){
    332 
    333 
    334                                 var count = $('.last-minute-element').length;
    335                                 var prev  = $('.wprb-last-minute-element-' + ( count - 1 ) );
    336                                 var next  = count;
    337                                 var data  = {
    338                                         'action': 'wprb-add-last-minute',
    339                                         'wprb-add-last-minute-nonce': wprbSettings.addLastMinuteNonce,
    340                                         'number': next
    341                                 }
    342 
    343                                 $.post(ajaxurl, data, function(response){
    344 
    345                                         $(prev).after(response);
    346 
    347                                 })
    348 
    349                         })
    350 
    351                 })
    352 
    353         }
    354 
    355        
    356         /**
    357          * Remove a last minute
    358          */
    359         self.removeLastMinute = function() {
    360 
    361                 jQuery(function($){
    362 
    363                         $(document).on('click', '.remove-last-minute-hover', function(){
    364 
    365                                 var element = $(this).closest('.last-minute-element');
    366 
    367                                 $(element).remove();
    368224
    369225                        })
    … …  
    463319                                $.post(ajaxurl, data, function(response){
    464320
    465                                         /*Display go premium*/
    466                                         $('.wprb-set-rooms-tables .go-premium').show('slow');
    467                                        
    468321                                        $(prev).after(response);
    469322
    … …  
    489342
    490343                                $(element).remove();
    491 
    492                                 /*Hide go premium*/
    493                                 if ( $('.wprb-room-tables-element-1').length == 0 ) {
    494 
    495                                         $('.wprb-set-rooms-tables .go-premium').hide();
    496 
    497                                 }
    498344
    499345                        })
    … …  
    564410
    565411        /**
    566          * Copy shortcodes to use in user notification
    567          */
    568         self.notificationsShortcodes = function() {
    569 
    570                 jQuery(function($){
    571 
    572                         var $temp;
    573                         var shortcode;
    574 
    575                         /*Add title*/
    576                         $('.shortcodes code').each( function(){
    577 
    578                                 $(this).attr('title', 'Click to copy');
    579 
    580                         })
    581 
    582                         /*Copy shortcode*/
    583                         $('.shortcodes code').on( 'click', function(){
    584 
    585                                 $temp     = $('<input>');
    586                                 shortcode = $(this);
    587                                
    588                                 $('body').append($temp);
    589                                 $temp.val($(shortcode).text()).select();
    590                                 document.execCommand('copy');
    591                                 $temp.remove();
    592 
    593                         })
    594 
    595                 })
    596 
    597         }
     412         * Widget colors picker
     413         */
     414        self.widgetColorPicker = function() {
     415
     416                jQuery(function($){
     417
     418                        if ( typeof $.fn.wpColorPicker === 'function' ) {
     419
     420                                $('.wprb-color-field').wpColorPicker();
     421
     422                        }
     423
     424                })
     425
     426        }
     427
    598428
    599429}
  • wp-restaurant-booking/trunk/readme.txt

    r3658642 r3685965  
    22Contributors: ghera74
    33Tags: booking, ticket, reservation, restaurant, bar
    4 Version: 1.2.4
    5 Stable tag: 1.2.4
     4Version: 1.3.0
     5Stable tag: 1.3.0
    66Requires at least: 5.0
    77Tested up to: 7.1
    … …  
    1616**AVAILABLE FUNCTIONALITIES**
    1717
    18 * Activate/ deactivate the booking functionlity in a click.
     18* Activate/deactivate the booking function in a click.
    1919* Booking widget position, even using the shortcode *[booking-button]*.
    20 * Set a number of bookable seats for each day of the week.
    21 * Define the time slots that can be booked every day
    22 * Outdoor tables option (Premium).
    23 * Last minute table option (Premium).
    24 * Set time limit within which to book a table.
     20* Customizable widget colors (background and text color).
     21* Set a number of bookable seats for each day of the week, with a minimum and a maximum bookable.
     22* Multiple bookable time slots for each day (for example lunch and dinner), with the interval between one time and the next.
     23* Closing days: days of the week and closing periods on specific dates (holidays).
     24* Set a time limit within which to book a table.
    2525* Set an average time of the customer at the table, useful for calculating availability.
    2626* Assign a table to each reservation.
    … …  
    2929* Admin and user email notifications.
    3030
     31**PREMIUM VERSION**
     32
     33The premium version of **ilGhera Restaurant Booking for WordPress** adds the following functionalities:
     34
     35* Outdoor seats, with availability calculated separately.
     36* Last minute tables.
     37* Multiple rooms, each with its own number of tables.
     38* HTML email templates with custom header and footer.
     39* Inline booking form using the shortcode *[booking-form]*.
     40
     41https://www.ilghera.com/product/wp-restaurant-booking-premium/
     42
    3143https://youtu.be/fAk2Hzm2E7k
    3244
    … …  
    4759== Screenshots ==
    4860
    49 1. Select date and number of people
     611. Select the date and the number of people
    50622. Select the booking time
    51633. Add your data
    52644. The reservation was completed
    53 5. General settings
    54 6. Last minute settings (Premium)
    55 7. Admin and user email settings
    56 8. Admin reservations
    57 9. Edit single reservation
     655. General settings, with the booking widget colors
     666. Bookable seats for each day of the week
     677. Bookable time slots, more than one for each day
     688. Closing days and closing periods
     699. Admin and user email notifications
     7010. Admin reservations
     7111. Edit single reservation
     7212. The functionalities available in the premium version
    5873
    5974
    6075== Changelog ==
     76
     77= 1.3.0 =
     78Release Date: 7 September 2026
     79
     80    * New: multiple bookable time slots for each day, now included in the free version.
     81    * New: closing days, both weekdays and closing periods on specific dates, now included in the free version.
     82    * New: customizable booking widget colors (background and text color).
     83    * New: Premium tab with the list of the features available in the premium version.
     84    * Tweak: settings pages cleaned up, the options reserved to the premium version are no longer shown as disabled fields.
     85    * Fix: the confirmation email was never sent to the customer, and the User notifications switch was not saved.
     86    * Fix: the Chosen library used by the multiple selects was enqueued but not included in the package, so both files returned a 404.
     87    * Fix: the link to the premium version pointed to a page that no longer exists.
     88
    6189
    6290= 1.2.4 =
  • wp-restaurant-booking/trunk/wp-restaurant-booking.php

    r3660604 r3685965  
    22/**
    33 * Plugin Name: ilGhera Restaurant Booking for WordPress
    4  * Plugin URI: https://www.ilghera.com/product/wordpress-restaurant-booking-premium
     4 * Plugin URI: https://www.ilghera.com/product/wp-restaurant-booking-premium
    55 * Description: A feature-rich and easy to use reservation system for bars and restaurants.
    66 * Author: ilGhera
    7  * Version: 1.2.4
     7 * Version: 1.3.0
    88 * Author URI: https://ilghera.com
    99 * Requires at least: 5.0
Note: See TracChangeset for help on using the changeset viewer.